B4J Question jSerial - Com port not found

barx

Well-Known Member
Licensed User
Longtime User
I'm delving into the world of serial communication for the first time and wanted to use b4j as a base.

Looking around I see that I should be able to use jSerial lib to send / receive data through USB port to a USB to RS232 lead.

Just as a quick and dirty test I chucked this together

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
   
    USB.Initialize("USB")
    Log(USB.ListPorts) '(ArrayList) [COM5]
    Log(USB.ListPorts.Get(0)) 'COM5
    USB.Open(USB.ListPorts.Get(0))
    astream.Initializeprefix(USB.GetInputStream, True, USB.GetOutputStream, "astream")
    'USB.SetParams(9600, 8, 1, 0)
   
End Sub

Sub MainForm_Closed
    USB.Close
End Sub

Sub astream_NewData (Buffer() As Byte)
    Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
    Log(s)
End Sub

At the end of the 'Log()' line I have put the logged value. As you can see the Adaptor lead is indeed detected (it is Com5) but when I try to open the port I get an error that the port is not found..... Funny, you saw it a second ago :confused:


Any Clues?
 

barx

Well-Known Member
Licensed User
Longtime User
Please delete the above thread, my pc crapped out shortly after this post. Win10 BSOD, upon starting back up, it worked, lol.
 
Upvote 0