I'm currently playing around a little bit with the MultiWii v2.2 code, to adapt and extend it to my own needs. Thereby i found two spots in the code, where I think there might be something not correct (maybe it has no practical effect, tough).
But I thought I'd post it here, and maybe some of you devs can have a look at it. I hope, this is welcome.
First spot in "MultiWii.ino", Line #215 in v2.2:
Code: Select all
static uint16_t previousTime = 0;
Shouldn't this variable be declared as "uint32_t", because it's assigned with "previousTime = micros()" later on?
Second spot in "Serial.ino", Line #828 in v2.2:
Code: Select all
return (serialHeadRX[port] - serialTailRX[port])%RX_BUFFER_SIZE;
With this line of code the fill level of the ring buffer in the function "SerialAvailable" is calculated. As I called this function cyclically to display the result as debug-output in the GUI, I noticed, that the result jumps sometimes to a high value - much higher, than the actual buffer size.
I'm currently implementing a non-blocking graupner hott telemetry-feature. I read the telemetry request of the receiver to one of the serial ports. Most of the time I get a "1" or "2" as a result of the "SerialAvailable"-Call, but every once in a while the result jumps to e.g. "194". I have not investigated this further, but it seems that on a special constellation of the Head and Tail variables the calculation fails
this fixes it
Code: Select all
return (serialHeadRX [port] + RX_BUFFER_SIZE - serialTailRX [port]) % RX_BUFFER_SIZE;
These code parts are the same in current pre 2.3 builds, also
I'm curious about your conclusions!
And: I really love the MultiWii-Project - keep up the great work!
Greets,
Edgar