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.

CC3000 API recv() is frozen

Other Parts Discussed in Thread: MSP430FR5739, MSP430F5438A

Hi, I'm trying to port the weather access code from " CC3000+LM4F232 Wi-Fi Web Server/Client Application " to MSP430FR5739  ( based on the "CC3000+FRAM WiFi Sensor Application  (new!)" code)

So , basically I copied the HTTPD file to FR5739 project. Because Google has closed its weather API so I use another site just for test. But every time the software is frozen at recv()

I printed HTTP access status to the serial port as below "

startHttp now....
ler=1
lerr=0
sentLen=87
cRetVal=0
iReadSocks=1
loop=0
before receciving

"

I traced into the recv() api --->simple_link_recv()   and then SimpleLinkWaitEvent(opcode, &tSocketReadEvent); 

SimpleLinkWaitEvent(unsigned short usOpcode, void *pRetParams)
{
//
// In the blocking implementation the control to caller will be returned only after the
// end of current transaction
//
tSLInformation.usRxEventOpcode = usOpcode;
hci_event_handler(pRetParams, 0, 0);
}

after hci_event_handler(pRetParams, 0, 0) is executed, the software is frozen.

it looks like the CC3000 doesn't return anything back so the whole software is blocked there. 

//////////////////////////////////////////////////////////

the web site I chose sends back a file around 1.2K (including the HTTP headers), and I managed to assign 1.4K byte to RX buffer.

#define SPI_BUFFER_SIZE 1400 //changed from 1700 to 1400 by Vincent 2012-10-05
#define RX_SPI_BUFFER_SIZE SPI_BUFFER_SIZE + 30
char pcCC3000_Rx_Buffer[RX_SPI_BUFFER_SIZE];
//char pcCC3000_Tx_Buffer[SPI_BUFFER_SIZE];
char pcCC3000_Tx_Buffer[200];

...................

iBytesReceived = recv(ulClientSocket, pcCC3000_Rx_Buffer,SPI_BUFFER_SIZE, 0);

...................

Does anybody have clue how to fix it? Thanks.

Vincent 

  • Hi Vincent, 

    It seems that you were able to request data to the server, do you logs showing what the server returned, any sniffed packets? Are you able to connect to the server from a browser without any problems, is this a local server or public one that I can try.  What is the status of the socket when you are calling the function 

    I also noticed that you are using the RX buffer as the application buffer, or is pcCC3000_Rx_Buffer a different buffer? the recv fuction will actually copy from the pcCC3000_Rx_Buffer to the buffer passed on the recv API.  


    Pedro

  • Hi Pedro,

    I dont have the sniff software but I do know what the returned package should look like. the web server is based on Google app engine. So by checking the server's log,  I know the MCU has successfully accessed it. and also by using the chrome navigator (by checking the detailed source code), I know what's the package should be returned.( that's why I know the package size is around 1.2K).

    Here are the status :

    ler=1  ...................  lerr = gethostbyname("exampleSite.appspot.com", 24, &ulGooglesIpAddr);
    lerr=0 .................... lerr = connect(ulClientSocket, &tSocketAddr, sizeof(tSocketAddr));
    sentLen=87 ..........SentLen = send(ulClientSocket, pucWeatherApiRequest,strlen(pucWeatherApiRequest), 0);

    cRetVal=0 ........... cRetVal = getsockopt(lSocketHandle, SOL_SOCKET,SOCKOPT_RECV_TIMEOUT, &uloptval, &optlen);

    iReadSocks=0 .... iReadSocks = select(2, &socks, 0, 0, &timeout);
    iReadSocks=0
    iReadSocks=0
    iReadSocks=0
    iReadSocks=0
    iReadSocks=0
    iReadSocks=1

    ////////////////////////////

    I think based on these status info, the HTTP GET has been sent (also verified by the server log) and the response package has been received ( by iReadSocks=1)

    ///////////////////

    iBytesReceived = recv(ulClientSocket, pcCC3000_Rx_Buffer,SPI_BUFFER_SIZE, 0);

    here is the code, the pcCC3000_Rx_Buffer is the buffer used by recv()   (my understanding is correct?)

    /////////////////////////////

    I found a thread (http://e2e.ti.com/support/low_power_rf/f/851/t/210263.aspx) mentioned the CC3000 recv() cannot read data if the socket is closed by remote site. I'm not sure if it's related to my situation ; (

  • Is the recv () function timing out?

    How about the RX buffer, did you tried to use a different buffer? 

    Pedro

  • recv () function timing out?

    <Vincent>no, just frozen there;

    How about the RX buffer, did you tried to use a different buffer? 

    <Vincent> I tried.

    #define SPI_BUFFER_SIZE 750 
    #define RX_SPI_BUFFER_SIZE SPI_BUFFER_SIZE + 30
    char pcCC3000_Rx_Buffer[RX_SPI_BUFFER_SIZE];
    //char pcCC3000_Tx_Buffer[SPI_BUFFER_SIZE];
    char pcCC3000_Tx_Buffer[100];
    char http_Rx_buffer[750];

    .............

    iBytesReceived = recv(ulClientSocket, http_Rx_buffer,750, 0);

    ///////////////////

    it's the same ; (


  • How about setting the receive timeout

    unsigned long timeout = 200; //milliseconds

    setsockopt( cosmSocket, SOL_SOCKET, SOCKOPT_RECV_TIMEOUT, &timeout, sizeof( timeout ) );

    Pedro

  • nothing happens ; ( 

    the code is still frozen there.

    BTW: is it possible for you to send me your email address? So I can send the whole project to you for reference. Thanks. 

  • Hi Pedro,

    Did you receive the project file I send to you last Friday? I used the "conversation" to send out the file. hopeful you already receive it.

    At the meantime, I tried the packet capture. The wireshark does capatured some packet sent from/to the CC3000. but unfortunately, the wireshark cannot recognize the proper TCP/IP and HTTP layer information. 0564.sample3.txt

    ( LsResear_02:0b:a7 (00:25:ca:02:0b:a7) is the CC3000)

    I have another problem for this:

    the payload is unrecognizable bit stream but it should be meaningful HTTP info.

    do you have any idea about this? or could you share with me what packet capture software you use? Thanks

  • Hi Vincent, 

    I got it, it looks that you sized the RX buffer too small, you use the minimal RX size which is 119 bytes. 

    #define CC3000_RX_BUFFER_SIZE   (CC3000_MINIMAL_RX_SIZE) 

    Then the app is requesting to read 900 bytes

    #define SPI_BUFFER_SIZE         900 

    iBytesReceived = recv(ulClientSocket, pcCC3000_Rx_Buffer,SPI_BUFFER_SIZE, 0);

    When trying to read more than the RX buffer size the host driver will loop forever:

    // The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size)
    // for the purpose of detection of the overrun. If the magic number is overriten - buffer overrun
    // occurred - and we will stuck here forever!
    if (sSpiInformation.pRxPacket[CC3000_RX_BUFFER_SIZE - 1] != CC3000_BUFFER_MAGIC_NUMBER)
    {
    while (1)
    ;
    }

  • Hi Pedro,

    Thanks to point out the problem and I tried to modified the below way , but it still  not work.

    1, change the CC3000 buffer size to the maximal-1519

    #define CC3000_RX_BUFFER_SIZE (CC3000_MAXIMAL_RX_SIZE)
    #define CC3000_TX_BUFFER_SIZE (CC3000_MAXIMAL_TX_SIZE)

    2, keep the SPI buffer the same 900 

    #define SPI_BUFFER_SIZE         900 

    3, by using the wireshark, I found the response byte for the web service is around 600 byte. 

    But it still dosen't work ; (

    any suggestion is appreciated

  • Hi Vincent,

         Have you got this issue solved ? If so please help me. I too got stuck in this recv function.

    Regards,

    Akshay

  • you need change the link file too:

    it uses "FRAM_DATA" for the buffer. because my HTTP response is big (1.2K) , I cannot get such big buffer on the MSP540FR5739. 

    I need port this code to other MSP430 for verification.

  • Hi Vincent, 

    Do you mean there is no space left on the FRAM to receive the HTTP frame? Have you tried reading it in smaller sizes, say your HTTP response is 1.2K then if you have 600 bytes receive buffer, then you could loop twice on the recv function and parse what you need:

    Example:

    receivedBytes = recv ( sd, buffer, 600);

    parse(buffer);

    while (receivedBytes == 600)

    {

       

       receivedBytes = recv ( sd, buffer, 600);  

      parse(buffer);

    }

    Also if you only send less (i.e. 300 bytes) , you could make your wlan_tx_buffer smaller, and increase your http buffer. 

    Pedro 

  • Thanks. but it looks like loop twice doesn't work. because there is return from 

    receivedBytes = recv ( sd, buffer, 600)

    it looks like the buffer has been overflew and the recv() function is just stuck there.

    BTW:

    Do you know anybody ever try to port the sensor application to MSP430F5438a?  MSP430F5438a has much more resource and I want to try on it. Thanks. 

  • Hi Vincent, 

    I do not know if anybody has ported the sensor app to the MSP430F438a. 

    If your spi_buffer is as big as the http buffer, then the receive function should not be stuck.  Is it getting stuck after the overflow?

    Pedro