RX working, still a bit messy

This commit is contained in:
2024-08-20 22:38:02 +02:00
parent 6c556b8fbf
commit 497e380860
5 changed files with 26 additions and 14 deletions

View File

@ -47,6 +47,9 @@
#include <sys/time.h>
#include "cpu.h"
#include "xil_printf.h"
// errno is a macro. If we define LWIP_ERRNO_INCLUDE to errno.h the preprocessor will replace it,
// breaking the include. Instead we supply a helper include which in turn includes errno.h
#define LWIP_ERRNO_INCLUDE <onrre.h>

View File

@ -78,7 +78,7 @@
#define PPP_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_ON
#define API_LIB_DEBUG LWIP_DBG_ON
#define API_MSG_DEBUG LWIP_DBG_ON
#define TCPIP_DEBUG LWIP_DBG_ON

View File

@ -1,5 +1,5 @@
LWIP_MALLOC_MEMPOOL_START
LWIP_MALLOC_MEMPOOL(50, 256)
LWIP_MALLOC_MEMPOOL(50, 512)
LWIP_MALLOC_MEMPOOL(50, 1512)
LWIP_MALLOC_MEMPOOL(50, 1550)
LWIP_MALLOC_MEMPOOL_END

View File

@ -215,13 +215,11 @@ xemacif_input_thread(struct netif *netif)
{
struct xemac_s *emac = (struct xemac_s *)netif->state;
while (1) {
xil_printf("input started\n");
/* sleep until there are packets to process
* This semaphore is set by the packet receive interrupt
* routine.
*/
sys_sem_wait(&emac->sem_rx_data_available);
xil_printf("input received\n");
/* move all received packets to lwIP */
xemacif_input(netif);

View File

@ -30,6 +30,7 @@
#include "lwip/inet.h"
#include "lwip/init.h"
#include "lwip/udp.h"
#include "lwip/tcpip.h"
#include "lwip/timeouts.h"
#include "netif/xadapter.h"
#include "xil_printf.h"
@ -135,13 +136,19 @@ void network_thread() {
#endif
}
void udp_receiver(void *arg, struct udp_pcb *pcb, struct pbuf *p,
const ip_addr_t *addr, u16_t port){
u32_t now = sys_now();
xil_printf("%i received len: %i tot_len: %i data: ", now, p->len, p->tot_len);
char * pointer = p->payload;
for(uint8_t i = 0; i < p->len; i++) {
xil_printf(" %c", pointer + i);
}
xil_printf("\n");
}
int main_thread(void * _) {
xil_printf("pre check\n");
vTaskDelay(200 * portTICK_PERIOD_MS);
xil_printf("check\n");
#if LWIP_DHCP == 1
int mscnt = 0;
#endif
@ -153,7 +160,10 @@ int main_thread(void * _) {
xil_printf("-----lwIP Socket Mode UDP Client Application------\r\n");
/* initialize lwIP before calling sys_thread_new */
lwip_init();
//lwip_init();
tcpip_init(NULL, NULL);
//give init some time
vTaskDelay(1000 * portTICK_PERIOD_MS);
/* any thread using lwIP should be created using sys_thread_new */
network_thread();
@ -196,15 +206,16 @@ int main_thread(void * _) {
struct udp_pcb *udpecho_raw_pcb = udp_new();
xil_printf("pcb: %p\r\n", udpecho_raw_pcb);
u32_t now = sys_now();
xil_printf("%i pcb: %p\r\n", now, udpecho_raw_pcb);
udp_sendto(udpecho_raw_pcb, tx, &addr, 1177);
udp_sendto(udpecho_raw_pcb, tx, &addr, 8100);
udp_recv(udpecho_raw_pcb,udp_receiver,NULL);
while (1) {
sys_check_timeouts();
xil_printf("pre loop\n");
vTaskDelay(200 * portTICK_PERIOD_MS);
xil_printf("loop\n");
}
pbuf_free(tx);