fixed pull conflict and socket ping test bug

This commit is contained in:
wlyu 2021-12-22 16:09:34 +08:00
commit aa43d46953
9 changed files with 68 additions and 43 deletions

View File

@ -32,11 +32,13 @@
* Includes * Includes
******************************************************************************/ ******************************************************************************/
//#if LWIP_IPV4 && LWIP_RAW #include <transform.h>
#if 1 #include "lwip/opt.h"
#if LWIP_IPV4 && LWIP_RAW
#include "ping.h" #include "ping.h"
#include "lwip/opt.h"
#include "lwip/timeouts.h" #include "lwip/timeouts.h"
#include "lwip/init.h" #include "lwip/init.h"
#include "netif/ethernet.h" #include "netif/ethernet.h"
@ -88,6 +90,8 @@
* Variables * Variables
******************************************************************************/ ******************************************************************************/
static pthread_t ping_demo_id = 0;
/******************************************************************************* /*******************************************************************************
* Code * Code
******************************************************************************/ ******************************************************************************/
@ -95,7 +99,7 @@
/*! /*!
* @brief Main function. * @brief Main function.
*/ */
int lwip_ping_test(void) static void *lwip_ping_test(void *param)
{ {
struct netif fsl_netif0; struct netif fsl_netif0;
#if defined(FSL_FEATURE_SOC_LPC_ENET_COUNT) && (FSL_FEATURE_SOC_LPC_ENET_COUNT > 0) #if defined(FSL_FEATURE_SOC_LPC_ENET_COUNT) && (FSL_FEATURE_SOC_LPC_ENET_COUNT > 0)
@ -127,8 +131,6 @@ int lwip_ping_test(void)
netif_set_default(&fsl_netif0); netif_set_default(&fsl_netif0);
netif_set_up(&fsl_netif0); netif_set_up(&fsl_netif0);
ping_init(&fsl_netif0_gw);
lw_print("\r\n************************************************\r\n"); lw_print("\r\n************************************************\r\n");
lw_print(" PING example\r\n"); lw_print(" PING example\r\n");
lw_print("************************************************\r\n"); lw_print("************************************************\r\n");
@ -140,6 +142,8 @@ int lwip_ping_test(void)
((u8_t *)&fsl_netif0_gw)[2], ((u8_t *)&fsl_netif0_gw)[3]); ((u8_t *)&fsl_netif0_gw)[2], ((u8_t *)&fsl_netif0_gw)[3]);
lw_print("************************************************\r\n"); lw_print("************************************************\r\n");
ping_init(&fsl_netif0_gw);
while (1) while (1)
{ {
/* Poll the driver, get any outstanding frames */ /* Poll the driver, get any outstanding frames */
@ -148,8 +152,25 @@ int lwip_ping_test(void)
} }
} }
void lwip_ping_thread(void)
{
int result = 0;
pthread_attr_t attr;
attr.schedparam.sched_priority = 15;
attr.stacksize = 4096;
result = pthread_create(&ping_demo_id, &attr, lwip_ping_test, NULL);
if (0 == result) {
lw_print("lwip_ping_test successfully!\n");
} else {
lw_print("lwip_ping_test failed! error code is %d\n", result);
}
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0), SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
LwPingTest, lwip_ping_test, lwip_ping_test); LwPingTest, lwip_ping_thread, lwip_ping_thread);
#endif #endif

View File

@ -63,4 +63,3 @@ int LwipUdpDemo(int argc, char *argv[])
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
UdpTest, LwipUdpDemo, UDP socket demo function); UdpTest, LwipUdpDemo, UDP socket demo function);
#endif #endif

View File

@ -102,6 +102,9 @@ static u32_t ping_time;
static struct raw_pcb *ping_pcb; static struct raw_pcb *ping_pcb;
#endif /* PING_USE_SOCKETS */ #endif /* PING_USE_SOCKETS */
#define PING_THREAD_STACKSIZE 4096
#define PING_THREAD_PRIO 15
/** Prepare a echo ICMP request */ /** Prepare a echo ICMP request */
static void static void
@ -354,8 +357,6 @@ ping_send(struct raw_pcb *raw, const ip_addr_t *addr)
#endif /* LWIP_DEBUG */ #endif /* LWIP_DEBUG */
} }
pbuf_free(p); pbuf_free(p);
// lw_print("lw: [%s] send %d\n", __func__, ping_size);
} }
static void static void
@ -390,9 +391,6 @@ ping_send_now(void)
#endif /* PING_USE_SOCKETS */ #endif /* PING_USE_SOCKETS */
#define PING_THREAD_STACKSIZE 4096
#define PING_THREAD_PRIO 0
void void
ping_init(const ip_addr_t* ping_addr) ping_init(const ip_addr_t* ping_addr)
{ {
@ -402,7 +400,7 @@ ping_init(const ip_addr_t* ping_addr)
#if PING_USE_SOCKETS #if PING_USE_SOCKETS
th = sys_thread_new("ping_thread", ping_thread, NULL, PING_THREAD_STACKSIZE, PING_THREAD_PRIO); th = sys_thread_new("ping_thread", ping_thread, NULL, PING_THREAD_STACKSIZE, PING_THREAD_PRIO);
lw_print("lw: [%s] sys %d addr %#x\n", __func__, th, (*ping_addr).addr); lw_print("lw: [%s] new thread %d addr %#x\n", __func__, th, (*ping_addr).addr);
#else /* PING_USE_SOCKETS */ #else /* PING_USE_SOCKETS */
ping_raw_init(); ping_raw_init();
#endif /* PING_USE_SOCKETS */ #endif /* PING_USE_SOCKETS */

View File

@ -7,7 +7,7 @@
* PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used
*/ */
#ifndef PING_USE_SOCKETS #ifndef PING_USE_SOCKETS
#define PING_USE_SOCKETS 0//LWIP_SOCKET #define PING_USE_SOCKETS LWIP_SOCKET
#endif #endif
void ping_init(const ip_addr_t* ping_addr); void ping_init(const ip_addr_t* ping_addr);

View File

@ -326,7 +326,7 @@ int gethostname_lwip(char* name, size_t len);
* Copyright 2017-2018 (c) Stefan Profanter, fortiss GmbH * Copyright 2017-2018 (c) Stefan Profanter, fortiss GmbH
* Copyright 2018 (c) Jose Cabral, fortiss GmbH * Copyright 2018 (c) Jose Cabral, fortiss GmbH
*/ */
// tst by wly
#define UA_ARCHITECTURE_FREERTOSLWIP 1 #define UA_ARCHITECTURE_FREERTOSLWIP 1
#ifdef UA_ARCHITECTURE_FREERTOSLWIP #ifdef UA_ARCHITECTURE_FREERTOSLWIP

View File

@ -207,16 +207,18 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
--------------------------------- ---------------------------------
*/ */
#define DEFAULT_RAW_RECVMBOX_SIZE 10
#define DEFAULT_UDP_RECVMBOX_SIZE 10 #define DEFAULT_UDP_RECVMBOX_SIZE 10
#define DEFAULT_TCP_RECVMBOX_SIZE 10 #define DEFAULT_TCP_RECVMBOX_SIZE 10
#define DEFAULT_ACCEPTMBOX_SIZE 10 #define DEFAULT_ACCEPTMBOX_SIZE 10
#define DEFAULT_THREAD_PRIO 25
#define DEFAULT_THREAD_STACKSIZE 1024 #define DEFAULT_THREAD_STACKSIZE 1024
#define TCPIP_THREAD_NAME "tcp"
#define TCPIP_THREAD_NAME "lwip" #define TCPIP_THREAD_STACKSIZE 4096
#define TCPIP_THREAD_STACKSIZE 2048
#define TCPIP_MBOX_SIZE 8 #define TCPIP_MBOX_SIZE 8
#define TCPIP_THREAD_PRIO 3 #define TCPIP_THREAD_PRIO 25
//#define IPERF_SERVER_THREAD_NAME "iperf_server" //#define IPERF_SERVER_THREAD_NAME "iperf_server"
//#define IPERF_SERVER_THREAD_STACKSIZE 1024 //#define IPERF_SERVER_THREAD_STACKSIZE 1024
@ -234,8 +236,12 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
#define LWIP_IPV4 1 #define LWIP_IPV4 1
#define LWIP_RAW 1 #define LWIP_RAW 1
#define FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE #define FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE
#define MEMP_LIB_MALLOC 1
#define MEMP_MEM_MALLOC 1
#define lw_print KPrintf #define lw_print KPrintf
#endif /* __LWIPOPTS_H__ */ #endif /* __LWIPOPTS_H__ */

View File

@ -269,12 +269,13 @@ sys_thread_t sys_thread_new(const char *name, lwip_thread_fn function, void *arg
arg, arg,
(uint32)stacksize, (uint32)stacksize,
(uint8)prio); (uint8)prio);
if (handle >= 0) if (handle >= 0)
{ {
StartupKTask(handle); StartupKTask(handle);
lw_print("lw: [%s] create %s handle %x\n", __func__, name, handle);
return handle; return handle;
} }
lw_print("lw: [%s] create %s failed\n", __func__, name);
return -ERROR; return -ERROR;
} }

View File

@ -1754,7 +1754,7 @@
* sys_thread_new() when the thread is created. * sys_thread_new() when the thread is created.
*/ */
#if !defined TCPIP_THREAD_STACKSIZE || defined __DOXYGEN__ #if !defined TCPIP_THREAD_STACKSIZE || defined __DOXYGEN__
#define TCPIP_THREAD_STACKSIZE 0 #define TCPIP_THREAD_STACKSIZE 4096
#endif #endif
/** /**
@ -1763,7 +1763,7 @@
* sys_thread_new() when the thread is created. * sys_thread_new() when the thread is created.
*/ */
#if !defined TCPIP_THREAD_PRIO || defined __DOXYGEN__ #if !defined TCPIP_THREAD_PRIO || defined __DOXYGEN__
#define TCPIP_THREAD_PRIO 1 #define TCPIP_THREAD_PRIO 25
#endif #endif
/** /**
@ -1772,7 +1772,7 @@
* sys_mbox_new() when tcpip_init is called. * sys_mbox_new() when tcpip_init is called.
*/ */
#if !defined TCPIP_MBOX_SIZE || defined __DOXYGEN__ #if !defined TCPIP_MBOX_SIZE || defined __DOXYGEN__
#define TCPIP_MBOX_SIZE 0 #define TCPIP_MBOX_SIZE 10
#endif #endif
/** /**
@ -1821,7 +1821,7 @@
* sys_thread_new() when the thread is created. * sys_thread_new() when the thread is created.
*/ */
#if !defined DEFAULT_THREAD_STACKSIZE || defined __DOXYGEN__ #if !defined DEFAULT_THREAD_STACKSIZE || defined __DOXYGEN__
#define DEFAULT_THREAD_STACKSIZE 0 #define DEFAULT_THREAD_STACKSIZE 4096
#endif #endif
/** /**
@ -1830,7 +1830,7 @@
* sys_thread_new() when the thread is created. * sys_thread_new() when the thread is created.
*/ */
#if !defined DEFAULT_THREAD_PRIO || defined __DOXYGEN__ #if !defined DEFAULT_THREAD_PRIO || defined __DOXYGEN__
#define DEFAULT_THREAD_PRIO 1 #define DEFAULT_THREAD_PRIO 25
#endif #endif
/** /**
@ -1839,7 +1839,7 @@
* to sys_mbox_new() when the recvmbox is created. * to sys_mbox_new() when the recvmbox is created.
*/ */
#if !defined DEFAULT_RAW_RECVMBOX_SIZE || defined __DOXYGEN__ #if !defined DEFAULT_RAW_RECVMBOX_SIZE || defined __DOXYGEN__
#define DEFAULT_RAW_RECVMBOX_SIZE 0 #define DEFAULT_RAW_RECVMBOX_SIZE 10
#endif #endif
/** /**
@ -1848,7 +1848,7 @@
* to sys_mbox_new() when the recvmbox is created. * to sys_mbox_new() when the recvmbox is created.
*/ */
#if !defined DEFAULT_UDP_RECVMBOX_SIZE || defined __DOXYGEN__ #if !defined DEFAULT_UDP_RECVMBOX_SIZE || defined __DOXYGEN__
#define DEFAULT_UDP_RECVMBOX_SIZE 0 #define DEFAULT_UDP_RECVMBOX_SIZE 10
#endif #endif
/** /**
@ -1857,7 +1857,7 @@
* to sys_mbox_new() when the recvmbox is created. * to sys_mbox_new() when the recvmbox is created.
*/ */
#if !defined DEFAULT_TCP_RECVMBOX_SIZE || defined __DOXYGEN__ #if !defined DEFAULT_TCP_RECVMBOX_SIZE || defined __DOXYGEN__
#define DEFAULT_TCP_RECVMBOX_SIZE 0 #define DEFAULT_TCP_RECVMBOX_SIZE 10
#endif #endif
/** /**
@ -1866,7 +1866,7 @@
* sys_mbox_new() when the acceptmbox is created. * sys_mbox_new() when the acceptmbox is created.
*/ */
#if !defined DEFAULT_ACCEPTMBOX_SIZE || defined __DOXYGEN__ #if !defined DEFAULT_ACCEPTMBOX_SIZE || defined __DOXYGEN__
#define DEFAULT_ACCEPTMBOX_SIZE 0 #define DEFAULT_ACCEPTMBOX_SIZE 10
#endif #endif
/** /**
* @} * @}