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.

EasyLink createpacket() function

Other Parts Discussed in Thread: CC1120

Hello,
I am trying to modify the packet sent with the EasyLink and I don't know why but when i change this line(changing the value to a different number from PKTLEN's value):
txBuffer[0] = PKTLEN;
inside of the createPacket function the board only transmit 4 packets. According to what i understand, this function just put the values that you want to send in the transmission buffer, ie, the payload of the packet, is it correct?
but according to what i see when i modify this function, i think is doing something else, but I've been trying to check the forum and the web but i didn't find anything, so i decided to write this post.
Can someone tell me what is exactly doing this function in the sample code EasyLink, because i would like to modify what i am sending, but i don't know how to do it for infinite packets, it stucks in 4 packets. I know that the structure of the packet that is by default in that function is in order to receive the packet with the SmartRF studio, but due to this is not my purpose i would like to know how to modify it.

Thanks in advance.

--I'm using the Smart TrxEB with the RF Module cc1120 running the sample code EasyLink

  • If you want to change the length byte (PKTLEN) you should change the #define PKTLEN 30 and not the txBuffer[0]. The reason for this is that you PKTLEN is used to set the size of the txBuffer and the size of txBuffer is again used to determine how many bytes should be written to the TXFIFO.

    Note that for this example 1 < PKTLEN < 126.

    Siri

     

  • First, thanks for the reply.

    I know that changing the PKTLEN value I can change the length of the packet, but my idea is not modify the length, what I want is to modify the content of the packet, not the length, but I tried to change the first line of the createpacket() function and it doesn't work, it just send 4 packets instead of infinite number, ie, i change the first byte of the txBuffer and it doesn't work. Does anyone know why?

    Thanks

  • If you are changing the first line in the createPacket function you are messing with the length as the length is the first thing you write to the txBuffer.

    txBuffer[0] = PKTLEN;                           // Length byte

    txBuffer[1] = (uint8) (packetCounter >> 8);     // MSB of packetCounter

    txBuffer[2] = (uint8)  packetCounter;           // LSB of packetCounter

    .

    .

    .

    It would be helpful if you could show your modified code so that we can figure out what is going on.

     

    Siri

  • Sorry for the late answer.

    my function createpacket is:

    /*****************************************************************************/
    static void createPacket(uint8 txBuffer[]) {
        uint8 i;
        txBuffer[0] =0x08;                           // Length byte
       
        // Fill rest of buffer with random bytes
        for(i = 1; i < (PKTLEN + 1); i++) {
            txBuffer[i] = (uint8)i;
        }
    }

    /******************************************************************************/

    and the PKTLEN is 10.

    I am just trying to modify the content of the txBuffer, but I don't know why i have to send first the PKTLEN.

    Thanks in advance

  • If you set PKTLEN to 10 your txBuffer will be 11 bytes long since

    // Initialize packet buffer of size PKTLEN + 1

    uint8 txBuffer[PKTLEN+1] = {0};

    The packet you create in your createPacket function will look like this:

    txBuffer[0] = 0x08

    txBuffer[1] = 0x01

    txBuffer[2] = 0x02

    txBuffer[3] = 0x03

    txBuffer[4] = 0x04

    txBuffer[5] = 0x05

    txBuffer[6] = 0x06

    txBuffer[7] = 0x07

    txBuffer[8] = 0x08

    txBuffer[9] = 0x09

    txBuffer[10] = 0x0A

    You will be writing 11 bytes to the TXFIFO since sizeof(txBuffer) is used as an argument to the cc112xSpiWriteTxFifo function

    // Write packet to TX FIFO

    cc112xSpiWriteTxFifo(txBuffer, sizeof(txBuffer));

    Since the radio is configured for variable packet length mode and you are writing 0x08 as the first byte to the TXFIFO the following will be sent on the air:

    0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08

    This mean that there will be two bytes left in the TXFIFO:

    0x09 and 0x0A

    Next time you write your packet to the FIFO this will be the content in the TXFIFO:

    0x09, 0x0A, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08

    0x09 will now be interpreted as the length byte and you will send the following on the air:

    0x09, 0x0A, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07

    0x08 will then be left in the FIFO.

    As you understand it is necessary that the length (first byte in the FIFO) matches the length of the payload you want to send.

    If you want your length byte to be 0x08 you should only write 9 bytes in total to the FIFO.

    If you want to send the following packet

    txBuffer[0] = 0x08

    txBuffer[1] = 0x01

    txBuffer[2] = 0x02

    txBuffer[3] = 0x03

    txBuffer[4] = 0x04

    txBuffer[5] = 0x05

    txBuffer[6] = 0x06

    txBuffer[7] = 0x07

    txBuffer[8] = 0x08

    txBuffer[9] = 0x09

    txBuffer[10] = 0x0A

    you must reconfigure the radio to use fixed packet length mode and set the packet length to 11.

    Siri