SIMPLEX
COMMUNICATION USING RS-232 IN C (CHARACTER PASSING)
SIMPLEX
CHARACTER TRANSMITER
#include<stdio.h>
#include<conio.h>
#include<bios.h>
#include<process.h>
#define COM1 0
main()
{
char ch;
int 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",&choice);
switch(choice)
{
case
1:
do
{
ch=getch();
printf("%c",ch);
outport(0x3F8,ch);
}
while(ch!=0x0d);
break;
case 2: exit(0);
}
}
}
Output:
SERIAL
COMMUNICATION USING RS-232 PROTOCOLS
1: Char
Transsmission... 2:Exit....
Enter Choice :
Darshikapatel
SIMPLEX
CHARACTER RECEIVER
#include<stdio.h>
#include<conio.h>
#include<bios.h>
#include<process.h>
#define
COM1 0
#define
DATA_READY 0x100
main()
{
char ch1;
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("\n Simplex Receiver\n");
printf(" \n
1: Char Receiver...\t
2:Exit....\n"); printf("\n Enter Choice :\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
do
{
status=bioscom(3,0,COM1);
if(status & DATA_READY)
{
ch1 = inport(0x3F8);
printf(" %c",ch1);
}
}
while(ch1!=0x0d);
break;
case 2:
exit(0);
}
}
}
No comments:
Post a Comment