From: perl@dwrsun4.UUCP (Robert Perlberg)
Newsgroups: comp.dcom.fax
Subject: Re: AT Fax commands
Date: 13 Aug 92 21:12:57 GMT
Organization: Dean Witter Reynolds Inc., New York

Here's a repost of something that I captured a while back.

From: nick@aimed.UUCP (Nick Pemberton)
Newsgroups: alt.fax,comp.dcom.modems,comp.periphs
Subject: Here is WRITEFAX.MAN, details on ZOOM modem programming
Date: 8 Dec 90 00:30:56 GMT
Organization: AIM, Inc, Toronto, Ontario

Well, after much waiting, dialing, etc, I finally have a copy of
WRITEFAX.MAN, which is a guide to programming the ZOOM MX 2400S modem,
amongst others. I have had a number of requests for this file, so I
thought I'd post it (its not that large anyway....)

------------snip----------snip--------snip---------
 
      SendFax Application Software Interface Specification Rev 2



Contents

1.0    Introduction

2.0    Physical interface

3.0    Command set

4.0    Data format

5.0    Example sessions




.pa
.he       SendFax Application Software Interface Specification



1.0    Introduction

This  document  defines the specifications  for  the  application 
software interface to a PC Fax/Modem board incorporating Sierra's 
SC11046, 2400 bps modem with Send only Fax at 4800 bps  (SendFax) 
chip.

The  device is intended to be used in internal cards for the  IBM 
PC  or  compatible  computers or for  use  in  standalone  modems 
interfacing to   any  computer using a standard RS232 port. 

Functions  and commands are defined to allow an extension to  Fax 
receive mode in the future.
 
The Fax/Modem board is designed such that it appears to the PC as 
a serial port.  The address of the board is user selectable to be 
one  of four ports, COM1, COM2, COM3 or COM4.  The  DCE  hardware 
makes  and terminates calls, manages the  communications  session 
and  transmits  image  data in  accordance  with  the  procedures 
defined  in the CCITT recommendation T.30.  The image data is  in 
modified  Huffman  compressed format as described  in  the  CCITT 
recommendation T.4.  

The  application  software running in the DTE  will  provide  the 
functions  of  user interface, conversion of user data  files  in 
various  formats  to fax format per CCITT T.4  specification  and 
transfer  of  data  to the DCE for modulation  according  to  the 
protocol defined in this document.

 
.pa



2.0    Physical Interface

2.1 Internal PC version

The  hardware  appears to the PC as a serial port at  an  address 
that  is user selectable to be one of four ports.  Table 1  lists 
the addresses and interrupt levels for various port selections.

To   the  application  software,  the  hardware  appears  as   an 
8250/16450  type UART.  The application software writes or  reads 
data  to  and  from registers in the UART.   Table  2  shows  the 
various registers and their addresses.  DTR and OUT2 bits in  MCR 
must be set before communicating with the hardware.  The software 
sends  commands  and  data  to the hardware  by  writing  to  the 
transmitter  holding  register (THR) in the UART.   Data  can  be 
written  to THR when THRE and/or TSRE bits in LSR are  set.    It 
receives  responses  or  data from the hardware  by  reading  the 
receive  buffer register (RBR).  Software should first check  the 
LSR to see if DR bit is set indicating data is available in  RBR. 
Interrupts  can  also  be  used  to  inform  the  software   that 
transmitter is empty or data is available in the receiver.  Refer 
to  the  8250/16450  data sheet or the  IBM  technical  reference 
manual  for more information on programming, reading and  writing 
to the UART.

2.2 RS232 Standalone version

The UART in the SC11011 controller can be configured by  changing 
one  bit  (Bit3) in the code to present its serial  port  to  the 
outside  world.   To enable the DTR control function,  the  AT&D2 
command must be issued befoer entering the fax mode. 

The  standard 2400 bps modem command set is extended for the  Fax 
application using a format of AT#F...  These commands were developed
in accordance with the original set proposed in the TIA T30 committee
in spring of 1989. Sierra is continuing to work with the T29.2 committee
to define teh ultimate standard command set for fax and data modems. 

In  the idle state the hardware is in  the  normal 2400  bps modem
mode.  The UART is programmed at speeds from  300 to 2400 bps to
communicate with the hardware. In the fax mode, the DTE is set to 19.2Kbps.
Four  states  are defined to allow a clear understanding  of  the 
hardware control process:

     1. Modem command mode:   AT commands accepted
                              2400 bps max
                              modem data mode entered online
                              
     2. Modem data mode:      +++ escapes to modem command mode
                              2400 bps max

     3. Fax command mode:     entered from modem command mode 
                              with #F1
                              19.2 kbps only
                         
     4. Fax data mode:        commands and data at 19.2kbps only
                              return to fax command by:
                                   sending command #F 
                                   end of call/ call disconnect 
                                   dropping DTR 

After  power-up  the  hardware is in the normal  2400  bps  modem 
command mode.

A  special command puts the hardware in the Fax mode.    Once  in 
the  Fax  mode, the UART must be programmed for 19,200  bps  data 
rate, 8 bits and no parity.  This is because the image data  must 
be  sent  to  the hardware at a rate that  is  faster  than  line 
transmission  rate.   For 4800 bps synchronous transmission  line 
rate, the UART rate must be at least 9600 bps.  To allow for  the 
future accomodation of 9600 bps line transmission rate, the  UART 
speed  in  Fax mode is fixed at 19,200 bps.   The UART  speed  is 
programmed by setting the DLAB bit in the modem control  register 
(MCR)  and by writing appropriate values to the  divisor  latches 
DLL  and  DLM.   Table 3 provides the DLL,  DLM  speed  selection 
values.    Flow  control  (XON/XOFF or RTS/CTS)  is  required  to 
synchronize  the flow of information between the DTE and the  DCE 
during image data transmission and HDLC frame reception.  In  the 
data transmission mode, software must not send data when CTS  bit 
is  off  or  when <XOFF> is received.   Data can  be  sent  after 
receiving <XON> or when CTS bit is set.
  
.pa



Table 1.       COM port addresses

COM1   3F8 - 3FF    IRQ4
COM2   2F8 - 2FF    IRQ3
COM3   3E8 - 3EF    IRQ4
COM4   2E8 - 2EF    IRQ3

Table 2.1       UART registers

I/O decode (Hex)
COM1   COM2    COM3    COM4    R/W     DLAB    Register
----------------------------------------------------------------
3F8    2F8     3E8     2E8      W        0       THR        
3F8    2F8     3E8     2E8      R        0       RBR          
3F8    2F8     3E8     2E8     R/W       1       DLL
3F9    2F9     3E9     2E9     R/W       1       DLM
3F9    2F9     3E9     2E9     R/W       0       IER
3FA    2FA     3EA     2EA      R        0       IIR
3FB    2FB     3EB     2EB     R/W       0       LCR
3FC    2FC     3EC     2EC     R/W       0       MCR
3FD    2FD     3ED     2ED     R/W       0       LSR   
3FE    2FE     3EE     2EE     R/W       0       MSR

Table 2.2      Register bit defintions

Register       7     6     5     4     3     2     1     0
---------------------------------------------------------------
THR            -------- TRANSMIT DATA (DLAB = 0) ---------
RBR            -------- RECEIVE DATA  (DLAB = 0) ---------
DLL            ---- DIVISOR LATCH LS BYTE (DLAB = 1) -----         
DLM            ---- DIVISOR LATCH MS BYTE (DLAB = 1) -----
IER            0    0     0      0    MSI   LSI  THRE   DA
IIR            0    0     0      0     0    ID1   ID0   IP/
LCR          DLAB   SB    SP    EPS   PEN   STB  WLS1  WLS0
MCR            0    0     0    LOOP  OUT2  OUT1   RTS   DTR
LSR            0   TSRE  THRE   BI    FE    PE    OR    DR
MSR          RLSD   RI    DSR   CTS  DRLS  TERI  DDSR  DCTS  
---------------------------------------------------------------

Table 3.       Speed selection table 

SPEED (BPS)    DLM (HEX)   DLL (HEX)
----------------------------------------
300               01          80
1200              00          60
2400              00          30
4800              00          18
9600              00          0C
19200             00          06      
----------------------------------------



3.0    Command Set

Extensions to the Hayes AT command set for Fax mode operation are 
defined in this section.

General

1) All extended commands start with the # prefix. This represents 
a  major  change  from previous versions  which  utilized  the  + 
prefix. The change was made to provide upward compatibility  with 
future  TIA command sets which are expected to use the +  symbol. 
For the immediate future, the firmware will accept either prefix.

2)  All extended commands have only one alpha character  followed 
by a numeric value in the range of decimal 0 to 255.  Value 0 may 
be omitted.

3)  Fax mode assumes XON/XOFF or CTS flow control in  data  mode.  
&D2 command must be issued for DTR controlled abort.

4) Once the hardware enters the Fax mode, it  will remain in  Fax 
mode ( and accept commands at 19.2 kbps ) until one of  following 
occurs :

       a) software issues a #F request to return to command mode
       b) a call disconnect frame is received
       c) application software issues an abort by dropping DTR

COMMANDS


#Bn     Speed control

#B/B0   Reserved         
#B1     Reserved
#B2     Reserved for V.23
#B3     Reserved for V.23
#B4    Fax transmission speed of 2400 bps
#B5     Fax transmission speed of 4800 bps
#B6     Fax transmission speed of 7200 bps
#B7     Fax transmission speed of 9600 bps

This  command is used to specify the initial speed at  which  the 
hardware will attempt to connect to the remote Fax machine.   For 
the SC11046 based hardware this will normally be 4800 bps, so  B5 
command  will  be  used.  However, the user  at  his  option  can 
specify a lower initial speed of 2400 bps by issuing B4.  If  the 
higher  initial speed is specified, the hardware will attempt  to 
establish connection at the higher speed and will fallback to the 
lower speed if unsuccessful.




 

En     Received frame display format selection

E/E0   Disable display of received HDLC frames
E1     Display frame in binary format
E2     Display frame in 2 digit ASCII Hex format



Fn     Mode control

F/F0   Return to normal modem mode (300 to 2400 bps data rate)
F1     Enter Fax mode (19,200 bps data rate)


Kn     DTE flow control

K/K0   Disable flow control
K3     Enable CTS flow control
K4     Enable XON/XOFF flow control

Mn     Speaker Control
M0     Speaker Always Off
M1     Speaker Off after Connect Message
M2     Speaker Always On
M3     Speaker Off during Dial

Pn     Number of pages to be transmitted (n = 1 to 255)


Rn     Resolution control

R/R0   Send document with normal resolution
R1     Send document with fine resolution


Tn     Test modes

T/T0   End test mode
T1     Enter  test mode 1.  This mode is used to dial  a  remote       
       Fax   machine  and  automatically  send  a  message   stored 
       in EPROM.
.pa


FAX result codes

During the Fax session the hardware will report the status of the 
call with result codes.  An action by the software may or may not 
be necessary depending on the response.

All the normal Hayes result codes will also be reported.

Verbose                Digit   Usage


CED                      a     Ansertone detected 

CFR                      g     Remote machine confirmation to receive

CONNECT 2400/FAX         w     Connection speed 2400 bps

CONNECT 4800/FAX         x     Connection speed 4800 bps

CONNECT 7200/FAX         y     Connection speed 7200 bps

CONNECT 9600/FAX         z     Connection speed 9600 bps

CRC ERROR                e     Error in received frame

CRP                      c     Repeat request

CSI                      -     Remote machine Identification

DCN                      d     Disconnect
 
DIS                      b     Remote machine capabilities frame

FTT                      f     Failure to train

INVALID FRAME            i     Received frame is invalid

 MCF                      m     Message received OK

RTN                      h     Message not received OK

RTP                      j     Retrain positive
.pa


4.0    Data format

The  Transmit Subscriber Identification data encoded in the  T.30 
negotiation  will be taken from the nvram location  Z3. 


Image  data  will be in compressed format  with  one  dimensional 
coding  rules  in accordance with the  CCITT  specification  T.4.  
Data will be coded assuming the receiving Fax machine is  capable 
of  a  scan time of 0 milliseconds per line.  Each line  of  data 
must  terminate  with a minimum of 3 bytes of zeroes  before  the  
EOL   sequence.  The  zeroes must be byte aligned.  The    software 
will   detect  the zero  bytes at the end of each line  and  fill 
in  the  required   number   of zeroes  based  on  the  speed  of 
connection  and the minimum scan time per  line specified by  the 
receiving  Fax machine.  Data  must  be coded with MSB the  first 
bit   to  be  transmitted from DTE to modem.The modem sends the
data LSB first to the phone line..    Transmission  of  data    
will   be synchronized using flow control (XON/XOFF or CTS). After
sending the  last  byte of page data, software will  wait   for a
response  from the hardware before issuing a command  or  sending
data  for the next page.

5.0    Example sessions

In  the  following  example sessions, the  response  is  enclosed 
within  <> brackets.  The defaults are B3 (4800 bps), P1  (single 
page), R0 (normal resolution) and T0 (no test mode).    

Each  command line terminates with a CRLF, a response begins  and 
terminates with a CRLF.

i) Send 1 page of document with normal resolution

Command                       Response

ATX4&D2#B3#P1#R0#T0#F1        <OK>      ; Enter Fax mode
                              <XOFF> CTS -> 0

ATDT4082639337                <OK>      ; Dial a Fax machine
                                        ; any AT response valid
                              <CED>
                                        ;  Answertone detected

                              <CSI = 408 263 1234>
                                        ; Called machine 
                                        ; identification
                              <DIS>
                                        ; Capabilities 
                                        ; frame received

                              <CFR>
                                        ; OK to send page data

                              <CONNECT 4800/FAX>
                                        ; Connection speed
   
                              <XON>  CTS -> 1
                                        ; Page 1 data is sent 
                                        ; using flow control
---DATA--SENT---
                              <XOFF> CTS -> 0
---DATA STOPPED---
                              <XON>  CTS -> 1
---DATA--SENT---
                                        ; No more data for page 1
                                        ; tx underflow

                              <XOFF> CTS -> 0
                              <MCF>
                                        ; Page 1 transmission OK
          
                              <NO CARRIER>
                                        ; Call terminated, return to 
                                        ; command mode

no new commands 
until here
ii) Send 2 pages of document with normal resolution

Command                       Response                          

ATX4&D2#B3#P2#R0#T0#F1                  ; Enter Fax mode
                              <XOFF> CTS -> 0
                              <OK>

ATDT4082639337                <OK>      ; Dial a Fax machine
                                        ; any AT response valid
                              <CED>
                                        ; Answertone detected

                              <INVALID FRAME> 
                                        ; Received frame invalid

                              <CSI = 408 263 1234>
                                        ; Called machine 
                                        ; identification

                              <DIS>
                                        ; Capabilities 
                                        ; frame received


                              <CFR>
                                        ; OK to send page data
                
                              <CONNECT 4800/FAX>
                                        ; Connection speed

                              <XON>  CTS -> 1
                                        ; Page 1 data is sent
                                        ; using flow control
---DATA--SENT---
                              <XOFF> CTS -> 0
---DATA STOPPED---
                              <XON>  CTS -> 1
---DATA--SENT---
                                        ; No more data for page 1
                                        ; tx underrun
                              <XOFF> CTS -> 0
                              <MCF>
                                        ; Page 1 transmission OK
                                        
                              <XON>  CTS -> 1
                                        ; Page 2 Data is sent
                                        ; using flow control
---DATA--SENT---
                              <XOFF> CTS -> 0
---DATA STOPPED---
                              <XON>  CTS -> 1
---DATA--SENT---
                                        ; No more data for page 2
                                        ; tx underrun

                              <XOFF> CTS -> 0
                              <MCF>
                                        ; Page 2 transmission OK
                              <NO CARRIER>
                                        ; Call terminated, return to 
                                        ; command mode 
no new commands 
until here

-- 
Nick Pemberton  		 uucp: !{lsuc, uunet!mnetor}!aimed!nick
AIM, Inc			  bus: (416) 429-1085
Toronto, Ontario, Canada         Home: (416) 690-0647
Newsgroups: comp.dcom.fax,comp.dcom.modems