From 40728e923132b267dde00db187e3d110db4e1075 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 15 Dec 2023 18:04:17 -0500 Subject: [PATCH] motan: Support recording lis2dw and mpu9250 sensors from data_logger.py Signed-off-by: Kevin O'Connor --- scripts/motan/data_logger.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/motan/data_logger.py b/scripts/motan/data_logger.py index 7d704c83c..81370713c 100755 --- a/scripts/motan/data_logger.py +++ b/scripts/motan/data_logger.py @@ -151,16 +151,15 @@ def handle_subscribe(self, msg, raw_msg): self.send_subscribe("stepq:" + stepper, "motion_report/dump_stepper", {"name": stepper}) # Subscribe to additional sensor data + stypes = ["adxl345", "lis2dw", "mpu9250", "angle"] config = status["configfile"]["settings"] for cfgname in config.keys(): - if cfgname == "adxl345" or cfgname.startswith("adxl345 "): - aname = cfgname.split()[-1] - self.send_subscribe("adxl345:" + aname, "adxl345/dump_adxl345", - {"sensor": aname}) - if cfgname.startswith("angle "): - aname = cfgname.split()[1] - self.send_subscribe("angle:" + aname, "angle/dump_angle", - {"sensor": aname}) + for st in stypes: + if cfgname == st or cfgname.startswith(st + " "): + aname = cfgname.split()[-1] + lname = "%s:%s" % (st, aname) + qcmd = "%s/dump_%s" % (st, st) + self.send_subscribe(lname, qcmd, {"sensor": aname}) def handle_dump(self, msg, raw_msg): msg_id = msg["id"] if "result" not in msg: