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 recvfrom hang problem



Hi,

My cc3000 hung when receiving udp packets from my android phone, but not always, sometimes can receive successfully but even this I can not get the correct source IP address.  

In my code, I can successfully open a socket by socket() and  bind it to a port(36000) by:

ulSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
ret = setsockopt( ulSocket, SOL_SOCKET, SOCKOPT_RECV_TIMEOUT, &timeout, sizeof( timeout ) );
ret = setsockopt( ulSocket, SOL_SOCKET, SOCKOPT_NONBLOCK, &unblock_enable, sizeof( unblock_enable ) );


tSocketAddr.sa_family = AF_INET;
tSocketAddr.sa_data[0] = 0x8c;
tSocketAddr.sa_data[1] = 0xa0;
memset(&tSocketAddr.sa_data[2], 0, 4);
bind(ulSocket, &tSocketAddr, sizeof(sockaddr));

Then I keep using ret = recvfrom(ulSocket, pucCC3000_Rx_Buffer, CC3000_APP_BUFFER_SIZE, 0, (sockaddr*)&tSocketAddr,  &tRxPacketLength);
to receive udp packet from my android phone in my local network.

Sometimes I can get my sending data in pucCC3000_Rx_Buffer successfully but sometimes hang in recvfrom function (still can ping to cc3000 during hanging). I has set the udp timeout value as 2s already. I  also tried using both blocking and non-blocking mode, the situation did not change. Even when I got the udp packet successfully the source IP resided in tSocketAddr is wrong and the returned tRxPacketLength is 12, but the receive data in pucCC3000_Rx_Buffer is correct. If I send the udp data to my PC in the same way I can get the correct information in Wireshark. My sending data is small just 2 bytes and the pucCC3000_Rx_Buffer is large enough (228 bytes). 

I set my socket timeout value as 0 and I can keep sending udp packet out if not receiving.

Host MCU: STM32F4
Host Driver version:  1.10.1
Service Pack version: 1.10
udp test app in android: UDP TCP Server Free, UDPTester 

Thanks. 

  • Hi.

    On 1.10.1 it is a known problem, when you call receive and no packets in internal CC3000 buffer - device hangs.

    You can use select() before call to receive to know if somethng received on certain port, and if received - then call recv() or recvfrom().

    But better move to 1.11.1. This problem is solved there and it seems to be more reliable firmware.

  • Dmitry Bodnya said:

    Hi.

    On 1.10.1 it is a known problem, when you call receive and no packets in internal CC3000 buffer - device hangs.

    You can use select() before call to receive to know if somethng received on certain port, and if received - then call recv() or recvfrom().

    But better move to 1.11.1. This problem is solved there and it seems to be more reliable firmware.

    Thank you, I will try select() first to see the performance. Since I am not using TI MCU, I think it is very complicated to update the firmware. I will try in the next step.

  • Dmitry Bodnya said:

    Hi.

    On 1.10.1 it is a known problem, when you call receive and no packets in internal CC3000 buffer - device hangs.

    You can use select() before call to receive to know if somethng received on certain port, and if received - then call recv() or recvfrom().

    But better move to 1.11.1. This problem is solved there and it seems to be more reliable firmware.

    Hi, the difference is my device only hang when I send a udp packet to it, i.e. it can keep running if I do not send anything. I have tried select(), after knew something is received on the certain port I call recvfrom() but it still hang. 

  • HI.

    It seems to be some other problem. In my case everything works well with select().

    Are you sure you have ported SPI driver correct?

    About  firmware update. If you have ported SPI driver then it is simple to port Patch Programmer to your platform to update Driver and Firmware.

  • Dmitry Bodnya said:

    HI.

    It seems to be some other problem. In my case everything works well with select().

    Are you sure you have ported SPI driver correct?

    About  firmware update. If you have ported SPI driver then it is simple to port Patch Programmer to your platform to update Driver and Firmware.

    Hi, yes, I also suspect the porting issue since even I can get the udp packet the source IP is always incorrect. But recently I can successfully init my cc3000, DHCP, ipconfig, scan ssid, smart config and send udp packet, why only got problem in udp receiving if that is the porting problem. Anyway, I will try to update the driver and firmware. Hope this can solve. Thank you.

    By the way, you are using TI MCU? I should patch to 1.10.2 first then to 1.11? or I can patch to 1.11 directly. 

  • Hi.

    I am not using TI MCU generally. I bought MSP FRAM when I had problems. I was also suspecting wrong porting and wanted to check it on MSP. 

    But our basic device is on another processor. So, we have CC300 on our board and we are using ported patch programmer to update firmware.

    From 1.10.1 you can use last patch programmer, I guess. From more previous versions is better to use 1.10.1 patch programmer first.

  • Dmitry Bodnya said:

    Hi.

    I am not using TI MCU generally. I bought MSP FRAM when I had problems. I was also suspecting wrong porting and wanted to check it on MSP. 

    But our basic device is on another processor. So, we have CC300 on our board and we are using ported patch programmer to update firmware.

    From 1.10.1 you can use last patch programmer, I guess. From more previous versions is better to use 1.10.1 patch programmer first.

    Hi, I think my problem is same as this one: http://e2e.ti.com/support/low_power_rf/f/851/t/265783.aspx

    It is like a common problem in CC3000, I visited this page before but my IRQ line does not keep low. Last night I got hang again in updating firmware. The program stuck in nvmem_read. The same point between recvfrom and nvmem_read is there is SimpleLinkWaitEvent followed by SimpleLinkWaitData in both functions. So I think I missed a IRQ.

    Now the IRQ problem is solved. Thank you very much for your kindly help. 

  • Hello LZC,

    I got a IRQ problem with the cc3000 TI module you solved. I modified SPIwirte(), but nvmem_read() did not work.

    Can you tell me how did you solved that?

    Thanks

    Tuong