add debug message

This commit is contained in:
lr 2024-05-23 15:50:37 +08:00
parent 2147d92121
commit 99967e9f9b
2 changed files with 210 additions and 220 deletions

View File

@ -81,7 +81,6 @@
timeouts. */ timeouts. */
#define MEMP_NUM_SYS_TIMEOUT 6 #define MEMP_NUM_SYS_TIMEOUT 6
/* ---------- Pbuf options ---------- */ /* ---------- Pbuf options ---------- */
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define PBUF_POOL_SIZE 45 #define PBUF_POOL_SIZE 45
@ -111,23 +110,19 @@
/* TCP receive window. */ /* TCP receive window. */
#define TCP_WND (11 * TCP_MSS) #define TCP_WND (11 * TCP_MSS)
/* ---------- ICMP options ---------- */ /* ---------- ICMP options ---------- */
#define LWIP_ICMP 1 #define LWIP_ICMP 1
/* ---------- DHCP options ---------- */ /* ---------- DHCP options ---------- */
/* Define LWIP_DHCP to 1 if you want DHCP configuration of /* Define LWIP_DHCP to 1 if you want DHCP configuration of
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
turning this on does currently not work. */ turning this on does currently not work. */
#define LWIP_DHCP 1 #define LWIP_DHCP 1
/* ---------- UDP options ---------- */ /* ---------- UDP options ---------- */
#define LWIP_UDP 1 #define LWIP_UDP 1
#define UDP_TTL 255 #define UDP_TTL 255
/* ---------- Statistics options ---------- */ /* ---------- Statistics options ---------- */
#define LWIP_STATS 0 #define LWIP_STATS 0
#define LWIP_PROVIDE_ERRNO 1 #define LWIP_PROVIDE_ERRNO 1
@ -213,7 +208,7 @@
#define DEFAULT_ACCEPTMBOX_SIZE 10 #define DEFAULT_ACCEPTMBOX_SIZE 10
#define DEFAULT_THREAD_STACKSIZE 1024 #define DEFAULT_THREAD_STACKSIZE 1024
#define TCPIP_THREAD_NAME "lwip" #define TCPIP_THREAD_NAME "tcpip"
#define TCPIP_THREAD_STACKSIZE 512 #define TCPIP_THREAD_STACKSIZE 512
#define TCPIP_MBOX_SIZE 8 #define TCPIP_MBOX_SIZE 8
#define TCPIP_THREAD_PRIO 3 #define TCPIP_THREAD_PRIO 3

View File

@ -25,8 +25,8 @@
#include <lwip/sys.h> #include <lwip/sys.h>
#if !NO_SYS #if !NO_SYS
#include "sys_arch.h"
#include "libserial.h" #include "libserial.h"
#include "sys_arch.h"
#include "usyscall.h" #include "usyscall.h"
#endif #endif
@ -51,7 +51,6 @@ u32_t sys_now(void)
return 1; return 1;
} }
sys_prot_t sys_arch_protect(void) sys_prot_t sys_arch_protect(void)
{ {
return 1; return 1;
@ -65,12 +64,10 @@ void sys_arch_unprotect(sys_prot_t pval)
err_t sys_sem_new(sys_sem_t* sem, u8_t count) err_t sys_sem_new(sys_sem_t* sem, u8_t count)
{ {
struct Session sem_session;
sem_t semaphore; sem_t semaphore;
connect_session(&sem_session, sem_server_name, 4096); connect_session(&sem->sess, sem_server_name, 4096);
sem_create(&sem_session, &semaphore, (int)count); sem_create(&sem->sess, &semaphore, (int)count);
sem->sem = semaphore; sem->sem = semaphore;
sem->sess = sem_session;
#if SYS_STATS #if SYS_STATS
++lwip_stats.sys.sem.used; ++lwip_stats.sys.sem.used;
if (lwip_stats.sys.sem.max < lwip_stats.sys.sem.used) { if (lwip_stats.sys.sem.max < lwip_stats.sys.sem.used) {
@ -116,8 +113,9 @@ u32_t sys_arch_sem_wait(sys_sem_t* sem, u32_t timeout)
if (sem->sem < 0) if (sem->sem < 0)
return SYS_ARCH_TIMEOUT; return SYS_ARCH_TIMEOUT;
printf("%s wait %d, %d\n", __func__, sem->sem, __LINE__);
sem_wait(&sem->sess, &sem->sem, 0); sem_wait(&sem->sess, &sem->sem, 0);
printf("%s, %d\n", __func__, __LINE__);
return 0; return 0;
} }
@ -140,14 +138,19 @@ void sys_mutex_set_invalid(sys_mutex_t* mutex)
{ {
sys_sem_set_invalid(mutex); sys_sem_set_invalid(mutex);
} }
void sys_mutex_lock(sys_mutex_t* mutex) void sys_mutex_lock(sys_mutex_t* mutex)
{ {
printf("%s(mtx: %d)\n", __func__, *mutex);
sys_arch_sem_wait(mutex, 0); sys_arch_sem_wait(mutex, 0);
printf("%s(mtx: %d), return\n", __func__, *mutex);
} }
void sys_mutex_unlock(sys_mutex_t* mutex) void sys_mutex_unlock(sys_mutex_t* mutex)
{ {
printf("%s(mtx: %d)\n", __func__, *mutex);
sys_sem_signal(mutex); sys_sem_signal(mutex);
printf("%s(mtx: %d), return\n", __func__, *mutex);
} }
sys_thread_t sys_thread_new(const char* name, lwip_thread_fn function, void* arg, int stacksize, int prio) sys_thread_t sys_thread_new(const char* name, lwip_thread_fn function, void* arg, int stacksize, int prio)
@ -303,8 +306,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t* q, void** msg, u32_t timeout)
if (msg != NULL) { if (msg != NULL) {
printf("sys_mbox_fetch: mbox %p msg %p\n", (void*)q, *msg); printf("sys_mbox_fetch: mbox %p msg %p\n", (void*)q, *msg);
*msg = q->msgs[q->first % SYS_MBOX_SIZE]; *msg = q->msgs[q->first % SYS_MBOX_SIZE];
} } else {
else{
printf("sys_mbox_fetch: mbox %p, null msg\n", (void*)q); printf("sys_mbox_fetch: mbox %p, null msg\n", (void*)q);
} }
@ -333,8 +335,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t* q, void** msg)
if (msg != NULL) { if (msg != NULL) {
printf("sys_mbox_tryfetch: mbox %p msg %p\n", (void*)q, *msg); printf("sys_mbox_tryfetch: mbox %p msg %p\n", (void*)q, *msg);
*msg = q->msgs[q->first % SYS_MBOX_SIZE]; *msg = q->msgs[q->first % SYS_MBOX_SIZE];
} } else {
else{
printf("sys_mbox_tryfetch: mbox %p, null msg\n", (void*)q); printf("sys_mbox_tryfetch: mbox %p, null msg\n", (void*)q);
} }
@ -382,13 +383,10 @@ int lwip_config_tcp(char* ip, char* mask, char* gw)
/* Registers the default network interface */ /* Registers the default network interface */
netif_set_default(&gnetif); netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif)) if (netif_is_link_up(&gnetif)) {
{
/*When the netif is fully configured this function must be called */ /*When the netif is fully configured this function must be called */
netif_set_up(&gnetif); netif_set_up(&gnetif);
} } else {
else
{
/* When the netif link is down this function must be called */ /* When the netif link is down this function must be called */
netif_set_down(&gnetif); netif_set_down(&gnetif);
return -1; return -1;
@ -406,6 +404,3 @@ int lwip_config_tcp(char* ip, char* mask, char* gw)
return 0; return 0;
#endif #endif
} }