Good morning,
i need to find one ore more smoothieboards (all set to DHCP) in a network. This is a Class B network, therefore an active TCP port scan is not a good idea.
For the Arduinos in the same network i implemented an UDP broadcast, the Arduinos simply answer with some ID string whenever they see a specific UDP packet on a specific UDP port. This was very easy to implement, around 8 lines of source code.
Now i want to implement the same feature in Smoothieware, but i have no idea where to start. I got the source code from github, it compiled OK and the Smoothieboard booted OK with my binary. So i’m all set for the source code changes, but where ?
Any suggestion to put me on the right track is welcome.
Thank You very much,
Christof
Imported from wikidot
Hey.
You want to look in https://github.com/Smoothieware/Smoothieware/tree/edge/src/libs/Network
Sorry for the short answer I’m in a hurry. Don’t hesitate to ask if you have questions.
Cheers.
I digged through the source code and as far as i understand all UDP packets go to
dhcpc_appcall in src\libs\Network\uip\dhcpc\dhcpc.c
due to
#define UIP_UDP_APPCALL dhcpc_appcall
then to
handle_dhcp
where i inserted some code after the promising comment with “some other UDP packet”
// we may have gotten some other UDP packet in which case just wait some more for the right packet
if (uip_newdata()) {
if (parse_msg() == DHCPOFFER) {
s.state = STATE_OFFER_RECEIVED;
break;
} else {
uip_ipaddr_t rIP;
struct uip_udp_conn * pConn;
rIP[0] = uip_conn->ripaddr[0];
rIP[1] = uip_conn->ripaddr[1];
pConn = uip_udp_new (& rIP, HTONS (4713));
// MAYBE A BROADCAST PACKET TO DETECT US?
uip_udp_send (4);
uip_udp_remove (pConn);
}
}</code>
I don’t check the source port at the moment and i don’t prepare the send buffer, i just want to get any reaction at all. But nothing.
I don’t understand where i should enter something to listen to my port (4712 in my case, will be an officially assigned one later).
Christof
I personally don’t think I can help you with this. If you read the code enough you should be able to figure it out.
It is now working. I needed to enhance the UIP part a little bit and i’m sure it’s not the optimal solution, but for my needs it’s OK. If anyone is interested i can supply my changes.
Best Regards,
Christof
I’m currently working on UDP communications (just receiving simple messages) and would be interested in what you had to change/add.