CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

UDP Broadcast using the CCS Ethernet development board

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
Greg Richter



Joined: 15 Feb 2008
Posts: 18
Location: Atlanta, Tulsa, Asheville

View user's profile Send private message Visit poster's website

UDP Broadcast using the CCS Ethernet development board
PostPosted: Fri Feb 15, 2008 1:14 pm     Reply with quote

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: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Mar 07, 2008 10:10 am     Reply with quote

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!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group