Indicate the RX port for the communications with microcontroller
TXnumber
Indicate the TX port for the communications with microcontroller
SETnumber
Set the RS485 into receiving (0) or sending (1) data mode
OUT@/ttl-device
Connect to receive-rs485-data node
SET1number
Connect to SET pin in receive-rs485-data
To use the node in your project you should have the antoniorruiz/rs485 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
#pragma XOD require "https://github.com/PaulStoffregen/SoftwareSerial"
#include<SoftwareSerial.h>
#define TX_485 8
#define RX_485 7
node {
meta {
using Type = SoftwareSerial*;
}
SoftwareSerial Serial_RS485 = SoftwareSerial (RX_485, TX_485);
Number foo;
uint8_t bar = 5;
void evaluate(Context ctx) {
bar += 42;
if (isSettingUp()) {
// This run once
foo = (Number)(bar + 1);
}
int SET;
SET = getValue<input_SET>(ctx);
pinMode (SET, OUTPUT);
Serial_RS485.begin(9600);
emitValue<output_SET1>(ctx, SET);
emitValue<output_OUT>(ctx, &Serial_RS485);
}
}