Linux – How to send AT commands to a modem in Linux

linuxmodemserial port

In Linux (Ubuntu) I am trying to send AT commands to a modem at /dev/ttyACM0. I tried to do it as:

sudo socat - /dev/ttyACM0

but when typing anything I just get a line repeating this command (I expect an OK).

When I do

sudo minicom modem1

it seems to work. I type an AT and get an OK. I type some crap, I get an ERROR.

It seems that modem1 for minicom is somehow configured to use the modem at /dev/ttyACM0.

How can I use socat to send AT commands? Do I need to configure something? Maybe I can use configurations for modem1 of minicom (I do not know how to find/see this configuration)?

Additional information

Is the given socat command correct? Should I play with some options? With the -v option I see the following:

AT
> 2013/10/23 17:10:28.917413  length=3 from=0 to=2
AT
< 2013/10/23 17:10:28.921598  length=3 from=0 to=2
AT
AT
ksjdhfjdgfhjkdfh
> 2013/10/23 17:10:30.244923  length=17 from=3 to=19
ksjdhfjdgfhjkdfh
< 2013/10/23 17:10:30.251383  length=29 from=3 to=31
ksjdhfjdgfhjk\b \bd\b \bf\b \bh\b \b
ksjdhfjdgfhj 

The device itself is found with the following dmesg output:

[5983726.808063] usb 2-1: USB disconnect, device number 3
[5983730.800021] usb 2-1: new full-speed USB device number 4 using uhci_hcd
[5983730.920014] usb 2-1: device descriptor read/64, error -71
[5983733.629524] usb 2-1: New USB device found, idVendor=0572, idProduct=1329
[5983733.629533] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[5983733.629539] usb 2-1: Product: USB Modem
[5983733.629544] usb 2-1: Manufacturer: Conexant
[5983733.629549] usb 2-1: SerialNumber: 24680246
[5983733.632673] cdc_acm 2-1:1.0: ttyACM0: USB ACM device

And the tty is configured as follows:

speed 57600 baud; line = 0;
eof = ^A; min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo -echoe

Best Answer

Try socat - /dev/ttyUSB2,crnl

This tells socat to send a carriage return as well as a line feed.

Clarification - this goes back to the dark days of electric typewriters, where you would have to tell it to roll the carriage back to position 0 on the page - ergo, a carriage return - as well as telling it to move the paper up one line.

Related Question