import utime
from machine import UART
from machine import Pin
import uos
# query: slave address\function code\start address (hi)\start address (lo)\number of points (hi)\number of points (lo)
# query: b'\x01\x03\x04\x00\x00\x08'
def test():
print("modbus")
uos.dupterm(None, 1)
modbus = UART(0)
modbus.init(baudrate=9600, parity=0, bits=8, stop=1, timeout=500, timeout_char=2, tx=Pin(1), rx=Pin(3))
print("Reading from modbus: {}".format(modbus))
while True:
modbus.write(b'\x01\x03\x04\x00\x00\x08')
print("Can read: {}".format(modbus.any()))
utime.sleep(0.1)
result = modbus.readline()
if result is not None:
print("Value of reading: {}, type of {}".format(result, type(result)))
utime.sleep(0.5)
uart = UART(0, 115200)
uos.dupterm(uart, 1)
I tried making the query, but I don't understand it as good therefore it's not working. Also, the result I get after reading is None, and accoding to micropython documentation, it shows, that it timeouted. Thanks again for any help!!!