B4J Question com port busy error trapping

saunwin

Active Member
Licensed User
Longtime User
Morning.

If I try to open a COM port that has been opened by another program, I get an error :-

jssc.SerialPortException: Port name - COM6; Method name - openPort(); Exception type - Port busy.

How do I trap this ?

Many thanks in advance.
 

saunwin

Active Member
Licensed User
Longtime User
Hi Erel,

Program stops with Error occurred on line: 257 (main). 257 is the sp.open(cmbport.value) line.


B4X:
Sub btnopen_MouseClicked (EventData As MouseEvent)
    If btnopen.Text = "Open" Then
        sp.Open(cmbport.Value)
        sp.SetParams (BaudRate , DataBits , StopBits , Parity )
        sp.PurgePort(8)
        astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "astream")      
        btnopen.text = "Close"
        lblstatus.Text = "Status: Connected"
    Else
        AStream_Terminated
    End If  
End Sub
 
Upvote 0
Top