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:
AT
AT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^JAT^
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 can't 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
compiled newer kernel: 3.6.11-gentoo and now when sending command:
echo "AT" > /dev/ttyUSB0
got result like:
OK
AT
OK
AT
OK
AT
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;
OK
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:
speed 9600 baud; rows 0; columns 0; 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 echoctl echoke