soc = sl_Socket(SL_AF_RF, SL_SOCK_RAW, channel); SlTimeval_t timeVal; timeVal.tv_sec = 0; timeVal.tv_usec = TU; SlSockNonblocking_t enableOption; enableOption.NonblockingEnabled = 1; sl_SetSockOpt(soc,SL_SOL_SOCKET,SL_SO_NONBLOCKING, (_u8 *)&enableOption,sizeof(enableOption)); // Enable/disable nonblocking mode sl_SetSockOpt(soc, SL_SOL_SOCKET, SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal)); if(soc < 0){ ERR_PRINT(soc); LOOP_FOREVER(); } // receive while(1){ byteNum = sl_Recv(soc, buff, 1469, 0); if(byteNum >= 0){ int i; if(byteNum > 18 && (buff[18] == 0xd6 || buff[23] == 0xb7)){ for(i = 8; i < byteNum; i++){ UART_PRINT("%02X", buff[i]); } UART_PRINT("\n\r"); } } else{ ERR_PRINT(byteNum); } UART_PRINT("Pass\n\r"); }
I'm using CC3200SDK_1.5.0 version. CC3200 is configured into transceiver mode.
The above is my code based on FreeRTOS framework. My questions are
- the error code return should be -11 from sl_Recv() no matter how many times I call it, as it runs.The actual situation is several -11 first, then followed by infinite amount of -100, and -100 is not a socket error.How to solve it ?
- Does the receive timeout work properly if the raw socket is configured to blocking mode and SL_SO_RCVTIMEO is set to a specific amount of time ? (Will it still return until timeout is reached ? Because I want to minimize the times of calling sl_Recv(), only timeout or a successful receive can return, an empty receive should be avoided)