mcumgr-android icon indicating copy to clipboard operation
mcumgr-android copied to clipboard

LogManager response with invalid format

Open bmoliveira opened this issue 4 years ago • 5 comments

Hi,

I'm trying to get the logs from a device using the LogManager, and while trying to getAllFromState(State) or manager.getAll() I'm getting an exception on the parse of an entry on the response object.

The Object is McuMgrLogResponse.Entry and the property that I'm getting the error is msg because the format is in Byte[] and I'm receiving it as String.

Does this error has something to do with any Mynewt updates that are breaking the SDK?

Thank you

bmoliveira avatar Oct 17 '19 17:10 bmoliveira

Hi, thanks for reporting the issue. I think there have been recent changes in mynewt for integrating mcumgr rather than using the old standard newtmgr.

I am not entirely sure what the issue is, but since both ios and android libraries' log collection is busted for seemingly the same reason, there must have been a change on the firmware side.

bgiori avatar Oct 17 '19 20:10 bgiori

@bmoliveira

I'm getting an exception on the parse of an entry on the response object.

  1. Can you paste the stack trace?

  2. Would you be able to check the system config variable value for LOG_VERSION in your mynewt target?

The most recent log version (3) has had the msg field as a byte array while previous version have used a string. However, the log version has not changed in years, so maybe an update on the firmware side has caused this field to change.

I will continue to look into other possibilities.

This

bgiori avatar Oct 17 '19 20:10 bgiori

  1. The error is in jackson when calling: manager.getAllFromState(LogManager.State("reboot_log")) or manager.getAll()

  2. When I have the LOG_VERSION I'll add it here.

Crash from

@Override
    public void onDataReceived(@NonNull BluetoothDevice device, @NonNull Data data) {
        try {
            T response = McuMgrResponse.buildResponse(McuMgrScheme.BLE, data.getValue(), responseType);
            onResponseReceived(device, response);
        } catch (final Exception e) {
            onInvalidDataReceived(device, data);
        }
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `byte[]` out of VALUE_STRING token
     at [Source: (byte[])"�jnext_index�dlogs��dnamejreboot_logdtypegentries��cmsgxmrsn:SYSTEM_OFF_INT, cnt:1, img:0.0.8.6, hash:6859d66e619961c36ee371030bfc4f7b216e4a176d47f70e9c790e0f02f8e263bts��1(eleveleindexfmodule��cmsgxmrsn:SYSTEM_OFF_INT, cnt:1, img:0.0.8.6, hash:6859d66e619961c36ee371030bfc4f7b216e4a176d47f70e9c790e0f02f8e263bts��O�eleveleindex�fmodule����brc�"; line: -1, column: 58] (through reference chain: io.runtime.mcumgr.response.log.McuMgrLogResponse["logs"]->java.lang.Object[][0]->io.runtime.mcumgr.response.log.McuMgrLogResponse$LogResult["entries"]->java.lang.Object[][0]->io.runtime.mcumgr.response.log.McuMgrLogResponse$Entry["msg"])
     at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1342)
     at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1138)
     at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1092)
     at com.fasterxml.jackson.databind.deser.std.PrimitiveArrayDeserializers.handleNonArray(PrimitiveArrayDeserializers.java:240)
     at com.fasterxml.jackson.databind.deser.std.PrimitiveArrayDeserializers$ByteDeser.deserialize(PrimitiveArrayDeserializers.java:498)
     at com.fasterxml.jackson.databind.deser.std.PrimitiveArrayDeserializers$ByteDeser.deserialize(PrimitiveArrayDeserializers.java:446)
     at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
     at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
     at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
     at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:195)
     at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:21)
     at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
     at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
     at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
     at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:195)
     at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:21)
     at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
     at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
     at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
     at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
     at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3091)
     at io.runtime.mcumgr.util.CBOR.toObject(CBOR.java:29)
     at io.runtime.mcumgr.response.McuMgrResponse.buildResponse(McuMgrResponse.java:229)
     at io.runtime.mcumgr.ble.callback.SmpDataCallback.onDataReceived(SmpDataCallback.java:28)
     at io.runtime.mcumgr.ble.callback.SmpResponse.onDataReceived(SmpResponse.java:29)
     at no.nordicsemi.android.ble.WaitForValueChangedRequest.notifyValueChanged(WaitForValueChangedRequest.java:358)
     at no.nordicsemi.android.ble.BleManager$BleManagerGattCallback.onCharacteristicChangedSafe(BleManager.java:2856)
     at no.nordicsemi.android.ble.MainThreadBluetoothGattCallback.lambda$onCharacteristicChanged$4$MainThreadBluetoothGattCallback(MainThreadBluetoothGattCallback.java:135)
     at no.nordicsemi.android.ble.-$$Lambda$MainThreadBluetoothGattCallback$7AU42XLOqZKSRIMVuifw3eecBbw.run(Unknown Source:8)
     at android.os.Handler.handleCallback(Handler.java:883)
     at android.os.Handler.dispatchMessage(Handler.java:100)
     at android.os.Looper.loop(Looper.java:214)
     at android.app.ActivityThread.main(ActivityThread.java:7356)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

bmoliveira avatar Oct 18 '19 09:10 bmoliveira

Hey,

Regarding the LOG_VERSION we are using the V2

bmoliveira avatar Oct 22 '19 14:10 bmoliveira

That is the issue. Not sure how it worked before (if it did) but V2 has been deprecated for V3 which uses a byte[] for the msg rather than a string. I would ask your firmware guys to change that sysconfig to 3 and things should work properly.

bgiori avatar Oct 22 '19 16:10 bgiori