Using CU for Communicating with Mobile Phone / Modem

Home / Using CU for Communicating with Mobile Phone / Modem

AT Commands is shortening of ATtention Commands. It is set of command understood by mobile phone and modem. Knowing AT command allow you to control your mobile phone by terminal, or even a modem you use.

In this article we will try to explore AT command using cu command. CU (Call Up) is a little tool for communicating with another system. It is a basic networking application that shipped with most linux (or maybe all) linux distribution. From linux man page we got information that cu is used to call up or connect directly or indirectly to another system and act as a dial in terminal. It can also do simple file transfers with no error checking.

To establish a connection using a modem we can invoke:

cu [ -d ] [ -h ] [ -m ] [ -T seconds ] [ -n ] [ -s speed] [ -t ] [ -e | -o ] Telephone / number

To specify the name of a device for a connection:

cu [ - d] [ -h ] [ -m ] [ -T seconds ] [ -s speed ] [ -e | -o ] -l line

To specify a system name for a connection:

cu [ - d] [ -h ] [ -m ] [ -T seconds ] [ -e | -o ] SystemName

For this article, I will using a modem (old modem which I forget the specification but it has 3.5G capability if I remember it) to perform a connection. Our goal is connecting to modem with cu application while we will discuss other use of AT commands like sending SMS in another article.

What we need:

  • mobile device, in this case modem as I said before.
  • USB cable, this for connecting our device and our computer.
  • Computer, of course! In this case I use GNU/Linux (well obviously)

Before proceeding, please switch to super user!

Device Recognition

First, we plug both of cable-end to the device and computer.

Make sure the device is recognized by computer. To see it, invoke this command:

dmesg | tail -10

That command will give last 10 message from kernel. Make sure you find entries indicated that your computer recognize the device. In my case I have this messages:

[12209.457401] usbserial: USB Serial Driver core
[12209.479009] USB Serial support registered for GSM modem (1-port)
[12209.479129] usbcore: registered new interface driver option
[12209.479131] option: v0.7.2:USB Driver for GSM modems
[12209.481986] option 3-1:1.0: GSM modem (1-port) converter detected
[12209.484529] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB0
[12209.484589] option 3-1:1.1: GSM modem (1-port) converter detected
[12209.486172] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB1
[12209.486229] option 3-1:1.2: GSM modem (1-port) converter detected
[12209.486653] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB2

My device is registered as GSM modem and has attached to ttyUSB0, ttyUSB1, and ttyUSB2. This result might be different in your system but find out these information, especially what terminal is your device attached to. There is no exception to CDMA phone / mobile. Unless it is not detected by system, you can proceed to next stage.

Our device is registered now, then let’s see the /dev directory to make sure.

ls /dev | grep tty

Because my device is attached as ttyUSB0, ttyUSB1, and ttyUSB2, I make sure that these file is present at /dev directory. Once we have confirmed it, we can proceed to next step.

Contacting and Communicating

In this step, we will try to contacting the device with information we got from previous command. Here I use terminal ttyUSB0. Start up terminal and fire cu command. But first, let’s specify our need.

In this article I need half duplex connection so I will give -h switch. The baud rate I use is 38400 (this is standard rate). And the line I use is /dev/ttyUSB0. Now let’s type on terminal:

cu -h -s 38400 -l /dev/ttyUSB0

If you are success, you will see a “Connected.” message on your terminal. Congratulation, in this stage we have established the connection to remote device.

Now, test if AT command is recognized by device. Give this command to your terminal:

AT

You should has OK response from device indicated that your device is supporting AT command.

Sometimes your device echoing every character you type. For example you type AT but in your terminal you see AATT. It would be difficult to see what command you have typed actually. For that case, we will disable the echo by giving command:

ATE0

And gotcha, you have your terminal give clear message.

To disconnecting your connection, you can type ~. (a tilde followed by a point), and press enter (carriage return). You should see the message “Disconnected” and be returned to your prompt (terminal).

Happy hacking! 😀

, ,

About Author

about author

xathrya

A man who is obsessed to low level technology.

1 Comment
  1. Five Ways to Communicate with Embedded Device in Linux - Xathrya.ID

    […] You might also want to read my old article: using CU to communicate with modem. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial