Print version

Hayes protocol for MORSE

Simulation of a telephone modem.

version 7.30


1. Introduction

The Hayes protocol simulates the use of the Hayes-compatible telephone modem, and uses standard AT commands. Some AT commands have no sense in the radio modem and are therefore ignored, although the radio modem does returns an OK to them (e.g. ATWn, AT&Nn). It is used for substituting a telephone line.

The Hayes protocol uses maintenance packets for finding out if one of the stations has been forcibly disconnected. In the case of a loss of the connection the protocol terminates the connection.

The Hayes protocol uses these signals of the RS-232C interface: Rx, Tx, RTS, CTS, DTR, DSR and CD. The RI signal is not used. RTS and CTS signals are used as a hand shake (if set up in the SPe menu).

The Hayes protocol is not suitable (due to large overheads) for short transmissions, when transmitting small volumes of data, because at least one exchange of overhead packets is required for making a connection.

2. Date Format

Controlling and setting up all values is carried out:

  • by the user using the terminal (using AT commands), examples:

    AT<CR>it is0x41 54 0D
    AT<CR><LF>it is0x41 54 0D 0A
    <CR><LF>OK<CR><LF>it is0x0D 0A 4F 4B 0D 0A
    more complex AT command:  
    ATD1234<CR>it is0x41 54 44 31 32 33 34 0D

    Characters in commands can be written in lower and upper case, decimal numbers or 0x hex.

3. Implementation in Morse

Implementation of the Hayes Protocol in Morse

Fig. 1: Implementation of the Hayes Protocol in Morse

DTE – Data Terminal Equipment.

3.1. Configuration of parameters in the CU

The Hayes protocol is configured using AT command or by setting the S-registers.

3.2. AT commands

The radio modem can be in two defined states –

  • OFF LINE – the modem is hung up

  • ON LINE – the modem is connected, and here we define two states –

    • command mode

    • data transmission

AT commands used in the radio modem –

AT commandAction
+++transition from ON LINE – transmission of data to the command mode, connection not interrupted, return to ON LINE status – transmission of date by ATO command
A/repeats the previous command
AT?help screen
AT?1help screen No.1
AT?Sreturns the S-register values
ATQ0response to commands on
ATQ1response to commands off
ATV0numerical response to command set (e.g. 1), also S14, bit 0x04
ATV1character response to command set (e.g. Connect)
ATE0local echo off, also S14, bit 0x01
ATE1local echo on
ATI,I0returns own number (network address)
ATDncalls entered “n” address, after CONNECT switches to ON LINE – data transmission
ATDn;calls entered “n” address, after CONNECT remains in command mode, does not switch to ON LINE – data transmission (switches to it after ATO or ATO0)
ATH,H0cancels connection (before ATH it must switch from ON LINE – transmission of date to command mode +++), switches to OFF LINE
ATO,O0return from command mode to ON LINE – data transmission
ATA“manual” response to call (if S0=0)
AT&C0signal CD in MR25 is still ON, i.e. S14 bit 0x2=1
AT&C1signal CD in CU switches according to state of connection, i.e. S14 bit 0x2=0 (ON LINE CD=ON, OFF LINE CD=OFF)
AT&W,&W0under development
ATZtermination of connection, renewal of protocol user profile FLASH memory, reset of protocol
AT&Fsets default parameters (S-registers) in Hayes protocol “Set default configuration profile”
AT&D0ignores DTR status, S14 bit 0x10=0
AT&D2for DTR->OFF:, hangs up, command mode, automatic response off, i.e. S14 bit 0x10=1
AT&Vreturns S-register values in RAM (active profile) and FLASH (stored profile)
ATSn=ysets S-register n to value y
ATSn?Returns register value n
ATXnSelection of set of possible return codes (significant if S14 0x08=1, i.e.permitted response)

3.3. S-registers

S0S0=0 is not picked up automatically, an ATA command must arrive
S0 > 0 the autoanswer function is switched on after the first RING tone
S2Escape code character – ESC – special character, used for switching from ON LINE to OFF LINE, default „+“ 2BH (043)
S3Carriage return character – CARRIAGE RETURN, default ODH (013)
S4Linefeed character – LINE FEED, default 0AH (010)
S5Backspace character – BACKSPACE, default 08H (008)
S7Connect timeout (sec.) – part of the time (added to the time defined by registed S29) over which the modem waits for a response to a call for making a connection. If by the time S7+S29 no response CONNECT arrives from the called modem, the modem sends a NO ANSWER message to the connected DTE
S10Carrier loss hangup timeout (10 sec.) – time in tens of seconds after which the connection is automatically terminated, if there is no communication, e.g. due to a loss of the radio connection. If it is set to 0, the connection is not terminated automatically (it is configured on the calling modem side)
S12Escape code quard time (1/50 sec.) – time delay in tens of milliseconds before and after the sequence of three ESC commands for converting the modem from ON LINE – transmission of data to the command mode
S14Flags– command echo, resulting code S14
S15S15=n ~ ATXn Set of return codes.
S29Dial delay (1/10 sec.) dial delay between RING and CONNECT sec/10 configured on the calling modem side)

There is no sense in setting up other registers in the radio modem.

3.4. Return Codes

There are 5 sets of return codes (X0, X1, X2, X3 and X4) in register S15 . There settings are given in the table.

Return codes are only displayed if they are permitted, i.e. response to commands – ATQ0 is on.

ATV0/ATV1 – numerical/character response

Return codesSetting
5CONNECT 1200 xxxx
7BUSY   xx
10CONNECT 2400 xxxx
13CONNECT 9600 xxxx
18CONNECT 4800 xxxx
20CONNECT 7200 xxxx
21CONNECT 12000 xxxx
25CONNECT 14400 xxxx
50CONNECT 19200 xxxx

3.5. Principle of Data Transmission

Switching on the modem

After connecting the supply voltage the radio modem is set to the command mode and configuration parameters stored permanently in memory are uploaded. In this state the modem accepts commands and communicates only with the connected computer. The CD signal is not active. In this state the required configuration can be set up.

Making a connection without the autoanswer function

We can make a call for a connection using command ATDn, where n is the address of the called radio modem. If the called radio modem is prepared for communication it sends RING information to its computer which means that it has been called. After executing command ATA (if no autoanswer is set) on the called computer the calling radio modem is informed about the connection that has been made and sends CONNECT information to its computer. ATA needs to be sent by time S29, otherwise the connection will not be made. After sending command ATA the period in register S29 is counted again (from the beginning irrespective of how much time has elapsed), and after it has elapsed CONNECT information is sent.

Register S0=0 – without the autoanswer function. An ATA command is necessary for making a connection.

Making a connection without the autoanswer function

Fig. 2: Making a connection without the autoanswer function

Making a connection with the autoanswer function

Register S0>0 – with the autoanswer function. The calling radio modem accepts a connection automatically without the need to enter an ATA command. A RING occurs only once, irrespective of how many “rings” are set in register S0.

Making a connection with the autoanswer function

Fig. 3: Making a connection with the autoanswer function

The called radio modem is informed by a return message that confirmation has been received and the called radio modem also sends CONNECT information to its computer. CONNECT information is sent upon expiry of the period set in register S29. At this moment the radio modem comes ON LINE – data transmission, activates the CD signal and is capable of communicating with its reciprocal radio modem.

Radio modem not responding

If the called radio modem does not respond within the time given by the sum of registers S7+S29, the calling modem according to registers S7+S29 returns NO ANSWER information to the computer. This state also applies to the situation where the modem does not respond and also to the situation when DTE does not respond.

If the called radio modem has already made a connection with another radio modem we receive a BUSY reply on calling for a connection.

Radio modem not responding

Fig. 4: Radio modem not responding

Switching to command mode

In the state ON LINE – data transmission all characters that the computer sends to the modem are transferred to the reciprocal radio modem. An exception is a sequence of three ESCAPE characters, which switch the radio modem from the ON LINE – data transmission state to the command mode (command mode – communication with the mode commences by means of AT commands without the need to interrupt the connection). Before and after this sequence there must be at least the space set in register S12. If the radio modem was switched to command mode, the connection was not interrupted, and then back to the ON LINE – data transmission state it is possible to get using command ATO Pokud byl radiový modem přepnut do příkazového módu, nebylo spojení přerušeno a zpět do stavu ON LINE – přenos dat je možné se dostat příkazem ATO.

Switching to command mode

Fig. 5: Switching to command mode

Terminating a connection

A connection can be terminated either by setting signal DTR OFF (AT&D2) or sending a command ATH, ATH0. If we want to terminate a connection using a command it is first necessary to set the radio modem to the command mode. In the command mode we can terminate a connection using command ATH or ATH0. Termination of a connection on one radio modem is transmitted to a second radio modem. A message about termination of the connection is sent to the second radio modem and this radio modem sends NO CARRIER information to the connected computer. Both radio modems switch to the OFF LINE state. After termination of the connection it is possible to make a connection with another radio modem.

Terminating a connection

Fig. 6: Terminating a connection

Maintenance packets

If a radio connection is lost both protocols carry out termination of the connection independently after the set timeout. Timeout for recognising a loss of connection is set in register S10. If register S10=0 the connection is not checked. For recognising a radio connection loss maintenance packets are used. Maintenance packets are sent if no user communication takes place and they are sent by both modems independently. Maintenance packets are always sent at the end of time S10/3 from both sides. If communication is interrupted a NO CARRIER command is sent to both modems upon expiry of period S10. Both radio modems switch to the OFF LINE state.

Maintenance packets

Fig. 7: Maintenance packets

S registers S10 and S29 are configured on the calling modem side so that it is possible to ensure a relationship to other parameters. These values are sent in a BEL packet to the called modem.

Types of Hayes protocol packets

Meaning of packetMorse data packet (typ 0A)
BEL0x02 + S10 + S29

4. Configuration Parameters

The Hayes protocol can be configured –

  • using AT commands (see help AT?, AT?1, AT?S)

  • in the modem menu SPe0t it is possible to set up a default set of S-registers using the command set de(f)ault , or some of the user sets of S-registers using the appropriate command. Individual S-registers can also be set up separately.

    Register values in SETR are displayed in hexadecimal but are entered in decimal.

    This setting is stored either in FLASH memory using the (w)rite command, or is activated using the (I)nit command. If these parameters are not initialised the protocol will not work with them.

HAYES parameters:
set     de(f)ault,
best of: (g)alaxy,
(H)oneywell master
(h)oneywell slave
S registers:
00 2B 0D 0A 08 00 0C 00 00 06 
00 32 00 04 04 00 00 00 00 00 
00 00 00 00 00 00 00 00 0A 00 

(a)ddress:00000000h  (c)mdmode:0001h  (s)tate:0000h  hang (r)eason:0000h
(C)RLF timeout:0000ms
(D)irect DCD:0000

Meaning of parameters –

  • Pre-set S-registers –

    Default parameters –

    HAYES parameters:
    set     de(f)ault

    Pre-set S-registers for special applications –

    best of: (g)alaxy,
    (H)oneywell master
    (h)oneywell slave

    Register values in individual pre-settings –

    RegisterdefaultHoneywell masterhoneywell slavegalaxy
  • S-registers

    S registers:
    00 2B 0D 0A 08 00 0C 00 00 06 
    00 32 00 04 04 00 00 00 00 00 
    00 00 00 00 00 00 00 00 0A 00 

    ATE0 AT&C1 ATV1 ATQ0 AT&D0 – distributed register S14

    ATX4 – register S15

  • Status of connection (does not set up, just shows current status of communication)

    (a)ddress:00000000h  (c)mdmode:0000h  (s)tate:0000h  
    hang (r)eason:0002h  (m)ode:0000
    • (a)ddress:00000000h – address of modem with which there is (was) a connection

    • (c)mdmode:0000h

      0 - line – ON LINE mode – data transmission

      1 - command – command mode

    • (s)tate:0000h – state the modem is in

      0 - off line – hung up

      1 - on line – connected from local station

      2 - rmt on line – connection was called up by the other side (see address)

      3 - connecting

      4 - rmt connecting – attempt to connect initialised by other side

      5 - hanging up

    • hang (r)eason:0000h – reason for cancelling connection (0,1,2,3 and 7), or not making connection (4,5 and 6)

      0-init – initialisation of protocol

      1-rmt – hung up from other side

      2-loc – hung up locally (ATH)

      3-carrier loss – after switching off radio modem


      5-ata wait – ATA wait time elapsed

      6-dial – S07 time elapsed (connect timeout)

      7-dtr – signal DTR OFF (locally)

    • (m)ode:0000 – special setting (default settings recommended)

    • (C)RLF timeout:0000ms – if a non-zero timeout is set packets are only sent if CLRF arrives or if the set timeout elapses

    • (D)irect DCD:0000 – on setting the DCD signal do not wait for S29 (dial delay) to elapse

      (D)irect DCD:0001 – signal DCD is set up after ATDx (x = any character)

      (D)irect DCD:000L – signal DCD is set up after ATDL (signal DCD is set up after sending the set character for ATD)

©  2024 RACOM s.r.o. All Rights Reserved.