Skip to content

Commit

Permalink
Bug fixes with serial port
Browse files Browse the repository at this point in the history
  • Loading branch information
Bing-Rover committed Mar 16, 2024
1 parent 54713fe commit 1ad66ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/src/messages/serial.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}
Expand All @@ -51,6 +54,7 @@ class SerialService extends MessageService {
Future<bool> 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));
Expand Down
2 changes: 1 addition & 1 deletion lib/subsystems.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1ad66ed

Please sign in to comment.