B4J Library jSerial library

Status
Not open for further replies.
The jSerial library allows you to open and communicate with other devices through the computer COM ports.

It can also be used to communicate with Bluetooth devices over a virtual com port.
(jBluetooth library is now available: https://www.b4x.com/android/forum/threads/jbluetooth-library.60184/)

SS-2013-11-21_15.46.10.png


The attached examples implement an Android <-> PC chat app.

In order to run the example you need to first pair the PC and the device and make sure that the Bluetooth is mapped to a virtual com port.

jSerial works with AsyncStreams. Both standard mode and prefix mode are supported. Note that prefix mode can only work if both sides of the connection follow the protocol.
Change AStream.InitializePrefix to AStream.Initialize to disable prefix mode.

jSerial depends on an open source project named JSSC: https://github.com/java-native/jssc

Updates:
v1.32 - Based on jssc v2.9.4.
v1.31 - Adds missing BAUDRATE, DATABITS, STOPBITS and PARITY constants.
v1.30 - Adds support for Java 11 and 64 bit computers based on: https://github.com/java-native/jssc

Instructions related to jSerial and B4J Packager 11: https://www.b4x.com/android/forum/threads/jserial-library.34762/post-735742
 

Attachments

  • B4J_Chat.zip
    1.7 KB · Views: 4,898
  • B4A_Chat.zip
    9.2 KB · Views: 2,918
  • jSerial.zip
    500.3 KB · Views: 1,257
Last edited:

jinyistudio

Well-Known Member
Licensed User
Longtime User

red30

Well-Known Member
Licensed User
Longtime User
Exchange is very slow - why? I connect microcontroller (USB CDC) to the android device (felUsbSerial library and USB) works fine. Rewrote the program on Windows, all the same only the exchange is very slow ... why?
 

red30

Well-Known Member
Licensed User
Longtime User
Can I work with this library by time out? T.m. I set the time (ex. 100 mls). When I get the first bit, I began to count time. When it is 100 mls, I transmete all that i have got.
 

roberto64

Active Member
Licensed User
Longtime User
Hi, who can help me, send SMS with B4j by connecting cn usb to a smartphone, I saw an example on B4R but I do not understand how to convert it to B4J.
regards
 

roberto64

Active Member
Licensed User
Longtime User
Hi Erel, the example of the first post B4j_Chat and B4A_chat putting them running at BA_Chat, clicking on the connect button can not find the port to connect to B4J_chart, in a few words it does not dial between PCs and smartphones.
regards
 

roberto64

Active Member
Licensed User
Longtime User
Hi, I'm looking for but in vain to connect with the B4J_Chat example with B4A_chat the two android devices with the pc, I also created the virtual serial port com virtual serial port but the two devices do not hook up, with B4A_chat when the button communicates to me That no device exists, on my device management as seen in the image the driver "SAMSUNG Mobile USB Composite Device" and "COM etc are the virtual ports" are where I am wrong or you can get help.
regards
 

Attachments

  • USBDISPO.png
    USBDISPO.png
    83 KB · Views: 449

roberto64

Active Member
Licensed User
Longtime User
If I connect to com5 from this error

B4X:
Waiting for debugger to connect...
Program started.
java.lang.RuntimeException: Message size too large. Prefix mode can only work if both sides of the connection follow the 'prefix' protocol.
    at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:214)
    at java.lang.Thread.run(Thread.java:748)
Error: (RuntimeException) java.lang.RuntimeException: Message size too large. Prefix mode can only work if both sides of the connection follow the 'prefix' protocol.
Connection is broken.
 

rtek1000

Active Member
Licensed User
Longtime User
I'm starting to get interested in b4j, this example was the first application I came into contact with.

The example worked fine, but I do not know how to edit the graphical part, b4J's version 5.82 IDE shows "Scene Builder Layout (deprecated)"

So I set up a new layout in case a newbie is interested in editing the new BJL file instead of the old FXML file.
 

Attachments

  • B4J_Chat_bjl.zip
    2.7 KB · Views: 561

javiman6969

Member
Licensed User
Longtime User
I have this problem too (std::bad_alloc).
Raspberry PI 2 with a USB Dongle,

Bus 001 Device 004: ID 0451:16a6 Texas Instruments, Inc. BM-USBD1 BlueRobin RF heart rate sensor receiver

I have correctly open /dev/ttyACM0 but closing the port, the result is (std::bad_alloc).

I use the last verison of JSSC
Any suggestion?

Thanks!


PD.: I can not find version 1.06 of jSerial for download. I have the version 1.05
 
Status
Not open for further replies.
Top