This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/LAUNCHXL-CC1310: Unable to print whole data received over RF on UART terminal.

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310

Tool/software: TI-RTOS

Hello,

I am using rfWakeOnRadioRx program from RF Examples on CC1310. The program is working fine along with rfWakeOnRadioTx. 

For the next part I am sending constant string of 5 char from one cc1310 lauchpad to other. The receiving CC1310 lauchpad receives data successfully without loss. But when it comes to print data on UART terminal it only shows four characters. Here is the code snippet.

void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)                  //called when data is received
{
    /* If we've received a new packet and it's available to read out */
    if (e & RF_EventRxEntryDone)
    {
        do
        {
            /* Toggle LED on RX */
            PIN_setOutputValue(ledPinHandle, Board_LED1, !PIN_getOutputValue(Board_LED1));

            /* Get current unhandled data entry */
            currentDataEntry = RFQueue_getDataEntry();

            /* Handle the packet data, located at &currentDataEntry->data:
             * - Length is the first byte with the current configuration
             * - Data starts from the second byte */
            packetLength      = *(uint8_t*)(&currentDataEntry->data);
            packetDataPointer = (uint8_t*)(&currentDataEntry->data + 3);            //pointer to actual data

            /* This code block is added to avoid a compiler warning.
            * Normally, an application will reference these variables for
            * useful data. */
            volatile uint8_t dummy;
            dummy = packetLength;
            dummy = dummy + packetDataPointer[0];

        } while(RFQueue_nextEntry() == DATA_ENTRY_FINISHED);

        UART_write(uart, packetDataPointer, sizeof(packetDataPointer));  //write data to uart
    }
}

packetDataPointer variable is of type static uint8_t*

To receive all five characters I changed line as follows

UART_write(uart, packetDataPointer, sizeof(packetDataPointer)+1);

with this it is showing all four characters. But when again if the data is of some more size then I want

sizeof(packetDataPointer) to change dynamically and I don't want to increase the size manually. What changes to be made to receive and print all the received data of different size?

  • If you are using the default WOR example, it uses variable packet length mode so the first byte received in the data entry (currentDataEntry->data) is the length byte.

    That means that if you send a packet with length byte 5:

    5, Data1, Data2, Data3, Data4, Data5

    packetLength = *(uint8_t*)(&currentDataEntry->data); will be 5 and this variable you can use when determining how many bytes yous should write over UART.

    packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1); will be a pointer to Data1, the first byte received after the length byte.

    I do not know why you are settings packetDataPointer = (uint8_t*)(&currentDataEntry->data + 3); as this is a pointer to the 4th byte received.

     

  • Thank you Siri,

    Your answer helped me to solve problem. I have used packetDataPointer = (uint8_t*)(&currentDataEntry->data + 3); because I thought the actual data is starting from 4th byte. I am confused about the packet format used to send the data. Till now I have only understood that the the first byte is the length of the data and next we have data bytes. But don't know what other bytes are there. Can you please tell me what is the packet format used for this communication?
  • The transmitter sends preamble, 4 bytes sync, 1 length byte, payload (number of bytes given by length byte) and then two CRC bytes. In the data entry you get 8 header bytes for the entry (described in the TRM), then the length byte and the payload byte. Afterwards there might be appended status bytes, timestamp, rssi etc. depending on the append settings in the API. The length byte is the first byte in the data entry after the header. That means that it is available on index 8. Payload starts on the next byte. You can monitor the complete data entry by putting a watch on the rxDataEntryBuffer.
    BR
    Siri