Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
922 Views

Reading UART1 using mraa on Intel edison

Hi,

I'm using Intel edison arduino expansion board with meta image.I want to integrate A6 GSM,GPRS module using digital pins 0 and 1. The mraa version I'm using is 0.9.5.I enabled the pins mentioned in the link . By using the code sample_uart.c(which is pinned below) ,I can see the output in cat /dev/ttyMFD1. But if I want to get the output in the same console,I tried mraa_uart_data_available and mraa_read function in the program basic_uart(1).c but there is no output in the same console where we are running the progarm.I tried changing the delay and adding the delay,but it is also invain.

I also tried adding libraries mentioned in the links

http://www.cmrr.umn.edu/~strupp/serial.html# 5_1 Serial Programming Guide for POSIX Operating Systems https://www.scivision.co/intel-edison-using-uart-ttymfd1-serial-port/

 

https://software.intel.com/en-us/articles/internet-of-things-using-mraa-to-abstract-platform-io-capa... _Toc7.1 https://software.intel.com/en-us/articles/internet-of-things-using-mraa-to-abstract-platform-io-capa... _Toc7.1

and the program is

# include /* Standard input/output definitions */

# include /* String function definitions */

# include /* UNIX standard function definitions */

# include /* File control definitions */

# include /* Error number definitions */

# include /* POSIX terminal control definitions */

# include

# include

int fd;

int counter;

int setupTTY(int fd, speed_t baud)

{

if (fd < 0)

return 0;

struct termios termio;

tcgetattr(fd, &termio);

cfmakeraw(&termio);

cfsetispeed(&termio, baud);

cfsetospeed(&termio, baud);

if (tcsetattr(fd, TCSAFLUSH, &termio) < 0)

{

//fprintf(stderr, "%s\n", "tcsetattr failed");

printf("address failed");

return 0;

}

return

int /* O - 0 = MODEM ok, -1 = MODEM bad */

init_uart(int fd) /* I - Serial port file */

{

char buffer[255]; /* Input buffer */

char *bufptr; /* Current char in buffer */

int nbytes; /* Number of bytes read */

int tries; /* Number of tries so far */

for (tries = 0; tries < 3; tries ++)

{

/* send an AT command followed by a CR */

if (write(fd, "AT\r", 3) < 3)

continue;

/* read characters into our string buffer until we get a CR or NL */

bufptr = buffer;

while ((nbytes = read(fd, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0)

{

bufptr += nbytes;

if (bufptr[-1] == '\n' || bufptr[-1] == '\r')

break;

}

/* nul terminate the string and see if we got an OK response */

*bufptr = '\0';

if (strncmp(buffer, "OK", 2) == 0)

return (0);

}

return (-1);

}

int main()

{

char buffer[255]; /* Input buffer */

char *bufptr; /* Current char in buffer */

int nbytes; /* Number of bytes read */

ioctl(fd,FIONREAD,&counter);

mraa_init();

mraa_uart_context m_uart;

m_uart = mraa_uart_init(0);

const char *devPath = mraa_uart_get_dev_path(m_uart);

if (!devPath)

{

//fprintf(stderr, "%s\n", "Could not get device path");

printf("Could not get device path");

return 0;

}

if ((fd = open(devPath, O_RDWR)) == -1)

{

//fprintf(stderr, "%s\n", "Could not open device path");

printf("Could not open device path");

return 0;

}

if (!setupTTY(fd, B115200))

{

//fprintf(stderr, "%s\n", "Could not setup TTY port");

printf("Could not setup TTY port");

return 0;

}

else

{

printf("baud rate is set\n");

}

init_uart(fd);

/* when we are done, close the device and exit */

close(fd);

return(0);

}

but there seems to no output.I have tried changing baud rate too.I have tried changing the delay.Please do needful.

Thanks and Regards,

Radhika

0 Kudos
2 Replies
Highlighted
Community Manager
9 Views

Hello Radhika,

 

 

Thank you for interest in the Intel® Edison Breakout Board.

 

 

I understand that you successfully integrated your Edison Board with the GSM GPRS A6 Module through the sample_uart.c program.

 

 

You mentioned that you can see the output in cat /dev/ttyMFD1, but that you "want to get the output in the same console". Could you please confirm that you want to see the output in the terminal without using the cat /dev/ttyMFD1 command? If that is not what you are trying to accomplish, please provide a simple diagram/image/picture showing your desired setup. It may help me better understand what you are trying to accomplish.

 

 

Also, you should update your MRAA I/O and UPM sensor libraries and perform your tests again. Please follow this link for more information https://software.intel.com/en-us/node/623543.

 

 

I'll be waiting for your response.

 

 

Regards,

 

Andres V.
0 Kudos
Highlighted
Community Manager
9 Views

Hello Radhika,

 

 

I was wondering if you had the chance to check the information provided.

 

 

Regards,

 

Andres V.
0 Kudos