Skip to content

Commit

Permalink
Bump dvg-qdevices==0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis-van-Gils committed Jul 15, 2020
1 parent 035c1b6 commit 6659fcb
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 68 deletions.
24 changes: 9 additions & 15 deletions Arduino_PyQt_demo_with_multithreading.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
__author__ = "Dennis van Gils"
__authoremail__ = "[email protected]"
__url__ = "https://github.com/Dennis-van-Gils/DvG_Arduino_PyQt_multithread_demo"
__date__ = "07-07-2020"
__version__ = "3.1"
__date__ = "16-07-2020"
__version__ = "4.0"

import os
import sys
from pathlib import Path
import time

import numpy as np
Expand All @@ -28,8 +27,6 @@
from dvg_debug_functions import dprint, print_fancy_traceback as pft

from dvg_devices.Arduino_protocol_serial import Arduino # I.e. the `device`

# from dvg_devices.Arduino_qdev import Arduino_qdev # Alternative approach as subclassed QDeviceIO()
from dvg_qdeviceio import QDeviceIO


Expand Down Expand Up @@ -324,13 +321,10 @@ def notify_connection_lost():
excl = " ! ! ! ! ! ! ! "
window.qlbl_title.setText("%sLOST CONNECTION%s" % (excl, excl))

str_msg = (
"%s %s\n" "Lost connection to Arduino.\n" " '%s', '%s': %salive"
) % (
str_msg = ("%s %s\n" "Lost connection to Arduino.\n" " '%s': %salive") % (
str_cur_date,
str_cur_time,
ard.name,
ard.identity,
"" if ard.is_alive else "not ",
)
print("\nCRITICAL ERROR @ %s" % str_msg)
Expand Down Expand Up @@ -362,7 +356,7 @@ def DAQ_function():
str_cur_time = cur_date_time.toString("HH:mm:ss")

# Query the Arduino for its state
[success, tmp_state] = ard.query_ascii_values("?", separator="\t")
success, tmp_state = ard.query_ascii_values("?", delimiter="\t")
if not (success):
dprint(
"'%s' reports IOError @ %s %s"
Expand All @@ -372,7 +366,7 @@ def DAQ_function():

# Parse readings into separate state variables
try:
[state.time, state.reading_1] = tmp_state
state.time, state.reading_1 = tmp_state
state.time /= 1000
except Exception as err:
pft(err, 3)
Expand Down Expand Up @@ -432,10 +426,10 @@ def DAQ_function():
# Connect to Arduino
# --------------------------------------------------------------------------

ard = Arduino(name="Ard", baudrate=115200)
ard.auto_connect(
Path("last_used_port.txt"), match_identity="Wave generator"
)
ard = Arduino(name="Ard", connect_to_specific_ID="Wave generator")

ard.serial_settings["baudrate"] = 115200
ard.auto_connect("last_used_port.txt")

if not (ard.is_alive):
print("\nCheck connection and try resetting the Arduino.")
Expand Down
22 changes: 9 additions & 13 deletions Arduino_PyQt_demo_with_multithreading__LARGE_TEXT.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
__author__ = "Dennis van Gils"
__authoremail__ = "[email protected]"
__url__ = "https://github.com/Dennis-van-Gils/DvG_Arduino_PyQt_multithread_demo"
__date__ = "02-07-2020"
__version__ = "3.0"
__date__ = "16-07-2020"
__version__ = "4.0"

import os
import sys
from pathlib import Path
import time

import numpy as np
Expand Down Expand Up @@ -354,13 +353,10 @@ def notify_connection_lost():
excl = " ! ! ! ! ! ! ! ! "
window.qlbl_title.setText("%sLOST CONNECTION%s" % (excl, excl))

str_msg = (
"%s %s\n" "Lost connection to Arduino.\n" " '%s', '%s': %salive"
) % (
str_msg = ("%s %s\n" "Lost connection to Arduino.\n" " '%s': %salive") % (
str_cur_date,
str_cur_time,
ard.name,
ard.identity,
"" if ard.is_alive else "not ",
)
print("\nCRITICAL ERROR @ %s" % str_msg)
Expand Down Expand Up @@ -392,7 +388,7 @@ def DAQ_function():
str_cur_time = cur_date_time.toString("HH:mm:ss")

# Query the Arduino for its state
[success, tmp_state] = ard.query_ascii_values("?", separator="\t")
success, tmp_state = ard.query_ascii_values("?", delimiter="\t")
if not (success):
dprint(
"'%s' reports IOError @ %s %s"
Expand All @@ -402,7 +398,7 @@ def DAQ_function():

# Parse readings into separate state variables
try:
[state.time, state.reading_1] = tmp_state
state.time, state.reading_1 = tmp_state
state.time /= 1000
except Exception as err:
pft(err, 3)
Expand Down Expand Up @@ -462,10 +458,10 @@ def DAQ_function():
# Connect to Arduino
# --------------------------------------------------------------------------

ard = Arduino(name="Ard", baudrate=115200)
ard.auto_connect(
Path("last_used_port.txt"), match_identity="Wave generator"
)
ard = Arduino(name="Ard", connect_to_specific_ID="Wave generator")

ard.serial_settings["baudrate"] = 115200
ard.auto_connect("last_used_port.txt")

if not (ard.is_alive):
print("\nCheck connection and try resetting the Arduino.")
Expand Down
17 changes: 8 additions & 9 deletions Arduino_PyQt_demo_with_multithreading__minimalistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
__author__ = "Dennis van Gils"
__authoremail__ = "[email protected]"
__url__ = "https://github.com/Dennis-van-Gils/DvG_Arduino_PyQt_multithread_demo"
__date__ = "02-07-2020"
__version__ = "3.0"
__date__ = "16-07-2020"
__version__ = "4.0"

import os
import sys
from pathlib import Path
import time

import numpy as np
Expand Down Expand Up @@ -134,7 +133,7 @@ def DAQ_function():
str_cur_time = cur_date_time.toString("HH:mm:ss")

# Query the Arduino for its state
[success, tmp_state] = ard.query_ascii_values("?", separator="\t")
success, tmp_state = ard.query_ascii_values("?", delimiter="\t")
if not (success):
dprint(
"'%s' reports IOError @ %s %s"
Expand All @@ -144,7 +143,7 @@ def DAQ_function():

# Parse readings into separate state variables
try:
[state.time, state.reading_1] = tmp_state
state.time, state.reading_1 = tmp_state
state.time /= 1000
except Exception as err:
pft(err, 3)
Expand Down Expand Up @@ -185,10 +184,10 @@ def DAQ_function():
# Connect to Arduino
# --------------------------------------------------------------------------

ard = Arduino(name="Ard", baudrate=115200)
ard.auto_connect(
Path("last_used_port.txt"), match_identity="Wave generator"
)
ard = Arduino(name="Ard", connect_to_specific_ID="Wave generator")

ard.serial_settings["baudrate"] = 115200
ard.auto_connect("last_used_port.txt")

if not (ard.is_alive):
print("\nCheck connection and try resetting the Arduino.")
Expand Down
17 changes: 8 additions & 9 deletions Arduino_PyQt_demo_without_multithreading.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
__author__ = "Dennis van Gils"
__authoremail__ = "[email protected]"
__url__ = "https://github.com/Dennis-van-Gils/DvG_Arduino_PyQt_multithread_demo"
__date__ = "02-07-2020"
__version__ = "3.0"
__date__ = "16-07-2020"
__version__ = "4.0"

import os
import sys
from pathlib import Path
import time

import numpy as np
Expand Down Expand Up @@ -341,7 +340,7 @@ def DAQ_function():
state.prev_tick = now

# Query the Arduino for its state
[success, tmp_state] = ard.query_ascii_values("?", separator="\t")
success, tmp_state = ard.query_ascii_values("?", delimiter="\t")
if not (success):
dprint(
"'%s' reports IOError @ %s %s"
Expand All @@ -350,7 +349,7 @@ def DAQ_function():

# Parse readings into separate state variables
try:
[state.time, state.reading_1] = tmp_state
state.time, state.reading_1 = tmp_state
state.time /= 1000
except Exception as err:
pft(err, 3)
Expand Down Expand Up @@ -406,10 +405,10 @@ def DAQ_function():
# Connect to Arduino
# --------------------------------------------------------------------------

ard = Arduino(name="Ard", baudrate=115200)
ard.auto_connect(
Path("last_used_port.txt"), match_identity="Wave generator"
)
ard = Arduino(name="Ard", connect_to_specific_ID="Wave generator")

ard.serial_settings["baudrate"] = 115200
ard.auto_connect("last_used_port.txt")

if not (ard.is_alive):
print("\nCheck connection and try resetting the Arduino.")
Expand Down
17 changes: 8 additions & 9 deletions foo_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
__author__ = "Dennis van Gils"
__authoremail__ = "[email protected]"
__url__ = "https://github.com/Dennis-van-Gils/DvG_Arduino_PyQt_multithread_demo"
__date__ = "02-07-2020"
__version__ = "3.0"
__date__ = "16-07-2020"
__version__ = "4.0"

import sys
from pathlib import Path
import time
import signal # To catch CTRL+C and quit

Expand Down Expand Up @@ -90,14 +89,14 @@ def update_terminal():

def DAQ_function():
# Query the Arduino for its state
[success, tmp_state] = ard.query_ascii_values("?", separator="\t")
success, tmp_state = ard.query_ascii_values("?", delimiter="\t")
if not (success):
dprint("'%s' reports IOError" % ard.name)
return False

# Parse readings into separate state variables
try:
[state.time, state.reading_1] = tmp_state
state.time, state.reading_1 = tmp_state
state.time /= 1000
except Exception as err:
pft(err, 3)
Expand Down Expand Up @@ -127,10 +126,10 @@ def DAQ_function():
if __name__ == "__main__":

# Connect to Arduino
ard = Arduino(name="Ard", baudrate=115200)
ard.auto_connect(
Path("last_used_port.txt"), match_identity="Wave generator"
)
ard = Arduino(name="Ard", connect_to_specific_ID="Wave generator")

ard.serial_settings["baudrate"] = 115200
ard.auto_connect("last_used_port.txt")

if not (ard.is_alive):
print("\nCheck connection and try resetting the Arduino.")
Expand Down
23 changes: 12 additions & 11 deletions foo_baz.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
- CLI output only
- Mode: INTERNAL_TIMER as master to another SINGLE_SHOT_WAKE_UP
- Trick with fake device 'Sync()'
TODO: Investigate hang in about_to_quit() when lost_connection was tripped.
"""
__author__ = "Dennis van Gils"
__authoremail__ = "[email protected]"
__url__ = "https://github.com/Dennis-van-Gils/DvG_Arduino_PyQt_multithread_demo"
__date__ = "02-07-2020"
__version__ = "3.0"
__date__ = "16-07-2020"
__version__ = "4.0"

import sys
from pathlib import Path
import time
import signal # To catch CTRL+C and quit

Expand All @@ -26,7 +27,7 @@
DAQ_INTERVAL_MS = 10 # 10 [ms]

# Show debug info in terminal? Warning: Slow! Do not leave on unintentionally.
DEBUG = False
DEBUG = True


# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -92,14 +93,14 @@ def update_terminal():

def DAQ_function():
# Query the Arduino for its state
[success, tmp_state] = ard.query_ascii_values("?", separator="\t")
success, tmp_state = ard.query_ascii_values("?", delimiter="\t")
if not (success):
dprint("'%s' reports IOError" % ard.name)
return False

# Parse readings into separate state variables
try:
[state.time, state.reading_1] = tmp_state
state.time, state.reading_1 = tmp_state
state.time /= 1000
except Exception as err:
pft(err, 3)
Expand Down Expand Up @@ -129,10 +130,10 @@ def DAQ_function():
if __name__ == "__main__":

# Connect to Arduino
ard = Arduino(name="Ard", baudrate=115200)
ard.auto_connect(
Path("last_used_port.txt"), match_identity="Wave generator"
)
ard = Arduino(name="Ard", connect_to_specific_ID="Wave generator")

ard.serial_settings["baudrate"] = 115200
ard.auto_connect("last_used_port.txt")

if not (ard.is_alive):
print("\nCheck connection and try resetting the Arduino.")
Expand Down Expand Up @@ -167,7 +168,7 @@ def tick(self):
# fmt: off
qdev_sync = QDeviceIO(sync)
qdev_sync.create_worker_DAQ(
DAQ_trigger = DAQ_trigger.INTERNAL_TIMER,
DAQ_trigger = DAQ_TRIGGER.INTERNAL_TIMER,
DAQ_function = sync.tick,
DAQ_interval_ms = DAQ_INTERVAL_MS,
debug = DEBUG,
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pyqt5~=5.12
pyqtgraph~=0.10

dvg-debug-functions~=2.0
dvg-qdeviceio~=0.2.0
dvg-devices~=0.0.5
dvg-qdeviceio~=0.2.1
dvg-devices~=0.0.6

0 comments on commit 6659fcb

Please sign in to comment.