Second time i explain this.
RX.CPP computeRC()
A spektrum sat does not send any message in failsafe. Its COMPLETELY USELESS to check for FAILSAFE_DETECT_TRESHOLD because the spektrum sat does not send ANY value in failsafe. The whole failsafe handling is already DONE in readSpektrum(void).
Same nonsense in SBUS. SBUS has a flag indicating failsafe, and again, its Its COMPLETELY USELESS to check for FAILSAFE_DETECT_TRESHOLD. The whole failsafe handling is already DONE in readSBus().
Why should the code be unnecessarily ugly, useless, unreadable and bulky ?
Same speksat and sbus failsafe nonsense in 2.3..
Same speksat and sbus failsafe nonsense in 2.3..
Last edited by Plüschi on Tue Nov 19, 2013 3:49 pm, edited 2 times in total.
Re: Same speksat and sbus failsafe nonsense in 2.3..
Plüschi wrote:Why should the code be unnecessarily ugly, useless, unreadable and bulky ?
You just described majority of multiwii code in a single sentence.
Re: Same speksat and sbus failsafe nonsense in 2.3..
Seriously, you are complaining about 3 lines in RX.cpp that are needed for everyone else and that only needs a more elaborate #if defined so it is ignored for sbus/spektrum? What makes the code at that specific place unreadable?
In general, yeah ... those #if #elif #endif clauses everywhere make the code pretty unreadable :/
In general, yeah ... those #if #elif #endif clauses everywhere make the code pretty unreadable :/
Re: Same speksat and sbus failsafe nonsense in 2.3..
Already asked for this half a year ago.
Nice and readable isnt it?
Compared to the actual nested ifdef hell its beatiful, faster, readable, consistent, simply superior
Code: Select all
void computeRC() {
....
#if defined(SBUS)
readSBus();
for (chan = 0; chan < RC_CHANS; chan++)
rcData[chan] = readRawRC(chan);
#elif defined(SPEKTRUM)
for (chan = 0; chan < RC_CHANS; chan++)
rcData[chan] = readRawRC(chan);
#else
rc4ValuesIndex++;
if (rc4ValuesIndex == 4) rc4ValuesIndex = 0;
....
Nice and readable isnt it?
Compared to the actual nested ifdef hell its beatiful, faster, readable, consistent, simply superior
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: Same speksat and sbus failsafe nonsense in 2.3..
Plüschi wrote:Nice and readable isnt it?
Compared to the actual nested ifdef hell
The actual nested ifdef adds probably some useless code using failsafe, but it allows a MSP RC control override even with SBUS or SPEKTRUM.
Re: Same speksat and sbus failsafe nonsense in 2.3..
Alexinparis wrote:it allows a MSP RC control override even with SBUS or SPEKTRUM.
Seriously, would it be hard to move that "for ... if (... rcSerialCount > 0)" at the end, after the very last last #endif ?
This way you could override openlrs as well
Also, restructuring SBUS would be a good idea. Check the endbyte as proposed by ralf, and dont copy the stuff if failsafe.
Then, we have #define SBUS_SERIAL_PORT in config.h wouldnt it be nice to ACTUALLY USE that define ?
Code: Select all
change:
while(SerialAvailable(1)){
int val = SerialRead(1);
into:
while(SerialAvailable(SBUS_SERIAL_PORT)){
int val = SerialRead(SBUS_SERIAL_PORT);
By calling readSBus(); from the same place readSpektrum(); is called we could finally have the channel loop outside the #ifdef's and have a short, readable, beautiful and well performing computeRC() routine.