From b5a6775cce46a0847a95eb0db52602e056779c96 Mon Sep 17 00:00:00 2001 From: svollenweider <34137138+svollenweider@users.noreply.github.com> Date: Fri, 3 Jan 2025 13:36:35 +0100 Subject: [PATCH 1/5] Update RS485CommClass.cpp Added RS485Config --- src/RS485CommClass.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 ****/ From b1f871ecbe0b39f917ebb9a48cfbadb0b229cd75 Mon Sep 17 00:00:00 2001 From: svollenweider <34137138+svollenweider@users.noreply.github.com> Date: Fri, 3 Jan 2025 13:39:12 +0100 Subject: [PATCH 2/5] Update RS485CommClass.h --- src/RS485CommClass.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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. From aca2de09cad235be8fa3c29e0d161c24e0a74587 Mon Sep 17 00:00:00 2001 From: svollenweider <34137138+svollenweider@users.noreply.github.com> Date: Mon, 15 Sep 2025 17:53:10 +0200 Subject: [PATCH 3/5] Update RS485_fullduplex.ino --- examples/RS485_fullduplex/RS485_fullduplex.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/RS485_fullduplex/RS485_fullduplex.ino b/examples/RS485_fullduplex/RS485_fullduplex.ino index 71a9dd4..ff4dbe6 100644 --- a/examples/RS485_fullduplex/RS485_fullduplex.ino +++ b/examples/RS485_fullduplex/RS485_fullduplex.ino @@ -38,7 +38,7 @@ void setup() { // - Half Duplex // - No A/B and Y/Z 120 Ohm termination enabled // Enable the RS485/RS232 system - MachineControl_RS485Comm.begin(115200, 0, 500); // Specify baudrate, and preamble and postamble times for RS485 communication + MachineControl_RS485Comm.begin(115200, SERIAL_8N1, 0, 500); // Specify baudrate, serial_config and preamble and postamble times for RS485 communication // Enable Full Duplex mode // This will also enable A/B and Y/Z 120 Ohm termination resistors @@ -70,4 +70,4 @@ void loop() { sendNow = millis() + sendInterval; } -} \ No newline at end of file +} From 13ee6dbebb7269a00fad5352e45f421191e4d537 Mon Sep 17 00:00:00 2001 From: svollenweider <34137138+svollenweider@users.noreply.github.com> Date: Mon, 15 Sep 2025 17:53:49 +0200 Subject: [PATCH 4/5] Update RS485_halfduplex.ino --- examples/RS485_halfduplex/RS485_halfduplex.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/RS485_halfduplex/RS485_halfduplex.ino b/examples/RS485_halfduplex/RS485_halfduplex.ino index 6bb6a36..9da354a 100644 --- a/examples/RS485_halfduplex/RS485_halfduplex.ino +++ b/examples/RS485_halfduplex/RS485_halfduplex.ino @@ -37,7 +37,7 @@ void setup() { // - Half Duplex // - No A/B and Y/Z 120 Ohm termination enabled // Enable the RS485/RS232 system - MachineControl_RS485Comm.begin(115200, 0, 500); // Specify baudrate, and preamble and postamble times for RS485 communication + MachineControl_RS485Comm.begin(115200, SERIAL_8N1, 0, 500); // Specify baudrate, serial config and preamble and postamble times for RS485 communication // Start in receive mode MachineControl_RS485Comm.receive(); @@ -65,4 +65,4 @@ void loop() { sendNow = millis() + sendInterval; } -} \ No newline at end of file +} From bf6efca62cc2e7fca1b7bae0fae3d677eeb9569d Mon Sep 17 00:00:00 2001 From: Silvan Vollenweider Date: Mon, 15 Sep 2025 18:12:30 +0200 Subject: [PATCH 5/5] Removed = in cpp --- src/RS485CommClass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RS485CommClass.cpp b/src/RS485CommClass.cpp index e6dfb41..c7afa6d 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, uint16_t config = SERIAL_8N1, int predelay, int postdelay) { +void RS485CommClass::begin(unsigned long baudrate, uint16_t config, int predelay, int postdelay) { /* Pinout configuration */ pinMode(PinNameToIndex(MC_RS485_TX_PIN), OUTPUT); pinMode(PinNameToIndex(MC_RS485_RX_PIN), OUTPUT);