thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.72k stars 829 forks source link

ERROR - [modbus_connector.py] - modbus_connector - 215 - 'bool' object is not iterable" #492

Closed PRiOTiers closed 3 years ago

PRiOTiers commented 3 years ago

I am not able to write 1/0 to a coil: If I write 1 through thingsboard, coil will be set to 1 If I write 0 through thingsboard, coil will be set to 1 as well.

I can write this coil with mbpoll without any issue instead:

I used mbpoll Function 0: Discrete output (coil) data type (binary 0 or 1)


Setup

{ "server": { "name": "Modbus Default Server", "type": "serial", "method": "rtu", "port": "/dev/ttymxc0", "baudrate": 9600, "stopbits": 1, "bytesize": 8, "timeout": 35, "devices": [ { "unitId": 91, "deviceName": "TEST_Device_001", "deviceType": "Device_001", "attributesPollPeriod": 5000, "timeseriesPollPeriod": 5000, "sendDataOnlyOnChange": false, "attributeUpdates": [ { "tag": "relay_01", "type": "bits", "functionCode": 5, "objectsCount": 1, "address": 17 }, .....


Output

""2021-03-17 11:42:53" - ERROR - [modbus_connector.py] - modbus_connector - 215 - 'bool' object is not iterable" Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/thingsboard_gateway-2.5.5.2-py3.8.egg/thingsboard_gateway/connectors/modbus/modbus_connector.py", line 213, in on_attributes_update self.__process_rpc_request(to_process, attribute_updates_command_config) File "/usr/local/lib/python3.8/site-packages/thingsboard_gateway-2.5.5.2-py3.8.egg/thingsboard_gateway/connectors/modbus/modbus_connector.py", line 340, in process_rpc_request rpc_command_config["payload"] = self.devices[content["device"]]["downlink_converter"].convert( File "/usr/local/lib/python3.8/site-packages/thingsboard_gateway-2.5.5.2-py3.8.egg/thingsboard_gateway/connectors/modbus/bytes_modbus_downlink_converter.py", line 71, in convert builder_functions"bits" File "/root/.local/lib/python3.8/site-packages/pymodbus/payload.py", line 161, in add_bits value = pack_bitstring(values) File "/root/.local/lib/python3.8/site-packages/pymodbus/utilities.py", line 91, in pack_bitstring for bit in bits: TypeError: 'bool' object is not iterable


Versions (please complete the following information):

Debian GNU/Linux 10 (buster) Kernel: 5.4.24 docker/stable 1.5-2 all Thingsboard IoT Gateway version 2.5.5.2 python3/stable 3.7.3-1 armhf

imbeacon commented 3 years ago

Hi @yvo-pfenninger ,

Thank you for your message, could you try to use the version from the master branch. It is a know issue and fix for it will be available in the next release.