I´m using mcu STM32F407VGT6 with ChibiOS + LWIP stack. I trying to receive broadcast packets.
I´m using blocking function netconn_recv. After reset, I can receive exactly first 9 incomming packets, then receiving is stopped a fuction still waits for incomming packets. I confident, that packets are comming (checked by wireshark).
Here is my code of receiving thread:
Code: Select all
WORKING_AREA(waThread_NetworkCTRL, 2048);
msg_t Thread_NetworkCTRL(void *arg) {
LWIP_UNUSED_ARG(arg);
chRegSetThreadName("NetworkCtrl");
static struct netconn *conn_ctrl_recv;
static struct netbuf *recv_buf;
err_t err;
conn_ctrl_recv = netconn_new(NETCONN_UDP); // create new connection
err = netconn_bind(conn_ctrl_recv, IP_ADDR_ANY, port_ctrl); // bind the connection
while(1){
// create buffer
recv_buf = netbuf_new();
//receive
err = netconn_recv(conn_ctrl_recv, &recv_buf);
if(err == ERR_OK){
printMsg("Incomming packet!\n");
}
netbuf_free(recv_buf);
netbuf_delete(recv_buf);
}
netconn_disconnect(conn_ctrl_recv);
return (msg_t)0;
}And here is simple python script for generating broadcast packets:
Code: Select all
import socket
import time
UDP_IP = "192.168.10.255"
UDP_PORT = 33001
MESSAGE = "ETC:NOTIFY;"
MESSAGE.encode ('utf-8')
UDP_IP.encode ('utf-8')
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
while(1):
sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT))
time.sleep(1) # delays for 5 seconds
Do you know how to solve my problem? Debug is "ON", but cant catch anything.
Thank you!
Adam