Comm32 Logo
Home Button  Buy Button 

Topic:   getPortStatus

By: Jay ZebrykPosted on: Jul 18 2020 at 03:45:11 PM
Having an industrial app which constantly polls various devices and reacts to different measurements, it would be highly useful to test if the port was busy before sending a message. A previous of your control had a GetPortStatus function which would be perfect. Could this be made available again? And if so, how much would this cost?
Jay Zebryk
Zebryk Engineering
zebryk.com/
Jay@Zebryk.com
Mobile: 508-868-2166

By: GuestPosted on: Jul 23 2020 at 11:12:33 AM
Are you asking about the getPortStatus function because you used it in that old version?

If you've never used the function then it probably didn't do what you think.

The problem it was supposed to solve:- When you try to Open a port, by calling PortOpen=True it will either fail or succeed. But, in the case of failure, you have no idea if it failed because:-

(a) the port does not exist
or
(b) the port exists but it's already open in some other application.

The GetPortStatus function attempted to give the answer to the above question. Only useful if called BEFORE opening or trying to open a port. The 'Busy' return value simply meant that the port exists but is open by some application.

In modern versions of Windows especially when using virtual or remote mapped com ports Windows itself often doesn't know if the port actually exists until you try to open it so the function, making Windows API calls, is pretty much useless anyway so doesn't exist in SComm32


By: Guest2Posted on: Jul 23 2020 at 11:30:51 AM
SComm32 has the .CommName function which you can use to get the same information.

Call that BEFORE opening the port. If the port exists then the CommName function returns the full 'friendly' name of the device. If the port does not exist it returns an empty string.

If you get an actual PortName you assume the port exists. You can then call PortOpen=True If that fails then you can assume the port exists but it's already open in some other application.

The above is, I believe, what the GetPortStatus function did under the hood anyway.

But, as previous poster said, it's possibly not reliable because CommName might return a full name even if a remote port has been disconnected because windows doesn't actually know that a remote device isn't available until after you've tried to open it.

Reply - add a comment to this topic.

You may enter letters, numbers and standard punctuation only. HTML and other scripts/tags will be rejected.

Topic:- getPortStatus


Enter the numbers.

Your name here is optional