comgt - a command line utlity for 3G devices
All of the 3G devices that we use to connect to the Internet have a serial modem like interface. These devices are controlled and managed over that interface using what are known as AT commands.
The purpose of comgt is to control these modems by sending AT commands. There are many command line utilities for communicating with the serial interface but comgt has many special features that make it very useful for 2G and 3G device control.
[comgt was previously known as gcom but for legal reasons I had to change the name.]
Development work has now stopped on comgt but is is still being used. Visit the comgt forum for more examples of how it can be used.
To use comgt you need to get the source file and compile the code for your system. This is very easy to do and only takes a few minutes. Before you start check that you have a C compiler installed. Open up a command terminal and type the following command:
If gcc is installed Linux will respond with its location:
If gcc is missing then nothing will be displayed and you will need to use your distribution's software package manager to install it.
You can get the source package from Sourceforge.
Open up a terminal and cd to the location of the the downloaded file. Then follow the following sequence to compile the comgt:
The following command will install comgt in to the correct location. Notice that you must run the install as the root user so I use the sudo command to get temporary root privileges:
On some systems (e.g. Suse) you would use the su command to give the terminal super user root privileges before typing the make install command
The simplest command is
which searches for compatible devices and tries to talk to them. If the device needs a PIN then you are asked to enter the PIN.
When you get a report that the device is registered on a network then you know things are working!
Enter PIN number: ****
Some of the newer device use ports that comgt does not have in its list but you can still control these devices using the -d control.
For example, the devices using the hso driver can be controlled like this:
which tells comgt to use the /dev/ttyHS1 port for communicating with the modem.
comgt can be made more useful by using scripts. There are several examples in /etc/comgt and the comgt man page will describe the script language in detail.
-d device set the device to be used to communicate with the data-card. Defaults to /dev/modem
-e turn on serial communications echo.
-h display summary help and exit.
-s don't run the internal default script before an external script.
-t change to an alternate line terminator (default ").
-v run in verbose mode. This traces scripts as they are executed. It is intended to help in debugging scripts.
-x for internal and external scripts, any reference to 115200 baud is converted to 57600. This is useful for data cards that don't like 115200 baud such as the GlobeTrotter EDGE.
comgt is a scripting language interpreter useful for establishing communications on serial lines and through PCMCIA modems as well as GPRS and 3G datacards. The source for comgt can be found here: Sourceforge
- Pre-defined built-in scripts for 2G/3G datacard control
- Simple, BASIC-like script language.
- Command-line and file sourcing of script.
- Multi-response waitfor.
- waitquiet permits line stabilization.
- In-line text capture.
- Multi-process support: fork, wait, kill, exit.
- Debugging verbose and log output.
- logging to file.
- Flow control: goto, gosub, return, if, else.
- Low-impact on system resources.
- Time commands and functions.
- String manipulations.
- Environment manipulation: env(), putenv.
- External utilities system calls: system, exec.
Supported GPRS and 3G datacards
comgt has been tested against GlobeTrotter GPRS,EDGE, Combo EDGE, 3G, 3G EDGE, HSDPA and GlobeTrotter Fusion as well as Vodafone 3G. It can set the PIN and display information about datacards before a PPP connection is started. Additionally, because the GlobeTrotter and Vodafone 3G/GPRS datacard have a secondary serial interface, these datacards can be monitored while a PPP connection is in existence and transferring data.
comgt is primarily designed to work with the GlobeTrotter range of datacards but should be compatible with any other GPRS or 3G datacard provided its interface is implemented as one or more serial or USB serial devices and it is controlled and queried by an implementation of the Hayes command interface with the same AT command extensions used by the listed datacards.
comgt has only one function: to run a script. This may be one of a number of "standard" internal scripts or an external script. Both types of script are invoked in the same way. The "standard" scripts are built into comgt and will work for serially connected modems, built-in modems, PCMCIA modems as well as the GlobeTrotter GPRS and the Vodafone 3G/GPRS datacards.
comgt This runs the default internal script. Running comgt without any script specified, e.g., comgt -d /dev/ttyS1 it will check for a PIN and prompt you if it is required. The next thing it does is wait for the device to register, it then reports the signal strength. If you don't specify a port with the -d option then /dev/modem is assumed. If the -s switch is not used then this default script is run before any external script.
comgt help Lists these and the other options available.
comgt info Lists the datacard configuration.
comgt sig Prints the signal strength.
comgt reg Prints the registration state.
comgt 3G Puts a GlobeTrotter 3G/Fusion and Vodafone 3G into 3G network only mode (UMTS/HSDPA).
comgt 2G Puts a GlobeTrotter 3G/Fusion and Vodafone 3G into 2G network only mode (GSM/GPRS/EDGE).
comgt 3G2G Puts a GlobeTrotter 3G/Fusion and Vodafone 3G into 3G preferred mode (UMTS/HSDPA and GSM/GPRS/EDGE).
comgt GTEDGE Use this command to initialise GlobeTrotter EDGE and GlobeTrotter Combo EDGE cards before doing anything else. (It switches on the radio).
comgt USA Switch to 900/1900 MHz band for USA operation. GlobeTrotter GPRS datacards only.
comgt EUROPE Switch to 900/1800 MHz band for European operation. GlobeTrotter GPRS datacards only.
As well as built in scripts you can make your own. The following script sets a Vodafone 3G datacard or Option Fusion card's UMTS mode to GPRS:
#Set GPRS only mode
set com 115200n81
set senddelay 0.05
waitquiet 1 0.2
print "Setting GPRS only mode"
If you saved the above script as GPRS you would call it like this:
If you needed to specify the port as well then do this:
comgt -d /dev/ttyS1 GPRS
You can also pass environment parameters to a comgt script via $env().