[bugfix] 修复获取float型参数结果为0
This commit is contained in:
parent
083e1d9e05
commit
0afe78b1c2
@ -78,7 +78,7 @@ class ModbusController:
|
|||||||
bytes_value = struct.pack('<HH', *swapped_registers)
|
bytes_value = struct.pack('<HH', *swapped_registers)
|
||||||
# Convert to float32 little endian byte-swap
|
# Convert to float32 little endian byte-swap
|
||||||
# For byte-swap, we need to swap the registers and then interpret as little endian
|
# For byte-swap, we need to swap the registers and then interpret as little endian
|
||||||
if param.data_type == "float32":
|
if param.data_type == "float":
|
||||||
return struct.unpack('<f', bytes_value)[0]
|
return struct.unpack('<f', bytes_value)[0]
|
||||||
|
|
||||||
elif param.data_type == "int32_t":
|
elif param.data_type == "int32_t":
|
||||||
|
Loading…
Reference in New Issue
Block a user