Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

CC3100MODBOOST: CC3100 sl_Send error

$
0
0

Part Number:CC3100MODBOOST

Hello to all,

I encounter problems while trying to send data via WLAN from a CC3100 module. I have read a lot of other posts with a similar topic (especially https://e2e.ti.com/support/wireless_connectivity/simplelink_wifi_cc31xx_cc32xx/f/968/t/350584), but I could not figure out a working solution. So I hope someone can help me. Here is what I am trying to do:

I am using the CC3100ModBoost device with a TMS570LS0432 controller. I have ported the SimpleLink's driver for the TMS570 controller and now the communication between CC3100 and TMS570 seems to work correctly. My SimpleLink module is configured as an access point in my program code. Then I can connect to the SimpleLink's WLAN with my Windows PC. The SimpleLink module sends a ping request and receives the PC's answer. After this a socket on the CC3100 module is opened to listen for incoming connections on port 5001. On my PC I open a java application that connects successfully to the SimpleLink on port 5001. Up to This point everything works perfecly (see my terminal output below).

Getting started with WLAN access-point application - Version 1.3.0
*******************************************************************************
Device is configured in default state 
Device started as Access Point
Waiting for clients to connect...!
Client connected to the device 
Pinging...
Ping properties: Size: 20 Bytes, Interval: 1000 ms, Timeout: 3000 ms,  Attempts: 3
Ping Packets Received: 2
Device and the station are successfully connected 
Starting TCP server...
Creating TCP server socket
Assigning local adress to server socket
Waiting for clients to connect...
Client connected successfully       <---------- up to this point everything works!
[TCP Server] Data send Error: -1

cc3100_main() return code: -3003

As soon as I try to send some data from the CC3100 device to my computer's java application the SimpleLink's sl_Send() method fails in its first call and returns the value -1 (SL_SOC_ERROR). This is caused by the _SlDrvDataWriteOp() method in driver.c, line 809 (see related topic above):

/*  we have indication that the last send has failed - socket is no longer valid for operations  */
if(g_pCB->SocketTXFailure & (1<<(Sd & BSD_SOCKET_ID_MASK)))
{
    SL_DRV_OBJ_UNLOCK(&g_pCB->FlowContCB.TxLockObj);
    return SL_SOC_ERROR;
}

In my case the 'g_pCB->SocketTXFailure' value is 0x05, Sd = 0x10 and BSD_SOCKET_MASK = 0x0F. So the driver reaches the 'return SL_SOC_ERROR' statement. So the result in the above if-statement is 0x10 & 0x0F = 0x00 --> 1 << 0x00 = 0x01 --> 0x05 & 0x01 = 0x01 != 0. Can somebody tell me when these SocketTXFailure bits can be set and why they are set? I don't use any operating system on the MCU. For your information, this is my method to open a TCP server socket  (it's mainly taken from the tcp_socket example):

static _i32 openTCPServer(_u16 Port) {

    SlSockAddrIn_t  Addr;
    SlSockAddrIn_t  LocalAddr;

    _u16          idx = 0;
    _u16          AddrSize = 0;
    _i16          SockID = 0;
    _i32          Status = 0;
    _i16          newSockID = 0;
    _u16          LoopCount = 0;
    _i16          sendSize = 0;

    for (idx=0 ; idx<BUF_SIZE ; idx++) {
        uBuf.BsdBuf[idx] = (_u8)(idx % 10);
    }

    LocalAddr.sin_family = SL_AF_INET;
    LocalAddr.sin_port = sl_Htons((_u16)Port);
    LocalAddr.sin_addr.s_addr = 0;

    println("Creating TCP server socket");
    SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
    if(SockID < 0) {
        println("[TCP Server] Create socket Error");
        ASSERT_ON_ERROR(SockID);
    }

    println("Assigning local adress to server socket");
    AddrSize = sizeof(SlSockAddrIn_t);
    Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
    if(Status < 0) {
        sl_Close(SockID);
        println("[TCP Server] Socket address assignment Error");
        ASSERT_ON_ERROR(Status);
    }

    println("Waiting for clients to connect...");
    Status = sl_Listen(SockID, 0);
    if( Status < 0 ) {
        sl_Close(SockID);
        println("[TCP Server] Listen Error");
        ASSERT_ON_ERROR(Status);
    }

    newSockID = sl_Accept(SockID, (struct SlSockAddr_t *)&Addr, (SlSocklen_t*)&AddrSize);
    if( newSockID < 0 ) {
        sl_Close(SockID);
        println("[TCP Server] Accept connection Error");
        ASSERT_ON_ERROR(newSockID);
    }
    else {
        println("Client connected successfully");
    }

    int i;
    for (i = 0; i < SEND_BUFFER_SIZE; i++) {
        sendBuffer[i] = (_u8) i;
    }

    while (1) {
        Status = sl_Send(SockID, sendBuffer, SEND_BUFFER_SIZE, 0);          <--------- in first attempt sl_Send() returns -1
        if (Status <= 0) {
            printInt("[TCP Server] Data send Error: %d\r\n", Status);
            Status = sl_Close(SockID);
            ASSERT_ON_ERROR(TCP_SEND_ERROR);
        }
        LoopCount++;
    }
}

Am I doing something wrong? I don't know why the sl_Send()  method does not work already in first attempt. By the way I am wondering why the ping packets can be send and received but the tcp socket can't send any data.

Thank you for any helpful answers.

Best regards
Michel


Viewing all articles
Browse latest Browse all 262198

Trending Articles