USB Modem is echoing back wrong characters

笑着哭i 提交于 2019-12-04 04:17:02

问题


I have a USB modem connected on port ttyACM0. When I open an application like Minicom and try to send it some commands, the echo back is not always what I type. For example, if I type in "A", I get "@". If I type in "T", I do get "T". It seems that the serial port is stripping the least significant bit off of my transmission. For example:

A = @

B = B

C = B

D = D

E = D

F = F

... and so on. I assume there is something wrong with my serial port configuration, but I've tried what seems like every combination and no luck. I'm probably missing something easy, but nothing obvious is sticking out to me. Any idea what may be wrong? My serial port configuration is listed below:

# stty -F /dev/ttyACM0 -a
speed 9600 baud;stty: /dev/ttyACM0
 line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^H; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt =     ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 100; time = 2;
-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

回答1:


Looking at your serial port settings, the most likely culprit here is -istrip. According to the man page, -istrip will strip off the upper bit of the bytes that come back.

Given that you have a lot of other serial port settings, you may be having weird issues with the driver as well. I don't know what settings minicom uses and how exactly to set them up(I generally use GTKTerm), but my experience has been the settings that GTKTerm uses will always work and avoid any odd characters in the input/output.

The settings that GTKTerm uses are the same as the following stty line:

stty -F /dev/ttyS0 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

As for not returning any data when you send the command, have you tried making sure that you are sending \r\n at the end of your command? There's also the possibility that one of the serial port settings that you are using is translating a CR/NL combination. If all the port settings are set correctly, the modem should respond back when you do something like the following:

cat /dev/ttyACM0 &
/bin/echo -n -e "AT\r\n" > /dev/ttyACM0

(the modem should respond OK\r\n)




回答2:


Try using

sudo screen /dev/ttyS0 9600

and see if you get the same behavior.



来源:https://stackoverflow.com/questions/48679189/usb-modem-is-echoing-back-wrong-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!