|
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
|