Community
cancel
Showing results for 
Search instead for 
Did you mean: 
EM4
New Contributor I
1,999 Views

Edison: get notification for UART data received

Jump to solution

Is there a way to get notification that UART data is received, or program must poll for data?

I'm using MRAA lib (my code is in C) to send/receive data and that works fine (after turning off kernel output on uart), but what i really need to do is one thread notifies another thread when data is received. Is this possible? Thank you.

1 Solution
BMass
New Contributor I
112 Views

Hello inteliot,

If you're programming in C you may have at least those two possibilities for knowing if there is any data in RX buffer of UART :

- Using the function provided by libmraa mraa_uart_data_available() : http://iotdk.intel.com/docs/master/mraa/uart_8h.html mraa: /var/lib/jenkins/workspace/mraa-doc/api/mraa/uart.h File Reference

- Using the Linux ioctl library directly : http://man7.org/linux/man-pages/man2/ioctl.2.html ioctl(2) - Linux manual page

Regards,

View solution in original post

7 Replies
Andriy_S_Intel
Employee
112 Views

UART is an asynchronous interface, so, you never know when the data is coming in. Thus, your driver should start a thread / process / part of mainloop to periodically poll the line for data.

EM4
New Contributor I
112 Views

Thanks. I understand that...maybe I didn't ask the right question. How should I check for data? Doing a ready or there is another (correct) way?

Thank you.

Andriy_S_Intel
Employee
112 Views

Sorry, I'm not familiar with libmraa at all, possible someone else can explain how you can achieve it there.

Sergio_A_Intel
Employee
112 Views

Hi inteliot,

Were you able to follow Bylos' suggestion? Do you still need help with this thread?

Sergio

EM4
New Contributor I
112 Views

Hi Bylos, Sergio,

I will try to use the mraa_uart_data_available tomorrow. So far i'm just reading and checking bytes read, which works, but i'm wondering if that's the most efficient. Is there any suggestion on how long to wait in between each read? I'm setting the baud rate to 115200.

thank you for suggestions. I'll report back afterwards.

Thanks.

EM4
New Contributor I
112 Views

I used this mraa_uart_data_available and it works great. Thanks.

don't know how i missed it before.

BMass
New Contributor I
113 Views

Hello inteliot,

If you're programming in C you may have at least those two possibilities for knowing if there is any data in RX buffer of UART :

- Using the function provided by libmraa mraa_uart_data_available() : http://iotdk.intel.com/docs/master/mraa/uart_8h.html mraa: /var/lib/jenkins/workspace/mraa-doc/api/mraa/uart.h File Reference

- Using the Linux ioctl library directly : http://man7.org/linux/man-pages/man2/ioctl.2.html ioctl(2) - Linux manual page

Regards,

View solution in original post

Reply