- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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,
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Sorry, I'm not familiar with libmraa at all, possible someone else can explain how you can achieve it there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi inteliot,
Were you able to follow Bylos' suggestion? Do you still need help with this thread?
Sergio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I used this mraa_uart_data_available and it works great. Thanks.
don't know how i missed it before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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,

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page