jacobrosenthal / node-newtmgr

Unofficial port of Apache mynewt newt manager newtmgr
6 stars 4 forks source link

log_show doesnt decode entries #6

Closed jacobrosenthal closed 7 years ago

jacobrosenthal commented 7 years ago

Were were using borc for cbor parsing https://github.com/dignifiedquire/borc

its decoding as [ { next_index: 9980, logs: [ [Object] ], rc: 0 } ]

Based on cbor.me

it should be: {"next_index": 9980, "logs": [{"name": "reboot_log", "type": 2, "entries": [{"msg": "rsn:REQUESTED, cnt:0, img:0.0.0.0", "ts": 449749952, "level": 4, "index": 9979, "module": 6}]}], "rc": 0}

For posterity, the buffer that newtmgr._decode is operating Buffer.from([0xbf, 0x6a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x19, 0x26, 0xfc, 0x64, 0x6c, 0x6f, 0x67, 0x73, 0x9f, 0xbf, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x6a, 0x72, 0x65, 0x62, 0x6f, 0x6f, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x64, 0x74, 0x79, 0x70, 0x65, 0x02, 0x67, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x9f, 0xbf, 0x63, 0x6d, 0x73, 0x67, 0x78, 0x21, 0x72, 0x73, 0x6e, 0x3a, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x45, 0x44, 0x2c, 0x20, 0x63, 0x6e, 0x74, 0x3a, 0x30, 0x2c, 0x20, 0x69, 0x6d, 0x67, 0x3a, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x62, 0x74, 0x73, 0x1a, 0x1a, 0xce, 0xa3, 0xc0, 0x65, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x04, 0x65, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x19, 0x26, 0xfb, 0x66, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x06, 0xff, 0xff, 0xff, 0xff, 0x62, 0x72, 0x63, 0x00, 0xff)]

borc is derived from node-cbor I tried all the cbor variants that borc itself was derived from but they seem to not be able to handle it either. https://github.com/hildjj/node-cbor which also can't decode this. Its seen activity more recently so I dropped an issue there

It turns out cbor-sync, a separate lineage decoder from a few years ago, actually did better! but still not all the way there { next_index: 9980, logs: [ { name: 'reboot_log', type: 2, entries: [Object] } ], rc: 0 }

and borc just broke our decoding by switching to newer uint8 arrays instead of buffers, but in a feature release so I switched to cbor-sync in 0.3.1 for now..

jacobrosenthal commented 7 years ago

Another set of siblings of cbor https://github.com/sandhawke/borc-refs https://github.com/sandhawke/node-cbor-refs

jacobrosenthal commented 7 years ago

closed in 188d0a9c7da8596a0ac5b110f4b9bb03cdfc2108