gpt4 book ai didi

java - Android Things GPS ArrayIndexOutOfBoundsException

转载 作者:行者123 更新时间:2023-12-02 11:06:26 24 4
gpt4 key购买 nike

我在树莓派 3 上使用 Adafruit Ultimate GPS Breakout v3 和 Android Things。使用以下驱动程序:

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$000(NmeaGpsModule.java:41) at com.google.android.things.contrib.driver.gps.NmeaGpsModule$1.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'

关于java - Android Things GPS ArrayIndexOutOfBoundsException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50924377/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com