Sign up ×

I have problem sending AT commands to my USB modem. At first I tried php-serial class, but when i was reading data, I got endless loop with strange data. Then I tried to debug problem and opened putty terminal, made command

cat /dev/ttyUSB0

and then sent command echo "AT" > /dev/ttyUSB0 after that I always got never ending loop from cat /dev/ttyUSB0 like this:


and this loop never ends. On windows all works just fine. I can connect to USB modem via virtual COM port and send command / get answer.

Question is why cant I just receive "OK" message from console, but instead of this I got this data loop?

Tried different huawei USB modems, and different stty settings and also default settings for huawei modems:

Baud rate: 9600 / 115200
Parity: none
Data bits = 8
Stop bits = 1
Flow control = none

test dev # uname -a
Linux test 3.5.7-gentoo #3 SMP Sun Feb 17 04:58:22 EET 2013 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 5200+ AuthenticAMD GNU/Linux

EDIT: compiled newer kernel: 3.6.11-gentoo and now when sending command:

echo "AT" > /dev/ttyUSB0

got result like:


it never ended, I terminated cat command, then sent other ( make call command ):

echo "ATDT 27789388;" > /dev/ttyUSB0

and got answer from cat without loop.

systest ~ # cat /dev/ttyUSB0
ATDT 27789388;


so why tty terminal is acting so strange ? maybe I don't know something about sending/reading data on serial ports ?


if it can help then output of stty -a -F /dev/ttyUSB0 command is:

-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8


share|improve this question

3 Answers 3

Check to see if modem-manager is running -- and kill it if it is.

If it thinks that the device is a modem, it will step in and try to dial the modem also. This fixed as similar problem for me recently.

share|improve this answer
Looked in active processes, and there are nothing like this. in what package modem-manager is shipped ? I only have compiled kernel support for usb modems, and also installed "usb_modeswitch" so that it can switch usb device to modem state and open a /dev/ttyUSB* port. If i use kermit application to dial a number everything works fine in kermit, output is like it needs to be. I dont understand why lower level write/read isn't working –  user777 Feb 20 '13 at 4:07
Looks like the modem is echoing the command back to you (expected) but then the tty port is sending the command back to the modem and creating your endless loop. Try: stty -echo to prevent the port from echoing the commands back to the modem. –  MikeV Apr 16 '13 at 23:34
If you're looking for it, modemmanager is closely linked to networkmanager - I think it's an extension to it or maybe part of the default package. On my systemd system I killed by symlinking /dev/null over the /etc/systemd/system modemmanager rule counterpart to /usr/share/systemd's default one... –  mikeserv Mar 18 '14 at 21:43

Doing AT command communication from the command line with just plain shell operations is rather unreliable. I suggest that you try to use the program atinout which is specifically written to issue AT command from the command line:

$ echo AT | atinout - /dev/ttyUSB0 -
share|improve this answer

Definitely look like your terminal setup is messed up. Check and play with these stty settings: echo echoe echok -echonl -echoprt echoctl echoke

share|improve this answer

Your Answer


