@@ -35,23 +35,31 @@ def run_binary_payload_ex():
3535 # ----------------------------------------------------------------------- #
3636 client = ModbusClient ('127.0.0.1' , port = 5020 )
3737 client .connect ()
38-
38+
3939 # ----------------------------------------------------------------------- #
4040 # If you need to build a complex message to send, you can use the payload
4141 # builder to simplify the packing logic.
4242 #
4343 # Here we demonstrate packing a random payload layout, unpacked it looks
4444 # like the following:
4545 #
46- # - a 8 byte string 'abcdefgh'
47- # - a 32 bit float 22.34
48- # - a 16 bit unsigned int 0x1234
49- # - another 16 bit unsigned int 0x5678
50- # - an 8 bit int 0x12
46+ # - an 8 byte string "abcdefgh"
5147 # - an 8 bit bitstring [0,1,0,1,1,0,1,0]
52- # - an 32 bit uint 0x12345678
53- # - an 32 bit signed int -0x1234
54- # - an 64 bit signed int 0x12345678
48+ # - an 8 bit int -0x12
49+ # - an 8 bit unsigned int 0x12
50+ # - a 16 bit int -0x5678
51+ # - a 16 bit unsigned int 0x1234
52+ # - a 32 bit int -0x1234
53+ # - a 32 bit unsigned int 0x12345678
54+ # - a 16 bit float 12.34
55+ # - a 16 bit float -12.34
56+ # - a 32 bit float 22.34
57+ # - a 32 bit float -22.34
58+ # - a 64 bit int -0xDEADBEEF
59+ # - a 64 bit unsigned int 0x12345678DEADBEEF
60+ # - another 64 bit unsigned int 0x12345678DEADBEEF
61+ # - a 64 bit float 123.45
62+ # - a 64 bit float -123.45
5563
5664 # The packing can also be applied to the word (wordorder) and bytes in each
5765 # word (byteorder)
@@ -123,12 +131,23 @@ def run_binary_payload_ex():
123131 # Here we demonstrate decoding a random register layout, unpacked it looks
124132 # like the following:
125133 #
126- # - a 8 byte string 'abcdefgh'
127- # - a 32 bit float 22.34
128- # - a 16 bit unsigned int 0x1234
129- # - another 16 bit unsigned int which we will ignore
130- # - an 8 bit int 0x12
134+ # - an 8 byte string "abcdefgh"
131135 # - an 8 bit bitstring [0,1,0,1,1,0,1,0]
136+ # - an 8 bit int -0x12
137+ # - an 8 bit unsigned int 0x12
138+ # - a 16 bit int -0x5678
139+ # - a 16 bit unsigned int 0x1234
140+ # - a 32 bit int -0x1234
141+ # - a 32 bit unsigned int 0x12345678
142+ # - a 16 bit float 12.34
143+ # - a 16 bit float -12.34
144+ # - a 32 bit float 22.34
145+ # - a 32 bit float -22.34
146+ # - a 64 bit int -0xDEADBEEF
147+ # - a 64 bit unsigned int 0x12345678DEADBEEF
148+ # - another 64 bit unsigned int which we will ignore
149+ # - a 64 bit float 123.45
150+ # - a 64 bit float -123.45
132151 # ----------------------------------------------------------------------- #
133152 address = 0x0
134153 count = len (payload )
@@ -174,7 +193,7 @@ def run_binary_payload_ex():
174193 print ("-" * 60 )
175194 for name , value in iteritems (decoded ):
176195 print ("%s\t " % name , hex (value ) if isinstance (value , int ) else value )
177-
196+
178197 # ----------------------------------------------------------------------- #
179198 # close the client
180199 # ----------------------------------------------------------------------- #
0 commit comments