Linux UDP Send block fails to send to broadcast address
2 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
Jon Boerner
2014 年 10 月 23 日
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'."
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!