Hi, I'm using opennetcf to try and connect my GPS. When I run the
following code, I get the Opening message, then right after get the
stopped. I never get a running message. I'm sure I'm using the right
port and baud rate. I've tried 3rd party GPS software on my device to
verify it does work. Just curious if anyone sees anything wrong with
this code. Thanks so much
using OpenNETCF.IO.Serial.GPS;




private void button1_Click(object sender, EventArgs e)
{
gps.GpsSentence += new
OpenNETCF.IO.Serial.GPS.GPS.GpsSentenceEventHandler(gps_GpsSentence);
gps.GpsCommState += new
OpenNETCF.IO.Serial.GPS.GPS.GpsCommStateEventHandler(gps_GpsCommState);

OpenNETCF.IO.Serial.BaudRates br =
OpenNETCF.IO.Serial.BaudRates.CBR_9600;
gps.BaudRate = br;
gps.ComPort = "COM4:";
gps.MinBaudRate = br;
gps.MaxBaudRate = br;
//gps.AutoDiscovery = true;
gps.Start();

}
private void gps_GpsCommState(object sender,
GpsCommStateEventArgs e)
{
switch (e.State)
{
case OpenNETCF.IO.Serial.GPS.States.Opening:
MessageBox.Show("GPS Opening");
break;
case OpenNETCF.IO.Serial.GPS.States.Running:
MessageBox.Show("GPS Started");
break;
case OpenNETCF.IO.Serial.GPS.States.Stopped:
MessageBox.Show("GPS Stop");
break;
case OpenNETCF.IO.Serial.GPS.States.Stopping:
MessageBox.Show("GPS Stopping");
break;

}
}

Re: OpenNETCF GPS by ctacke/>

ctacke/>
Thu Nov 29 15:13:11 PST 2007

The code looks ok - step into the OpenNETCF GPS code and see where it's
going south.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


"John" <johnwadeunderwood@yahoo.com> wrote in message
news:bad3e9c0-9af7-41dd-a53e-e8327484f0bb@y20g2000hsy.googlegroups.com...
> Hi, I'm using opennetcf to try and connect my GPS. When I run the
> following code, I get the Opening message, then right after get the
> stopped. I never get a running message. I'm sure I'm using the right
> port and baud rate. I've tried 3rd party GPS software on my device to
> verify it does work. Just curious if anyone sees anything wrong with
> this code. Thanks so much
> using OpenNETCF.IO.Serial.GPS;
>
>
>
>
> private void button1_Click(object sender, EventArgs e)
> {
> gps.GpsSentence += new
> OpenNETCF.IO.Serial.GPS.GPS.GpsSentenceEventHandler(gps_GpsSentence);
> gps.GpsCommState += new
> OpenNETCF.IO.Serial.GPS.GPS.GpsCommStateEventHandler(gps_GpsCommState);
>
> OpenNETCF.IO.Serial.BaudRates br =
> OpenNETCF.IO.Serial.BaudRates.CBR_9600;
> gps.BaudRate = br;
> gps.ComPort = "COM4:";
> gps.MinBaudRate = br;
> gps.MaxBaudRate = br;
> //gps.AutoDiscovery = true;
> gps.Start();
>
> }
> private void gps_GpsCommState(object sender,
> GpsCommStateEventArgs e)
> {
> switch (e.State)
> {
> case OpenNETCF.IO.Serial.GPS.States.Opening:
> MessageBox.Show("GPS Opening");
> break;
> case OpenNETCF.IO.Serial.GPS.States.Running:
> MessageBox.Show("GPS Started");
> break;
> case OpenNETCF.IO.Serial.GPS.States.Stopped:
> MessageBox.Show("GPS Stop");
> break;
> case OpenNETCF.IO.Serial.GPS.States.Stopping:
> MessageBox.Show("GPS Stopping");
> break;
>
> }
> }



RE: OpenNETCF GPS by srhartone

srhartone
Sun Dec 02 07:31:00 PST 2007

I've never used the OpenNETCF implementation of this. But what device are you
running on? As if you are running on Windows Mobile 5 or later then you can
use the Intermediate Driver which makes coding the GPS integration so much
easier as you need not work directly with NMEA.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"John" wrote:

> Hi, I'm using opennetcf to try and connect my GPS. When I run the
> following code, I get the Opening message, then right after get the
> stopped. I never get a running message. I'm sure I'm using the right
> port and baud rate. I've tried 3rd party GPS software on my device to
> verify it does work. Just curious if anyone sees anything wrong with
> this code. Thanks so much
> using OpenNETCF.IO.Serial.GPS;
>
>
>
>
> private void button1_Click(object sender, EventArgs e)
> {
> gps.GpsSentence += new
> OpenNETCF.IO.Serial.GPS.GPS.GpsSentenceEventHandler(gps_GpsSentence);
> gps.GpsCommState += new
> OpenNETCF.IO.Serial.GPS.GPS.GpsCommStateEventHandler(gps_GpsCommState);
>
> OpenNETCF.IO.Serial.BaudRates br =
> OpenNETCF.IO.Serial.BaudRates.CBR_9600;
> gps.BaudRate = br;
> gps.ComPort = "COM4:";
> gps.MinBaudRate = br;
> gps.MaxBaudRate = br;
> //gps.AutoDiscovery = true;
> gps.Start();
>
> }
> private void gps_GpsCommState(object sender,
> GpsCommStateEventArgs e)
> {
> switch (e.State)
> {
> case OpenNETCF.IO.Serial.GPS.States.Opening:
> MessageBox.Show("GPS Opening");
> break;
> case OpenNETCF.IO.Serial.GPS.States.Running:
> MessageBox.Show("GPS Started");
> break;
> case OpenNETCF.IO.Serial.GPS.States.Stopped:
> MessageBox.Show("GPS Stop");
> break;
> case OpenNETCF.IO.Serial.GPS.States.Stopping:
> MessageBox.Show("GPS Stopping");
> break;
>
> }
> }
>

Re: OpenNETCF GPS by ctacke/>

ctacke/>
Sun Dec 02 11:22:27 PST 2007

Just FYI, the OpenNETCF GPS stuff allows you to not work with NMEA as well -
it does that parsing for you - and it works with older devices.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



"Simon Hart [MVP]" <srhartone@yahoo.com> wrote in message
news:E310D4C6-0BA7-498E-85E7-B958AA6638B2@microsoft.com...
> I've never used the OpenNETCF implementation of this. But what device are
> you
> running on? As if you are running on Windows Mobile 5 or later then you
> can
> use the Intermediate Driver which makes coding the GPS integration so much
> easier as you need not work directly with NMEA.
> --
> Simon Hart
> Visual Developer - Device Application Development MVP
> http://simonrhart.blogspot.com
>
>
> "John" wrote:
>
>> Hi, I'm using opennetcf to try and connect my GPS. When I run the
>> following code, I get the Opening message, then right after get the
>> stopped. I never get a running message. I'm sure I'm using the right
>> port and baud rate. I've tried 3rd party GPS software on my device to
>> verify it does work. Just curious if anyone sees anything wrong with
>> this code. Thanks so much
>> using OpenNETCF.IO.Serial.GPS;
>>
>>
>>
>>
>> private void button1_Click(object sender, EventArgs e)
>> {
>> gps.GpsSentence += new
>> OpenNETCF.IO.Serial.GPS.GPS.GpsSentenceEventHandler(gps_GpsSentence);
>> gps.GpsCommState += new
>> OpenNETCF.IO.Serial.GPS.GPS.GpsCommStateEventHandler(gps_GpsCommState);
>>
>> OpenNETCF.IO.Serial.BaudRates br =
>> OpenNETCF.IO.Serial.BaudRates.CBR_9600;
>> gps.BaudRate = br;
>> gps.ComPort = "COM4:";
>> gps.MinBaudRate = br;
>> gps.MaxBaudRate = br;
>> //gps.AutoDiscovery = true;
>> gps.Start();
>>
>> }
>> private void gps_GpsCommState(object sender,
>> GpsCommStateEventArgs e)
>> {
>> switch (e.State)
>> {
>> case OpenNETCF.IO.Serial.GPS.States.Opening:
>> MessageBox.Show("GPS Opening");
>> break;
>> case OpenNETCF.IO.Serial.GPS.States.Running:
>> MessageBox.Show("GPS Started");
>> break;
>> case OpenNETCF.IO.Serial.GPS.States.Stopped:
>> MessageBox.Show("GPS Stop");
>> break;
>> case OpenNETCF.IO.Serial.GPS.States.Stopping:
>> MessageBox.Show("GPS Stopping");
>> break;
>>
>> }
>> }
>>



Re: OpenNETCF GPS by John

John
Mon Dec 03 10:00:49 PST 2007

On Dec 2, 8:31 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> I've never used the OpenNETCF implementation of this. But what device are you
> running on? As if you are running on Windows Mobile 5 or later then you can
> use the Intermediate Driver which makes coding the GPS integration so much
> easier as you need not work directly with NMEA.
> --
> Simon Hart
> Visual Developer - Device Application Development MVPhttp://simonrhart.blogspot.com
>
> "John" wrote:
> > Hi, I'm using opennetcf to try and connect my GPS. When I run the
> > following code, I get the Opening message, then right after get the
> > stopped. I never get a running message. I'm sure I'm using the right
> > port and baud rate. I've tried 3rd party GPS software on my device to
> > verify it does work. Just curious if anyone sees anything wrong with
> > this code. Thanks so much
> > using OpenNETCF.IO.Serial.GPS;
>
> > private void button1_Click(object sender, EventArgs e)
> > {
> > gps.GpsSentence += new
> > OpenNETCF.IO.Serial.GPS.GPS.GpsSentenceEventHandler(gps_GpsSentence);
> > gps.GpsCommState += new
> > OpenNETCF.IO.Serial.GPS.GPS.GpsCommStateEventHandler(gps_GpsCommState);
>
> > OpenNETCF.IO.Serial.BaudRates br =
> > OpenNETCF.IO.Serial.BaudRates.CBR_9600;
> > gps.BaudRate = br;
> > gps.ComPort = "COM4:";
> > gps.MinBaudRate = br;
> > gps.MaxBaudRate = br;
> > //gps.AutoDiscovery = true;
> > gps.Start();
>
> > }
> > private void gps_GpsCommState(object sender,
> > GpsCommStateEventArgs e)
> > {
> > switch (e.State)
> > {
> > case OpenNETCF.IO.Serial.GPS.States.Opening:
> > MessageBox.Show("GPS Opening");
> > break;
> > case OpenNETCF.IO.Serial.GPS.States.Running:
> > MessageBox.Show("GPS Started");
> > break;
> > case OpenNETCF.IO.Serial.GPS.States.Stopped:
> > MessageBox.Show("GPS Stop");
> > break;
> > case OpenNETCF.IO.Serial.GPS.States.Stopping:
> > MessageBox.Show("GPS Stopping");
> > break;
>
> > }
> > }

I'm working on a windows mobile 5 device. I stepped into the OpenNETCF
code, and it gets an error message saying com4: is not on device. As a
test I used a 3rd party app and set it to com4: and baud 9600, the 3rd
party app worked great. Not sure why the code thinks the com4: is not
on the device. Any Thoughts?

ps. I'm currently trying to get some code working that was already
used in the past on older devices.. I'm not unwilling to rewrite it
though if I need to. I noticed you mentioned using the Intermediate
Driver, I'll have to look into that, I have not seen that before,
thanks for the advice.

The code in GPS.cs located in the OpenNETCF.IO.Serial.GPS that I found
the error.

protected virtual void OnError(Exception exception,string
message,string gps_data)
{
lasterror=message;

if (Error!=null) Error(this,exception,message,gps_data);
}

Thanks

Re: OpenNETCF GPS by John

John
Mon Dec 03 10:03:44 PST 2007

On Dec 2, 12:22 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
> Just FYI, the OpenNETCF GPS stuff allows you to not work with NMEA as well -
> it does that parsing for you - and it works with older devices.

Is there an example out there for this? I'm not sure what you mean in
the above statement, pretty new to working with GPS.

Thanks

Re: OpenNETCF GPS by ctacke/>

ctacke/>
Mon Dec 03 10:14:44 PST 2007

Just a guess, but the port may be in use, and that's why the library is
failing. I've not looked at that code in a couple years, so I'm not sure,
but I know the underlying serial classes have been tested and used pretty
heavily. You'd need to debug down to the call to CreateFile and see what
exactly is being returned. Probably a 55 for GetLastError at that point.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



"John" <johnwadeunderwood@yahoo.com> wrote in message
news:9fb60316-970a-4f3a-a03a-735f197b4429@e67g2000hsc.googlegroups.com...
> On Dec 2, 8:31 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
>> I've never used the OpenNETCF implementation of this. But what device are
>> you
>> running on? As if you are running on Windows Mobile 5 or later then you
>> can
>> use the Intermediate Driver which makes coding the GPS integration so
>> much
>> easier as you need not work directly with NMEA.
>> --
>> Simon Hart
>> Visual Developer - Device Application Development
>> MVPhttp://simonrhart.blogspot.com
>>
>> "John" wrote:
>> > Hi, I'm using opennetcf to try and connect my GPS. When I run the
>> > following code, I get the Opening message, then right after get the
>> > stopped. I never get a running message. I'm sure I'm using the right
>> > port and baud rate. I've tried 3rd party GPS software on my device to
>> > verify it does work. Just curious if anyone sees anything wrong with
>> > this code. Thanks so much
>> > using OpenNETCF.IO.Serial.GPS;
>>
>> > private void button1_Click(object sender, EventArgs e)
>> > {
>> > gps.GpsSentence += new
>> > OpenNETCF.IO.Serial.GPS.GPS.GpsSentenceEventHandler(gps_GpsSentence);
>> > gps.GpsCommState += new
>> > OpenNETCF.IO.Serial.GPS.GPS.GpsCommStateEventHandler(gps_GpsCommState);
>>
>> > OpenNETCF.IO.Serial.BaudRates br =
>> > OpenNETCF.IO.Serial.BaudRates.CBR_9600;
>> > gps.BaudRate = br;
>> > gps.ComPort = "COM4:";
>> > gps.MinBaudRate = br;
>> > gps.MaxBaudRate = br;
>> > //gps.AutoDiscovery = true;
>> > gps.Start();
>>
>> > }
>> > private void gps_GpsCommState(object sender,
>> > GpsCommStateEventArgs e)
>> > {
>> > switch (e.State)
>> > {
>> > case OpenNETCF.IO.Serial.GPS.States.Opening:
>> > MessageBox.Show("GPS Opening");
>> > break;
>> > case OpenNETCF.IO.Serial.GPS.States.Running:
>> > MessageBox.Show("GPS Started");
>> > break;
>> > case OpenNETCF.IO.Serial.GPS.States.Stopped:
>> > MessageBox.Show("GPS Stop");
>> > break;
>> > case OpenNETCF.IO.Serial.GPS.States.Stopping:
>> > MessageBox.Show("GPS Stopping");
>> > break;
>>
>> > }
>> > }
>
> I'm working on a windows mobile 5 device. I stepped into the OpenNETCF
> code, and it gets an error message saying com4: is not on device. As a
> test I used a 3rd party app and set it to com4: and baud 9600, the 3rd
> party app worked great. Not sure why the code thinks the com4: is not
> on the device. Any Thoughts?
>
> ps. I'm currently trying to get some code working that was already
> used in the past on older devices.. I'm not unwilling to rewrite it
> though if I need to. I noticed you mentioned using the Intermediate
> Driver, I'll have to look into that, I have not seen that before,
> thanks for the advice.
>
> The code in GPS.cs located in the OpenNETCF.IO.Serial.GPS that I found
> the error.
>
> protected virtual void OnError(Exception exception,string
> message,string gps_data)
> {
> lasterror=message;
>
> if (Error!=null) Error(this,exception,message,gps_data);
> }
>
> Thanks



Re: OpenNETCF GPS by ctacke/>

ctacke/>
Mon Dec 03 10:17:41 PST 2007

I simply mena that you don't have to manually parse the raw NMEA data - the
GPS library has classes that encapsulate that for you. Look at the Position
class.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com




"John" <johnwadeunderwood@yahoo.com> wrote in message
news:eb01441e-12f4-49b9-ad87-7fd8bde6405f@o42g2000hsc.googlegroups.com...
> On Dec 2, 12:22 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
>> Just FYI, the OpenNETCF GPS stuff allows you to not work with NMEA as
>> well -
>> it does that parsing for you - and it works with older devices.
>
> Is there an example out there for this? I'm not sure what you mean in
> the above statement, pretty new to working with GPS.
>
> Thanks



Re: OpenNETCF GPS by srhartone

srhartone
Mon Dec 03 11:15:00 PST 2007

Have you set the port to "COM4:" including the colon? Just a guess, I've
never looked at the code.

If you are running your code on WM5 or later only it would make more sense
to use the Intermediate Driver:
http://msdn2.microsoft.com/en-us/library/bb202086.aspx
Because not only is it easier to code, it allows more than one application
to read from the GPS chipset at the same time. This is not possible when
reading directly from the chipset using the serial class.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"John" wrote:

> On Dec 2, 8:31 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> > I've never used the OpenNETCF implementation of this. But what device are you
> > running on? As if you are running on Windows Mobile 5 or later then you can
> > use the Intermediate Driver which makes coding the GPS integration so much
> > easier as you need not work directly with NMEA.
> > --
> > Simon Hart
> > Visual Developer - Device Application Development MVPhttp://simonrhart.blogspot.com
> >
> > "John" wrote:
> > > Hi, I'm using opennetcf to try and connect my GPS. When I run the
> > > following code, I get the Opening message, then right after get the
> > > stopped. I never get a running message. I'm sure I'm using the right
> > > port and baud rate. I've tried 3rd party GPS software on my device to
> > > verify it does work. Just curious if anyone sees anything wrong with
> > > this code. Thanks so much
> > > using OpenNETCF.IO.Serial.GPS;
> >
> > > private void button1_Click(object sender, EventArgs e)
> > > {
> > > gps.GpsSentence += new
> > > OpenNETCF.IO.Serial.GPS.GPS.GpsSentenceEventHandler(gps_GpsSentence);
> > > gps.GpsCommState += new
> > > OpenNETCF.IO.Serial.GPS.GPS.GpsCommStateEventHandler(gps_GpsCommState);
> >
> > > OpenNETCF.IO.Serial.BaudRates br =
> > > OpenNETCF.IO.Serial.BaudRates.CBR_9600;
> > > gps.BaudRate = br;
> > > gps.ComPort = "COM4:";
> > > gps.MinBaudRate = br;
> > > gps.MaxBaudRate = br;
> > > //gps.AutoDiscovery = true;
> > > gps.Start();
> >
> > > }
> > > private void gps_GpsCommState(object sender,
> > > GpsCommStateEventArgs e)
> > > {
> > > switch (e.State)
> > > {
> > > case OpenNETCF.IO.Serial.GPS.States.Opening:
> > > MessageBox.Show("GPS Opening");
> > > break;
> > > case OpenNETCF.IO.Serial.GPS.States.Running:
> > > MessageBox.Show("GPS Started");
> > > break;
> > > case OpenNETCF.IO.Serial.GPS.States.Stopped:
> > > MessageBox.Show("GPS Stop");
> > > break;
> > > case OpenNETCF.IO.Serial.GPS.States.Stopping:
> > > MessageBox.Show("GPS Stopping");
> > > break;
> >
> > > }
> > > }
>
> I'm working on a windows mobile 5 device. I stepped into the OpenNETCF
> code, and it gets an error message saying com4: is not on device. As a
> test I used a 3rd party app and set it to com4: and baud 9600, the 3rd
> party app worked great. Not sure why the code thinks the com4: is not
> on the device. Any Thoughts?
>
> ps. I'm currently trying to get some code working that was already
> used in the past on older devices.. I'm not unwilling to rewrite it
> though if I need to. I noticed you mentioned using the Intermediate
> Driver, I'll have to look into that, I have not seen that before,
> thanks for the advice.
>
> The code in GPS.cs located in the OpenNETCF.IO.Serial.GPS that I found
> the error.
>
> protected virtual void OnError(Exception exception,string
> message,string gps_data)
> {
> lasterror=message;
>
> if (Error!=null) Error(this,exception,message,gps_data);
> }
>
> Thanks
>

Re: OpenNETCF GPS by John

John
Wed Dec 05 08:51:21 PST 2007

I found the problem. In GPS.cs as it was looping through the devices,
this following line caused
an exception, which skipped some very needed code. Thanks for
everyones help.

strport = strport.Substring(0,strport.IndexOf("'"));

Here is the full function that was causing the problem:

private string[] devices()
{
// lists all modems on the device
ArrayList al = new ArrayList();
RegistryKey defkey;
string[] keyNames;
string keyvalue="";
string strport="";

// now get the active
defkey=Registry.LocalMachine.CreateSubKey(@"Drivers\Active");

keyNames =defkey.GetSubKeyNames();
foreach (string x in keyNames)
{

try
{
keyvalue=defkey.CreateSubKey(x).GetValue("Key").ToString();
strport=defkey.CreateSubKey(x).GetValue("Name").ToString();

// fudge to remove rubbish off the end of the string
strport = strport.Substring(0,strport.IndexOf("'"));

RegistryKey thekey=Registry.LocalMachine.CreateSubKey(keyvalue);

if (strport.StartsWith("COM"))
al.Add(strport);
}
catch
{

}
}
return (string[]) al.ToArray(typeof(string));
}

Re: OpenNETCF GPS by ctacke/>

ctacke/>
Wed Dec 05 10:07:07 PST 2007

Wow - that is ugly. It should be doing a Trim('\0') if anything.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


"John" <johnwadeunderwood@yahoo.com> wrote in message
news:a27aba61-4ab6-4ede-a1d5-473ef4ae0a49@x69g2000hsx.googlegroups.com...
>I found the problem. In GPS.cs as it was looping through the devices,
> this following line caused
> an exception, which skipped some very needed code. Thanks for
> everyones help.
>
> strport = strport.Substring(0,strport.IndexOf("'"));
>
> Here is the full function that was causing the problem:
>
> private string[] devices()
> {
> // lists all modems on the device
> ArrayList al = new ArrayList();
> RegistryKey defkey;
> string[] keyNames;
> string keyvalue="";
> string strport="";
>
> // now get the active
> defkey=Registry.LocalMachine.CreateSubKey(@"Drivers\Active");
>
> keyNames =defkey.GetSubKeyNames();
> foreach (string x in keyNames)
> {
>
> try
> {
> keyvalue=defkey.CreateSubKey(x).GetValue("Key").ToString();
> strport=defkey.CreateSubKey(x).GetValue("Name").ToString();
>
> // fudge to remove rubbish off the end of the string
> strport = strport.Substring(0,strport.IndexOf("'"));
>
> RegistryKey thekey=Registry.LocalMachine.CreateSubKey(keyvalue);
>
> if (strport.StartsWith("COM"))
> al.Add(strport);
> }
> catch
> {
>
> }
> }
> return (string[]) al.ToArray(typeof(string));
> }