OS5 Multicast STM32F407

18 Sep 2019

Hi,

I have a STM32F407 that i was running multicast on with no issues, i have converted over to OS5 and i am currently unable to send or receive any multicast traffic. Can anyone provide any feedback or know why this would not be working. Code is as follows:

void Multicast(){ UDPSocket Multicast_Server(&eth0); Multicast_Server.bind("5007"); Bind to port 5007 if (Multicast_Server.join_multicast_group("224.1.1.1") != 0) { Serial0.printf("Error joining the multicast group\r\n"); while (true) {} }

SocketAddress Multicast_Client; char Multicast_Buffer[1024]; while(true){ char out_buffer2[] = "Multicast Data etc etc"; Multicast_Server.sendto(Multicast_Client, out_buffer2, sizeof(out_buffer2)); Serial0.printf("Waiting for Multicast Packet\r\n"); int n = Multicast_Server.recvfrom(&Multicast_Client, Multicast_Buffer, sizeof(Multicast_Buffer)); Serial0.printf("Packet Received is :%s %s\r\n", Multicast_Client.get_ip_address(), Multicast_Buffer); } }

20 Sep 2019

Hi Chris,

Since UDPSocket ( S * stack ) has been deprecated after mbed-os-5.11

https://os.mbed.com/docs/mbed-os/v5.13/mbed-os-api-doxy/class_u_d_p_socket.html#a20e38c01002e12f625ef22a10aaae163

You should modify your code like

UDPSocket Multicas_Server;
result = socket.open(net);
if (result != 0) {
     printf("Error! socket.open() returned: %d\n", result);
}

Please refer our example here.

https://github.com/ARMmbed/mbed-os-example-sockets

Thanks, Desmond

02 Oct 2019

Hi Desmond,

thank you for your reply, sorry for the delay i did not see the response until now. I found that it was how i was defining the port / binding the port. when i set this as a #define MPort 5007 and used Multicast_Server.bind(MPort) this resolved my issue.

Kind Regards Chris