Greg Richter
Joined: 15 Feb 2008 Posts: 18 Location: Atlanta, Tulsa, Asheville
|
UDP Broadcast using the CCS Ethernet development board |
Posted: Fri Feb 15, 2008 1:14 pm |
|
|
Nice piece of code, with a little gotcha for UDP broadcast in UDP.C round about line 165:
// If remoteNode is supplied, remember it.
if ( remoteNode )
{
memcpy((void*)&p->remoteNode,
(void*)remoteNode,
sizeof(p->remoteNode));
}
// else Set broadcast address - TO BE DONE */
Oh, bother ... You can either modify the library code, or simply put:
RemoteNode.MACAddr.v[0] = 0xFF; // remote broadcast node
RemoteNode.MACAddr.v[1] = 0xFF;
RemoteNode.MACAddr.v[2] = 0xFF;
RemoteNode.MACAddr.v[3] = 0xFF;
RemoteNode.MACAddr.v[4] = 0xFF;
RemoteNode.MACAddr.v[5] = 0xFF;
RemoteNode.IPAddr.v[0] = 255;
RemoteNode.IPAddr.v[1] = 255;
RemoteNode.IPAddr.v[2] = 255;
RemoteNode.IPAddr.v[3] = 255;
... in your code to enable UDP broadcast. Truly a minor tweak, but it chewed up half a day chasing it down. If you're doing UDP broadcast with this library, this'll save you some time. Works beautifully, now.
-Greg _________________ Madness takes it toll; please have exact change. |
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Fri Mar 07, 2008 10:10 am |
|
|
The MAC address is fine. The IP layer address broadcast may or may not work depending on the stack implementation of the intended remote node. It also will not transit a router. A subnet broadcast can be used instead.
Let's say your target is on on subnet 192.168.1.0 with a mask of 255.255.255.0 then the broadcast address for the subnet is 192.168.1.255 - you can reach this from the local subnet or from behind a router. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|