4

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
Brent
  • 1,743
  • 3
  • 16
  • 27
  • That modem probably uses AT commands, did you try any of them? for example ATZ? result? – Fusho Feb 28 '18 at 18:46
  • Yes, I'm trying AT commands, but the issue is that the modem doesn't recognize what I'm tying. If I type "ATZ" and hit return, it will echo "@TZ", but return doesn't seem to execute the command. I've posted to the linux-serial mailing list to see if I can get any additional help debugging the problem: https://marc.info/?l=linux-serial&m=151970073905793&w=2 – Brent Mar 01 '18 at 04:41
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Mar 02 '18 at 05:00
  • Understood. Can this topic be moved to Unix & Linux Stack Exchange or do I need to create a new post? – Brent Mar 02 '18 at 13:28

2 Answers2

4

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)

rm5248
  • 2,590
  • 3
  • 17
  • 16
  • I think you're onto something. Executing the echo command you wrote does return properly. It seems that if you have more than one byte to write in the buffer, it works. If I copy and paste an AT command into minicom, it works. If I create an application to write to the serial port it also works. It only doesn't work if I open minicom and manually type in AT commands. Toggling the -istrip flag didn't seem to make a difference though. I'm so confused... – Brent Mar 01 '18 at 15:24
  • @Brent Have you tried it with only the serial settings I posted? You may need to do `stty -F /dev/ttyACM0 sane` to revert to a better state to try the settings from. – rm5248 Mar 01 '18 at 21:22
  • Yes, I set the ttyACM0 serial port to the same settings you posted above, but it did not make a difference. Being able to send AT commands by pasting them into the terminal is a huge help, but ModemManager doesn't play so nice with it. ModemManager is unable to talk to the modem due to this problem I'm having. I would normally suspect there is something wrong with the hardware, but all other USB devices work without any issues (webcams, flash drives, etc.). – Brent Mar 02 '18 at 03:17
0

Try using

sudo screen /dev/ttyS0 9600

and see if you get the same behavior.

Pang
  • 9,564
  • 146
  • 81
  • 122
  • /dev/ttyS0 does not exist on my device. Should it? I basically have tty0 - tty63, and then the real UART ports on my board (ttymxc0-4), and the ttyACMx ports from the modem. – Brent Mar 07 '18 at 05:50