M README.md => README.md +8 -8
@@ 6,14 6,14 @@ Serial port interface for UNI-T UT61E and other multimeters with the ES51922 chi
```text
$ ./es51922-serial.py /dev/ttyUSB0
-0.00295 V
-0.00276 V
-0.00261 V
-0.00253 V
-0.00248 V
-0.00248 V
-0.00233 V
-0.00227 V
+568001372643789 0.000194 A
+568001872601936 0.000194 A
+568002372779994 0.000194 A
+568002872870679 0.000194 A
+568003372731644 0.000194 A
+568003872919904 0.000194 A
+568004372819470 0.000194 A
+568004872363278 0.000195 A
```
## Documents
M es51922-serial.py => es51922-serial.py +12 -4
@@ 3,6 3,7 @@
import argparse
import enum
import sys
+import time
from decimal import Decimal
import serial
@@ 162,6 163,7 @@ def parse(packet):
parser = argparse.ArgumentParser()
parser.add_argument("port")
+parser.add_argument("--no-time", action="store_true")
parser.add_argument("--no-units", action="store_true")
if __name__ == "__main__":
@@ 170,13 172,19 @@ if __name__ == "__main__":
try:
with Serial(args.port) as ser:
for packet in ser:
+ t = time.monotonic_ns()
+
try:
value, unit = parse(packet)
- if not args.no_units:
- print(value, unit)
- else:
- print(value)
except ValueError as e:
print(e, file=sys.stderr)
+ continue
+
+ print_args = [value]
+ if not args.no_time:
+ print_args.insert(0, t)
+ if not args.no_units:
+ print_args.append(unit)
+ print(*print_args)
except (KeyboardInterrupt, BrokenPipeError):
pass