Skip to content

Commit

Permalink
Merge pull request #298 from tinymovr/develop
Browse files Browse the repository at this point in the history
Version 1.6.2 (supplemental)
  • Loading branch information
yconst authored Sep 25, 2023
2 parents 43c7de4 + 7dc6822 commit 1fd00b4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
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

0 comments on commit 1fd00b4

Please sign in to comment.