HALF 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 COM2 1
#define COM1ADDR
0x2F8
#define
DATA_READY 0x100
#define
TRANS_READY 0x2000
main()
{
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(" 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);
}
}
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