Send AT commands to USB modem

Posted: April 6, 2012 in Linux, osX

The idea to monitor and communicate with the device is the same on both OS, what changes is the device name. For Linux the devices name to use can be found with

sudo dmesg | grep tty

Normally is/dev/ttyUSB0,  /dev/ttyUSB1,  /dev/ttyUSB2,  /dev/ttyUSB3,  /dev/ttyUSB4 for Linux, and on my Mac osX Lion I have

ls -l /dev/cu.*
crw-rw-rw- 1 root wheel /dev/cu.HUAWEIMobile-Diag
crw-rw-rw- 1 root wheel /dev/cu.HUAWEIMobile-Modem
crw-rw-rw- 1 root wheel /dev/cu.HUAWEIMobile-Pcui

For this purpose lets assume a generic device name <DEVICE>, that it is either a Linux or osX tty. First we need to find out which of the several terminal is used for communication, and for that we need to open monitor terminals for each of the devices.

Terminal 1: cat /dev/<DEVICE1>
Terminal 2: cat /dev/<DEVICE2>
Etc..

and in another terminal we send an AT command like this:

echo "ATi^M" > /dev/<DEVICE> #(note: ^M is ctrl+v+m)

And one of the monitor terminals above will show something like this:

ATi
Manufacturer: huawei
Model: E353
Revision: 11.810.09.40.156
IMEI: 86816500xxxxxxxxx
+GCAP: +CGSM,+DS,+ES
OK

In my mac the terminal that I need to use is /dev/cu.HUAWEIMobile-Pcui and in Linux is /dev/ttyUSB0.

About these ads
Comments
  1. […] The basic idea for this console based process comes from the article "Send AT commands to USB modem" by brunomgalmeida. […]

  2. shideneyu says:

    Doesn’t work…
    echo “ATi^M” > /dev/ttyUSB0
    -> zsh: permission denied: /dev/ttyUSB0

    Also tried with the other ports. Using linux. Thx anyways for the article

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s