B4J Library jSerial library

Status
Not open for further replies.

rdkartono

Member
Licensed User
Hi Erel,

Set Parameter already correct (4800 bps, 8 bit, 1 stop bit, None parity), because i already can read GPS string correctly. I can get correct Time, Longitude, and Latitude string. This port (/dev/ttyAMA0) is the result from "dmesg | grep tty".
I tried calling GPS_PORT.PurgePort(GPS_PORT.PURGE_RXCLEAR) everytime AsyncStreams.New_Data event triggered (after i get the data), yet still after few seconds std::bad_alloc still showed.
I tried polling to serialport bytesavailable value using a timer with interval 1 ms, yet bytesavailable always return 0.
I tried to wrap serial port inputstream to TextReader, yet also no data available.

It seems that AsyncStreams.New_Data event is the only way to get serial data, yet it is unstable.

Please advice more.
Thanks.
 

a_carignan

Member
Licensed User
I can not connect the two software together. on the phone, it displays an error connecting to the computer and it shows no wear.
 

alexhi

Member
Licensed User
sp.Open(cmbPort.Value) Works in Windows but does not work Mac OS , in Mac OS X 10.9 receives NULL
 

wonder

Expert
Licensed User
I need help! :(

I did everything right, paired my phone with the PC. Added a COM port and tried to connect.
When I choose my PC name, I get a pairing request on my phone, which after one second disappears and I get a "connection reset by peer" java.io error.
I've tried the prefix and standard mode, recompiling both B4A and B4A apps. HELP! :(

 

SimonElck

Member
Licensed User
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: http://www.b4x.com/android/forum/threads/jbluetooth-library.60184/)



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: http://code.google.com/p/java-simple-serial-connector/ (the jar file is included in the zip file).
I compiled this program an ran it.
It works fine, BUT
as soon as I make an installable version with packager, it does not work anymore.
It quits at the line sp.Open(cmbPort.Value)
Even when I put it in a try /catch it quits
Again the prog works fine when I run it, either debug or release.
It has nothing to do with readonly files either.

Please help, I'm stuck!
 

SimonElck

Member
Licensed User
Thanks Erel,
It's going to be a bit awkward for my users.
Will the packager installed Java still be sufficient when going this way, or will the end-users have to install jre or something?
 
Status
Not open for further replies.
Top