Communication between two serial ports with Linux

Hope someone can help me. I am trying to make serial port communications in ARM (I work with Linux). The fact is that I use a program called terminal in windows, which I use to view the output.

I have two cables connected from my ARM to the USB of my computer. What I do is open two windows of the terminal program, and I connect to the mail serial port until everything is fine.

Now in one of the windows I have an ARM console (this is the ttymxc1 serial port) in which I write, for example, "echo hello> / dev / ttymxc2" (ttymxc2 is a different port in other windows). When I executed it, there was doubt, a decrease like this: "<0> <0 <0 <0 <0 <0 <0>". I read, and I found out that this is usually a baud rate problem, so I change the baud rate of "ttymxc2" to 115200 as "ttymxc1" at the same speed. As soon as I did this and I tried to send the same echo again, you will see the following: <0> © :: * ë & lt 0, so somenthig has changed.

I get all the parameters of both serial ports, and this is the output:

stty -a -F /dev/ttymxc1    

speed 115200 baud;stty: /dev/ttymxc1
line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^J;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
 -parenb -parodd 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     


stty -F /dev/ttymxc2 115200    

stty -a -F /dev/ttymxc2    

speed 115200 baud;stty: /dev/ttymxc2
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; flush = ^O; min = 1; time = 0;
-parenb -parodd 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    

, , 115200 8n1 no Handshaking .

,

setserial /dev/ttymxc2 -v autoconfig

/dev/ttymxc2, UART: undefined, Port: 0x0000, IRQ: 60

setserial /dev/ttymxc0 -v autoconfig

/dev/ttymxc0, UART: undefined, Port: 0x0000, IRQ: 58

, , , somenthing :

setserial /dev/ttymxc2 uart 16550A

:

setserial: can't set serial info: Invalid argument

, , ttymxc1 undefined, , ARM , , somen .

, .

dmesg | grep tty:

Kernel command line: noinitrd loglevel=7 no_console_suspend console=ttymxc1,115200 
fec_mac=00:05:51:07:B3:B5 mtdparts=gpmi-          nand:512k(NBoot)ro,2m(UBoot)ro,256k(UBootEnv),256k
(UserDef),6m(Kernel)ro,-(TargetFS) gpmi_debug_init enable_wait_mode=off   ubi.mtd=TargetFS root=ubi0:rootfs rootfstype=ubifs rootwait rw
bootconsole [ttymxc1] enabled
imx-uart.0: ttymxc0 at MMIO 0x2020000 (irq = 58) is a IMX
imx-uart.1: ttymxc1 at MMIO 0x21e8000 (irq = 59) is a IMX
console [ttymxc1] enabled, bootconsole disabled
imx-uart.2: ttymxc2 at MMIO 0x21ec000 (irq = 60) is a IMX

/proc/tty/driver

/dev/tty             /dev/tty        5       0 system:/dev/tty
/dev/console         /dev/console    5       1 system:console
/dev/ptmx            /dev/ptmx       5       2 system
/dev/vc/0            /dev/vc/0       4       0 system:vtmaster
rfcomm               /dev/rfcomm   216 0-255 serial
IMX-uart             /dev/ttymxc   207 16-23 serial
pty_slave            /dev/pts      136 0-1048575 pty:slave
pty_master           /dev/ptm      128 0-1048575 pty:master
pty_slave            /dev/ttyp       3 0-255 pty:slave
pty_master           /dev/pty        2 0-255 pty:master
unknown              /dev/tty        4 1-63 console

cat/proc/tty/driver/IMX-uart :

0: uart:IMX mmio:0x02020000 irq:58 tx:0 rx:0 DSR|CD
1: uart:IMX mmio:0x021E8000 irq:59 tx:12075 rx:358 RTS|DTR|DSR|CD
2: uart:IMX mmio:0x021EC000 irq:60 tx:0 rx:0 DSR|CD
+4
1

/proc/tty/driver/IMX-uart , , Linux ARM , echo hello > /dev/ttymxc2. , - /dev/ttymxc2, .

Ia

- imx-uart.2 . , , RS-232 . , .

Ib

(), , . :


<PC COM port_A> ----------(cable_A)-----------<imx-uart.1> 

:

<PC COM port_B> ----------(cable_B)-----------<imx-uart.2> 

, 115200 8n1.

, .
, :

<PC COM port_A> ----------(cable_B)-----------<imx-uart.1> 

- , :


<PC COM port_B> ----------(cable_B)-----------<imx-uart.1> 

<PC COM port_A> ----------(cable_A)-----------<imx-uart.2> 

, ARM.
.

II

, . - USB. , -, COM port_A COM port_B USB- RS-232-USB?

, imx-uart.1 imx-uart.1.
RS-232 ?
, RS-232?

USB-to-TTL- FTDI, . FTDI, SoC, . , . "FTDI" FTDI USB-RS232 MAX3232 ( RS-232 3.3V) .
Sparkfun FTDI ( ), TTL-RS232 ( MAX3232 ) . Sparkfun FTDI , - , .

, ( SoC) 115200 .
.
, , , ( ) 9600 1200.

+6

Source: https://habr.com/ru/post/1543235/


All Articles