Hi All,
I'm attempting to transmit a small (5 byte) UDP message on the broadcast I.P. address for my local network (10.0.0.255) and am not seeing any indication that the message is being sent. If I send the message to a specific address on my network (10.0.0.66) it works properly. The sendto() function is returning the proper number of bytes sent, but nobody is receiving. I have Wireshark looking for activity and I have a small utility on a PC that receives UDP messages. Both properly show received data when the UDP broadcast message is sent by another device or if my project transmits to a specific I.P. address, neither show any activity when a broadcast message is sent by my project. I'm using RTCS 4.0.2 ported to MQX 3.8.1.1 and a Freescale MPC5125 processor. All other Ethernet communications with this project (stream sockets) works properly.
Here's a code snip.
void UDP_CallAll(void)
{
uint_32 lSockHandle, lOption;
int_32 lRetval;
sockaddr_in addr_send;
char cTxBuf[] = "Hello";
//Create a datagram socket
lSockHandle = socket(AF_INET, SOCK_DGRAM, 0);
if(lSockHandle == RTCS_SOCKET_ERROR)
return;
//Bind the socket
addr_send.sin_family = AF_INET;
addr_send.sin_port = 1480;
addr_send.sin_addr.s_addr = INADDR_ANY;
lRetval = bind(lSockHandle, &addr_send, sizeof(addr_send));
if(lRetval != RTCS_OK)
return;
addr_send.sin_family = AF_INET;
addr_send.sin_port = 1480;
// addr_send.sin_addr.s_addr = 0x0A000042; //<-- This works
addr_send.sin_addr.s_addr = 0x0A0000FF; //<-- This doesn't (no errors indicated)
//If RTCS_MSG_NOLOOP flag is set, the datagram is not duplicated for the local host interface
//If RTCS_MSG_NONBLOCK flag is set, calls to send() or sendto() will be non-blocking and return immediately
//----------------------------------------------------------------------------
lOption = RTCS_MSG_NOLOOP | RTCS_MSG_NONBLOCK;
lRetval = sendto(lSockHandle, cTxBuf, 5, lOption, (struct sockaddr *)&addr_send, sizeof(addr_send));
if(lRetval == RTCS_ERROR)
return;
else if(lRetval != 5)
return;
lRetval = shutdown(lSockHandle, FLAG_ABORT_CONNECTION);
if(lRetval != RTCS_OK)
return;
return;
}
Any thoughts? Is there a RTCS or MQX option that I need to configure to get this to work? Is UDP Broadcast supported? Maybe I need to Multi-cast? Thanks in advance for any tips, hints or suggestions.
Best Regards,
Tim