init method

  1. @override
Future<bool> init()
override

Initializes the connection to the device.

Implementation

@override
Future<bool> init() async {
  try {
    if (!await serial.init()) {
      logger.critical("Could not open IMU on port $imuPort");
      return false;
    }
    subscription = serial.stream.listen(handleSerial);
    _commandSubscription = collection.server.messages.onMessage(
      name: SubsystemsCommand().messageName,
      constructor: SubsystemsCommand.fromBuffer,
      callback: handleCommand,
    );
    serial.startListening();
    logger.info("Reading IMU on port $imuPort");
    return true;
  } catch (error) {
    logger.critical("Could not open IMU", body: "Port $imuPort, Error: $error");
    return false;
  }
}