NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages

This is an example of how to use the RS485Control, RS485DataAvailable, RS485Disable, RS485Initialize, RS485Enable, UseRS485, RS485Uart, RS485Status, RS485Read, RS485ReadEx, TextOut, and Wait functions.

// RS-485 receiver program
inline void WaitForMessageToBeSent()
task main()
byte mlen;
string buffer;
// configure the S4 port as RS485
// make sure the RS485 system is turned on
// // initialize the UART to default values
// RS485Initialize();
// configure the UART (this is equivalent to RS485Initialize)
Wait(MS_1); // make sure everything is turned on
byte ACK[] = {1};
while (true) {
// wait for a message to arrive.
// read the number of bytes message
until(RS485DataAvailable() >= 5);
// read the number of bytes
long cnt = 0;
UnflattenVar(buffer, cnt);
// send out ACK
// now wait for the real message
until(RS485DataAvailable() >= cnt);
// now read the actual message
RS485ReadEx(buffer, cnt);
// RS485Read(buffer);
// send out ACK
// display message
TextOut(0, LCD_LINE1, buffer);