[Sorry the damn forum eat my question.]
Hello people.
Since you can see on other post in this forum that I’ve created, I’m(and other prople too) having a lot of problems with Seeed GPS module sold by GHI. After a lot of discussion and nothing handled, I decided to seek for other options.
I got a Prolific based GPS USB-to-serial. Now I’m trying to use the USBHost module to get the NMEA data from this thing and try handle my problem with other module.
So, the bare code is:
void DeviceConnectedEvent(USBH_Device device)
{
Debug.Print("Device connected");
switch (device.TYPE)
{
...
case USBH_DeviceType.Serial_Prolific:
serialUSB = new USBH_SerialUSB(device, 4800,
System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
serialUSB.Open();
serialUSBThread = new Thread(SerialUSBThread);
serialUSBThread.Start();
break;
...
}
}
void SerialUSBThread()
{
byte[] data = new byte[200];
while (true)
{
serialUSB.Read(data, 0, data.Length);
StreamReader r = new StreamReader(new MemoryStream(data));
Debug.Print(r.ReadLine());
}
}
Now, the connection is made, and the serialUSB start grab the NME sentences but something is wrong. The data that comes from NMEA strings seems to be cut. Part on one line part on other.
$GPGGA,010604.064,,,,,0,00,,,M,0.0,M,,0000*57
V,1,1,00*79
PGGA,012527.064,,,,,0,00,,,M,0.0,M,,0000*57
$GPGGA,012528.064,,,,,00,,,M,0.0,M,,0000*57
,0,00,,,M,0.0,M,,0000*58
$GPGGA,012529.064,,,,,0,00,,,M,0.0,M,,0000*59,,,,,,*1E
$GPGGA,012530.064,,,,,0,00,,,M,0.0,M,,0000*51
So, I have two questions:
- What is wrong with this simple code that the strings are coming wraped?
- Anyone has a NMEA parser sample so I don’t have to write myself one from scratch?
Thanks a lot. Really appreciate.