Download Print this page

Advantech PCL-740 User Manual page 26

Serial communication rs-232/422/485/current-loop interface card

Advertisement

/* 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);
if (rec[i] == 0x0d)
{
}
i++;
}
else
{
/* Check timeout */
timeout—;
if (timeout == 0)
{
}
}
} /* 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() */
rec[i+1]='\0';
flag=0;
printf("\nReceived data: %s\n", rec);
flag = 0;
printf("\nTimeout error\n");
/* Receive data */
Appendix A Register structure and format
23

Advertisement

loading