modbus Allow swap: byte for datatype: string. (#103441)

This commit is contained in:
jan iversen 2023-11-06 07:52:15 +01:00 committed by GitHub
parent fd3d615c0d
commit 5eba6dbc9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -63,8 +63,8 @@ PARM_IS_LEGAL = namedtuple(
],
)
# PARM_IS_LEGAL defines if the keywords:
# count: ..
# structure: ..
# count:
# structure:
# swap: byte
# swap: word
# swap: word_byte (identical to swap: word)
@ -84,7 +84,7 @@ DEFAULT_STRUCT_FORMAT = {
DataType.INT64: ENTRY("q", 4, PARM_IS_LEGAL(False, False, True, True, True)),
DataType.UINT64: ENTRY("Q", 4, PARM_IS_LEGAL(False, False, True, True, True)),
DataType.FLOAT64: ENTRY("d", 4, PARM_IS_LEGAL(False, False, True, True, True)),
DataType.STRING: ENTRY("s", -1, PARM_IS_LEGAL(True, False, False, False, False)),
DataType.STRING: ENTRY("s", -1, PARM_IS_LEGAL(True, False, False, True, False)),
DataType.CUSTOM: ENTRY("?", 0, PARM_IS_LEGAL(True, True, False, False, False)),
}

View File

@ -513,6 +513,20 @@ async def test_config_wrong_struct_sensor(
False,
"07-05-2020 14:35",
),
(
{
CONF_COUNT: 8,
CONF_INPUT_TYPE: CALL_TYPE_REGISTER_HOLDING,
CONF_DATA_TYPE: DataType.STRING,
CONF_SWAP: CONF_SWAP_BYTE,
CONF_SCALE: 1,
CONF_OFFSET: 0,
CONF_PRECISION: 0,
},
[0x3730, 0x302D, 0x2D35, 0x3032, 0x3032, 0x3120, 0x3A34, 0x3533],
False,
"07-05-2020 14:35",
),
(
{
CONF_COUNT: 8,