writing data over RS232

writing data over RS232

Diego Iastrubni elcuco at kde.org
Mon May 7 21:24:36 IDT 2012


Hi all,

I have been assigned at work to write a specific protocol between two 
machines, which eventually will be over RS232. As part of the development I 
decided to write it on linux, and simulate the communication using a named 
pipe. In theroy, it should be trivail since the protocol only needs to know 
about the FD to read/write to, correct? Wrong.

I face two problems (maybe one, as both problems seem similar):

When I try to read from the PC (Ubuntu 12.04, 64bit), the read just aborts 
returning "0". If I run the application several times, I somtimes see that the 
app can read ONE byte. Sometimes.

When I write from the PC, and read from the device (Andriod, 2.3.7, Linux 
2.6.38.8) the android device reads garbage. I mean, the byte count is wrong, 
and the content is usually garbage.

When I connect microcom (busybox) on Android (actually "microcom /dev/ttyS3 | 
hexdump -C") I can see that the bytes sent are mostly arriving, however maybe 
times bytes are missing, and sometimes the same bytes are read twice (I sent 
"testing 123" and read "testing 12323").

Some remarks:

- ttyS* are opened on both sides using "open(file, O_RDWR|O_NOCTTY)"
- speeds are set on both side using "csetispeed(&to, B1900);csetospeed(&to, 
B1900);", note that I lowered the speed for the test. 
- The Android side has no HW flow control (that might be the trigger).

What would you recommend me to do?

- diego



More information about the Linux-il mailing list