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.