|
4 | 4 | - CLI output only |
5 | 5 | - Mode: INTERNAL_TIMER as master to another SINGLE_SHOT_WAKE_UP |
6 | 6 | - Trick with fake device 'Sync()' |
| 7 | +
|
| 8 | +TODO: Investigate hang in about_to_quit() when lost_connection was tripped. |
7 | 9 | """ |
8 | 10 | __author__ = "Dennis van Gils" |
9 | 11 | __authoremail__ = "vangils.dennis@gmail.com" |
10 | 12 | __url__ = "https://github.com/Dennis-van-Gils/DvG_Arduino_PyQt_multithread_demo" |
11 | | -__date__ = "02-07-2020" |
12 | | -__version__ = "3.0" |
| 13 | +__date__ = "16-07-2020" |
| 14 | +__version__ = "4.0" |
13 | 15 |
|
14 | 16 | import sys |
15 | | -from pathlib import Path |
16 | 17 | import time |
17 | 18 | import signal # To catch CTRL+C and quit |
18 | 19 |
|
|
26 | 27 | DAQ_INTERVAL_MS = 10 # 10 [ms] |
27 | 28 |
|
28 | 29 | # Show debug info in terminal? Warning: Slow! Do not leave on unintentionally. |
29 | | -DEBUG = False |
| 30 | +DEBUG = True |
30 | 31 |
|
31 | 32 |
|
32 | 33 | # ------------------------------------------------------------------------------ |
@@ -92,14 +93,14 @@ def update_terminal(): |
92 | 93 |
|
93 | 94 | def DAQ_function(): |
94 | 95 | # Query the Arduino for its state |
95 | | - [success, tmp_state] = ard.query_ascii_values("?", separator="\t") |
| 96 | + success, tmp_state = ard.query_ascii_values("?", delimiter="\t") |
96 | 97 | if not (success): |
97 | 98 | dprint("'%s' reports IOError" % ard.name) |
98 | 99 | return False |
99 | 100 |
|
100 | 101 | # Parse readings into separate state variables |
101 | 102 | try: |
102 | | - [state.time, state.reading_1] = tmp_state |
| 103 | + state.time, state.reading_1 = tmp_state |
103 | 104 | state.time /= 1000 |
104 | 105 | except Exception as err: |
105 | 106 | pft(err, 3) |
@@ -129,10 +130,10 @@ def DAQ_function(): |
129 | 130 | if __name__ == "__main__": |
130 | 131 |
|
131 | 132 | # Connect to Arduino |
132 | | - ard = Arduino(name="Ard", baudrate=115200) |
133 | | - ard.auto_connect( |
134 | | - Path("last_used_port.txt"), match_identity="Wave generator" |
135 | | - ) |
| 133 | + ard = Arduino(name="Ard", connect_to_specific_ID="Wave generator") |
| 134 | + |
| 135 | + ard.serial_settings["baudrate"] = 115200 |
| 136 | + ard.auto_connect("last_used_port.txt") |
136 | 137 |
|
137 | 138 | if not (ard.is_alive): |
138 | 139 | print("\nCheck connection and try resetting the Arduino.") |
@@ -167,7 +168,7 @@ def tick(self): |
167 | 168 | # fmt: off |
168 | 169 | qdev_sync = QDeviceIO(sync) |
169 | 170 | qdev_sync.create_worker_DAQ( |
170 | | - DAQ_trigger = DAQ_trigger.INTERNAL_TIMER, |
| 171 | + DAQ_trigger = DAQ_TRIGGER.INTERNAL_TIMER, |
171 | 172 | DAQ_function = sync.tick, |
172 | 173 | DAQ_interval_ms = DAQ_INTERVAL_MS, |
173 | 174 | debug = DEBUG, |
|
0 commit comments