RadioLink + USB (TX/RX Mismatch)

Hi,

I’ve modified the wireless_adc_tx and rx apps to (1) use RadioLink instead of RadioQueue and (2) transmit a set of 8-bit integers instead of the serial number. For some reason, the last integer output to the COM port does not match the value I set in the source code - i.e., txPacket[4] does not match rxPacket[4]. Every other value matches as expected, and I haven’t been able to parse out a pattern (setting it to “3” in tx results in “0” on the terminal, “23” → “0”, “4” → “2”, etc). Any troubleshooting tips would be helpful!

EDIT: Now, no matter the value of txPacket[4], the terminal output shows “03”.

TX CODE

void adcToRadioService()
{
    static uint16 lastTx = 0;

    uint8 XDATA * txPacket;

    // Check to see if it is time to send a report and
    // if there is a radio TX buffer available.
    if ((uint16)(getMs() - lastTx) >= param_report_period_ms && (txPacket = radioLinkTxCurrentPacket()))
    {
        // Both of those conditions are true, so send a report.

        uint8 i;
        uint16 XDATA * ptr = (uint16 XDATA *)&txPacket[5];

        // This should be done before all the ADC readings, which take about 3 ms.
        lastTx = getMs();

        // Byte 0 is the length.
        txPacket[0] = 16;

        // Bytes 1-4 are the serial number. MODIFIED
        txPacket[1] = 1;
        txPacket[2] = 2;
        txPacket[3] = 3;
        txPacket[4] = 4; //TERMINAL OUTPUT (RX CODE) NEVER MATCHES THIS VALUE

        adcSetMillivoltCalibration(adcReadVddMillivolts());

        // Bytes 5-16 are the ADC readings on channels 0-6.        
        for (i = 0; i < 6; i++)
        {
            *(ptr++) = adcConvertToMillivolts(adcRead(i));
        }

        radioLinkTxSendPacket(0);
    }
}

RX CODE

void radioToUsbService()
{
    uint8 XDATA * rxPacket;


    // Check if there is a radio packet to report and space in the
    // USB TX buffers to report it.
    if ((rxPacket = (uint8 XDATA *)radioLinkRxCurrentPacket()) && usbComTxAvailable() >= 64)
    {
        // We received a packet from a Wixel, presumably one running
        // the wireless_adc_tx app.  Format it nicely and send it to
        // the USB host (PC).

        uint8 i;
        uint16 XDATA * ptr_16bit = (uint16 XDATA *)&rxPacket[5];

        printf("%02d-%02d-%02d-%02d-%02d %5u",
         rxPacket[0],
         rxPacket[1],
         rxPacket[2],
         rxPacket[3], 
         rxPacket[4], //THIS VALUE IS NOT MATCHING txPacket[4] IN THE TX CODE
         (uint16)getMs()
         );

        for(i = 0; i < 6; i++)
        {
            printf(" %5u", *(ptr_16bit++));
        }

        putchar('\r');
        putchar('\n');

        radioLinkRxDoneWithPacket();
    }
}

TERMINAL OUTPUT

Hello.

I am sorry you are having trouble with the Wixel. I do not see any issues in the code you posted. Could you post the complete code for both the transmitter and the receiver here? If I don’t notice anything wrong in the code, I’d like to try running the code on two Wixels here to see if I can reproduce the problem. What versions of the Wixel SDK and SDCC are you using? What operating system are you running on the machine that compiles the code?

–David

Hi David,

Seems like it was a hardware issue (specifically the USB cable) - unsure about why exactly, but everything works as expected now. I can still post the code if you’d like. Thanks!