Linux UDP Send block fails to send to broadcast address

2 views (last 30 days)
I have a Simulink model that generates target code to run under Embedded Linux (3.3.0) on a target OMAP-L138 LCDK board. The model periodically uses a Linux UDP Send block to transmit a small packet of data to a host PC. The block parameters are: port 7000, address '10.255.255.255'. When I generate the code a file called linuxUDP.c is created. If I build the code and download to the target and run it I never see the UDP message coming from the board.
I found that I have to manually edit the linuxUDP.c file to add a 'broadcast' option to the socket, i.e;:
int BroadcastEnable = 1;
setsockopt(((TgtSockStructT *) device)->sockfd, SOL_SOCKET, SO_BROADCAST, &BroadcastEnable , 4);
Then when I build the modified code and run it everything works fine and the UDP message is transmitted from the target.
Is this a bug with the generated code from the model or am I doing something wrong with the block that is stopping the broadcast message from being sent? I tried using address '255.255.255.255' but I still had to make the same mods to the linuxUDP.c to get the message to be sent.

Answers (1)

Jon Boerner
Jon Boerner on 23 Oct 2014
Did you happen to try setting the IP Address value in the block to '127.0.0.1'? The dialog says "'255.255.255.255' for broadcast", but if you look in the documentation, it says "To broadcast the UDP message, retain the default value, '127.0.0.1'."

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!