modpoll 0.7.1__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modpoll
3
- Version: 0.7.1
4
- Summary: A New Command Line Tool for Modbus
3
+ Version: 0.7.2
4
+ Summary: A New Command-line Tool for Modbus and MQTT
5
5
  Home-page: https://helloysd.gitlab.io/modpoll
6
6
  License: MIT
7
7
  Author: Ying Shaodong
@@ -21,7 +21,7 @@ Requires-Dist: requests (>=2.28.1,<3.0.0)
21
21
  Project-URL: Repository, https://github.com/gavinying/modpoll
22
22
  Description-Content-Type: text/markdown
23
23
 
24
- # modpoll - A New Command-line Tool for Modbus
24
+ # modpoll - A New Command-line Tool for Modbus and MQTT
25
25
 
26
26
  [![pipeline status](https://gitlab.com/helloysd/modpoll/badges/master/pipeline.svg)](https://gitlab.com/helloysd/modpoll/-/commits/master)
27
27
  [![License](https://img.shields.io/pypi/l/modpoll)](https://gitlab.com/helloysd/modpoll/-/blob/master/LICENSE)
@@ -182,10 +182,10 @@ The configuration can be either a local file or a remote public URL resource.
182
182
  If you are blocked by company firewall for online device or prefer a local test, you can launch your own device simulator by running *modsim* locally,
183
183
 
184
184
  ```bash
185
- docker run -p 5020:5020 helloysd/modsim
185
+ docker run --rm -p 5020:5020 helloysd/modsim
186
186
  ```
187
187
 
188
- It will create a virtual Modbus TCP device running at `localhost:5020`, and then you can poll it using *modpoll* tool,
188
+ It will create a virtual Modbus TCP device running at `localhost:5020`, and you can open a new terminal, poll the virtual device using *modpoll* tool,
189
189
 
190
190
  ```bash
191
191
  modpoll \
@@ -197,7 +197,12 @@ modpoll \
197
197
  > Use `sudo` before the docker command if you want to use the standard port `502`.
198
198
 
199
199
  ```bash
200
- sudo docker run -p 502:5020 helloysd/modsim
200
+ sudo docker run --rm -p 502:5020 helloysd/modsim
201
+ ```
202
+
203
+ In a new terminal,
204
+
205
+ ```
201
206
  modpoll \
202
207
  --tcp localhost \
203
208
  --config https://raw.githubusercontent.com/gavinying/modpoll/master/examples/modsim.csv
@@ -256,7 +261,7 @@ The *modpoll* tool will subscribe to the topic `<mqtt_topic_prefix>/<deviceid>/s
256
261
  A docker image has been provided for user to directly run the program without local installation,
257
262
 
258
263
  ```bash
259
- docker run helloysd/modpoll
264
+ docker run --rm helloysd/modpoll
260
265
  ```
261
266
 
262
267
  It shows the version of the program by default.
@@ -264,7 +269,7 @@ It shows the version of the program by default.
264
269
  Similar to the above *modsim* test, we can poll data with `docker run`, in order to avoid printing out received data, the argument `--daemon` or `-d` is recommended to use with docker.
265
270
 
266
271
  ```bash
267
- docker run helloysd/modpoll \
272
+ docker run --rm helloysd/modpoll \
268
273
  modpoll -d \
269
274
  --tcp modsim.topmaker.net \
270
275
  --config https://raw.githubusercontent.com/gavinying/modpoll/master/examples/modsim.csv
@@ -274,7 +279,7 @@ If you want to load a local configure file, you need to mount a local folder ont
274
279
  for example, if the child folder `examples` contains the config file `modsim.csv`, we can use it via the following command,
275
280
 
276
281
  ```bash
277
- docker run -v $(pwd)/examples:/app/examples helloysd/modpoll \
282
+ docker run --rm -v $(pwd)/examples:/app/examples helloysd/modpoll \
278
283
  modpoll -d \
279
284
  --tcp modsim.topmaker.net \
280
285
  --config /app/examples/modsim.csv
@@ -1,4 +1,4 @@
1
- # modpoll - A New Command-line Tool for Modbus
1
+ # modpoll - A New Command-line Tool for Modbus and MQTT
2
2
 
3
3
  [![pipeline status](https://gitlab.com/helloysd/modpoll/badges/master/pipeline.svg)](https://gitlab.com/helloysd/modpoll/-/commits/master)
4
4
  [![License](https://img.shields.io/pypi/l/modpoll)](https://gitlab.com/helloysd/modpoll/-/blob/master/LICENSE)
@@ -159,10 +159,10 @@ The configuration can be either a local file or a remote public URL resource.
159
159
  If you are blocked by company firewall for online device or prefer a local test, you can launch your own device simulator by running *modsim* locally,
160
160
 
161
161
  ```bash
162
- docker run -p 5020:5020 helloysd/modsim
162
+ docker run --rm -p 5020:5020 helloysd/modsim
163
163
  ```
164
164
 
165
- It will create a virtual Modbus TCP device running at `localhost:5020`, and then you can poll it using *modpoll* tool,
165
+ It will create a virtual Modbus TCP device running at `localhost:5020`, and you can open a new terminal, poll the virtual device using *modpoll* tool,
166
166
 
167
167
  ```bash
168
168
  modpoll \
@@ -174,7 +174,12 @@ modpoll \
174
174
  > Use `sudo` before the docker command if you want to use the standard port `502`.
175
175
 
176
176
  ```bash
177
- sudo docker run -p 502:5020 helloysd/modsim
177
+ sudo docker run --rm -p 502:5020 helloysd/modsim
178
+ ```
179
+
180
+ In a new terminal,
181
+
182
+ ```
178
183
  modpoll \
179
184
  --tcp localhost \
180
185
  --config https://raw.githubusercontent.com/gavinying/modpoll/master/examples/modsim.csv
@@ -233,7 +238,7 @@ The *modpoll* tool will subscribe to the topic `<mqtt_topic_prefix>/<deviceid>/s
233
238
  A docker image has been provided for user to directly run the program without local installation,
234
239
 
235
240
  ```bash
236
- docker run helloysd/modpoll
241
+ docker run --rm helloysd/modpoll
237
242
  ```
238
243
 
239
244
  It shows the version of the program by default.
@@ -241,7 +246,7 @@ It shows the version of the program by default.
241
246
  Similar to the above *modsim* test, we can poll data with `docker run`, in order to avoid printing out received data, the argument `--daemon` or `-d` is recommended to use with docker.
242
247
 
243
248
  ```bash
244
- docker run helloysd/modpoll \
249
+ docker run --rm helloysd/modpoll \
245
250
  modpoll -d \
246
251
  --tcp modsim.topmaker.net \
247
252
  --config https://raw.githubusercontent.com/gavinying/modpoll/master/examples/modsim.csv
@@ -251,7 +256,7 @@ If you want to load a local configure file, you need to mount a local folder ont
251
256
  for example, if the child folder `examples` contains the config file `modsim.csv`, we can use it via the following command,
252
257
 
253
258
  ```bash
254
- docker run -v $(pwd)/examples:/app/examples helloysd/modpoll \
259
+ docker run --rm -v $(pwd)/examples:/app/examples helloysd/modpoll \
255
260
  modpoll -d \
256
261
  --tcp modsim.topmaker.net \
257
262
  --config /app/examples/modsim.csv
@@ -5,7 +5,7 @@ from . import __version__
5
5
 
6
6
  def get_parser():
7
7
  parser = argparse.ArgumentParser(
8
- description=f"modpoll v{__version__} - A New Command Line Tool for Modbus"
8
+ description=f"modpoll v{__version__} - A New Command-line Tool for Modbus and MQTT"
9
9
  )
10
10
  parser.add_argument(
11
11
  "-v",
@@ -37,7 +37,7 @@ def get_utc_time():
37
37
 
38
38
 
39
39
  def app(name="modpoll"):
40
- print("\nmodpoll - A New Command Line Tool for Modbus\n", flush=True)
40
+ print("\nmodpoll - A New Command-line Tool for Modbus and MQTT\n", flush=True)
41
41
 
42
42
  signal.signal(signal.SIGINT, _signal_handler)
43
43
 
@@ -155,6 +155,9 @@ class Poller:
155
155
  elif "int64" == ref.dtype:
156
156
  ref.update_value(decoder.decode_64bit_int())
157
157
  cur_ref += ref.ref_width
158
+ elif "float16" == ref.dtype:
159
+ ref.update_value(decoder.decode_16bit_float())
160
+ cur_ref += ref.ref_width
158
161
  elif "float32" == ref.dtype:
159
162
  ref.update_value(decoder.decode_32bit_float())
160
163
  cur_ref += ref.ref_width
@@ -231,6 +234,8 @@ class Reference:
231
234
  self.ref_width = 4
232
235
  elif "uint64" == dtype:
233
236
  self.ref_width = 4
237
+ elif "float16" == dtype:
238
+ self.ref_width = 1
234
239
  elif "float32" == dtype:
235
240
  self.ref_width = 2
236
241
  elif "float64" == dtype:
@@ -26,7 +26,8 @@ def _on_connect(client, userdata, flags, rc, properties=None):
26
26
  log.info("Connection successful")
27
27
  # Subscribing in on_connect() means that if we lose the connection and
28
28
  # reconnect then subscriptions will be renewed.
29
- client.subscribe(f"{args.mqtt_topic_prefix}+/set")
29
+ qos = userdata.get("qos", 0) # Default to QoS 0 if not provided
30
+ client.subscribe(f"{args.mqtt_topic_prefix}+/set", qos)
30
31
  elif rc == 1:
31
32
  log.warning("Connection refused - incorrect protocol version")
32
33
  elif rc == 2:
@@ -83,7 +84,11 @@ def mqttc_setup(config):
83
84
  else:
84
85
  clientid = args.mqtt_clientid
85
86
  global mqttc
86
- mqttc = mqtt.Client(clientid, clean_session=(args.mqtt_qos == 0))
87
+ mqttc = mqtt.Client(
88
+ clientid,
89
+ clean_session=(args.mqtt_qos == 0),
90
+ userdata={"qos": args.mqtt_qos},
91
+ )
87
92
  if args.mqtt_use_tls:
88
93
  if args.mqtt_tls_version == "tlsv1.2":
89
94
  tlsVersion = ssl.PROTOCOL_TLSv1_2
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "modpoll"
3
- version = "0.7.1"
4
- description = "A New Command Line Tool for Modbus"
3
+ version = "0.7.2"
4
+ description = "A New Command-line Tool for Modbus and MQTT"
5
5
  authors = ["Ying Shaodong <helloysd@gmail.com>"]
6
6
  readme = "README.md"
7
7
  homepage = "https://helloysd.gitlab.io/modpoll"
File without changes
File without changes
File without changes