Search in sources :

Example 1 with MTK3339GPS

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();
    }
}
Also used : MTK3339GPS(com.robo4j.hw.rpi.serial.gps.MTK3339GPS) ConfigurationException(com.robo4j.ConfigurationException) IOException(java.io.IOException)

Aggregations

ConfigurationException (com.robo4j.ConfigurationException)1 MTK3339GPS (com.robo4j.hw.rpi.serial.gps.MTK3339GPS)1 IOException (java.io.IOException)1