9

in the BusyBox command for Linux exists the command microcom to communicate with a serial modem:

BusyBox v1.13.2 (2012-05-10 17:13:08 CEST) multi-call binary

Usage: microcom [-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY

Copy bytes for stdin to TTY and from TTY to stdout

Options:    
        -d  Wait up to DELAY ms for TTY output before sending every next byte to it
        -t  Exit if both stdin and TTY are silent for TIMEOUT ms
        -s  Set serial line to SPEED
        -X  Disable special meaning of NUL and Ctrl-X from stdin

Instead of using stdin to type the AT commands I want to place them insise a text file and redirect the content of that file as the stdin for the above command. For example, I have a file

/tmp/at.txt

with the AT command AT, which usually gets confirmed by the TTY with an OK. A standard session with stdin looks like:

microcom -t 3000 -X /dev/ttyS5                                 
at
OK

in which the string at was entered directly on the keyboard. In order to use the content of the file /tmp/at.txt (contains just 'at\n'). To do this,. I have tried the following variations:

microcom -t 3000 -X /dev/ttyS5  < /tmp/at.txt   
microcom -t 3000 /dev/ttyS5  < /tmp/at.txt 
cat /tmp/at.txt |  microcom -t 3000 /dev/ttyS5
tail -f  /tmp/at.txt |  microcom -t 3000 /dev/ttyS5
cat /tmp/at.txt |  microcom -t 3000 /dev/ttyS5 -X
tail -f  /tmp/at.txt |  microcom -t 3000 /dev/ttyS5 -X

and none of them worked, i.e. none of those commands did return the text 'OK' on the screen. I therefore conclude that there is some problem redirecting the content of the file /tmp/at.txt as stdin for the command microcom. Maybe is has to do with how the end-of-line is interpreted or the end-of-file. If someone has some idea, I would appreciate some help.

Thanks,

Alex

0

3 Answers 3

10

You need end AT COMMANDS with special character \r

echo "AT+CIMI\r" | microcom -t 2000 /dev/ttyS5

With \n it doesn't work

Grettings

Sign up to request clarification or add additional context in comments.

1 Comment

if beside busybox you use a real shell, like bash, don't forget the specifiy the -e and -n flag to echo: echo -ne "AT+CSQ\r\n" | microcom -X -t 1000 /dev/modem_at1
5

Im running the microcom in BusyBox v1.18.4 under SliTaz 4.0 & I duplicated the problem & then solved it. If youre going to emulate keyboard input at this level the takefile has to have a full CRLF after every line because the keyboard key transmits a ^M (0x0D). The Linux standard 0x0A written by most ASCII editors is not sufficient.

There are many ways to do it but I just created the takefile with an extra byte at the end of every line then used the ncurses-hexedit program to zap the byte to a 0x0D. I tested the above commands & got an OK response with the input taken from such a file.

Hope this helps.

Comments

0

echo ATE | sudo socat - /dev/ttys5,crnl

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.