Hello everyone!
I'm currently using Keil uVision 5 in order to program an UDP interface in order to communicate with another machine on my local network.
While the reception of messages via the configured UDP Socket work, the sending of messages does not appear to work, as I recieve a "netError" value on the netStatus value that the netUDP_Send() function returns. Based on the reference, this error simply states that the sending failed. I was not able to find any explanation as to why I am getting this error. Do you have any ideas or suggestions?
Here is a sample of the code I use to recieve and send the UDP messages (I am trying to send form the local 10000 UDP Port, to my computer's 61345 UDP port, whose IP adress is 192.168.1.72 :
NET_ADDR addr = { NET_ADDR_IP4, 61345, 192, 168, 1, 72}; int8_t start(void){ int32_t socket = netUDP_GetSocket(udp_receive_callback); if(socket >= 0){ //Le socket est bien alloué if(netUDP_Open(socket,10000) == netOK){ uint8_t *sendbuf; sendbuf = netUDP_GetBuffer(1); sendbuf[0]=0x65; netStatus status = netUDP_Send(socket,&addr,sendbuf,1); if(status == netOK) return 1; else{ return -1; } } else return -1; } return -1; }
Thank you very much, showing the debug output was very useful! THanks to it I discovered that the state of the network Component was at "link-down", and by trying to send a first UDP message, the state changed to "link-up". My solution to the problem for now is to try to send the udp message while the netStatus returned is not netOK (so that as soon as the link gets up, the message gets sent).