43907WIFI传输卡顿问题

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

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

cross mob
jiwe_4607096
Level 1
Level 1
First question asked First reply posted First like given

向各位大侠请教

        最近在用43907 WIFI做高速数据传输,传输率在25Mbps。传输用的是UDP传输,在传输的过程中总发生无规律的卡顿数据无法稳定传输。

在开发板CYW943907AEVAL1F上用snip.udp_transmit稍作修改后做同样的测试,也发现数据传输不稳定现象。

请大侠们指点迷津。

以下分别是测试代码和测试结果图片

#include "wiced.h"

#define UDP_MAX_DATA_LENGTH         1024

#define UDP_TARGET_PORT             50007

#define UDP_TARGET_IP MAKE_IPV4_ADDRESS(192,168,0,2)

static wiced_result_t tx_udp_packet();

static wiced_udp_socket_t  udp_socket;

wiced_thread_t tx_linedata_thread_id;

static const wiced_ip_setting_t device_init_ip_settings =

{

        INITIALISER_IPV4_ADDRESS( .ip_address, MAKE_IPV4_ADDRESS(192,168,  0,  1) ),

        INITIALISER_IPV4_ADDRESS( .netmask,    MAKE_IPV4_ADDRESS(255,255,255,  0) ),

        INITIALISER_IPV4_ADDRESS( .gateway,    MAKE_IPV4_ADDRESS(192,168,  0,  1) ),

};

void tx_linedata_thread(uint32_t arg)

{

    while(1)

    {

        wiced_rtos_delay_microseconds(350);

        tx_udp_packet();

    }

}

void application_start(void)

{

    wiced_interface_t interface;

    wiced_result_t result;

    wiced_init( );

    result = wiced_network_up_default( &interface, &device_init_ip_settings );

    if( result != WICED_SUCCESS )

    {

        printf("Bringing up network interface failed !\r\n");

    }

    if (wiced_udp_create_socket(&udp_socket, UDP_TARGET_PORT, interface) != WICED_SUCCESS)

    {

        WPRINT_APP_INFO( ("UDP socket creation failed\n") );

    }

        wiced_rtos_create_thread(&tx_linedata_thread_id, 0, "tx_linedata_thread", tx_linedata_thread, 4096, NULL);

}

wiced_result_t tx_udp_packet()

{

    wiced_packet_t*          packet;

    char*                    udp_data;

    uint16_t                 available_data_length;

    const wiced_ip_address_t INITIALISER_IPV4_ADDRESS( target_ip_addr, UDP_TARGET_IP );

    if ( wiced_packet_create_udp( &udp_socket, UDP_MAX_DATA_LENGTH, &packet, (uint8_t**) &udp_data, &available_data_length ) != WICED_SUCCESS )

    {

        return WICED_ERROR;

    }

    wiced_packet_set_data_end( packet, (uint8_t*) udp_data + UDP_MAX_DATA_LENGTH );

    if ( wiced_udp_send( &udp_socket, &target_ip_addr, UDP_TARGET_PORT, packet ) != WICED_SUCCESS )

    {

        WPRINT_APP_INFO( ("UDP packet send failed\n") );

        wiced_packet_delete( packet ); /* Delete packet, since the send failed */

        return WICED_ERROR;

    }

    return WICED_SUCCESS;

}

下图为测试wifi稳定性图片

Capture.PNG

0 点赞
3 回复数
Murali_R
Moderator
Moderator
Moderator
250 sign-ins 250 replies posted 100 solutions authored

Hi

I tried out the code which you have attached and looks like it has some issues, as my board continuously resets.Could you please attach the project which you used for testing and got the attached screenshot as throughput?

I tested with snip.udp_transmit by changing the transmission time to 1ms and i'm receiving the data without any issues.

Could you try the throughput testing with tools like iperf instead of testing it using windows task manager?

Thanks

jiwe_4607096
Level 1
Level 1
First question asked First reply posted First like given

hi MuraliR_36,

非常感谢回复!

我的测试代码就是从snip.udp_transmit修改过来的。

因为实际项目需要做了以下几个变动,其他没有变化

变动如下:

wifi_config_dct.h中

Capture1.PNG

在udp_transmit.c中

把wiced_rtos_register_timed_event(...)改为创建一个线程,在线程中循环sleep 350微秒,发送1024个byte数据,全部代码如下

/*

* Copyright 2018, Cypress Semiconductor Corporation or a subsidiary of

* Cypress Semiconductor Corporation. All Rights Reserved.

*

* This software, associated documentation and materials ("Software"),

* is owned by Cypress Semiconductor Corporation

* or one of its subsidiaries ("Cypress") and is protected by and subject to

* worldwide patent protection (United States and foreign),

* United States copyright laws and international treaty provisions.

* Therefore, you may use this Software only as provided in the license

* agreement accompanying the software package from which you

* obtained this Software ("EULA").

* If no EULA applies, Cypress hereby grants you a personal, non-exclusive,

* non-transferable license to copy, modify, and compile the Software

* source code solely for use in connection with Cypress's

* integrated circuit products. Any reproduction, modification, translation,

* compilation, or representation of this Software except as specified

* above is prohibited without the express written permission of Cypress.

*

* Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,

* EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED

* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress

* reserves the right to make changes to the Software without notice. Cypress

* does not assume any liability arising out of the application or use of the

* Software or any product or circuit described in the Software. Cypress does

* not authorize its products for use in any products where a malfunction or

* failure of the Cypress product may reasonably be expected to result in

* significant property damage, injury or death ("High Risk Product"). By

* including Cypress's product in a High Risk Product, the manufacturer

* of such system or application assumes all risk of such use and in doing

* so agrees to indemnify Cypress against all liability.

*/

/** @file

*

* UDP Transmit Application

*

* This application snippet demonstrates how to send a UDP packet

* to a network client (and optionally receive a UDP response).

*

* Features demonstrated

*  - Wi-Fi softAP mode

*  - DHCP server

*  - UDP transmit

*

* Application Instructions

*   1. Connect a PC terminal to the serial port of the WICED Eval board,

*      then build and download the application as described in the WICED

*      Quick Start Guide

*   2. Ensure Python 2.7.x (*NOT* 3.x) is installed on your computer

*   3. Connect your computer using Wi-Fi to "WICED UDP Transmit App"

*        - SoftAP credentials are defined in wifi_config_dct.h

*   4. Open a command shell

*   5. Run the python UDP echo server as follows from the udp_transmit dir

*      c:\<WICED-SDK>\Apps\snip\udp_transmit> c:\path\to\Python27\python.exe udp_echo_server.py

*        - Ensure your firewall allows UDP for Python on port 50007

*

*   The network to be used can be changed by the #define WICED_NETWORK_INTERFACE in wifi_config_dct.h

*   In the case of using AP or STA mode, change the AP_SSID and AP_PASSPHRASE accordingly.

*

*   When WICED_NETWORK_INTERFACE is set as WICED_AP_INTERFACE in wifi_config_dct.h,

*   The WICED application starts a softAP, and regularly sends a broadcast

*   UDP packet containing a sequence number. The WICED app prints the

*   sequence number of the transmitted packet to the UART.

*

*   The computer running the UDP echo server receives the

*   packet and echoes it back to the WICED application. If the

*   #define GET_UDP_RESPONSE is enabled the WICED app prints the

*   sequence number of any received packet to the UART.

*

*   When the Wi-Fi client (computer) joins the WICED softAP,

*   it receives an IP address such as 192.168.0.2. To force

*   the app to send UDP packets directly to the computer (rather than

*   to a broadcast address), comment out the #define UDP_TARGET_IS_BROADCAST

*   and change the target IP address to the IP address of your computer.

*

*/

#include "wiced.h"

/******************************************************

*                      Macros

******************************************************/

/******************************************************

*                    Constants

******************************************************/

#define UDP_MAX_DATA_LENGTH         1024

#define UDP_TARGET_PORT             50007

#define UDP_TARGET_IP MAKE_IPV4_ADDRESS(192,168,0,2)

char test[2038] = {0,};

/******************************************************

*                   Enumerations

******************************************************/

/******************************************************

*                 Type Definitions

******************************************************/

/******************************************************

*                    Structures

******************************************************/

/******************************************************

*               Static Function Declarations

******************************************************/

static wiced_result_t tx_udp_packet();

/******************************************************

*               Variable Definitions

******************************************************/

static const wiced_ip_setting_t device_init_ip_settings =

{

        INITIALISER_IPV4_ADDRESS( .ip_address, MAKE_IPV4_ADDRESS(192,168,  0,  1) ),

        INITIALISER_IPV4_ADDRESS( .netmask,    MAKE_IPV4_ADDRESS(255,255,255,  0) ),

        INITIALISER_IPV4_ADDRESS( .gateway,    MAKE_IPV4_ADDRESS(192,168,  0,  1) ),

};

static wiced_udp_socket_t  udp_socket;

/******************************************************

*               Function Definitions

******************************************************/

wiced_thread_t tx_linedata_thread_id;

void tx_linedata_thread(uint32_t arg)

{

    while(1)

    {

        wiced_rtos_delay_microseconds(350);

        tx_udp_packet();

    }

}

void application_start(void)

{

    wiced_interface_t interface;

    wiced_result_t result;

    /* Initialise the device and WICED framework */

    wiced_init( );

    printf("Bringing up network interface failed !\r\n");

    WPRINT_APP_INFO( ("UDP socket creation failed\n") );

    /* Bring up the softAP and network interface */

    result = wiced_network_up_default( &interface, &device_init_ip_settings );

    if( result != WICED_SUCCESS )

    {

        printf("Bringing up network interface failed !\r\n");

    }

    /* Create UDP socket */

    if (wiced_udp_create_socket(&udp_socket, UDP_TARGET_PORT, interface) != WICED_SUCCESS)

    {

        WPRINT_APP_INFO( ("UDP socket creation failed\n") );

    }

        wiced_rtos_create_thread(&tx_linedata_thread_id, 0, "tx_linedata_thread", tx_linedata_thread, 4096, NULL);

}

/*

* Sends a UDP packet

*/

wiced_result_t tx_udp_packet()

{

    wiced_packet_t*          packet;

    char*                    udp_data;

    uint16_t                 available_data_length;

    const wiced_ip_address_t INITIALISER_IPV4_ADDRESS( target_ip_addr, UDP_TARGET_IP );

    /* Create the UDP packet */

    if ( wiced_packet_create_udp( &udp_socket, UDP_MAX_DATA_LENGTH, &packet, (uint8_t**) &udp_data, &available_data_length ) != WICED_SUCCESS )

    {

        WPRINT_APP_INFO( ("UDP tx packet creation failed\n") );

        return WICED_ERROR;

    }

    memcpy(udp_data,test,UDP_MAX_DATA_LENGTH);

    /* Set the end of the data portion */

    wiced_packet_set_data_end( packet, (uint8_t*) udp_data + UDP_MAX_DATA_LENGTH );

    /* Send the UDP packet */

    if ( wiced_udp_send( &udp_socket, &target_ip_addr, UDP_TARGET_PORT, packet ) != WICED_SUCCESS )

    {

        WPRINT_APP_INFO( ("UDP packet send failed\n") );

        wiced_packet_delete( packet ); /* Delete packet, since the send failed */

        return WICED_ERROR;

    }

    return WICED_SUCCESS;

}

0 点赞
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

hello:

    What is the time interval about the speed reducing ?   is  it regular ?

I suggest to do some compare tests to judge where is the issue happening ? like below:

1.  try to transfer less data every interval.

2.  try to capture sniffer to judge the issue is from RX or TX, 

     to see if there have many re-transmissions.

3.  try to add logs to judge if it is blocked on OS side .