Skip to content

[BUG] Multiple registers write (function 16) uses wrong endianness convention #1275

Description

@cfloridia

Dear community,
during my test of the IoTGateway MODBUS connector I found a bug in the write operation of data type involving multiple registers.
I tested int32 and float32, but I suspect that the problem span to other multiple register data type.
In brief, the word order defined in the connection properties is not respected in the RPC perations.

I using the latest available Docker Container: thingsboard/tb-gateway:3.4.4
image

Below I have reported two tests that can help to preproduce the issue.

This is the IoTGateway coinfiguration reported as text for "cut and paste":

{
"master": {
"slaves": [
{
"host": "host.docker.internal",
"port": 502,
"type": "tcp",
"method": "socket",
"timeout": 35,
"byteOrder": "BIG",
"wordOrder": “BIG",
"retries": true,
"retryOnEmpty": true,
"retryOnInvalid": true,
"pollPeriod": 5000,
"unitId": 1,
"deviceName": "DeviceWrite",
"deviceType": "Test",
"sendDataOnlyOnChange": false,
"connectAttemptTimeMs": 5000,
"connectAttemptCount": 10000,
"waitAfterFailedAttemptsMs": 10000,
"attributes": [
{
"tag": "Status",
"type": "16int",
"functionCode": 3,
"objectCount": 1,
"address": 2
}
],
"rpc": [
{
"tag": "setValue",
"type": "32int",
"functionCode": 16,
"objectsCount": 2,
"address": 4
},
{
"tag": "getValue",
"type": "32int",
"functionCode": 3,
"objectsCount": 2,
"address": 4
}
],
"timeseries": [
{
"tag": "Signal_0",
"type": "32int",
"functionCode": 3,
"objectsCount": 2,
"address": 4,
"multiplier": 1
}
]
}
]
}
}

### TEST 1
image

### TEST 2
Changing the wordOrder the result change a little:

image

image

I thing the issue is related to other two issues I found in the forum:
#775
#1135

The problem should be in this region:

def __process_request(self, content, rpc_command_config, request_type='RPC'):

Thanks for your support
Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions