Read large amount of data from a TCP socket

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

I'm newbie in WICED SDK and I'm trying to read all the packets received from an streaming radio. I only receive a few packets, after this the socket is closed. I'm using SDK 2.4.1 (the last suported for the SN8200 platform). I read and print the packet data with this (modified) source code:

do

{

    uint16_t amount_to_read;

    uint16_t total_available;

    uint8_t* packet_data     = NULL;

    uint16_t space_available = 0;

    rx_result = wiced_tcp_receive( &socket, &rx_packet, timeout );

    if ( rx_packet == NULL ){

        rx_result = wiced_tcp_receive( &socket, &rx_packet, timeout );

        if ( result != WICED_SUCCESS){

            WPRINT_APP_INFO(( "Error\r\n" ));

            break;

        }

    }

    wiced_packet_get_data( rx_packet, 0, &packet_data, &space_available, &total_available);

    amount_to_read = MIN( BUFFER_LENGTH, space_available );

    memcpy( buffer, packet_data, amount_to_read);

    // Print packet data

    buffer[ BUFFER_LENGTH ] = 0x0;

    WPRINT_APP_INFO(( "%s", buffer ));

    /* Check if we need a new packet */

    if ( amount_to_read == space_available ){

        wiced_packet_delete( rx_packet );

        rx_packet = NULL;

    }

    else{

        /* Otherwise update the start of the data for the next read request */

        wiced_packet_set_data_start( rx_packet, packet_data + amount_to_read);

    }

}while ( rx_result == WICED_SUCCESS );

I don't know if I'm doing something wrong or if there are any limitation (amount of data received, memory stack...).

Any suggestion will be appreciated.

0 Likes
3 Replies
Anonymous
Not applicable

One update : WICED SDK 3.1.0  supports SN8200 and this is is lot better than 2.4.1 beacause platform files are more managable,

Now regarding your issue,

1. Are you updating the the received data in a global buffer, If you're filling the data in a buffer declared with in stack there is an Chance for stackoverflow, so try to update a global buffer.

2. Printing large amount of data is not advisable , beacause printing takes a lot of time , so better print all the data when you've completed reception.

0 Likes
Anonymous
Not applicable

Thanks for replying.

About updating to 3.1, in this response says that SN8200 (stm32f1x) doesn't support SDK 3.1:

http://community.broadcom.com/docs/DOC-1576

Have you any patch that make it possible?

The buffer is declared as global variable. The idea is obtaining all the audio data from a streaming radio (so we're reading data continuosly) and send it to an STM32F4 for processing it (that's why I'm printing to serial console).

I probed with different size stack with no result.

0 Likes
Anonymous
Not applicable

I reduced the TCP Window Size and now seems to work. Although I get a low througput (~65,5Kbps).