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

[BUG] modbus_connector - 345 - required argument is not an integer" #448

Closed smartwizint closed 2 years ago

smartwizint commented 3 years ago

Describe the bug I am doing a connection test of the thingsboard IoT Gateway and thingsboard by setting up a modus connector on the Gateway. When updating the "shared attributes" of "device" in thingsboard, I get an error in some cases.

  1. If the "type" of "attributeUpdates" is set to "16bit" in the modbus.json setting, no error occurs. "attributeUpdates": [ { "tag": "shared_attribute_write", "type": "16int", "wordOrder": "LITTLE", "byteOrder": "BIG", "functionCode": 6, "objectsCount": 1, "address": 0 } ],

  2. An error occurs when the "type" of "attributeUpdates" is set to "32bit" or "64bit" in the modbus.json setting. "attributeUpdates": [ { "tag": "shared_attribute_write", "type": "32int", "wordOrder": "LITTLE", "byteOrder": "BIG", "functionCode": 6, "objectsCount": 2, "address": 0 } ],

Connector name (If bug in the some connector): modbus_connector

Error traceback (If available): ""2020-12-21 13:00:16" - ERROR - [modbus_connector.py] - modbus_connector - 345 - required argument is not an integer" Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-2.5.4-py3.7.egg/thingsboard_gateway/connectors/modbus/modbus_connector.py", line 343, in process_rpc_request response = self.function_to_device(rpc_command_config, rpc_command_config["unitId"]) File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-2.5.4-py3.7.egg/thingsboard_gateway/connectors/modbus/modbus_connector.py", line 298, in __function_to_device unit=unit_id) File "/home/pi/.local/lib/python3.7/site-packages/pymodbus/client/common.py", line 92, in write_register return self.execute(request) File "/home/pi/.local/lib/python3.7/site-packages/pymodbus/client/sync.py", line 108, in execute return self.transaction.execute(request) File "/home/pi/.local/lib/python3.7/site-packages/pymodbus/transaction.py", line 158, in execute broadcast=broadcast File "/home/pi/.local/lib/python3.7/site-packages/pymodbus/transaction.py", line 228, in _transact packet = self.client.framer.buildPacket(packet) File "/home/pi/.local/lib/python3.7/site-packages/pymodbus/framer/socket_framer.py", line 206, in buildPacket data = message.encode() File "/home/pi/.local/lib/python3.7/site-packages/pymodbus/register_write_message.py", line 42, in encode packet += struct.pack('>H', self.value) struct.error: required argument is not an integer

Versions (please complete the following information):

imbeacon commented 2 years ago

Hi @smartwizint ,

This issue was fixed in the gateway, you can try to use the latest release version or the version from the master branch.