From 94a00b25b4ba76149a56844d53685be739c752da Mon Sep 17 00:00:00 2001 From: freemp <10712989+freemp@users.noreply.github.com> Date: Wed, 22 Mar 2023 07:22:00 +0100 Subject: [PATCH 1/2] Make delay depend on number of bits per character As per specification, there should be always 11 bits transmitted for each character. --- .../ModbusRTUClientParameters/ModbusRTUClientParameters.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/RTU/ModbusRTUClientParameters/ModbusRTUClientParameters.ino b/examples/RTU/ModbusRTUClientParameters/ModbusRTUClientParameters.ino index 91b9ec4..15dcfc4 100644 --- a/examples/RTU/ModbusRTUClientParameters/ModbusRTUClientParameters.ino +++ b/examples/RTU/ModbusRTUClientParameters/ModbusRTUClientParameters.ino @@ -22,9 +22,9 @@ constexpr auto baudrate { 19200 }; // Paragraph 2.5.1.1 MODBUS Message RTU Framing // https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf constexpr auto bitduration { 1.f / baudrate }; -constexpr auto wordlen { 9.6f }; // try also with 10.0f -constexpr auto preDelayBR { bitduration * wordlen * 3.5f * 1e6 }; -constexpr auto postDelayBR { bitduration * wordlen * 3.5f * 1e6 }; +constexpr auto charlen { 11.0f }; +constexpr auto preDelayBR { bitduration * charlen * 3.5f * 1e6 }; +constexpr auto postDelayBR { bitduration * charlen * 3.5f * 1e6 }; void setup() { Serial.begin(9600); From aed35cb68870123bfd1c69c416aa22c5a4c59020 Mon Sep 17 00:00:00 2001 From: kidpixo Date: Thu, 11 May 2023 11:54:15 +0200 Subject: [PATCH 2/2] Update api.md correct a small markdown typo in `requestFrom` input type descriptio. --- docs/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 48e1b3c..76097f3 100644 --- a/docs/api.md +++ b/docs/api.md @@ -229,7 +229,7 @@ int requestFrom(int id, int type, int address,int nb); #### Parameters - id (slave) - id of target, defaults to 0x00 if not specified -type - type of read to perform, either COILS, DISCRETE_INPUTS, HOLDING_REGISTERS, or INPUT_REGISTERS +- type - type of read to perform, either COILS, DISCRETE_INPUTS, HOLDING_REGISTERS, or INPUT_REGISTERS - address start address to use for operation - nb - number of values to read