Clear the FEC encode buffer before use#3473
Conversation
070e8f8 to
14c8c6d
Compare
There was a problem hiding this comment.
Ah! Now I see how I also had fixed it by initing a second, cleared buffer too, thinking that the timing was the problem. I clearly didn't test that correctly because this works and solves all the issues I was seeing yesterday, including the connection dropout when switching to 1:2 for telemboost. I think you also removed the "removed the compiler initialisation of the outbuffer" because we still need to do that, for those 3 extra bytes?
This FEC code needs a little rework I think, but we can save that for a less-pressing time.
- FECEncode clears the encodedBuffer despite writing to all positions
- FECEncode needs to clear the FECBuffer (which it could do in its loop) but instead we're doing it with a memset in the caller, to a buffer we also clear before we call it (but we need to because of the 3 trailing bytes needed)
- The top level buffer is some randomly chosen 32 bytes instead of what it needs to be
- FECEncode calls HammingTableEncode which itself is just returning an array lookup, leading to extra function calls across units. We really should just move all of hamming into FEC.cpp
- None of this is in IRAM (FECEncode, HammingTableEncode, the const table), leading me to wonder how important that is at all since so much of the code we call from an ISR isn't.
- The FEC functions could use some comments about the fact that it can ONLY operate on 8 bytes of data
- Between all of this it could be a little faster (inlining of hamming functions) and be roughly 200 fewer bytes of code
mha1
left a comment
There was a problem hiding this comment.
Telemetry tested X-Band and 2.4G K packet rates at 1:2 and STD ok.
|
I agree with everything you have said @CapnBry. |
The FEC codec or's the data into the output buffer so it is assumed that the buffer is initialised to zeroes!
I've put a
memsetas the first line of the function so this is no longer a requirement on the caller.