Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9868 Discussions

how can I get data count of uart buffer using mraa lib on intel edison board

xzhan35
New Contributor I
1,557 Views

Hi all,

I use read() function to read data from uart in mraa library, and I set a noblock mode, but I don't know how can I get the uart buffer data count use the ioctl() function.

I don't use arduino IDE. I programm and build the source code in edison.

0 Kudos
1 Solution
Pedro_M_Intel
Employee
200 Views

Hello connor.zhang,

As far as I understand the only way to get the UART buffer data count, is, as you mentioned, using the ioctl function. I didn't quite understand your question, are you having issues using iotctl?

If so, I'll post here some links that I believe you might find helpful:

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

http://www.cmrr.umn.edu/~strupp/serial.html# 5_1 Serial Programming Guide for POSIX Operating Systems

Peter.

View solution in original post

5 Replies
Pedro_M_Intel
Employee
201 Views

Hello connor.zhang,

As far as I understand the only way to get the UART buffer data count, is, as you mentioned, using the ioctl function. I didn't quite understand your question, are you having issues using iotctl?

If so, I'll post here some links that I believe you might find helpful:

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

http://www.cmrr.umn.edu/~strupp/serial.html# 5_1 Serial Programming Guide for POSIX Operating Systems

Peter.

View solution in original post

xzhan35
New Contributor I
200 Views

Hi peter,

I used ioctl(fd,FIONREAD,&counter), I include , but it have error :

root@edison:~/eulerspace# gcc main2.c -o main2 -lmraa

main2.c: In function 'main':

main2.c:33:23: error: 'FIONREAD' undeclared (first use in this function)

ioctl(serialPort, FIONREAD, &counter);

^

KEckh
Valued Contributor III
200 Views

my Guess is you are not including the necessary header files. My guess is that it is in:

# include

Carlos_M_Intel
Employee
200 Views

Hi connor.zhang

Were you able to compile your code without errors and receive data in the buffer?

Regards;

CMata

xzhan35
New Contributor I
200 Views

hi CMata,

I can receive data in the buffer ,thanks a lot.

Reply