cdholding image

comm32 home
comm32 forum
buy comm32

Introduction
Install Comm32
Why Not MsComm?

Properties
   .Break
   .CDHolding
   .CommEvent
   .CommPort
   .CTSHolding
   .DSRHolding
   .DTREnable
   .EOFEnable
   .Handshaking
   .InBufferCount
   .InBufferSize
   .Input
   .InputLen
   .InputMode
   .NullDiscard
   .OutBufferCount
   .OutBufferSize
   .OutPut
   .ParityReplace
   .PortOpen
   .RThreshold
   .RTSEnable
   .Settings
   .STHreshold


Comm32 Properties
   .DeviceName
   .EOFChar
   .EvtChar
   .EvtCharEnable
   .OutPutEx
   .OutPutMode
   .ParallelEnable
   .TxTimeout

Comm32 Functions
   .getByte

   .GetPortStatus
   .InstalledDrivers
   .putByte
   .PortExists
   .ReadBytes
   .ReadString
   .WriteBytes
   .WriteString

OnComm Event
Hardware/Cables etc

GetPortStatus

Retrieves a numerical value giving information about a given com port

ReadOnly at Runtime.

Only available using the Comm32 ocx. Not supported by MSComm32

         Syntax result = object.GetPortStatus(value)
     
  object Name of the communications control.
  value Numerical Com port number in the range 1 to 256
  result

A numerical value

     
    0 = comPortAvailable
1 = comPortBusy
2 = comPortNotFound
'// The port exists and is free/available to be opened
'// The port exists but it is already opened/in use
'// The port does not exist at all
    Values 3 and above '// Unexpected result. The result code will have the
'// same meaning as the "MS System Error Codes"

Remarks:

This is a function call - not a property - you do not need to change the .CommPort property - Simply pass the desired port number in the function call as shown in the example below:-

'// We're going to populate a listbox with the short "Com" names of com ports that are known to exist.
'// We'll also indicate if the port is available or busy

Private Sub PopulateList( )
Dim i as Long

       List1.Clear
       
'// In this example we'll test for ports up to 32 - you can test up to 256 if you want.
       For i = 1 To 32
              Select Comm1.GetPortStatus( i )

                  Case 0
                     List1.AddItem "Com" & i & " is available"

                  Case 1
                     List1.AddItem "Com" & i & " is busy"

                  Case 2
                     '// Port does not exist. We won't add it to the list

                  Case Else
                     '// Unexpected result (See below)
              End Select
       Next i
 
End Sub

Return values 3 and above. In most cases when using locally attached com ports accessed by real applications all return values will be in the range 0 to 2. Results above 2 usually mean that the port does exist - or at least Windows 'thinks' it exists - but for some reason the port could not be enumerated. For example if the physical port is located on a remote port server then the local virtual/driver 'stub' may appear to be present and the port would appear in Windows Device manager but a network error could make the port inaccessible and the extended result code might relate to network timeout errors. (See the page "System Error Codes" on the MSDN website)

See also DeviceName and InstalledDrivers properties.

 

 

Copyright (c) 2010 Axis Controls Ltd