Serial Port: Plain Text
Minimal RS-485 usage: initialise the port, print every carriage-return delimited message that arrives, and transmit a text line once per second.
let port = 1; // Available ports vary depending on the device. Refer to the serial.init documentation
function serialRxCallback(msg){
print("Received Serial Msg");
print("Port:", msg.port); // port of incoming msg
print("Overflowed:", msg.ovf); // msg.ovf is boolean true / false
print("Data:", msg.data);
}
serial.init(port, 19200);
serial.listen(port, "\r", serialRxCallback); // buffer rx until a carriage return arrives
while(run()){
serial.tx(port, "Hello World over serial!\r");
waitMS(1000);
}