From 8d654879833636e60d5fe63cb7afbf9bdf3552ec Mon Sep 17 00:00:00 2001 From: Jack Rubacha Date: Tue, 21 May 2024 17:50:39 -0400 Subject: [PATCH] misc fixes and improvements - bump calypso - fix calypso iroh - fix docker ruamel from #127 embedded - add qmicli to prep for #155 - add can bus util and remove can data rate --- Dockerfile | 6 ++-- .../configs/raspberrypi3_64_ap_defconfig | 2 ++ .../rootfs_overlay_iroh/etc/init.d/S76calypso | 29 +++++++++++++++++++ odysseus_tree/package/calypso/calypso.mk | 2 +- .../tpu_telemetry/telemetry/__init__.py | 1 + .../tpu_telemetry/telemetry/poll_data/can.py | 15 ++++++---- 6 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 odysseus_tree/overlays/rootfs_overlay_iroh/etc/init.d/S76calypso diff --git a/Dockerfile b/Dockerfile index 7c137117..56334ebd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,10 +32,8 @@ RUN apt-get update && apt-get install -y \ graphviz \ git-lfs \ util-linux \ - wpasupplicant - -# just for calypso require ruamel.yaml -RUN apt-get update && apt-get install -y python3-pip && pip install --break-system-packages "ruamel.yaml<0.18.0" + wpasupplicant \ + python3-ruamel.yaml # add all buildroot files there WORKDIR /home/odysseus/build diff --git a/odysseus_tree/configs/raspberrypi3_64_ap_defconfig b/odysseus_tree/configs/raspberrypi3_64_ap_defconfig index da02b41a..6df69a6b 100644 --- a/odysseus_tree/configs/raspberrypi3_64_ap_defconfig +++ b/odysseus_tree/configs/raspberrypi3_64_ap_defconfig @@ -34,6 +34,7 @@ BR2_PACKAGE_LM_SENSORS=y BR2_PACKAGE_RASPI_GPIO=y BR2_PACKAGE_PYTHON3=y BR2_PACKAGE_CA_CERTIFICATES=y +BR2_PACKAGE_LIBQMI=y BR2_PACKAGE_BMON=y BR2_PACKAGE_DHCPCD=y BR2_PACKAGE_DROPBEAR=y @@ -44,6 +45,7 @@ BR2_PACKAGE_IPERF3=y BR2_PACKAGE_IPROUTE2=y BR2_PACKAGE_IPUTILS=y BR2_PACKAGE_IW=y +BR2_PACKAGE_UQMI=y BR2_PACKAGE_WIRELESS_REGDB=y BR2_PACKAGE_HTOP=y BR2_PACKAGE_KMOD_TOOLS=y diff --git a/odysseus_tree/overlays/rootfs_overlay_iroh/etc/init.d/S76calypso b/odysseus_tree/overlays/rootfs_overlay_iroh/etc/init.d/S76calypso new file mode 100644 index 00000000..591e71b3 --- /dev/null +++ b/odysseus_tree/overlays/rootfs_overlay_iroh/etc/init.d/S76calypso @@ -0,0 +1,29 @@ +#!/bin/sh + +PIDFILE=/var/run/calypso.pid +EXECUTABLE=/usr/bin/calypso +INTERFACE_NAME=can0 +BROKER_IP=192.168.100.1:1883 + +case "$1" in + start) + echo "Sleeping, waiting to start" + sleep 20s + echo "Starting calypso..." + # start (S) executable (x) in background (b), make pid file (m) at p + start-stop-daemon -S -x "$EXECUTABLE" -b -m -p "$PIDFILE" -- mqtt $BROKER_IP $INTERFACE_NAME skip_can_configure + ;; + stop) + echo "Stopping calypso..." + # stop (K) and remove pidfile + start-stop-daemon -K -p "$PIDFILE" + rm "$PIDFILE" + ;; + restart|reload) + "$0" stop + "$0" start + ;; + *) + echo "Usage: {start|stop|restart/reload}" + exit 1 +esac diff --git a/odysseus_tree/package/calypso/calypso.mk b/odysseus_tree/package/calypso/calypso.mk index 04c48c09..1370fab3 100644 --- a/odysseus_tree/package/calypso/calypso.mk +++ b/odysseus_tree/package/calypso/calypso.mk @@ -1,4 +1,4 @@ -CALYPSO_VERSION = 8803595b62c5252da2aed2c433e1db135769e6c4 +CALYPSO_VERSION = 14e484ca7c5d15273a44391f609aaa335094837d CALYPSO_SITE_METHOD = git CALYPSO_SITE = https://github.com/Northeastern-Electric-Racing/Calypso CALYPSO_GIT_SUBMODULES = YES diff --git a/odysseus_tree/sources/tpu_telemetry/telemetry/__init__.py b/odysseus_tree/sources/tpu_telemetry/telemetry/__init__.py index 5bef90c1..ed4c1e8e 100644 --- a/odysseus_tree/sources/tpu_telemetry/telemetry/__init__.py +++ b/odysseus_tree/sources/tpu_telemetry/telemetry/__init__.py @@ -32,6 +32,7 @@ async def set_interval(self, stop: asyncio.Event): measure = self.measurement() except Exception as e: print("Exception in ", type(self)) + print("Exception is: ", e) failure=True diff --git a/odysseus_tree/sources/tpu_telemetry/telemetry/poll_data/can.py b/odysseus_tree/sources/tpu_telemetry/telemetry/poll_data/can.py index 75c454aa..38b7db82 100644 --- a/odysseus_tree/sources/tpu_telemetry/telemetry/poll_data/can.py +++ b/odysseus_tree/sources/tpu_telemetry/telemetry/poll_data/can.py @@ -1,8 +1,8 @@ from .. import BufferedCommand, MeasureTask -# read in 1/10 a second increments -FETCH_CMD = ["bmon","-o", "format:fmt='$(attr:txrate:bytes) $(attr:rxrate:bytes)\n'", "-p", "can0" ] +# read using can-utils canbusload, ensure to change bitrate accordingly +FETCH_CMD = ["canbusload","can0@500000"] class CanMT(MeasureTask, BufferedCommand): def __init__(self): MeasureTask.__init__(self, 1000) @@ -10,11 +10,16 @@ def __init__(self): def measurement(self): items = self.read() + # filter out only newlines as list members + items = filter(lambda x: x != '\n', items) send_data = [] for item in items: - item = item.strip('\'').split(" ") - data = [item[0].strip(), item[1].strip()] - send_data.append(('TPU/Can/DataRate', data, 'kb/s')) + item = item.strip('\'').strip().split(" ") + # get rid of empty strings in list + item = list(filter(None, item)) + # convert percentage to decimal + send_data.append(('TPU/Can/BusUtil', [str(float(item[5].strip().strip("%")) / 100)], '%')) + send_data.append(('TPU/Can/BitsUsed', [item[2].strip()], 'bits')) return send_data