Rockwell Automation 5370 CVIM Communications Manual User Manual
Page 129

Chapter 5
Using the RS-232 Ports
5–59
case 14:
err =send_message(portnum,”\013\002\031”, 3);
break;
case 15:
err =send_message(portnum,”\013\002\034”, 3);
break;
case 16:
err =send_message(portnum,”\013\002\035”, 3);
break;
default:
break;
} /* End switch (op_num) statement */
if (err)
printf (”Error code: %04xn”,err);
if (replen)
{
printf (”Response ”);
for (x=0; x<replen; x++)
printf (”%02X”, reply [x]);
printf (”n”);
}
} while (op num>=0); */ End do loop */
}
/* Transmits the message pointed to by msg, consisting of len characters.
If the message is not acknowledged, re–transmits it up to 2 more times.
Returns zero if successful or nonzero if an error occurs. */
int send_message (portnum, msg, len)
int portnum */ Communications port # */
unsigned character *msg */ Pointer to message data */
int len; */ Length of message */
{
int x, ch, chksum, err, retry=3;
do
{
/* if an incoming char is waiting, clear it out */
while (_bios_serialcom(_COM_STATUS, portnum, 0) & 256)
_bios_serialcom(_COM_RECEIVE, portnum, 0);