micropython modus - pairty even not defined? #14061
Unanswered
Nilan8902
asked this question in
RP2040 / Pico
Replies: 1 comment
-
from machine import UART
u = UART(0,19200,8,0,1) # parity even
u = UART(0,19200,8,1,1) # parity odd |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to connect to one our standard controllers using a pico with the pico-2ch-rs485 hat. uisng Thonny i got almost everything to work, but can't get the last bit. Our controller is 19200 Baud, Even, 1. and i need to change the parity from the default None to Even.
When I change None to Even the text is not highlighted and running the code I get an error that the name 'Even' isn't defined.
How can I enable a communication with Parity Even?
from machine import UART
from machine import Pin
import struct
import time
import machine
from umodbus.serial import Serial as ModbusRTUMaster
RTU Host/Master setup
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
host = ModbusRTUMaster(
pins=rtu_pins, # given as tuple (TX, RX)
baudrate=19200, # optional, default 9600
data_bits=8, # optional, default 8
stop_bits=1, # optional, default 1
parity=None, # optional, default None
# ctrl_pin=12, # optional, control DE/RE
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)
print('Status of coil 123: {}'.format(coil_status))
Beta Was this translation helpful? Give feedback.
All reactions