Hi,
I am just about to finish commercial project which is a scada gateway. Afteer finalizing this issue we will be ready for a 500 products to be sold for beginnig. So I have to solve this problem. I am developing with spider but the final product will be with emx module. ver 4.1
I am trying to make a PPP connection with both telit GSM module and Thuraya satallite module. There is no problem with telit. But I couldnt make a ppp connection with thuraya.
I did the same project with pic and I was able to establish PPP connection with TNS010i chip ( http://www.tcpipchip.com/product.html ) which has a tcp stack pap authentication. When I heard about emx module and tcp stack libraries, I thought to re write the project with c# and not using extra tns010i chip just to make a ppp connectiion.
I have used both the exaple in 4.1 sdk and my code aswell. Tried all the baudrates, handshake choices…etc.
Attaching both code and output.
namespace ppp
{
public class Program
{
public static OutputPort THURAYA_ON;
public static OutputPort THURAYA_RESET;
public static OutputPort telit_RESET;
public static OutputPort telit_on_of;
static SerialPort THURAYA_UART = new SerialPort("COM2", 19200, Parity.None, 8, StopBits.One);
static void UART_YAZ(SerialPort UART, string KOMUT, bool SATIRSONU_EKLE)
{
Thread.Sleep(100);
if (SATIRSONU_EKLE)
KOMUT = KOMUT + "\r";
byte[] buffer1 = Encoding.UTF8.GetBytes(KOMUT);
UART.Write(buffer1, 0, buffer1.Length);
Thread.Sleep(100);
}
static void THURAYA_UART_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
byte[] buffer = new byte[THURAYA_UART.BytesToRead];
THURAYA_UART.Read(buffer, 0, buffer.Length);
THURAYA_UART.DiscardInBuffer();
THURAYA_UART.Flush();
string output_imu = bytesToString(buffer);
Debug.Print( output_imu);
}
static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
if (e.IsAvailable)
{
if (PPP.IsLinkConnected)
{
Debug.Print("PPP ok!");
}
}
else
{
if (!PPP.IsLinkConnected)
{
Debug.Print("PPP connection was dropped or disconnected!");
}
}
}
static void modem_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
{
Debug.Print("error!!");
// Serial communication is loosing data
}
public static string bytesToString(byte[] bytes)
{
string s = "";
for (int i = 0; i < bytes.Length; ++i)
s += (char)bytes[i];
return s;
}
public static void Main()
{
NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
THURAYA_UART.Handshake = Handshake.None ;
THURAYA_UART.ErrorReceived += new SerialErrorReceivedEventHandler(modem_ErrorReceived);
NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();
THURAYA_UART.Open();
THURAYA_UART.DataReceived += new SerialDataReceivedEventHandler(THURAYA_UART_DataReceived);
THURAYA_ON = new OutputPort((Cpu.Pin)EMX.Pin.IO67, true );
Thread.Sleep(3000);
THURAYA_ON.Write(false);
Thread.Sleep(2000);
UART_YAZ(THURAYA_UART, "AT", true);
Thread.Sleep(100);
UART_YAZ(THURAYA_UART, " AT&K=0", true);
Thread.Sleep(100);
UART_YAZ(THURAYA_UART, "AT+CMEE=2", true);
Thread.Sleep(100);
UART_YAZ(THURAYA_UART, "AT+CREG?", true);
Thread.Sleep(100);
UART_YAZ(THURAYA_UART, "AT+csq", true);
Thread.Sleep(100);
UART_YAZ(THURAYA_UART, "AT+GPSFIXREQ", true);
UART_YAZ(THURAYA_UART, "AT+FLO=2", true);
UART_YAZ(THURAYA_UART, "ATH", true);
UART_YAZ(THURAYA_UART, "ATE", true);
UART_YAZ(THURAYA_UART, "AT+csq", true);
UART_YAZ(THURAYA_UART, "AT+CGDCONT=1,\"IP\",\"get\"", true);
UART_YAZ(THURAYA_UART, "AT+CGACT=1,1", true);
PPP.Enable(THURAYA_UART);
UART_YAZ(THURAYA_UART, "ATD*99***1#\r", true);
Debug.Print("Connecting PPP");
PPP.Connect("", "");
ATcommander at = new ATcommander(THURAYA_UART);
while (true)
{
switch (PPP.Connect("", ""))
{
case PPP.ConnectionStatus.Authentication_Faild:
Debug.Print("Authentication_Faild");
break;
case PPP.ConnectionStatus.Connection_Faild:
Debug.Print("Connection_Faild");
break;
case PPP.ConnectionStatus.Connected:
netif = NetworkInterface.GetAllNetworkInterfaces();
Debug.Print("PPP Network settings:");
Debug.Print("IP Address: " + netif[0].IPAddress);
Debug.Print("Subnet Mask: " + netif[0].SubnetMask);
Debug.Print("Default Getway: " + netif[0].GatewayAddress);
Debug.Print("DNS Server: " + netif[0].DnsAddresses[0]);
break;
case PPP.ConnectionStatus.Disconnected:
Debug.Print("Disconnected");
break;
}
output:
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Native.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Hardware.dll’
The thread ‘’ (0x2) has exited with code 0 (0x0).
OK
OK
OK
+CSQ:
37, 99
OK
+GPSFI
XREQ: 0
OK
OK
OK
OK
+CSQ:
37, 99
OK
OK
Connecting PPP
PPP connection was dropped or disconnected!
ERROR
CONNECT
~ÿ}#À!}!}!} }8}!}$}&@ }%}&y¶ñ’}“}&} } } } }'}”}(}“}^b~~ÿ}#À!}!}”} }8}!}$}&@ }%}&üÂóI}“}&} } } } }'}”}(}“Å}%~
~ÿ}#À!}”
}!} }}"
}&ÿÿÿÿ¨ü~
~ÿ}#À!}"
}!} }}"
}&ÿÿÿÿ¨ü~
~ÿ}#À!}!
}#} }8}!
}$}&@ }%}
&©CÈh}“}&} } } }
}'}”}(}“S~
~ÿ}#À!}”
}!} }}"
}&ÿÿÿÿ¨ü
~~ÿ}#À!}!}$} }8}
!}$}&@ }%}&7T>}"
}&} } } } }‘}“}(
}”}+<~
~ÿ}#À!}!
}%} }8}!
}$}&@ }%}
&o3÷}"}&} } } }
}’}“}(}”§~
~ÿ}#À!}"
}!} }}"
}&ÿÿÿÿ¨ü~
~ÿ}#À!}!
}&} }8}!
}$}&@ }%}
&}2x]Þ}“}&} } }
} }'}”}(}"Êw~
~ÿ}#À!}!
}'} }8}!
}$}&@ }%}
&} } } }
Ҽ^~
~ÿ}#À!}”
}!} }}"
}&ÿÿÿÿ¨ü~
~ÿ}#À!}!
}(} }8}!
}$}&@ }%}
&s@ á}“}&} } } }
}'}”}(}“ù~
~ÿ}#À!
PPP connection was dropped or disconnected!
Connection_Faild
}”}!} }}"}&ÿÿÿÿ
}!} }$ðâ
~
~ÿ}#À!}"
}!} }}"
}&ÿÿÿÿ¨ü~
~ÿ}#À!}"
}!} }}"
}&ÿÿÿÿ¨ü~
~ÿ}#À!}!
})} }8}!
}$}&@ }%}
&} } } }
}'}"}(}
“Ïs~
~ÿ}#À!}!
}} }8}!
}$}&@ }%}
}&} } }
} }'}"}(
}“l~
~ÿ}#À!}”
}!} }}”
}&ÿÿÿÿ¨ü~
NO CAR
RIER
+SGPSA: 0, 0