Hi all, I am a newbie with .NET Micro Framework. I have a problem and maybe I am missing something.
I am trying to make the DPWS HelloWorldServer_MF work in my Mountaineer Ethernet board. The same example works OK if I target the emulator.
After unsuccessfully trying .NET MF 4.2. Last week I altri tried .NET 4.3 MF beta that you announced here:
https://www.ghielectronics.com/community/forum/topic?id=13619
I did some investigation and found in this forum an old topic that deals with the problem I am facing now:
https://www.ghielectronics.com/community/forum/topic?id=8889&page=1
In this thread I did not find any solutions. I hoped that .NET 4.3 solved this issue.
In .NET MF 4.2 the example just crashes. The problem turns out with a SocketException generated from the DPWS stack in the Porting Kit.
The error code come is 10049 and comes directly from native code.
SocketException.ErrorCode = 10049 - WSAEADDRNOTAVAIL (Cannot assign requested address).
by looking closer to the issue the execption is generated within the “OnOpen” method of “UdpTransportBindingConfig” when the following instruction executes:
m_udpReceiveClient.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, multicastOpt);
In .NET MF 4.3 the example does not crash but it still does not work.
If you look at “OnOpen” method in “UdpTransportBindingConfig” class you can see that the problem is hidden because the instructions that cause the Socket exception are within
a try/catch block that simply ignores exceptions when trtying to jojn multicast group:
try
{
m_udpReceiveClient.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, ipAddr );
m_udpReceiveClient.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, multicastOpt);
}
catch{}
With .NET MF 4.3 installed in my device, I have captured with WireShark multicast packets generated by both HelloWorldServer_MF project (MF server) when executed in
Mountaineer Ethernet board and by the WCF client example running in a PC.
The result is that the Mountaineer board correctly sends “Hello” UDP messages using standard multicast address 239.255.255.250.
Unfortunately Mountaineer board does not answer the “Probe” UDP messages that the WCF client example sends using the same multicast address (239.255.255.250).
I have a high suspect that the Mountaineer Board does not detect the UDP messages sent by the PC because the “SetSocketOption” method still fails to join the multicast group.
I have then had a look at native code, LwIP 1.3.2 source code to figure out where this error could occur.
In sock.h the WSAEADDRNOTAVAIL is remapped to EADDRNOTAVAIL.
In arch.h EADDRNOTAVAIL is assigned a numeric code.
I think that the only place where this error could be generated is in ‘sockets.c’ module within the “lwip_setsockopt_internal” function.
In particular within this code fragment.
case IP_ADD_MEMBERSHIP:
case IP_DROP_MEMBERSHIP:
{
/* If this is a TCP or a RAW socket, ignore these options. */
struct ip_mreq *imr = (struct ip_mreq *)optval;
ip_addr_t if_addr;
ip_addr_t multi_addr;
inet_addr_to_ipaddr(&if_addr, &imr->imr_interface);
inet_addr_to_ipaddr(&multi_addr, &imr->imr_multiaddr);
if(optname == IP_ADD_MEMBERSHIP){
data->err = igmp_joingroup(&if_addr, &multi_addr);
} else {
data->err = igmp_leavegroup(&if_addr, &multi_addr);
}
if(data->err != ERR_OK) {
data->err = EADDRNOTAVAIL;
}
}
break;
Most likely “igmp_joingroup” function fails.
Questions:
- Are you aware of any work arounds or solution to this issue?
- Is this a problem in LWIP or in the Ethernet driver?
- How can you compile the LwIP stack in DEBUG mode so that I can see debug messages sent somewhere (I would prefer in Outpuit window within Visual Studio)?
Thank you in advance for your feedback.
Kind Regards
Karnize