Forums > Java

weather station into max

August 13, 2007 | 1:04 am

Hi,

Hi – mxj works! cool, but…

I have an issue that I could use some advice with:

Background on my project:

I have built a weather station (full of fun wind, solar, temp, etc.
sensors). This weather station uses the "1-Wire" system from Dallas
Semiconductors. The java code I am using is called "simpleWeather"
and comes from weathertoys.net.

I’m on an Intel Mac and using a Keyspan USB adapter as the serial port
to talk to my sensors.

The "simpleweather" java code uses two libraries (one for the serial
adapter and one for the 1-Wire devices), a class for each sensor
(currently 6 total), and a main class called simpleWeather. All of
the classes use a "package" called simpleWeather.

I have (with help) successfully gotten this to work in Max. I have an
object named "mxj simpleWeather.SimpleWeather" that takes a bang in
its inlet and sends the data from each sensor to its own outlet (6
total).

It’s finicky, but does work.

Here’s my problem. When I "bang" the object, Max freezes (spinny
wheel mode) for about 2.5 seconds, and then it gives me my data.

Do any of you have any suggestions for a way that I might be able to
access the data without stopping whatever process is happening in
max/jitter?

Do you need more info to answer this – if so what?

..or since it’s a serial port, am I better off trying to get the data
through the "serial" object? – tho I’m not sure I can convert/rewrite
the Java code in max.

thx in advance.

Bart


August 13, 2007 | 1:19 am

Sound like you need multithreading. Luckily in JAVA this is quite
easy. I’ve uploaded some code that is fairly straightforward and
shows how to do multithreading in JAVA. In particluar, look at the
FileUploader class. It inherits from runnable and has start(), run(),
and stop() methods for managing the thread it contains. You can take
this class, slap your serial/USB stuff in it and it shouldn’t block
Max anymore.

http://www.mat.ucsb.edu/~whsmith/AutoUpload.zip

wes


August 13, 2007 | 5:54 am

Great thx! I’m not exactly sure how to implement it, but let me hack
at it for a few days and see if/how it works. I also want to reread
some of the threading that is discussed in "Scheduler, Clocks, and
Executables, Oh My!" from the manual…

I might need to upload my main simpleWeather.java for you (or someone)
to see what’s all going on under the hood.

bbw

On 8/12/07, Wesley Smith wrote:
> Sound like you need multithreading. Luckily in JAVA this is quite
> easy. I’ve uploaded some code that is fairly straightforward and
> shows how to do multithreading in JAVA. In particluar, look at the
> FileUploader class. It inherits from runnable and has start(), run(),
> and stop() methods for managing the thread it contains. You can take
> this class, slap your serial/USB stuff in it and it shouldn’t block
> Max anymore.
>
> http://www.mat.ucsb.edu/~whsmith/AutoUpload.zip
>
> wes
>

bartwoodstrup.com
vodstrup.com


August 17, 2007 | 12:33 am

Hey Wes – thanks again. That was really easy to implement and worked great!

Bart

On 8/13/07, bart woodstrup wrote:
> Great thx! I’m not exactly sure how to implement it, but let me hack
> at it for a few days and see if/how it works. I also want to reread
> some of the threading that is discussed in "Scheduler, Clocks, and
> Executables, Oh My!" from the manual…
>
> I might need to upload my main simpleWeather.java for you (or someone)
> to see what’s all going on under the hood.
>
> bbw
>
>
>
> On 8/12/07, Wesley Smith wrote:
> > Sound like you need multithreading. Luckily in JAVA this is quite
> > easy. I’ve uploaded some code that is fairly straightforward and
> > shows how to do multithreading in JAVA. In particluar, look at the
> > FileUploader class. It inherits from runnable and has start(), run(),
> > and stop() methods for managing the thread it contains. You can take
> > this class, slap your serial/USB stuff in it and it shouldn’t block
> > Max anymore.
> >
> > http://www.mat.ucsb.edu/~whsmith/AutoUpload.zip
> >
> > wes
> >
>
>
> –
>
>
> bartwoodstrup.com
> vodstrup.com
>

bartwoodstrup.com
vodstrup.com


Viewing 4 posts - 1 through 4 (of 4 total)