Skip to content

Commit b694439

Browse files
committed
update quickstart for ieee double-precision
1 parent 8a7ea7a commit b694439

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
# General information about the project.
5252
project = u'pyModbusTCP'
53-
copyright = u'2017, Loïc Lefebvre'
53+
copyright = u'2021, Loïc Lefebvre'
5454
author = u'Loïc Lefebvre'
5555

5656
# The version info for the project you're documenting, acts as replacement for

docs/quickstart/index.rst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Quick start guide
44
Overview of the package
55
-----------------------
66

7-
pyModbusTCP give access to modbus/TCP server through the ModbusClient object.
7+
pyModbusTCP give access to modbus/TCP server through the ModbusClient object.
88
This class is define in the client module.
99

1010
Since version 0.1.0, a server is available as ModbusServer class. This server
@@ -24,12 +24,12 @@ Package setup
2424

2525
from PyPi::
2626

27-
# for Python 2.7
28-
sudo pip-2.7 install pyModbusTCP
29-
# or for Python 3.2
30-
sudo pip-3.2 install pyModbusTCP
31-
# or upgrade from an older release
32-
sudo pip-3.2 install pyModbusTCP --upgrade
27+
# for Python 2
28+
sudo pip2 install pyModbusTCP
29+
# or for Python 3
30+
sudo pip3 install pyModbusTCP
31+
# upgrade from an older release
32+
sudo pip3 install pyModbusTCP --upgrade
3333

3434
from Github::
3535

@@ -71,7 +71,7 @@ For open/close socket before/after read or write, do this::
7171

7272
c = ModbusClient(host="localhost", auto_open=True, auto_close=True)
7373

74-
You can also open manually the TCP link. After this, you call a modbus request
74+
You can also open manually the TCP link. After this, you call a modbus request
7575
function (see list in next section)::
7676

7777
if c.open():
@@ -148,7 +148,7 @@ or::
148148

149149
c.debug(True)
150150

151-
when debug is enable all debug message is print on console and you can see
151+
when debug is enable all debug message is print on console and you can see
152152
modbus frame::
153153

154154
c.read_holding_registers(0, 4)
@@ -199,15 +199,23 @@ Sample data mangling, usefull for interface PLC device.
199199
# display "[True, False, True, False, False, False, False, False]"
200200
print(utils.get_bits_from_int(0x05, val_size=8))
201201

202-
- gateway between IEEE single precision float and python float::
202+
- IEEE single/double precision floating-point::
203203

204204
from pyModbusTCP import utils
205205

206-
# convert python float 0.3 to 0x3e99999a (32 bits IEEE representation)
206+
# 32 bits IEEE single precision
207+
# encode : python float 0.3 -> int 0x3e99999a
207208
# display "0x3e99999a"
208209
print(hex(utils.encode_ieee(0.3)))
209-
210-
# convert python float 0.3 to 0x3e99999a (32 bits IEEE representation)
210+
# decode: python int 0x3e99999a -> float 0.3
211211
# display "0.300000011921" (it's not 0.3, precision leak with float...)
212212
print(utils.decode_ieee(0x3e99999a))
213213

214+
# 64 bits IEEE double precision
215+
# encode: python float 6.62606957e-34 -> int 0x390b860bb596a559
216+
# display "0x390b860bb596a559"
217+
print(hex(utils.encode_ieee(6.62606957e-34, double=True)))
218+
# decode: python int 0x390b860bb596a559 -> float 6.62606957e-34
219+
# display "6.62606957e-34"
220+
print(utils.decode_ieee(0x390b860bb596a559, double=True))
221+

0 commit comments

Comments
 (0)