feat: Add new Modbus datatypes with correct byte ordering and GUI hints#2390
feat: Add new Modbus datatypes with correct byte ordering and GUI hints#2390steve0023 wants to merge 3 commits into
Conversation
- Add UInt64, UInt64LE, Int64MLE, UInt64MLE, Int64MBE, UInt64MBE datatypes - Fix _swap to support swapType=4 (MLE 64-bit: reverse all 4 words) - Add swapType=3 (MBE: swap words between halves) - Add byte order hints in Modbus tag type dropdown (Teltonika notation) - Update ModbusTagType enum with all new types Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New datatypes added: - UInt64, UInt64LE: 64-bit unsigned integers (BE and LE) - Int64MBE, UInt64MBE: 64-bit signed/unsigned, byte order 7,8,5,6,3,4,1,2 (validated: MBslave 'little endian byte swap') - Int64MLE, UInt64MLE: 64-bit signed/unsigned, byte order 5,6,7,8,1,2,3,4 (validated: MBslave 'big endian byte swap') - Float64MBE, Float64MLE: 64-bit double with matching byte orders - Int32MBE, UInt32MBE, Float32MBE: 32-bit byte order 2,1,4,3 (validated: MBslave 'big endian byte swap') Fixes: - Bool: read 2 bytes (UInt16BE) for Holding Registers, fallback to 1 byte for Coils - Float32/Float32LE/Float32MLE/Float32MBE: apply precision=7 to avoid float32 rounding artifacts - _swap: parser now works on a buffer copy to avoid corrupting shared Modbus response buffer GUI improvements: - ModbusTagType enum sorted by: Bool, 16-bit, 32-bit, 64-bit groups (BE, LE, MLE, MBE) - Byte order hints added to tag type dropdown using byte order notation (e.g. 'Byte order 2,1,4,3') Not tested (no LE simulator available): - Int16LE, UInt16LE, Int64LE, UInt64LE With a lot of help of Claude Sonnet 4.6
|
Hi @steve0023 Thanks for the PR. I have just added regression tests for the current Modbus datatype conversions so we can protect existing behavior while reviewing this PR. There are a couple of compatibility issues we need to handle before merging:
Even if the new byte ordering is more correct for some devices, changing an already existing datatype can break existing FUXA projects. In particular, the current So if this PR needs a different 64-bit order, please add it as a new datatype instead of changing the meaning of the existing one.
The PR changes Holding-register boolean support is useful, but it should not change the existing
FUXA currently does not support
The change to parse from a buffer copy is good. Avoiding mutation of the shared Modbus response buffer is a real fix and should stay.
This may be useful for display noise, but it changes raw parsed values. I would prefer keeping raw parsing exact and applying display/format rounding elsewhere, unless we have a specific bug this fixes. Preferred path:
With that approach we can merge the useful new datatype support without causing regressions for existing projects. This is a valuable improvement and it is very close; we just need to make it additive and regression-safe so existing users do not get unexpected value changes after upgrading. |
📌 Description
Add new Modbus datatypes for 32-bit and 64-bit with correct byte ordering, fix existing parser bugs, and improve the tag type dropdown with byte order hints.
What was changed:
UInt64,UInt64LE,Int64MBE,UInt64MBE,Int64MLE,UInt64MLE,Float64MBE,Float64MLEInt32MBE,UInt32MBE,Float32MBE(Byte order 2,1,4,3)Boolparser: read 2-byte UInt16BE for Holding Registers, fallback to 1 byte for CoilsFloat32precision artifacts by applying 7 significant digits rounding_swap: parser now works on a buffer copy to avoid mutating the shared Modbus response bufferInt32MLE (32bit INT, Byte order 3,4,1,2))ModbusTagTypeenum by bit-width group then endiannessByte order reference (validated against MBslave simulator):
Int32MLE3,4,1,2Int32MBE2,1,4,3Int64MBE7,8,5,6,3,4,1,2Int64MLE5,6,7,8,1,2,3,4🧪 Type of Change
🚫 Build Artifacts Check
/client/dist🔍 Checklist
📝 Additional Notes
Tested with MBslave simulator:
Not tested (requires little-endian device):
Known limitation: JavaScript
Numberprecision limits Int64/UInt64 to ~15 significant digits. Very large 64-bit values will be approximated.With a lot of help of Claude Sonnet 4.6