Android Question jSerial Error Port busy

Status
Not open for further replies.

red30

Well-Known Member
Licensed User
Longtime User
I am using a Bluetooth module for data transfer. On a laptop with built-in Bluetooth, I connect to my device and enter the password. At the same time, two new com ports appear in the device manager. If through the terminal I open the com port and send data, then I see how the data is transmitted and I get a response. If I try to open the same com port via B4J using the jSerial library, the program freezes and crashes:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 452 (first)
jssc.SerialPortException: Port name - COM13; Method name - openPort(); Exception type - Port busy.
    at jssc.SerialPort.openPort(SerialPort.java:164)
    at anywheresoftware.b4j.serial.Serial.Open(Serial.java:85)
    at b4j.forteza.liana.finaled.first$ResumableSub_IzmSpeed.resume(first.java:4097)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
    at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1018)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)
Why is this happening? Why does everything work through the terminal, but through the jSerial library I get an error?
 

DonManfred

Expert
Licensed User
Longtime User
Why is this happening? Why does everything work through the terminal, but through the jSerial library I get an error?
Probably because the port is still used by the terminal.
Restart your device/pc and try again without using terminal.
The error is
jssc.SerialPortException: Port name - COM13; Method name - openPort(); Exception type - Port busy.
the port is already in use...
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
Probably because the port is still used by the terminal.
Restart your device/pc and try again without using terminal.
The error is

the port is already in use...
When I opened the com port via B4J, the terminal was closed. I rebooted the PC, and without opening any terminals, I started the program on the B4J - the error repeated itself. At the same time, I open the terminal again, and everything works.
It's not that the com was opened by another program.
 
Upvote 0
Status
Not open for further replies.
Top