Appendix A Register structure and format 23
/* Receive data on Port 2 (COM2) */
i=0;
flag=1;
timeout=TIME_OUT;
while (flag)
{
/* Check for received data on port*/
if ((inportb(base1+5) & 1) !=0)
{
rec[i]=inportb(base1); /* Receive data */
if (rec[i] == 0x0d)
{
rec[i+1]=’\0';
flag=0;
printf(“\nReceived data: %s\n”, rec);
}
i++;
}
else
{ /* Check timeout */
timeout—;
if (timeout == 0)
{
flag = 0;
printf(“\nTimeout error\n”);
}
}
} /* End of receive data while() */
printf("\nEnter string (max 15 char) or Q to quit:");
gets(cmd);
} /* End of "Enter string" while() */
} /* End of main() */
Komentáře k této Příručce