串口0发送
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<bios.h>
send(int port,char cc);
main()
{
union
{
char ch[2];
int status;
}port_status;
char cc;
bioscom(0,0xEB,0);
port_status.status=bioscom(3,0,0);
if(port_status.status&0x100)
{
printf("error\n");
}
else
{
printf("jiuxu\n");
} /*************以上为初始化**********/
while(1)
{
send(0,0x0a);
}
}
send(int port,char cc)
{
union
{
char ch[2];
int status;
}port_status;
port_status.status=bioscom(1,cc,0);
if(port_status.status&128)
{
printf("error\n");
}
printf("OK\n");
}
串口1接收
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<bios.h>
receive(int port);
main()
{
union
{
char ch[2];
int status;
}port_status;
bioscom(0,0xEB,1);
port_status.status=bioscom(3,0,1);
if(port_status.status&0x100)
{
printf("error\n");
}
else
{
printf("jiuxu\n"); /***********以上为初始化************/
}
while(1)
{
receive(1);
}
}
receive(int port)
{
union
{
char ch[2];
int status;
}port_status;
port_status.status=bioscom(2,0,port);
printf("OK\n");
printf("%x\n",port_status.ch[0]);
}