Clarifications, updated 28/5/00
The DTE sends whole packets to the DCE. Thus when only the RTS is reset (set to 0)
the DCE waits to receive the whole packet and only then acknowledges with resetting the CTS.
If the DTR is reset as well before the whole packet has been received, this means that the DTE wants to terminate communication immediately, even in the middle
of a packet.
Write a program that simulates the Modem Communication Protocol (by sending
a file) between a DTE (processor) to a DCE (modem). The sender will be
the DTE and the receiver the DCE. The program will be called dte2dce
and receives from the user the following command line parameters:
For example the sender must run his program like this:
Mode (dte or dce).
The COM (COM1, COM2, COM3 or COM4).
Word length (5 - 8).
Number of stop bits (1, 1.5, 2).
Parity (even, odd, or none).
Transfer rate (given the transfer rate you must compute the baud rate).
Name of text file to transfer (dte only).
C:\>dte2dce dte COM1 8 1 odd 1200 ex4.c
The receiver must run his program like this:
C:\>dte2dce dce COM1 8 1 odd 1200
The program must get the base address of the COM from the BIOS (address
After the transmission parameters have been set, the DTE establishes communication
according to protocol.
It then reads the file line by line and sends each line as a "packet" to
A packet is a block of bytes framed by a flag byte, the value of the flag
byte is 0x7e (the '~' character). The packet is followed by the CRC byte.
If the input file contains the '~' character it is exchanged with the string
"/$/@/" (you may assume this string isn't in the input file).
Data is sent using the code you have written for the previous assignment.
You must make sure of course before sending a byte that the DCE is ready
to receive data (the CTS and DSR
When the DTE isn't transmitting (reading from the file for example) the
RTS must be reset, this
notifies the DCE that transmission is suspended.
After the file is sent the connection is severed (terminated) by
resetting the DTR.
As in the previous assignment you must listen for errors that the DCE might
detect and send, print them, and terminate transmission (according to protocol).
It doesn't matter which side is started first, the DCE must wait for the
DTE and vice-versa. Thus when a program exits it must make sure that all
the control lines are reset.
After the transmission parameters have been set, the DCE waits until the
DTE establishes communication.
It then enters a loop where it receives "packets" from the DTE. The packets
are stored in a buffer. When the buffer is full the DCE prints its contents
to the screen. The DCE must reset the CTS
when it is printing and set it when it is ready to receive more packets.
If there is an error in the data the DCE must let the DTE know what the
error is (a bad CRC or a packet that doesn't start with the '~' char are
also errors). Only the DTE can terminate communication by reseting the
DTR. The DCE then resets the DSR.