We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Serial class problem? (Read 3130 times)
Serial class problem?
Dec 12th, 2008, 3:09am
 
I've ported Processing 1.0.1 to opensolaris, and have been
using it with XBee receivers.  It was fairly easy
to get things to build and work - I used the platform
Java implementation, and scooped up JOGL and librxtx from
the usual places.  librxtx was actually the most work ..
but that's another story.

I'm impressed - this is a cool system you guys have built.

One particularly tricky problem I had seems to be
with the Serial class - I could see characters being
delivered to the buffer, but every time my applet
went to look for them, there was nothing there.

After tearing my hair out a bit, I did the usual
println thing, and eventually discovered that while
the serialEvent method was being called repeatedly
delivering data to the buffer, the available() method
only ever returned zero to its caller - until,
of course, I added a println in *that* method, and
everything started working.

So, given I'm trying all this on a four core AMD box,
and both opensolaris and Sun's Java are good at
exposing concurrency to applications, I began to
wonder if there's a race condition problem?

Specifically, the serialEvent method manipulates the
buffer array and bufferLast and bufferIndex under
'synchronized(buffer)', while available() uses no
synchronization whatsoever.  Thus available()
can observe the bufferLast and bufferIndex variables
in an inconsistent state.

Then I took *all* the println's away, and simply wrapped
the body of the available() method in synchronized(buffer)
and everything kept on working.

Maybe this is using a sledgehammer to crack a nut,
but my XBee experiments are working just fine now.

If this is indeed the problem, I wonder if there's a
better/more elegant/more efficient way to ensure that
the buffer and its indices are kept in a consistent
state?

Comments?
Re: Serial class problem?
Reply #1 - Jun 11th, 2009, 5:11am
 
Hi tpm, I'm looking to build processing on openSolaris 0906, and was wondering if you could assist by providing details of your build method? Any help would be appreciated.
Re: Serial class problem?
Reply #2 - Sep 4th, 2009, 9:46am
 
It was really easy to build and run the Linux version on OpenSolaris 0906.  

Code:
cd processing/build/linux
pfexec ln -s /usr/java .
cd ..
./make.sh
./run.sh


If you're interested in packaging it for Opensolaris and have any familiarity with RedHat/SuSE style .spec files, try our online build and review environment at jucr.opensolaris.org.  As a Sun employee, there's lots of paperwork I'd have to go through to submit it myself, but if anyone else is inclined, I'd vote for it!  BTW most well-written Linux apps and most well written Java apps will run fine on OpenSolaris.  OpenSolaris tends to be stricter than Linux, but if you're a good coder, that won't bother you!
Page Index Toggle Pages: 1