MOD5213: RS232 communication
Posted: Thu Feb 17, 2011 8:47 am
Hi,
I used a MOD5213 talk to a device through RS232 (UART 1). MOD5213 sent a command to the device and device feedback status. MOD5213 will write feedback status on UART 0. Problem is: when MOD5213 read the feedback from the device (on UART1), it sent back the readout content to the device (on UART1), which caused problem. I use NBEClipse and the code is as follow:
{
SimpleUart(1, 19200); // Initialize UART1
writestring(1, "GetStatus\r\n"); // Send command to UART1
OSTimeDly(2);
assign_stdio(1);
if ( charavail(1) ) // Listen to UART1
{
gets(buffer); // Read UART1 if feedback detected
assign_stdio(0);
}
else
{
assign_stdio(0);
writestring(0, "Communication ERROR\r\n");
return 1;
}
writestring(0, buffer); // Write device feedback value to UART0
writestring(0, "\r\n");
}
Thanks.
I used a MOD5213 talk to a device through RS232 (UART 1). MOD5213 sent a command to the device and device feedback status. MOD5213 will write feedback status on UART 0. Problem is: when MOD5213 read the feedback from the device (on UART1), it sent back the readout content to the device (on UART1), which caused problem. I use NBEClipse and the code is as follow:
{
SimpleUart(1, 19200); // Initialize UART1
writestring(1, "GetStatus\r\n"); // Send command to UART1
OSTimeDly(2);
assign_stdio(1);
if ( charavail(1) ) // Listen to UART1
{
gets(buffer); // Read UART1 if feedback detected
assign_stdio(0);
}
else
{
assign_stdio(0);
writestring(0, "Communication ERROR\r\n");
return 1;
}
writestring(0, buffer); // Write device feedback value to UART0
writestring(0, "\r\n");
}
Thanks.