From ee5ad6bc2696966f3f6d3ae381042c9f5d60e647 Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Sun, 29 Jan 2023 12:50:38 +0100 Subject: [PATCH] add RP2 and pyboard pin usage examples for RTU examples in documentation, relates to #7 and #17 --- docs/EXAMPLES.md | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/docs/EXAMPLES.md b/docs/EXAMPLES.md index 90db8db..2439640 100755 --- a/docs/EXAMPLES.md +++ b/docs/EXAMPLES.md @@ -27,8 +27,22 @@ RTU (serial/UART) to a requesting host device. from umodbus.serial import ModbusRTU # RTU Client/Slave setup -# the following example is for an ESP32 + +# the following definition is for an ESP32 rtu_pins = (25, 26) # (TX, RX) +uart_id = 1 + +# the following definition is for a RP2 +# rtu_pins = (Pin(0), Pin(1)) # (TX, RX) +# uart_id = 0 +# +# rtu_pins = (Pin(4), Pin(5)) # (TX, RX) +# uart_id = 1 + +# the following definition is for a pyboard +# rtu_pins = (Pin(PB6), Pin(PB7)) # (TX, RX) +# uart_id = 1 + slave_addr = 10 # address on bus as client client = ModbusRTU( @@ -39,7 +53,7 @@ client = ModbusRTU( # stop_bits=1, # optional, default 1 # parity=None, # optional, default None # ctrl_pin=12, # optional, control DE/RE - # uart_id=1 # optional, see port specific documentation + uart_id=uart_id # optional, default 1, see port specific documentation ) register_definitions = { @@ -95,8 +109,21 @@ setting data at a RTU (serial/UART) client/slave. from umodbus.serial import Serial as ModbusRTUMaster # RTU Host/Master setup -# the following example is for an ESP32 + +# the following definition is for an ESP32 rtu_pins = (25, 26) # (TX, RX) +uart_id = 1 + +# the following definition is for a RP2 +# rtu_pins = (Pin(0), Pin(1)) # (TX, RX) +# uart_id = 0 +# +# rtu_pins = (Pin(4), Pin(5)) # (TX, RX) +# uart_id = 1 + +# the following definition is for a pyboard +# rtu_pins = (Pin(PB6), Pin(PB7)) # (TX, RX) +# uart_id = 1 host = ModbusRTUMaster( pins=rtu_pins, # given as tuple (TX, RX) @@ -105,7 +132,7 @@ host = ModbusRTUMaster( # stop_bits=1, # optional, default 1 # parity=None, # optional, default None # ctrl_pin=12, # optional, control DE/RE - # uart_id=1 # optional, see port specific documentation + uart_id=uart_id # optional, default 1, see port specific documentation ) coil_status = host.read_coils(slave_addr=10, starting_addr=123, coil_qty=1)