View Single Post
  #6   Spotlight this post!  
Unread 16-12-2008, 16:30
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,721
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Decoding GPS with C#

C# defaults to standard ASCII encoding for serial ports and suchlike. There's no need for re-encoding the string or anything like that. If you really think it's necessary, however, it's much much easier to do this in the port setting area before comport.Open():

comport.Encoding = Encoding.ASCII;

Also, thanks to a bit of googling to identify your odd GPS, I ran across your somewhat more informative post on XKCD. The nice webpage you link from there about your Delorme Tripmate actually tells you straight out that the string you should be attempting to send is "ASTRAL\r\n". So it's nice to have that confirmed, and you can stick with that as the string to send.

I assume that you've actually linked your button click function to your button's onClick event, but just for grins, you could try forcing your program to send "ASTRAL\r\n" as soon as it opens the comport. To wit:
Code:
                // Open the port
                comport.Open();
                button1.Text = "Close Port";
                comport.Write("ASTRAL\r\n");
That should guarantee that your string is getting sent at some point, since it has to call Write after successfully opening the port.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter