vanvught / rpidmx512

Orange Pi DMX512 / RDM / MIDI / OSC / Art-Net / WS28xx / L6470 / Stepper / TLC59711 / PCA9685 / Servo / PWM / TCNet / SMPTE / RDMNet / LLRP / GD32 / GigaDevice / Raspberry Pi
http://www.orangepi-dmx.org/
MIT License
392 stars 108 forks source link

Experimental #138

Closed hippyau closed 4 years ago

hippyau commented 4 years ago

Hi Arjan!

So please have a look and see what you reckon. It works confirmed with my big clock and SystimeReader.

opi> [12] {set ltc stop}
nCmdIndex=2
ValidateArg() src/h3/shell.cpp, line 174: m_Argc=2
0:[ltc]{3}
1:[stop]{4}
LTC Systime Command: ltc!stop
opi> [13] {set ltc start}
nCmdIndex=2
ValidateArg() src/h3/shell.cpp, line 174: m_Argc=2
0:[ltc]{3}
1:[start]{5}
LTC Systime Command: ltc!start
opi> 

It's not awesome code, but the third approach I came up with that seems to work well.
Keen to see how you would change/fix my code.

A better way to get current ltcSource? Implement __builtin_expect((x),1) in HandleRequest

I'm a bit mentally ill, I see these in linux kernel and it's so much more readable to me with these macros....

#define likely(x)       __builtin_expect((x),1)
#define unlikely(x)     __builtin_expect((x),0)

so likely(return==0) { return; // it would execute this, yes? }?

vanvught commented 4 years ago

Hi Hippy,

With my OS, a non-interrupting while loop with Run methods, then when checking for received data on UDP:

    if (__builtin_expect((m_nBytesReceived < 8), 1)) {
        return;
    }

it is most likely that there is no datagram available. Therefore it is expected that the the m_nBytesReceived is mostly 0 or less than the smallest package we expect to receive.

This latest pull request is on master. That should not be done.

Greetings, Arjan