pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.16k stars 889 forks source link

Modbus simulator - Added support for additional datatypes #2202

Open pnl-jseb opened 1 month ago

pnl-jseb commented 1 month ago

This update adds native support for some of the most commonly found datatypes in OT systems. This includes support for bitfields, unsigned integers, signed integers, and floating point numbers in multiple word sizes (16 bit, 32 bit and 64 bit).

Relevant changes include: A reworked version of simulator.py that relies on struct.unpack, struct.pack, and other native functions to simplifly datatype handling while also incorportating additional checks to ensure the register layout behaves as expected. In order to simplifly future work development, the Bits field has been renamed bitfield16, while also adding support for 32 and 64 bit fields. To help facilitate adoption, several changes have been done to the project files to ensure a smooth transition. This includes:

Resolves [discussion]: #1458 Partially addresses: #1284

janiversen commented 1 month ago

This is a very big PR, which will be very hard to review ! splitting it into a number of smaller PRs is needed.

This smaller PR are needed not only for review but also for regression testing.

The rename of bitfield to bitfield16 ... is illogical since a bit field can be anything from 1bit to 10of thousands,

There seems to be a lot of good stuff in this PR, which would be nice to merge in smaller chunks.

pnl-jseb commented 1 month ago

Thanks for the feedback, I will do a rollback of the bitfieldXX structures and just keep the bits. As for breaking into smaller chunks, I'm unsure of the best course of action, but I can certainly try to work with you to ensure a smooth merge.

janiversen commented 2 weeks ago

Any progress on this PR ?