I have a Mio P550 device that includes GPS. I am trying to use SerialPort to get NMEA sentences, just using SerialPort.Read (). The data is returned in some strange encoding. GPS should return NMEA sentences in ASCII, but it is not. Here is my code to read:
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 the approximate value that I get in return: xæææxfæ`æxæføøøxxxøx
I also have a second device (Asus A636N) that returns NMEA sentences in ASCII, and my code works fine.
Mio, NMEA ASCII? , ? System.Text.Encoding.xxx.GetString(), , - , .