Proper use of radioComRxAvailable

pololu.github.com/wixel-sdk/radi … tml#l00098 tells me never to depend on radioComRxAvailable for a specific value greater than one.

I suppose the following code is using it correctly then?

alarm = 0;
while (1) {
if (alarm) {   // ALARM STATE
    if (radioComRxAvailable()) {
         alarm=0;
    }        
} else {
    if (radioComRxAvailable()) {
        while (radioComRxAvailabe()) {
              radioComRxReceiveByte();
              count = 0;
        }
     } else {
          count++;
     }
    if (count > 10000) {
        alarm = 1;
    }
    }
}

Hello, hagna.

Your code has a typo: “radioComRxAvailabe”.

Also, your code has an infinite loop in it. You are not calling the proper functions to maintain the USB connection or blink the LEDs in that loop, so that might be a problem for you if you want to easily get your Wixel into bootloader mode.

It looks like you are trying to set “alarm” to 1 if no bytes have been received from the radio in a while. I would recommend using the getMs() function instead of incrementing a counter in a loop. This will give you much more control over the timing.

Other than that, your use of radioComRxAvailable looks correct.

–David