I am trying to connect to a virtual com port provided by the drivers of a u-blox GPS device.
The device appears normally under the Sensors tab in Device Manager and I can really get the coordinate data using GeoCoordinateWatcher
class from C#.
But I want to read the underlying NMEA data.
So in the process of doing that I installed the Virtual Com Port
driver provided by U-BLOX and it generated a u-blox virta com port in devices manager.
Connecting to that using Putty
is OK and I can see all the NMEA lines being dumped there.
but when I try to connect to the same port (after Putty
is closed obviously) using C# I get the exception mentioned in the title
The given port name does not start with COM/com or does not resolve to a valid serial port
My code is fairly simple (not the first time I use com ports) and everything is correctly defined (Port Name, Stop Bits, Parity, BaudRate etc). I even tried changing to a "wrong" com port name to see the exception I will get and it is completely different (Com Port does not a exit exception).
So what is happening with C# at this point? Am I doing something wrong? Is this a bug in the SerialPort class? Putty seems to work just fine in connecting and streaming the data. My code is as simple as the following
m_port = new SerialPort
{
PortName = m_portName,
BaudRate = m_baudRate,
Parity = m_parityBit,
DataBits = m_dataBits,
StopBits = m_stopBit
};
m_port.Open();
I even tried hardcoding the values and I still get the same exception. I tried many of the suggested solutions found here, none of them helped. I also tried changing the COM port number from Device Manager advanced settings, that also did not help