Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Endless data loop from dev/ttyUSB while sending AT commands
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
tester777
n00b
n00b


Joined: 17 Feb 2013
Posts: 6

PostPosted: Sun Feb 17, 2013 7:25 pm    Post subject: Endless data loop from dev/ttyUSB while sending AT commands Reply with quote

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

Code:
    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:

Code:
    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 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:

Code:
    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:

Code:
    echo "AT" > /dev/ttyUSB0


got result like:
Code:

    OK
    AT
    OK
    AT
    OK
    AT


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

Code:
    echo "ATDT 27789388;" > /dev/ttyUSB0


and got answer from cat without loop.
Code:

    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 ?
Back to top
View user's profile Send private message
Ant P.
Advocate
Advocate


Joined: 18 Apr 2009
Posts: 2218
Location: UK

PostPosted: Sun Feb 17, 2013 11:06 pm    Post subject: Reply with quote

Try sending a carriage return (\r) instead - echo adds a newline (\n) by default.
Back to top
View user's profile Send private message
tester777
n00b
n00b


Joined: 17 Feb 2013
Posts: 6

PostPosted: Sun Feb 17, 2013 11:25 pm    Post subject: Reply with quote

Ant P. wrote:
Try sending a carriage return (\r) instead - echo adds a newline (\n) by default.


Can you write how exactly i need to send command ?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31373
Location: 56N 3W

PostPosted: Sun Feb 17, 2013 11:32 pm    Post subject: Reply with quote

tester777,

Code:
emerge minicom

There is no need to mess with cat and echo
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
tester777
n00b
n00b


Joined: 17 Feb 2013
Posts: 6

PostPosted: Sun Feb 17, 2013 11:50 pm    Post subject: Reply with quote

NeddySeagoon wrote:
tester777,

Code:
emerge minicom

There is no need to mess with cat and echo


Thanks for that tip, I will read docs of that soft, but I was writing php application and used php-serial class for modem communication, but that class returned same thing - never ending loop. So i started debugging, and found that it's not php problem, but linux.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31373
Location: 56N 3W

PostPosted: Mon Feb 18, 2013 12:03 am    Post subject: Reply with quote

tester777,

Its not a linux problem. It has to do with the way you set up and talk to the serial port.
minicom has worked since before I began with linux in 1999.

Its open source software, so you can see what it does.

You can also try the chat program, which is used to establish a serial connection to a remote system before PPP is started.
It operates from a script.

I suspect cat and echo do not give the result you want because they are both trying to control the serial port at the same time.
Two drivers for the same hardware is always a bad thing.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
tester777
n00b
n00b


Joined: 17 Feb 2013
Posts: 6

PostPosted: Mon Feb 18, 2013 12:13 am    Post subject: Reply with quote

NeddySeagoon wrote:
tester777,

Its not a linux problem. It has to do with the way you set up and talk to the serial port.
minicom has worked since before I began with linux in 1999.

Its open source software, so you can see what it does.

You can also try the chat program, which is used to establish a serial connection to a remote system before PPP is started.
It operates from a script.

I suspect cat and echo do not give the result you want because they are both trying to control the serial port at the same time.
Two drivers for the same hardware is always a bad thing.


I installed minicom, and started reading docs, but looks like it is like text client, and dialing and other stuff is made manually by user navigating text menu.
I need to send some commands to modem, so it could send SMS or make call or conference call using AT commands.
I wanted to do that over php, that would open stream and paste data into serial port, and then after some time tried to read answer from that port.
Can minicom be used like this ?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31373
Location: 56N 3W

PostPosted: Mon Feb 18, 2013 10:33 am    Post subject: Reply with quote

tester777,

minicom is intended to be used interactively by it can store AT command strings too.

To semi-automate what you want, chat is probably better, since it sends AT commands as you script and can listen or responses and deal with some error conditions.

By all means use php but only after you know the process you want to write in php works when you do it at a lower level.
e.g, with minicom and chat. chat is provided by net-dialup/ppp
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
tester777
n00b
n00b


Joined: 17 Feb 2013
Posts: 6

PostPosted: Mon Feb 18, 2013 5:01 pm    Post subject: Reply with quote

NeddySeagoon wrote:
tester777,

minicom is intended to be used interactively by it can store AT command strings too.

To semi-automate what you want, chat is probably better, since it sends AT commands as you script and can listen or responses and deal with some error conditions.

By all means use php but only after you know the process you want to write in php works when you do it at a lower level.
e.g, with minicom and chat. chat is provided by net-dialup/ppp



Thanks for advice, you pointed me to right way and i found net-misc/ckermit, looks like kermit does what i need and i also will read docs about chat app.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 31373
Location: 56N 3W

PostPosted: Mon Feb 18, 2013 5:11 pm    Post subject: Reply with quote

tester777,

Kermit provides lots of protocols for moving data over a serial link.

The most important thing to know about Kermit is that it really was named after a certain Green Frog :)
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum