From 5c75cfa63aeb3dd177a83de23390ac91bff66338 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 26 Sep 2023 12:46:24 +0200 Subject: [PATCH] lwip both directions working --- bsp_z7/lwip/lwipopts.h | 4 +- .../libsrc/standalone/src/outbyte.c | 2 +- mission/main.cpp | 2 +- mission/testIp.cpp | 40 +++++++++++++++---- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/bsp_z7/lwip/lwipopts.h b/bsp_z7/lwip/lwipopts.h index df3b981..f2006a4 100644 --- a/bsp_z7/lwip/lwipopts.h +++ b/bsp_z7/lwip/lwipopts.h @@ -105,8 +105,8 @@ #define TCP_FR_DEBUG LWIP_DBG_OFF #define TCP_QLEN_DEBUG LWIP_DBG_OFF #define TCP_RST_DEBUG LWIP_DBG_OFF -#define TIMERS_DEBUG LWIP_DBG_ON -#define LWIP_DEBUG_TIMERNAMES LWIP_DBG_ON +#define TIMERS_DEBUG LWIP_DBG_OFF +#define LWIP_DEBUG_TIMERNAMES LWIP_DBG_OFF #endif #define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) diff --git a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/outbyte.c b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/outbyte.c index db60e6d..c7a3b12 100644 --- a/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/outbyte.c +++ b/bsp_z7/ps7_cortexa9_0/libsrc/standalone/src/outbyte.c @@ -15,5 +15,5 @@ void outbyte(char c); #endif void outbyte(char c) { - XUartPs_SendByte(STDOUT_BASEADDRESS, c); + //XUartPs_SendByte(STDOUT_BASEADDRESS, c); } diff --git a/mission/main.cpp b/mission/main.cpp index 1201e25..9889f5f 100644 --- a/mission/main.cpp +++ b/mission/main.cpp @@ -162,7 +162,7 @@ int main(void) { kernel. */ 10240, /* The size of the stack to allocate to the task. */ &taskParameters, /* The parameter passed to the task - not used in this simple case. */ - 1, /* The priority assigned to the task. */ + 4, /* The priority assigned to the task. */ nullptr); /* The task handle is not required, so NULL is passed. */ vTaskStartScheduler(); diff --git a/mission/testIp.cpp b/mission/testIp.cpp index 8bdad45..6543e7d 100644 --- a/mission/testIp.cpp +++ b/mission/testIp.cpp @@ -4,21 +4,37 @@ #include #include #include -#include #include +#include #include #include #include extern "C" { +void slipif_rxbyte_input(struct netif *netif, u8_t c); -void myInitDone(void *arg) { - puts("init done"); - +void myInitDone(void *arg) { puts("init done"); } + +struct netif netif; + +void pollUart(void *) { + while (1) { + if (XUartPs_IsReceiveData(STDIN_BASEADDRESS)) { + u32 RecievedByte; + /* Wait until there is data */ + while (XUartPs_IsReceiveData(STDIN_BASEADDRESS)) { + RecievedByte = XUartPs_ReadReg(STDIN_BASEADDRESS, XUARTPS_FIFO_OFFSET); + slipif_rxbyte_input(&netif, (u8)RecievedByte); + } + } + vTaskDelay(pdMS_TO_TICKS(5)); + } } } + + uint32_t sio_data; sio_fd_t sio_open(u8_t devnum) { return &sio_data; } @@ -33,17 +49,25 @@ void testIp() { slip_mask = IPADDR4_INIT_BYTES(255, 255, 255, 0), slip_gw = IPADDR4_INIT_BYTES(10, 25, 0, 1); - struct netif netif; - netifapi_netif_add(&netif, &slip_addr, &slip_mask, &slip_gw, NULL, slipif_init, - netif_input); + netifapi_netif_add(&netif, &slip_addr, &slip_mask, &slip_gw, NULL, + slipif_init, netif_input); netifapi_netif_set_default(&netif); - //should be done by driver, which does not do it, so we do it here + // should be done by driver, which does not do it, so we do it here netifapi_netif_set_link_up(&netif); netifapi_netif_set_up(&netif); vTaskDelay(pdMS_TO_TICKS(2000)); + xTaskCreate( + pollUart, /* The function that implements the task. */ + "uart", /* The text name assigned to the task - for debug only as it is not used by the + kernel. */ + 2048, /* The size of the stack to allocate to the task. */ + nullptr, /* The parameter passed to the task - not used in this simple case. */ + 1, /* The priority assigned to the task. */ + nullptr); + puts("socket"); int serverSocket = socket(AF_INET, SOCK_DGRAM, 0);