Fighting with Serial Communications

Grrr...
Java is multi-platform .... Yay !
Java runs on all sorts of operating systems, anything which can run a JVM ... Yay !
Mac 32/64, Windows 32/64, Linux 32/64, Arm 32, .. write code once, and it runs on all platforms ... Yay !
But in some cases, we need to talk to the hardware directly ...  Uh oh...
This means someone has to write a C program which works as a bridge between Java & the hardware .. Uh oh
C programs are not binary compatible .... Grrr
C source programs are often not compatible on different platforms ....  Grrr
This makes Java talking over a serial line robustly & consistently in a standardized way very difficult ... Grrr
There is a project called RXTX from qbang which is old (very old in software years) - which tries to make sending data over a serial line from Java easy .... Yay !
But the code is so old, fragile, and full of holes that there are issues on different platforms..  Linux serial ports never close for instance, and there are race conditions and deadlocks ... Grrr.
Qbang / RXTX - seem basically dead as far as development ... Grrr
So, now I'm trying to get another project called JSSC to work ... Yay.. 
But, unfortunately, I'm getting some weird results on Windows 7 64 bit ..  Grrr  
The trace shows output from a Arduino Mega card - "occasionally" - every other data read comes back as 1024 :P ... Grrr

Was hoping JSSC was going to be a magic bullet ... doesn't look like it ... Grrr

Hmmm...  just thought, this might be because JSSC is not ready when I read the data - the "data ready" notification is slightly different in JSSC versus RXTX...  I don't want to spend much more time (at this time) on this - fortunately, I've created a SerialDevice abstraction which interfaces with JSSC or RXTX - and allows me to switch them out easily.

Back to RXTX for a while and I'll look at the closing issue a little more closely... then, put it on the back burner for a while...


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Schlick's picture

quest...

But in some cases, we need to talk to the hardware directly ...  Uh oh...
This means someone has to write a C program which works as a bridge between Java & the hardware .. Uh oh

 Hey,

What exactly are you looking for here Grog?

 

 

GroG's picture

Heh, I'm looking for a

Heh,

I'm looking for a stable, open source JNI Serial library for Java... Something where the maintainers create and distribute good binary releases for all the relevant platforms inclusive of (x86.32.linux, x86.64.linux, x86.32.windows, x86.64.windows, x86.32.mac, x86.64.mac, arm.32.linux, & arm.64.linux)

Know of any such libraries?

Schlick's picture

aahhhh, lemme see what I have

aahhhh, lemme see what I have in the garage.....

ummm, nope!

.... that's a bit past me.