View Single Post
  #6   Spotlight this post!  
Unread 16-12-2008, 14:50
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Decoding GPS with C#

A thought came to mind... I believe the .NET framework works in Unicode by default, which means it's probably sending double-wide characters, and most serial devices expect single-wide (ASCII) characters. You'll need to use the the Encoding class to convert between them. There's plenty of examples on MSDN, I've also included one below:

using System;
using System.Text;

class ASCIIEncodingExample {
public static void Main() {
// The encoding.
ASCIIEncoding ascii = new ASCIIEncoding();

// A Unicode string
String unicodeString = "ASTRAL\n";

// Encode string.
Byte[] encodedBytes = ascii.GetBytes(unicodeString);

foreach (Byte b in encodedBytes)
{
Console.Write((char)b);
}

Console.ReadLine();
}
}
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor