I have a Mio P550 device, which has a GPS included. I try to use SerialPort to get NMEA sentences, by simply use SerialPort.Read(). Data is returned in some weird encoding. GPS should return NMEA sentences in ASCII, but it doesn't. Here is my code for reading:
dataLength = this.serialPort.Read(buffor, 0, Gps.BUFFOR_LENGTH);
Debug.WriteLine("data length: " + dataLength);
if (dataLength > 0)
{
for (int i = 0; i < dataLength; i++)
{
char c = Convert.ToChar(buffor[i]);
if (c == '\r' || c == '\n')
{
string data = stringBuilder.ToString();
Debug.WriteLine("data readed: " + data);
if (data.StartsWith("$GPGGA"))
{
this.OnLocationChanged(data);
}
stringBuilder.Length = 0;
}
else
{
stringBuilder.Append(c);
}
Debug.WriteLine("readed data: " + stringBuilder.ToString());
}
And here is sample value I get in return: xæææxfæ`æxæføøøxxxøx
I have also second device (Asus A636N), which return NMEA sentences in ASCII and my code works great.
What I have to do with Mio device to get NMEA sentences in ASCII? Or how I can get encoding for data returned by device? I try use all classes from System.Text.Encoding.xxx.GetString() to get string from readed bytes but it doesn't return right data - it returns data similar to sample above.