studer-innotec / xcom485i

Python library to access Studer-Innotec Xcom-485i device through Modbus RTU over a serial port
MIT License
6 stars 4 forks source link

Check if Modbus telegramm/answer exist #3

Open Jusufs opened 1 year ago

Jusufs commented 1 year ago

Hi, I wrote a python routine with a list of Modbus telegram numbers like:

` list = [10000, 372, 920, 418, 666, 198, ... 1098]

    xcom485i = Xcom485i(serial_port, DIP_SWITCHES_ADDRESS_OFFSET, debug=False)
    while list:
        read_value = xcom485i.read_parameter(xcom485i.addresses.xt_1_device_id, list[0]) # modbus reg
        list.pop(0)`

How can I check that e.g. non existent modbus telegram 10000 returns error please ?

TypeError: not all arguments converted during string formatting Call stack: File "/etc/openhab2/scripts/xcom485i/r_1all.py", line 45, in <module> read_value = xcom485i.read_parameter(xcom485i.addresses.xt_1_device_id, list[0]) # modbus reg File "/usr/local/lib/python3.9/dist-packages/xcom485i/client.py", line 150, in read_parameter logger.error("--> Modbus error : ", e)

I'm trying to sort out nonexistent/ non answering modbus telegrams from primary list and build a secondary list with only valid telegrams. Thanks.