serialports listing slow

I have program that uses serialport in windows. At program start I list all serialports:

count = System.SerialPortCount
For i = 0 To count - 1
serialpopup.AddRow(System.SerialPort( i ).Name )

On some computers it takes few minutes. I think it is this old bug 8212:

Is there any workaround, or is this MBS plugin only solution?
In some windows computers listing works just fine. Is there a way to find these ports (that hangs this listing) in windows and hide or remove those?


Well, I wrote the WindowsSerialPortsMBS class for this.

As I had a customer needing this last week, I even fixed a bug on this recently.
So our plugin can give you a list of devices.

The problem is that Xojo tries to open all ports and there are timeouts.

Yes, I have license to 1.33 complete and it solved this.
Problem seems to be huawei 3g modem serialports…
Maybe I update plugins if I run on bug You have fixed recently :slight_smile:

Not sure if this is as useful as Christian’s solution, but on Windows it turned out to be much faster to refer to the serial ports by name, rather than by number. Fortunately on Windows, they tend to have very predictable names:

all the way to “COM255”

You can attempt to open each of them (a surprisingly fast process), and whichever ones open successfully are the ones you know you can work with.

Cool, didn’t know it was overloaded.

Why am I getting all 0 to 24 ports to scanList? How do You try to open ports?

for i as integer = 0 to 24 Serial1.SerialPort=System.SerialPort("COM"+Str(i)) If Serial1.Open=True Then scanList.AddRow("COM"+Str(currentCom)) Serial1.Close End If next i

This line is what is actually opening the serial port. It’s not intended to see if a port is open.

From the language reference:

[quote]Serial.Open ( ) As Boolean
Attempts to open the serial port. Returns True if the port was opened and False if it was not.[/quote]

In other words the 25 ports are now open. If they had not opened they would not have been added to your list.

But theres only four com ports in my pc… So even the ports that don’t exist return true?

I can only run on a mac at the moment so I am not totally sure. Perhaps someone who has access to a pc can give an answer that has been tested on windows. But I believe the com ports you are opening do not have to actually have a physical port (ie. a place to plug in a device) in order to be opened.

I ran that com port opening test for ports 0 to 24 on Windows XP and all report as opened OK, despite only COM1 existing.

[quote]On some computers it takes few minutes. I think it is this old bug 8212:
Feedback Case #8212[/quote]

I bet the computers where this takes a few minutes have Bluetooth devices with serial port profiles attached. Due to the high latency of these devices, the enumeration performed by Xojo takes a very long time. This is a 5-year old bug.

But guess what? The case has been updated today from ‘Verified’ to ‘Fixed’.

Wow, good news :smiley: