On 2/12/19 5:17 pm, Stuart Longland wrote:
> wpantund logs (running wpantund directly rather than via systemd):
>> wpantund[5727]: NCP => Framing error 6: [80 03 72 50 00 60 01 3E 7E 00 28 11 3F FD 9E E3 08 E1 4C B8 77 00 00 00 00 00 00 00 FD FD 34 FE 56 78 91 00 10 5F 96 D9 31]
>> wpantund[5727]: NCP => Framing error 6: [80 03 72 4B 01 60 00 FC 1D 01 23 11 3F FD 9E E3 08 E1 4C B8 77 00 00 00 00 00 00 00 FD FD 34 FE 56 78 91 00 10 7E BB 06 83]
Some sleuthing… these messages are actually tunnelled over the spinel
link from the NCP. Specifically here:
https://github.com/openthread/openthread/blob/master/src/ncp/ncp_uart.cpp#L278-L309
This is called by this block of code:
https://github.com/openthread/openthread/blob/master/src/ncp/ncp_uart.cpp#L248-L276
which in turn, is called by this function pointer reference:
https://github.com/openthread/openthread/blob/master/src/ncp/ncp_uart.cpp#L87
which leads us here:
https://github.com/openthread/openthread/blob/master/src/ncp/hdlc.cpp#L239-L261
Soon as I see HDLC mentioned, I can't help but think of AX.25 and KISS
framing. I guess SLIP, KISS and other protocols all have a common
ancestor in HDLC. Funny to think my mucking around with packet radio on
VHF has relevance here. :-)
That said, I'm trying to understand the logic in that case block:
> if (mDecodedLength > 0)
> {
> otError error = OT_ERROR_PARSE;
>
> if ((mDecodedLength >= kFcsSize)
> #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
> && (mFcs == kGoodFcs)
> #endif
> )
> {
> // Remove the FCS from the frame.
> mWritePointer.UndoLastWrites(kFcsSize);
> error = OT_ERROR_NONE;
> }
>
> mFrameHandler(mContext, error);
> }
The outer `if` is easy enough… HDLC framing says you can have any
non-zero number of "flag" bytes between frames. The inner one is a
head-scratcher.
"If decoded length is greater than the size of the FCS", that's fine,
but then "and FCS is equal to kGoodFcs (0xf0b8)"… that has me confused.
Surely one would be comparing the computed FCS (in mFcs) with the
*given* FCS at the last two bytes of the frame?
Or is that special value of 0xf0b8 chosen so that when the FCS given in
the frame is considered by `updateFcs`, that the resultant FCS should be
equal to 0xf0b8?
Is there a way I can send a test SPINEL frame to a NCP and have it echo
that frame back to me as it was received?
Regards,