Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.6.2 (supplemental) #298

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions studio/Python/tinymovr/dfu.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Usage:
dfu.py --node_id=ID [--bin=PATH | --recovery] [--no-reset]
dfu.py --node_id=ID [--bin=PATH | --recovery] [--no-reset] [--bus=<bus>] [--chan=<chan>] [--bitrate=<bitrate>]

Options:
--node_id=ID The CAN Node ID of the device in DFU mode.
--bin=PATH The path of the .bin file to upload.
--recovery Perform recovery procedure for inaccessible DFU bootloader.
--no-reset Do not perform a reset following successful flashing.
--bus=<bus> One or more interfaces to use, first available is used [default: canine,slcan_disco].
--chan=<chan> The bus device "channel".
--bitrate=<bitrate> CAN bitrate [default: 1000000].
"""

import sys
Expand Down Expand Up @@ -123,15 +126,22 @@ def upload_bin(device, bin_path):

def spawn():
# Parse command line arguments
args = docopt(__doc__)
node_id = int(args["--node_id"])
bin_path = args["--bin"]
arguments = docopt(__doc__)
node_id = int(arguments["--node_id"])
bin_path = arguments["--bin"]

# Set up the device
params = get_bus_config(["canine", "slcan_disco"])
params["bitrate"] = 1000000
buses = arguments["--bus"].rsplit(sep=",")
channel = arguments["--chan"]
bitrate = int(arguments["--bitrate"])

if args["--recovery"]:
if not channel:
params = get_bus_config(buses)
params["bitrate"] = bitrate
else:
params = {"bustype": buses[0], "channel": channel, "bitrate": bitrate}

if arguments["--recovery"]:

input("Please power off the device and then press any key to continue...")
print("Now power on the device.")
Expand Down Expand Up @@ -162,7 +172,7 @@ def spawn():
else:
upload_bin(device, bin_path)
compare_bin_w_device(device, bin_path, string="Verifying")
if not args["--no-reset"]:
if not arguments["--no-reset"]:
print("Resetting device...")
device.reset()
destroy_tee()
Expand Down
4 changes: 2 additions & 2 deletions studio/Python/tinymovr/gui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ def timings_updated(self, timings_dict):
meas_freq = timings_dict["meas_freq"]
meas_freq_str = "-" if meas_freq == 0 else "{:.1f}Hz".format(meas_freq)
self.status_label.setText(
"{}\t CH:{:.0f}%\t RT:{:.1f}ms".format(
"{}\t Load:{:.0f}%\t RT:{:.1f}ms".format(
meas_freq_str,
timings_dict["load"],
timings_dict["load"] * 100,
timings_dict["getter_dt"] * 1000,
)
)
Expand Down
11 changes: 10 additions & 1 deletion studio/Python/tinymovr/gui/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def __init__(self, busparams, logger):
)
self.timed_getter = TimedGetter()

self.dt_update = 1
self.dt_load = 0
self.t_last_update = time.time()

@QtCore.Slot()
def stop(self):
destroy_tee()
Expand Down Expand Up @@ -102,12 +106,17 @@ def _init_containers(self):
self.dynamic_attrs_last_update = {}

def _update(self):
t = time.time()
self.dt_update = self.dt_update * 0.95 + (t - self.t_last_update) * 0.05
self.t_last_update = t
self.mutx.lock()
t = time.time()
last_updated = self._get_attr_values()
self.dt_load = self.dt_load * 0.95 + (time.time() - t) * 0.05
if len(last_updated) > 0:
self.updateAttrsSignal.emit(last_updated)
self.updateTimingsSignal.emit(
{"meas_freq": 0, "load": 0, "getter_dt": self.timed_getter.dt}
{"meas_freq": 1/self.dt_update, "load": self.dt_load/self.dt_update, "getter_dt": self.timed_getter.dt}
)
self.mutx.unlock()

Expand Down