Hi John,
As you requested I used my Frontline protocol analyzer tool with an RS-232 Probe to intercept and record the communications on the serial connection between the board and the modem.
I have attached screen shots of the protocol analyzer output.
As you can see when I’m debugging and the code is working correctly we can see 2 IP ver4 frames are sent. When the board is not running in debug mode we do not see the IP ver4 frames on the wire.
It looks like all the PPP communications are working as expected both while debugging and not debugging. This seems to confirm my suspicion that the networking stack is not sending the Dns.GetHostEntry() requests on the active network interface unless I’m debugging. And this is the reason why we don’t see the IP ver4 frames.
If you’d like I can send you the protocol analyzer output files and you can look through the raw data for any issues, but I suspect the issue is not the communications on the serial port, but rather the network stack not sending traffic on the correct interface when running without the debugger.
Here is the code I’m running for reference:
using Gadgeteer;
using GHI.Networking;
using Microsoft.SPOT;
using Microsoft.SPOT.Net.NetworkInformation;
using System.IO.Ports;
using System.Text;
using System.Threading;
using System.Net;
public class Program
{
private static AutoResetEvent evt;
private static void Main()
{
Thread.Sleep(10000);
evt = new AutoResetEvent(false);
NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
using (var port = new SerialPort("COM2", 115200, Parity.None, 8, StopBits.One))
{
port.ReadTimeout = 100;
port.Handshake = Handshake.RequestToSend;
port.Open();
port.DiscardInBuffer();
port.DiscardOutBuffer();
//SendATCommand(port, "AT+CGDCONT=2,\"IP\",\"YOUR APN\"");
//SendATCommand(port, "ATDT*99***2#");
SendATCommand(port, "ATD#777");
using (var netif = new PPPSerialModem(port))
{
netif.Open();
netif.Connect(PPPSerialModem.AuthenticationType.Pap, "", "");
evt.WaitOne();
while (netif.IPAddress == "0.0.0.0")
{
Thread.Sleep(100);
}
Debug.Print(string.Concat("The IP Address is: ", netif.IPAddress));
//The network is now ready to use.
var dnsEntry = Dns.GetHostEntry("google.com");
Debug.Print(string.Concat("Host Entry: ", dnsEntry.AddressList[0].ToString()));
}
}
}
private static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
if (e.IsAvailable)
evt.Set();
}
private static void SendATCommand(SerialPort port, string command)
{
var sendBuffer = Encoding.UTF8.GetBytes(command + "\r");
var readBuffer = new byte[256];
var read = 0;
port.Write(sendBuffer, 0, sendBuffer.Length);
while (true)
{
read += port.Read(readBuffer, read, readBuffer.Length - read);
var response = new string(Encoding.UTF8.GetChars(readBuffer, 0, read));
if (response.IndexOf("OK") != -1 || response.IndexOf("CONNECT") != -1)
break;
}
}
}
The error which happens when not debugging and we don’t’ see any IP ver4 frames on the wire.
[quote]Connecting to EMX_Gadgeteer…Connected
Created EE.
The IP Address is: 75.237.30.69
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::getaddrinfo [IP: 0000] ####
#### System.Net.Dns::GetHostEntry [IP: 0008] ####
#### Program::Main [IP: 009b] ####
#### SocketException ErrorCode = 10060
Uncaught exception
Done.[/quote]