@@ -35,23 +35,31 @@ def run_binary_payload_ex():
35
35
# ----------------------------------------------------------------------- #
36
36
client = ModbusClient ('127.0.0.1' , port = 5020 )
37
37
client .connect ()
38
-
38
+
39
39
# ----------------------------------------------------------------------- #
40
40
# If you need to build a complex message to send, you can use the payload
41
41
# builder to simplify the packing logic.
42
42
#
43
43
# Here we demonstrate packing a random payload layout, unpacked it looks
44
44
# like the following:
45
45
#
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"
51
47
# - 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
55
63
56
64
# The packing can also be applied to the word (wordorder) and bytes in each
57
65
# word (byteorder)
@@ -123,12 +131,23 @@ def run_binary_payload_ex():
123
131
# Here we demonstrate decoding a random register layout, unpacked it looks
124
132
# like the following:
125
133
#
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"
131
135
# - 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
132
151
# ----------------------------------------------------------------------- #
133
152
address = 0x0
134
153
count = len (payload )
@@ -174,7 +193,7 @@ def run_binary_payload_ex():
174
193
print ("-" * 60 )
175
194
for name , value in iteritems (decoded ):
176
195
print ("%s\t " % name , hex (value ) if isinstance (value , int ) else value )
177
-
196
+
178
197
# ----------------------------------------------------------------------- #
179
198
# close the client
180
199
# ----------------------------------------------------------------------- #
0 commit comments