GPIO UART (/dev/ttyAMA0) closes randomly (EOF)
Posted: Wed Sep 05, 2012 5:42 pm
(I've searched for AMA and UART before posting this)
So I've recently got /dev/ttyAMA0 working . I use it mainly by calling read (in blocking mode) on it to grab data as fast as possible. I've noticed that it randomly will return a 0 from read(...) which means EOF and any subsequent attempt to call read keeps returning 0. Does anyone know how I can prevent this? I need the port to stay open.
It should be easy to dupe for anyone who has this UART setup.
My source code is right here: http://www.rulecity.com/browse/rpi/sertest.cpp.txt
To build, just do :
g++ sertest.cpp -o sertest
Here is a sample of the output I get when I run it twice.
The serial port on the other end is continuously sending data at about a rate of 2900 bytes/second so less than the capacity of the 115200 speed setting.
So I've recently got /dev/ttyAMA0 working . I use it mainly by calling read (in blocking mode) on it to grab data as fast as possible. I've noticed that it randomly will return a 0 from read(...) which means EOF and any subsequent attempt to call read keeps returning 0. Does anyone know how I can prevent this? I need the port to stay open.
It should be easy to dupe for anyone who has this UART setup.
My source code is right here: http://www.rulecity.com/browse/rpi/sertest.cpp.txt
To build, just do :
g++ sertest.cpp -o sertest
Here is a sample of the output I get when I run it twice.
Code: Select all
pi@raspberrypi /mnt/vldp-hw/src/io $ ./sertest
1008
2001
terminate called after throwing an instance of 'std::runtime_error'
what(): Got unexpected EOF!
Aborted
pi@raspberrypi /mnt/vldp-hw/src/io $ ./sertest
1008
2008
3008
4008
5008
terminate called after throwing an instance of 'std::runtime_error'
what(): Got unexpected EOF!
Aborted