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.

Bugreport CC3000HostDriver: SpiReadDataCont() calculates wrong data length



Hi,

line 499 in spi.c in function SpiReadDataCont() tries to make the data length to be read even, as all CC3000 data needs to be 16 bit aligned in length. However, the current implementation makes sure the data length is always odd (e.g. 100 gets fixed into 101 etc).

Line 499 should read:

if ((HEADERS_SIZE_EVNT + data_to_recv) & 1)

See also line 521 where this is correct.

Cheers,

Johannes

  • Hi Johannes, 

    Which spi version are you using? I could not reference the line number you mentioned. Did you use the latest sensor app?

    Pedro 

  • Hi Pedro,

    thanks for the response. I am using the latest Basic Wifi App spi.c (1.12.6.10) since the source of the Sensor app is only available as a Windows EXE and I do not use Windows. spi_version.h says version 6. I verified the line number in question:  499.

    This is the code I mean in spi.c: See ERROR below:

    long
    SpiReadDataCont(void)
    {
        long data_to_recv;
            unsigned char *evnt_buff, type;
    
            
        //
        //determine what type of packet we have
        //
        evnt_buff =  sSpiInformation.pRxPacket;
        data_to_recv = 0;
            STREAM_TO_UINT8((char *)(evnt_buff + SPI_HEADER_SIZE), HCI_PACKET_TYPE_OFFSET, type);
            
        switch(type)
        {
            case HCI_TYPE_DATA:
            {
                            //
                            // We need to read the rest of data..
                            //
                            STREAM_TO_UINT16((char *)(evnt_buff + SPI_HEADER_SIZE), HCI_DATA_LENGTH_OFFSET, data_to_recv);
                            if (!((HEADERS_SIZE_EVNT + data_to_recv) & 1)) // ERROR: remove negation
                            {       
                    data_to_recv++;
                            }
    
                            if (data_to_recv)
                            {
                    SpiReadDataSynchronous(evnt_buff + 10, data_to_recv);
                            }
                break;
            }
            case HCI_TYPE_EVNT:
            {
                            // 
                            // Calculate the rest length of the data
                            //
                STREAM_TO_UINT8((char *)(evnt_buff + SPI_HEADER_SIZE), HCI_EVENT_LENGTH_OFFSET, data_to_recv);
                            data_to_recv -= 1;
                            
                            // 
                            // Add padding byte if needed
                            //
                            if ((HEADERS_SIZE_EVNT + data_to_recv) & 1)
                            {
                                    
                        data_to_recv++;
                            }
                            
                            if (data_to_recv)
                            {
                    SpiReadDataSynchronous(evnt_buff + 10, data_to_recv);
                            }
    
                            sSpiInformation.ulSpiState = eSPI_STATE_READ_EOT;
                break;
            }
        }
            
        return (0);
    }
    
  •        I agree with the Johannes's finding, I also make confuse with this bug ,when odd length datas always are received lack of one , then cc300 stop responding the next API,so I fix as above description. datas received noraml.