RS-232: losing data

strombrg

New Member
Joined
Jul 28, 2020
Messages
4
Reaction score
0
Credits
55
I have an RS-232 based peripheral hooked up to a zareason (Micro-Star International MS-16GD) laptop running Debian 10.4.

The laptop needs to read data from the peripheral, and it mostly succeeds, but once in a while it looks like some data is getting lost.

The peripheral has no flow control. It's using a binary protocol, so software flow control is probably impractical, and hardware flow control is probably not going to happen either as that would seem to require hardware changes in the peripheral itself.

The peripheral is hooked up to the laptop using a Chipi-X RS-232 <-> USB adapter. The Chipi-X appears to have a reputable chip in it, according to lsusb:
Bus 001 Device 006: ID 0403:6015 Future Technology Devices International, Ltd Bridge(I2C/SPI/UART/FIFO)

Is there a way of tuning the Linux driver to deter bytes from getting dropped? I think it's probably this driver that's getting used, from lsmod:
usbserial 53248 1 ftdi_sio

Thanks!
 
Last edited:


This can be a can of worms to debug.

The first place I would check is the parity bits.

https://en.wikipedia.org/wiki/8-N-1 -- This is usually the most common, but it's not always what is used.

The second thing you need to check is the bps, or baud rate. Both sides need to talk
at the same speed, 9600 bps used to be common, but now 19200 or 28800 is common.

Usually setting those two things correctly will fix the connection. (but not always).
 
The code on the laptop is trying to talk to the peripheral like it is N81 38400. I'm attempting to confirm that's correct from the peripheral's perspective.

The protocol between the peripheral and the laptop is very binary, and that makes me suspect some of these special characters in stty are incorrect:
$ stty -a < /dev/ttyUSB0
below cmd output started 2020 Tue Jul 28 03:11:53 PM PDT
speed 38400 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 0; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc

EG, I don't want anything to get erased if a ^? is sent.

I'm using pyserial for the communication, but that's maybe more of a stackoverflow question.

I changed the stty settings for special characters (carefully using a < and a sleep), to look like:
speed 38400 baud; rows 0; columns 0; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = <undef>;
stop = <undef>; susp = <undef>; rprnt = <undef>; werase = <undef>; lnext = <undef>; discard = <undef>; min = 0; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc

Thanks.
 
BTW, changing those special characters to undef may or may not be necessary, but I'm pretty sure it's insufficient if it's helping at all, because I changed the settings using /usr/bin/stty and I still got dropped characters. I'd rather undef them using Python, but for now, I know I need something more.
 

Staff online

Members online


Top