0
votes

I'm trying to read the data coming in on a serial port from a BU-353S4 USB GPS. I'm getting nothing as far as readable NMEA sentences. The GPS works perfectly with a Raspberry Pi.

This is for a .NET console application. There are similar questions all over the web, but none of the samples seem to work.

var port = new SerialPort
{
    PortName = "COM5",
    BaudRate = 4800,
    Parity = Parity.None,
    DataBits = 8,
    StopBits = StopBits.One,
};
port.DataReceived += Port_DataReceived;


private static void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    string line = "";
    SerialPort port = (SerialPort)sender;
    line = port.ReadExisting();
    Console.Write(line);
}

and...

private static void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    SerialPort port = (SerialPort)sender;
    var count = port.BytesToRead;
    var buffer = new byte[count];
    port.Read(buffer, 0, count);
    var line = Encoding.ASCII.GetString(buffer);
    Console.Write(line);
}

No matter what I try, I end up with something like:

?)))))(((((#Y ?""!!!!!!!? ??z ?----------?D? ?

?J ?&%%%%%%%%%?? ?%$$$$$$$$$f Qx ?++++****** ?! ? ? #???? ) xm???? =?? ? ????? ???? ]? t? D0?? ????? 3 4???? 2\

2
Are you sure the port settings are correct? I find PuTTY to be a great tool for serial port device troubleshooting. - itsme86
Why are you using 4800 BAUD instead of 9600 BAUD? People use 4800 only because Synchronous Read of Serial Port on Windows DOES NOT WORK!!! Always use 9600 (or faster) Asynchronous Read which always work. The reason Rasberry worked is somebody set the baud rate to 4800 in the device and your device is set at the default rate which is probably 9600 or 19200. Nobody uses 4800 BAUD except as a kludge because faster rates are unreliable using Synchronous read. - jdweng
@jdweng, Device specification is 4800bps.BU-353S4 Users Guide Is the device driver not installed correctly, or is it running on Windows 8.1-10 that is not written as compatible, or something else? BU-353S4 Cable GPS with USB interface (SiRF Star IV) - kunif
Does it work with vendor application shown in the user guide? Check Device manager to see if it is on Com5. - jdweng
Make sure you set port.Handshake = Handshake.None; The cable could have pins wired that may create issues. Turning handshake to None will ignore any issues with the cable. - jdweng

2 Answers

0
votes

Turns out the GPS was sending SiRF instead of NMEA. Once I followed the steps in this SuperUser post to switch it to NMEA, everything worked perfectly!

0
votes

The issue is todo with the BAUD RATE, try changing your value to one that's compatible with your device.

I was receiving this error and this is what I did to solve the issue~

_GPSReceiver = new SerialPort("COM9");
_GPSReceiver.ReceivedBytesThreshold = 1024;
_GPSReceiver.ReadTimeout = 5000;
_GPSReceiver.BaudRate = 4800;
_GPSReceiver.Parity = Parity.None;
_GPSReceiver.StopBits = StopBits.One;
_GPSReceiver.DataBits = 7;
_GPSReceiver.Handshake = Handshake.None;
_GPSReceiver.Encoding = ASCIIEncoding.ASCII;

_GPSReceiver.DataReceived += new SerialDataReceivedEventHandler(GPSReceiver_DataReceived);
_GPSReceiver.Open();