当前位置: 代码迷 >> C语言 >> 串口通讯前几个字节丢失的问题
  详细解决方案

串口通讯前几个字节丢失的问题

热度:324   发布时间:2007-05-11 10:20:53.0
串口通讯前几个字节丢失的问题

/*interrupt sevice*/
void interrupt far asyncint()
{

InBuffer[buffin++]= inportb(BaseAddCOM4);
if(buffin>=INBUFFNUM)
buffin = 0;

outportb(0x20,0x20);
}


/*Read char from buffer*/
unsigned char read_char(void)
{
unsigned unch;
if(buffout!=buffin)
{
unch = InBuffer[buffout];
buffout++;
if(buffout>=OUTBUFFNUM)
buffout = 0;
return(unch);
}

}

main()
{
/*前略,就开了接收中断*/
for(i=0;i<7;i++)
{
ucChar[i] = read_char();
ucChar1[i]=~ucChar[i];
printf("%x ",ucChar[i]);
}

}
下位机发回来7字节数据,而我只能接收到后面3-4个字节得数,请指点!

搜索更多相关的解决方案: 串口  通讯  字节  buffout  unch  

----------------解决方案--------------------------------------------------------
  相关解决方案