C语言串口通信-源代码
(*Char)=Buffer[CircOut];
if(CircOut<MaxBufLen-1)CircOut++;
else CircOut=0;
CharsInBuf--;
Flag=0;
}
return Flag;
}
int SendChar(unsigned char Char)
{
if((inp(comportaddr+5)&0x20)==0) return -1;
outp(comportaddr,Char);
return 0;
}
main()
{
int i,c;
unsigned char InChar;
Init_COM(COM232,COMINT,1200,8,1,0);
while(1)
{
if(kbhit())
{if((InChar=getch())==27)break;
else while(SendChar(InChar));
}
if(GetCharInBuf(&InChar)==0)
printf("%c",InChar);
}
Restore();
}
接收程序:
#include <dos.h>
#include <fstream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define RXD 0 //接收
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库C语言串口通信-源代码(3)在线全文阅读。
相关推荐: