I’m trying to learn the GX440 that has ended up on my desk.
I’ve been able to run the configuration utility successfully, and was able to execute AT*GPSDATA? command via a C# routine that handles login. So I was feel a bit confident moving forward. I went to configure the GPS Steaming reporting:
Local Reporting Time Interval: 10
Local Report Type: GPS + Date
Starting Destination Port: 17335
Number of Extra Destination Ports: 0
Local Report IP Destination : 192.168.13.100
Report Odometer: Disable
Report Digital Inputs: Disable
I then picked up some C# code from Microsoft, shown below… It is hardly completed code, but I put some breakpoints in place to understand how things work. Unfortunately, nothing appears to get past the TcpClient tcpClient = tcpListener.AcceptTcpClient(); statement. The GPS functionality is enabled.
I’ve been programming for almost 30 years, but have not done any socket level stuff for a very long time, please excuse any obvious errors on my part. Where have I gone wrong in trying to receive periodic GPS updates on the local IP? Alternatively, I did some quick searches trying to find code to support this, but came up empty. Any suggestions are greatly appreciated!
Thanks!
Bob
<snip – trial C# code – started in its own thread – never gets past the Debug.Print(“Top of the loop”) statement >
public void createListener()
{
string output;
// Create an instance of the TcpListener class.
TcpListener tcpListener = null;
IPAddress ipAddress = IPAddress.Parse("192.168.13.100");
try
{
// Set the listener on the local IP address
// and specify the port.
tcpListener = new TcpListener(ipAddress, 17335);
tcpListener.Start();
Debug.Print("Waiting for a connection...");
}
catch (Exception e)
{
output = "Error: " + e.ToString();
int i = output.Length;
}
try
{
while (true)
{
// Always use a Sleep call in a while(true) loop
// to avoid locking up your CPU.
Debug.Print("Top of the loop");
Thread.Sleep(10);
// Create a TCP socket.
// If you ran this server on the desktop, you could use
// Socket socket = tcpListener.AcceptSocket()
// for greater flexibility.
TcpClient tcpClient = tcpListener.AcceptTcpClient();
// Read the data stream from the client.
byte[] bytes = new byte[1024];
NetworkStream stream = tcpClient.GetStream();
stream.Read(bytes, 0, bytes.Length);
string ss = System.Text.Encoding.ASCII.GetString(bytes);
//SocketHelper helper = new SocketHelper();
//helper.processMsg(tcpClient, stream, bytes);
int nc = bytes.GetLength(0);
}
}
catch (Exception ex)
{
string s = ex.Message;
int ix = s.Length;
}
}