Assignment #3
Clarifications, updated 15/3/00
Although you may receive any word length your program has to work only for
lengths 7 and 8.
Write a program that sends messages between two computers through their serial
ports.
The program will be called talk2me and receives from the user the following
command line parameters:
- Mode (send or recv).
- 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).
For example the sender must run his program like this:
C:\>talk2me send COM1 8 1 odd 1200
The receiver must run his program like this:
C:\>talk2me recv COM1 8 1 odd 1200
The program must get the base address of the COM from the BIOS (address 0x400).
Sending
After the transmission parameters have been set, the program enters a loop
where it receives strings from the user and sends them through the
serial port. This is done by writing each char to the THR. Have the NULL char
signal the end of the string. Don't forget to check the LSR to make sure the
current char has been sent. If an error in transmission happens you must notify
the user that an error occured, where it occured (sender or receiver) and what
the error is.
Termination of the program is performed by sending the "quit" string (use
strncmp() to check if the string is the quit string).
When the quit string has been received the program breaks the transmission by
setting the Break bit of the LCR and then exiting.
Receiving
After the transmission parameters have been set, the program enters a loop
where it receives chars from the RBR, writes them into a buffer and when the
NULL char is received prints the string. Check if a new char has arrived by
reading the LSR.
If there is an error in the data the receiver must let the sender and the user
know what
the error is. In the case of an error you may stop transmission.
The receiver is notified that the sender has finished transmitting when the
Break signal is sent on the line.