0

Serial port communication isn't working in Linux on my machine. How to solve?

I have a USB to NULL-modem to USB plugged in. Using this Serial cable in Windows works fine. Can transfer 100MB file in Windows. In Ubuntu Linux. I am having trouble. I can't even get command line to work.


Setting up ports:

sudo chmod o+rw /dev/ttyS0
sudo chmod o+rw /dev/ttyS4

crw-rw-rw- 1 root dialout 4, 64 Feb 10 14:31 /dev/ttyS0
crw-rw-rw- 1 root dialout 4, 68 Feb 10 14:20 /dev/ttyS4

dmesg | grep ttyS
[    0.412092] 00:07: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    0.433676] 0000:00:16.3: ttyS4 at I/O 0xf0e0 (irq = 19, base_baud = 115200) is a 16550A

Communication:

On one terminal:
cat -v < /dev/ttyS0   or   cat -v < /dev/ttyS4


On another terminal:
echo -e "\x7E\x03\xD0\xAF und normaler Text" > /dev/ttyS0

stty -aF /dev/ttyS0
speed 57600 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

stty -aF /dev/ttyS4
speed 57600 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

This is the documentation:

https://www.digi.com/resources/documentation/Digidocs/90001541/tasks/t_use_terminals.htm?TocPath=Get%20started%20with%20MicroPython%7C_____8

3
  • What does stty -aF /dev/ttyS0 command say (and similarly for /dev/ttyS4)?
    – d.c.
    Commented Feb 10, 2021 at 23:13
  • updated with results
    – jdl
    Commented Feb 10, 2021 at 23:15
  • NOTE: Picocom shows port to port communication works.
    – jdl
    Commented Feb 10, 2021 at 23:16

2 Answers 2

0

You said it's a USB-to-serial device? Then the device name will most likely be of the form /dev/ttyUSB*, not /dev/ttyS*. If you have just one such device, the name will probably be /dev/ttyUSB0.

The very first Linux step in the instructions you linked also says:

Open a terminal in Linux and type picocom -b 115200 /dev/ttyUSB0

Your /dev/ttyS0 looks like a normal physical serial port (on a laptop, it might be available using a docking station only), and since /dev/ttyS4 seems to be related to PCI ID 0000:00:16.3 in your dmesg output, it's probably the Intel AMT/MEI serial-over-LAN management endpoint. Neither of those has anything at all to do with USB-to-serial devices.

0

You need somebody to do flow control. If the serial line is emulated, you need to behave as it were really a serial line.

One possibility is to establish network. You can do it using good old slip:

  1. slattach /dev/ttyS0 on one side, slattach /dev/ttyS4 on the other. Now you have a new "network adapter" called probably sl0 on either side.
  2. You can give it an address (e. g. using ip addr aadd 172.16.16.1/30 brd + dev sl0) and make it active (ip link set sl0 up). Similarly on the other side (but with the other address).
  3. Then use it as any other network connection.

Other possibilities include file transfer utilities like kermit. I am afraid, simple cat or echo wouldn't be enough.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .