use of com.robo4j.hw.rpi.serial.gps.MTK3339GPS in project robo4j by Robo4J.
the class MtkGPSUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
serialPort = configuration.getString("serialPort", DEFAULT_SERIAL_PORT);
readInterval = configuration.getInteger("readInterval", DEFAULT_READ_INTERVAL);
String scheduler = configuration.getString("scheduler", PROPERTY_VALUE_PLATFORM_SCHEDULER);
boolean usePlatformScheduler = PROPERTY_VALUE_PLATFORM_SCHEDULER.equals(scheduler);
try {
mtk3339gps = new MTK3339GPS(serialPort, readInterval);
} catch (IOException e) {
throw new ConfigurationException("Could not instantiate GPS!", e);
}
if (usePlatformScheduler) {
scheduledFuture = getContext().getScheduler().scheduleAtFixedRate(() -> mtk3339gps.update(), 10, readInterval, TimeUnit.MILLISECONDS);
} else {
mtk3339gps.start();
}
}
Aggregations