C# serial communication with u-blox gps
Solution 1
If you can communicate with the GPS using HyperTerminal then in principle there's no reason why you shouldn't be able to in C#. Are you sure you've configured the serial port correctly, particularly the baud rate, data bits, stop bits, parity, and flow control settings?
You could use SysInternals PortMon tool to look at the low-level I/O and compare how HyperTerminal and your C# program each configure the serial port. Maybe this will provide some useful information.
Solution 2
I have sucessfully used the SerialPort class in .Net 2 also with gps on a virtual comport. It seems your virtual comport driver is slightly off. If you can't locate a newer driver I would suggest you call the WinAPI functions for reading the serial port.
Take a look at this code for instance: http://www.codeproject.com/KB/system/SerialPortComm.aspx
Related videos on Youtube
Leluke
Updated on June 04, 2022Comments
-
Leluke almost 2 years
I have a GPS from u-blox.com with a USB-connection and driver. The driver installs a virual COM port that pops up when you plug the USB in. Using a hyperterminal I can then watch the flow of data from the GPS.
Then I want the data in my program, not so easy...
I have implemented some methods using the serialPort class to read from the GPS, but am unsuccessful. I have programmed several serial device readers and writers before in C#, but this one stops me.
As an example, the simple code in simpleSerial will not give you anything unless you unplug and replug the USB.
Have tried reading it with matlab, which works great, but as the rest of my program that needs the GPS data is in c#, that doesn't quite fix the problem.
Is there some high level C# things going on in the serialPort class that I can circumvent? Or is there any known problems reading USB-serialports, which I assume works like my GPS?
-
Leluke over 15 yearsI don't have to write anything to the port to get output, it spews out when I start it. Also the nmea protocol uses carriage return and line feed. Unless the hyperterminal sends anything upon opening that I'm not aware off?
-
Leluke over 15 yearsThe example was in vc++, but I'll try together with msdn.microsoft.com/en-us/library/2d9wy99d.aspx to use the WinAPI functions.