Same speksat and sbus failsafe nonsense in 2.3..

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
Plüschi
Posts: 433
Joined: Thu Feb 21, 2013 6:09 am

Same speksat and sbus failsafe nonsense in 2.3..

Post by Plüschi »

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 ?
Last edited by Plüschi on Tue Nov 19, 2013 3:49 pm, edited 2 times in total.

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Same speksat and sbus failsafe nonsense in 2.3..

Post by timecop »

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.

Sebbi
Posts: 478
Joined: Sun Jul 08, 2012 1:08 am
Location: Germany
Contact:

Re: Same speksat and sbus failsafe nonsense in 2.3..

Post by Sebbi »

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 :/

User avatar
Plüschi
Posts: 433
Joined: Thu Feb 21, 2013 6:09 am

Re: Same speksat and sbus failsafe nonsense in 2.3..

Post by Plüschi »

Already asked for this half a year ago.

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 :mrgreen:

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Same speksat and sbus failsafe nonsense in 2.3..

Post by Alexinparis »

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.

User avatar
Plüschi
Posts: 433
Joined: Thu Feb 21, 2013 6:09 am

Re: Same speksat and sbus failsafe nonsense in 2.3..

Post by Plüschi »

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 :lol:

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.

Post Reply