Modem Fun, Hayes AT Commands
Another Cool ‘newbie’ project...
Hayes AT Commands and how they can easily be implemented into your code, giving your application the ability to command the modem with very little effort. You, of course, must have a Hayes compatible modem and be connected to a phone line. Now- lets start...
Opening a "COM": When attempting to access the modem, you must first open a "COM" this depends on how you have your modem set up. You may be on "COM1" or "COM4" , etc... it all depends on your settings. Make sure you open the right "COM" or your commands will be ignored. Here is an example (in BASIC) of how one would open "COM" for output...
'BASIC Source Code
Open "COM3" for Output as #1
Print #1, "ATDT 555-1234"
Print #1, "ATZ"
Close #1
The previous code opens "COM3" for output. Prints "AT" , this tells the modem that it is a command. The "D" is for Dial and the "T" for tone. "Z" resets the modem.
After you call a number you can read data from the COM using “Input #1, Var”, Where Var is the variable the data is stored. If the value of Var is null or 0 then there is nothing to talk to, or handshake… If you do get data , probably something like “OK, Connected at 9600” then there is another computer on the other end.
This is again a small Tutorial for Newbies. You can useany language you want to implement the AT Commands (I used BASIC, but you can do this with anything from C to Perl.) I hope this can be a fun project for any newbie/non-newbie with a small bit programming knowledge and a few hours to mess with their modem … Positive AntiPoints are greatly appreciated!
Here is a small list of AT Commands... And the syntax to use them:
Syntax:
> The command text should start with "AT" or "at", except for the commands "A/" and "+++". Keep the Case the same; "At" or "aT" wont work.
> Several commands can be given in one command line. I wouldn’t do this, just to make things simple. But please- experiment...
> The commands can be given in upper or lower case. I like Upper case.
> A command text should contain less than 40 characters. If len(CMD$) > 40 then Exit Sub
> Commands and command texts must be terminated with an <ENTER> or Carriage return [Char$(13)], except +++ and A/
> A telephone number can exist of following characters:
1 2 3 4 5 6 7 8 9 * = , ; # + > . All other characters are ignored (spaces, underscores, etc...)
> After the command "ATZ" (Modem Reset) has been issued, a pause of two-three seconds should be respected before entering the next command.
I have included a few commands in the zip file...