From 1ad66ed1830a980703b07e56ff75519ccc4c865b Mon Sep 17 00:00:00 2001 From: Binghamton University Rover Team Date: Sat, 16 Mar 2024 02:18:28 -0400 Subject: [PATCH] Bug fixes with serial port --- lib/src/messages/serial.dart | 8 ++++++-- lib/subsystems.dart | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/src/messages/serial.dart b/lib/src/messages/serial.dart index 11ef174..871b4ad 100644 --- a/lib/src/messages/serial.dart +++ b/lib/src/messages/serial.dart @@ -28,10 +28,13 @@ class SerialService extends MessageService { logger.trace("IMU is on: $imuPort"); final gpsCommand = await Process.run("realpath", ["/dev/rover-gps"]); final gpsPort = gpsCommand.stdout.trim(); + const piPort = "/dev/ttyAMA0"; logger.trace("GPS is on: $gpsPort"); - return [ + logger.trace("All ports: $allPorts"); + final forbiddenPorts = {imuPort, gpsPort, piPort}; + return [ for (final port in allPorts) - if (port != imuPort && port != gpsPort) + if (!forbiddenPorts.contains(port)) port, ]; } @@ -51,6 +54,7 @@ class SerialService extends MessageService { Future init() async { devices = await getFirmware(); for (final device in devices) { + logger.debug("Initializing device: ${device.port}"); await device.init(); if (!device.isReady) continue; final subscription = device.stream?.listen((data) => _onMessage(data, device)); diff --git a/lib/subsystems.dart b/lib/subsystems.dart index 4a9397d..e23d923 100644 --- a/lib/subsystems.dart +++ b/lib/subsystems.dart @@ -47,7 +47,7 @@ class SubsystemsCollection extends MessageService { result &= await gps.init(); result &= await imu.init(); logger.info("Subsystems initialized"); - if (result) { + if (!result) { logger.warning("The subsystems did not start properly"); } isReady = true;