1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <process.h>
#include<string.h>
#define PORT1 0x3F8
void main(void)
{
int c,ch,cnt,select;
loop:
clrscr();
outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */
outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */
outportb(PORT1 + 0 , 0x0c); /* Set Baud rate - Divisor Latch Low Byte */
outportb(PORT1 + 1 , 0x00); /* Set Baud rate - Divisor Latch High Byte */
outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */
outportb(PORT1 + 2 , 0xC7); /* FIFO Control Register */
outportb(PORT1 + 4 , 0x0B); /* Turn on DTR, RTS */
cnt=0;
cout<<"1. Transmission Mode\n";
cout<<"2. Exit\n\n";
cout<<"Enter your Option: ";
cin>>select;
if(select==1)
{
clrscr();
char str[200]={'\0'},st;
cout<<"Enter string(less than 200) to trasmit\n";
gets(str);
cout<<"\nTotal number of "<<strlen(str)<<" characters entered";
cout<<"\nPress enter to transmit...";
getch();
for(int x=0;x<strlen(str);x++)
{
outport(PORT1,str[x]);
}
clrscr();
cout<<"\n\n\t\t\t\tPRESS ESCAPE TO EXIT\n";
do
{
c = inportb(PORT1 + 5);
if (c & 1)
{
st = inportb(PORT1);
cout<<st;
cnt++;
}
if(kbhit())
{
ch=getch();
}
}while(ch !=27);
cout<<"\nTotal number of "<<cnt<<" characters recieved";
cout<<"Press enter to continue..."<<getch();
}
else
{
exit(0);
}
goto loop;
}
|