phil loh
phil loh

Reputation: 21

Odd SerialPort names which do not work

The Problem is simple, i am coding a tool which is able to connect GPS devices over the IO.Ports.SerialPort function in .NET

Everything works fine, but to list all available COM interfaces it looks like:

COM1  
COM2%  
COM3°
COM12$

its impossible to connect to a device which is called COM3°. If i simply try to connect manually to COM3 it works perfect.

this is the code snippet which i am using right now:

For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1
        cbbCOMPorts.Items.Add(System.IO.Ports.SerialPort.GetPortNames(i))
Next

Thanks for your help ;)

Upvotes: 2

Views: 910

Answers (3)

dbasnett
dbasnett

Reputation: 11773

This is another reason to use .Net 4.0 when using SerialPorts. Probably the biggest issue is to fix USB SerialPorts being removed when the port is open, which leads to many problems (yeah, I know that the user isn't supposed to...).

Upvotes: 0

Richard Morgan
Richard Morgan

Reputation: 7691

Does the information at this Connect MSDN post help?

Specifically, I see this:

Thank you for reporting this issue. The root cause of this (RegistryKey.GetValue fails to properly handle non-null terminated string data) will be fixed for the next version of the .NET Framework.

Regards, Justin Van Patten

Edit: As noted in the comments above, this link and issue can be found in an existing Stackoverflow question.

Upvotes: 2

Hans Passant
Hans Passant

Reputation: 942255

I've seen this before, it's been a while. This is a bug in the driver, it is writing junk to the registry. Bobby gave you the location, have a look-see with Regedit.exe. Some kind of USB device, I imagine. Throw it away and find another from a different manufacturer. Cr*ppy drivers is not something you want to deal with.

Upvotes: 4

Related Questions