FULL DUPLEX COMMUNICATION USING RS-232
IN C (CHARACTER PASSING)
CHARACTER TRANSMITTER-RECEIVER
#include<stdio.h>
#include<conio.h>
#include<bios.h>
#include<process.h>
#define
COM1 0
#define
COM2 0
#define
COM1ADDR 0x3F8
#define
DATA_READY 0x100
#define
TRANS_READY 0x2000
void
main()
{
int
ch;
printf("enter
your choice");
printf("\n
1:transmit \n 2:receive");
switch(ch)
{
case
1:
{
transfer();
break;
}
case 2:
{
receive();
break;
}
}
}
transfer()
{
char
ch,ch1,tfile;
int
status,choice;
char
setting,baud = 0xe0,parity = 0x08,data = 0x04,stop = 0x03;
setting = baud |
parity | data | stop;
clrscr();
bioscom(0,setting,COM1);
while(1)
{
clrscr();
printf("\n SERIAL COMMUNICATION USING RS-232
PROTOCOLS\n");
printf(" 1:
Char Transsmission...\t
2:Exit....\n");
printf("\n Enter Choice :\n");
scanf("%d",&ch);
switch(choice)
{
case 1:
do
{
ch=getch();
if(ch==0x0d)
printf("\n");
printf("%c",ch);
output(0x3f8,ch);
}
while(ch!=0x1b);
break;
case 2:exit(0);
}
}
}
receive()
{
char ch,ch1;
int
status,choice;
char
setting,baud = 0xe0,parity = 0x08,data = 0x04,stop = 0x03;
setting = baud |
parity | data | stop;
clrscr();
bioscom(0,setting,COM2);
while(1)
{
clrscr();
printf("\n SERIAL COMMUNICATION USING RS-232
PROTOCOLS\n");
printf("\n
1: Char Receive...\t
2:Exit....\n");
printf("\n Enter Choice :\n");
scanf("%d",&ch1);
switch(choice)
{
case 1:
do
{
status=bioscom(3,0,COM2);
if(status &
DATA_READY)
{
ch1 =
inport(0x2F8); if(ch1==0x0d)
printf("\n");
if(ch1==0x1b)
break;
printf("
%c",ch1);
}
}
while(ch1!=0x1d);
break;
case 2: exit(0);
}
}
}
No comments:
Post a Comment