diff --git a/src/RS485CommClass.cpp b/src/RS485CommClass.cpp index 4cd4b75..e6dfb41 100644 --- a/src/RS485CommClass.cpp +++ b/src/RS485CommClass.cpp @@ -17,7 +17,7 @@ RS485CommClass::RS485CommClass(arduino::UART& uart_itf, PinName rs_tx_pin, PinNa RS485CommClass::~RS485CommClass() { } -void RS485CommClass::begin(unsigned long baudrate, int predelay, int postdelay) { +void RS485CommClass::begin(unsigned long baudrate, uint16_t config = SERIAL_8N1, int predelay, int postdelay) { /* Pinout configuration */ pinMode(PinNameToIndex(MC_RS485_TX_PIN), OUTPUT); pinMode(PinNameToIndex(MC_RS485_RX_PIN), OUTPUT); @@ -45,7 +45,7 @@ void RS485CommClass::begin(unsigned long baudrate, int predelay, int postdelay) _enable(); /* Call begin() base class to initialize RS485 communication */ - RS485Class::begin(baudrate, predelay, postdelay); + RS485Class::begin(baudrate, config, predelay, postdelay); return; } @@ -92,4 +92,4 @@ void RS485CommClass::_disable() { arduino::UART _UART4_ {MC_RS485_TX_PIN, MC_RS485_RX_PIN, NC, NC}; RS485CommClass MachineControl_RS485Comm(_UART4_); -/**** END OF FILE ****/ \ No newline at end of file +/**** END OF FILE ****/ diff --git a/src/RS485CommClass.h b/src/RS485CommClass.h index b518533..a87d91e 100644 --- a/src/RS485CommClass.h +++ b/src/RS485CommClass.h @@ -54,10 +54,11 @@ class RS485CommClass : public RS485Class { * This method initializes the RS485 communication protocol with the specified baud rate and pre/post delays. * * @param baudrate The desired baud rate for the RS485 communication. + * @param config The desired Serial config (bits, parity and stopbits), see HardwareSerial.h * @param predelay The delay before sending data in the RS485 communication (default: RS485_DEFAULT_PRE_DELAY). * @param postdelay The delay after sending data in the RS485 communication (default: RS485_DEFAULT_POST_DELAY). */ - void begin(unsigned long baudrate = 115200, int predelay = RS485_DEFAULT_PRE_DELAY, int postdelay = RS485_DEFAULT_POST_DELAY); + void begin(unsigned long baudrate = 115200, uint16_t config = SERIAL_8N1, int predelay = RS485_DEFAULT_PRE_DELAY, int postdelay = RS485_DEFAULT_POST_DELAY); /** * @brief Close the RS485 communication protocol.