AdvancedClimateSystems / uModbus

Python implementation of the Modbus protocol.
Mozilla Public License 2.0
211 stars 82 forks source link

Added the packer methods #65

Closed rtu-dataframe closed 5 years ago

rtu-dataframe commented 5 years ago

Added the packer methods to keep simple the data reading and writing, as requested in the issue #61 , i've created three functions in the utils.py in order to simplify the data packing and unpacking while reading/writing some different data types like Float, Double, etc... (Data Types Here)

In everyday use, you can simply use those methods importing the utils.py module and read (for example) a float value like shown below:

f = data_unpacker(response, '>', 'f')

instead of:

f = struct.unpack('>f', struct.pack('>H', high_byte) + struct.pack('>H', low_byte)[0]
coveralls commented 5 years ago

Coverage Status

Coverage decreased (-1.3%) to 95.039% when pulling fd08bd9cbf51e0e184d6b017b299abfc91dd8a65 on Simonefardella:master into 0560a42308003f4072d988f28042b8d55b694ad4 on AdvancedClimateSystems:master.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.4%) to 95.921% when pulling dc1d82c160c0fcc649a995ca3299d6334f618779 on Simonefardella:master into 0560a42308003f4072d988f28042b8d55b694ad4 on AdvancedClimateSystems:master.

rtu-dataframe commented 5 years ago

A new pull request will be submitted after some fix