lwip both directions working

This commit is contained in:
Ulrich Mohr 2023-09-26 12:46:24 +02:00
parent 3697705319
commit 5c75cfa63a
4 changed files with 36 additions and 12 deletions

View File

@ -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)

View File

@ -15,5 +15,5 @@ void outbyte(char c);
#endif
void outbyte(char c) {
XUartPs_SendByte(STDOUT_BASEADDRESS, c);
//XUartPs_SendByte(STDOUT_BASEADDRESS, c);
}

View File

@ -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();

View File

@ -4,21 +4,37 @@
#include <arpa/inet.h>
#include <cstring>
#include <lwip/ip_addr.h>
#include <lwip/tcpip.h>
#include <lwip/netifapi.h>
#include <lwip/tcpip.h>
#include <netif/slipif.h>
#include <sys/socket.h>
#include <xuartps.h>
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);