Android 事物 GPS ArrayIndexOutOfBoundsException

Android Things GPS ArrayIndexOutOfBoundsException

我将 Adafruit Ultimate GPS Breakout v3 与 Android Things on a raspberry Pi 一起使用 3. 使用以下驱动程序:

https://github.com/androidthings/contrib-drivers/tree/master/gps

我试图在按下按钮时在 TextView 中显示当前位置。 我可以记录 NMEA 消息,但经常收到无效的 GSV 消息。它还会因 ArrayIndexOutOfBoundsException 而很快崩溃。

有人可以帮忙吗?

这是日志:

:33:08.782 2536-2536/com.google.android.things.contrib.driver.gps I/zygote: Deoptimizing void com.google.android.things.contrib.driver.gps.NmeaParser.handleSatelliteData(java.lang.String[]) due to block bounds check elimination 06-19 08:33:08.783 2536-2536/com.google.android.things.contrib.driver.gps D/AndroidRuntime: Shutting down VM 06-19 08:33:08.791 2536-2536/com.google.android.things.contrib.driver.gps E/AndroidRuntime: FATAL EXCEPTION: main Process: com.google.android.things.contrib.driver.gps, PID: 2536 java.lang.ArrayIndexOutOfBoundsException: length=19; index=19 at com.google.android.things.contrib.driver.gps.NmeaParser.handleSatelliteData(NmeaParser.java:199) at com.google.android.things.contrib.driver.gps.NmeaParser.processMessageFrame(NmeaParser.java:101) at com.google.android.things.contrib.driver.gps.NmeaGpsModule.handleFrameEnd(NmeaGpsModule.java:206) at com.google.android.things.contrib.driver.gps.NmeaGpsModule.processBuffer(NmeaGpsModule.java:175) at com.google.android.things.contrib.driver.gps.NmeaGpsModule.readUartBuffer(NmeaGpsModule.java:160) at com.google.android.things.contrib.driver.gps.NmeaGpsModule.access[=12=]0(NmeaGpsModule.java:41) at com.google.android.things.contrib.driver.gps.NmeaGpsModule.onUartDeviceDataAvailable(NmeaGpsModule.java:138) at com.google.android.things.pio.UartDeviceImpl$UartDeviceCallbackDispatch.dispatchInterruptEvent(UartDeviceImpl.java:250) at com.google.android.things.pio.CallbackDispatch.onFileDescriptorEvents(CallbackDispatch.java:149) at android.os.MessageQueue.dispatchEvents(MessageQueue.java:284) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:325) at android.os.Looper.loop(Looper.java:142) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 06-19 08:33:08.804 2536-2536/com.google.android.things.contrib.driver.gps I/Process: Sending signal. PID: 2536 SIG: 9

更新:

在此处将 NmeaParser 从 19 更改为 2 后:

// Parse the satellites in this message
for (int i = 4; i < 2; i += 4) {
    if (!nmea[i].isEmpty()) {
        Satellite sat = new Satellite();
        sat.svid = Integer.parseInt(nmea[i]);
        sat.elevation = parseTrackAngle(nmea[i+1]);
        sat.azimuth = parseTrackAngle(nmea[i+2]);
        sat.snr = parseSignal(nmea[i+3]);

        mSatellites.put(sat.svid, sat);
    }
}

我没有遇到崩溃,但我仍然收到无效的 GSV 消息。

GPS 驱动程序中的 NmeaParser 错误地处理了可变长度的 GSV 消息。我们刚刚发布了修复解析的新驱动程序 v1.1。您应该更新您的应用以指向最新的工件:

implementation 'com.google.android.things.contrib:driver-gps:1.1'