小弟还是一个新手,请教各位一个问题,还望不吝赐教!
以下是我在tc下的一个小程序,功能是向串口端port发送一个字符,但是在执行到
“if(r.h.ah&128)”时,老是判断出错,我查了一下书,发现这个语句是用来判
断存放串口端状态位的ah寄存器的位7--超时错误标志是否为1,请教各位,com口
在何时发生超时错误,又如何解决?还望多多指教!
#define PORT 0
#include <dos.h>
#include <stdio.h>
void sport(),port_init(),wait();
void sport(port,c)
int port;
char c;
{
union REGS r;
printf("%d,\n",r.h.ah); /*debug 4*/
r.x.dx=port;
r.h.al=c;
r.h.ah=1;
printf("%d,%d,\n",r.h.ah,r.h.al); /*debug 5*/
int86(0x14,&r,&r);
printf("%d,%d,\n",r.h.ah,r.h.al); /*debug 6*/
if(r.h.ah&128) /* 出错部分*/
{
printf ("send error detected in serial port\n");
exit(1);
}
}