[Copying my reply to this thread -- we'll see if we can keep it all on
this thread!]
One of the problems with using the Arduino as an HID device is that
it's an extra step for existing Arduino users to do before they would
be able to use your applet. To turn the Arduino into an HID device you
need to flash new firmware onto it using an AVR-ISP programmer, which
isn't part of most people's Arduino kit, and you can no longer use the
USB to upload sketches, so you need to keep switching back and forth
between the HID firmware and the default usbserial if you're
developing on the Arduino.
That said, the advantage is that, once you turn your Arduino into an
HID device, you would be able to use it on any computer without
needing to install Arduino's serial driver.
So if the plan would be to pre-build x Arduinos ahead of time and send
them out to schools or something, then HID may well be the best way to
go. If the plan is to be able to appeal to people who already use
Arduinos (and so already have the drivers installed) and who want to
be able to plug in their devices and instantly see graphs in a
browser, I feel like using the traditional USB serial output would be
best.
I've started experimenting with the non-HID Arduinos, and have had
success communicating with the Arduino in my Java IDE using the RXTX
Java library,
http://rxtx.qbang.org/wiki/index.php/Main_Page. There's
a simple example you can use to get started in the Java Interfacing
section of the Arduino site,
http://arduino.cc/playground/Interfacing/Java.
I was planning on spending a little bit of time working out how to
integrate this into our sensor project to be used in an applet.
Sam
On Mar 15, 11:25 pm, Stephen Bannasch <
stephen.banna...@deanbrook.org>
wrote:
> At 12:55 PM -0400 3/13/12, Peter Malcolm <
peter.t.malc...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> >Hi Stephen,
>
> >I hope this email finds you well. I met you at the EduCoder retreat in January, and was very intrigued by all of the work you
> >are doing and have done with the Concord Consortium -- probeware, graphing and html5. For my graduate assistantship, I'm
> >doing work that overlaps with this in a lot of ways, and I would love if you had the chance to give some advice.
>
> >I am working with my friend Caner (cc'd here) on an interface that communicates between the Arduino and a browser. We are
> >scaling up to including this in WISE / WISEngineering.
>
> >The attached image shows an overview of the techniques we have been using. We have managed to put together a system that uses
> >Flash, but we have found it to be unreliable and we are currently trying to move away from Flash.
>
> >As a replacement, we are investigating Java. I remember your advice was to try to:
> >A) treat the Arduino as an HID device
> >B) develop nar files
> >and
> >C) incorporate the JNA so as to talk to DLL's.
>
> >I'm weak in C and know nothing about .NET, and I feel a little overwhelmed. If we decide to stick to just Java and JNLP (with
> >maybe some Processing for the Arduino) do you think this could still be done?
> >I have toyed with your code here a little bit:
> ><
https://github.com/stepheneb/lightweight-sensor-graphs/blob/master/pu...>
https://github.com/stepheneb/lightweight-sensor-graphs/blob/master/pu...
> >As a place to get started. Is there a place I could pull down some of the sources for the JNLP files to start tinkering with
> >those?
>
> >Any advice you have on this would be greatly appreciated. Once we get some traction, we will put this up on github and move
> >the conversation to wise4dev.
>
> Hi Peter,
>
> I am cc'ing this to our public cc-developers email list (you are welcome to subscribe) because we have an ongoing conversation
> there about working more with Arduinos and also to our public org-concord-sensor list (discussion about the Java code for
> talking with sensors).
>
>
http://groups.google.com/group/cc-developers
>
http://groups.google.com/group/org-concord-sensor
>
> Here's a bunch of stuff to get started with.
>
> The Vernier GoIO interface uses the USB HID protocol and there is a full open stack of Java and C code for communicating with
> it -- so it makes a great deal of sense to use these collection of resources as a pattern.
>
> Buy or acquire a Vernier GoTemp (about $40) -- that way you can easily test some of the stuff I am going to describe below.
>
> Get an updated version of eclipse with m2e maven integration and egit installed and clone this repo:
https://github.com/concord-consortium/sensor-projects
>
> That has all of our sensor code written in Java and using JNA to talk to C libraries which talk to drivers that communicateto
> probeware interfaces.
>
> Now get our sensor-project collection of projects building on your system. The important ones are sensor, sensor-vernier, and
> goio-jna.
>
> Try running the test program in sensor-vernier for testing the goio (GoTemp) probe you now have.
>
>
https://github.com/concord-consortium/sensor-projects/blob/master/sen...
>
> That uses the goio-jna project for talking to the Vernier GoIO interface.
>
>
https://github.com/concord-consortium/sensor-projects/tree/master/goi...
>
> JNA is a MUCH more civilized way to communicate between Java and C then the older JNI system.
>
> A folder included in the goio-jna project at the top level is GoIO_SDK. This is a copy of the public domain Vernier GoIO
> SDK. Vernier made the complete GoIO SDK public domain. This includes the low-level C code that communicates over HID.
>
> I maintain a git clone of The Vernier GoIO SDK here:
https://github.com/concord-consortium/goio_sdk
>
> Here's the low-level C code for Mac OS X (there is also code for Win32 and Linux) for communicating via the built-in USB HID
> interface to a Vernier GoIO (like the GoTemp I suggested you buy).
>
>
https://github.com/concord-consortium/goio_sdk/tree/master/src/GoIO_c...
>
> Download this repo get it building and get it's test programs working with your GoTemp.
>
> Now you have both source and working C code for talking to a specific type of USB HID device.
>
> This code probably does MUCH more than you need to do at the start but it's very useful to have all this working code to
> examine.
>
> Mow start at the other end.
>
> Put your Arduino into the mode where it uses HID and write the smallest C program to read some lind of data from it. If your
> Arduino won't do this get a newer one that will.
>
> Now fork the sensor-projects repo and make a new arduino-goio project by copying the structure of the goio-jna .
>
> Determine the minimal set of functionality you need to implement to connect the java code to your C code. You may need to
> extend the C driver you created.
>
> It would be great if you also included your C project in your fork of sensor-projects. In general we are just using windowsand
> macos shared libraries and header files with the Java projects -- but it would make a very nice example if the C code for a
> simple driver to a USB HID arduino device was there too. That makes it much more likely that other folks can contribute to the
> project.
>
> Once you have the arduino-jna project working see if you can create a sesnsor-arduino project by reproducing the goio part of
> the sensor-vernier project. With this working you'll have something that you can now use easily from Java ... but you can also
> make an invisible Java applet to talt to the Arduino and use the browser instead of development.
>
> We have a new project funded by a grant from google that's working on making an HTML5 modeling and probeware workbench. This
> is(and will be) ALL open source code that anyone can use.
>
> Here's the developer landing page:
http://lab.dev.concord.org/
>
> Most of our work so far has been creating an HTML5 computational simulation of molecular dynamics by re-creating our Java
> application called Molecular workbench ... but the projects goals are more than just molecular dynamics, we want to create
> amore general modeling workbench by including thermodynamic simulations and others.
>
> You can see an example of the current form of the molecular simulation here:
>
>
http://lab.dev.concord.org/examples/complex-atoms-model/complex-atoms...
>
> As part of this work we have developed much better graphing tools for showing data streams from models or sensors.
>
> Here's a simple extracted example of the basic grapher features:
http://bl.ocks.org/1920939(code:https://gist.github.com/1920939).
>
> Recently I have made a prototype using some of the grapher code connected to a model running in a NetLogo applet.
>
> demo:
http://stepheneb.github.com/netlogo-gcc/index.html
> code:
https://github.com/stepheneb/netlogo-gcc
>
> I mention this to show how the grapher code can be easy in integrate with something else that produces data and ALSO as a
> smaller example of communicating with an applet (in this case NetLogo).
>
> There are all sorts of tricky annoying bits getting Java <=> JavaScript communication working reliably. I recently described
> some of how we communicate between JavaScript <=> Java applet in our sensor-applets code on a thread on the netlogo-devel list:
>
> Subject: Here's what we did in our sensor-applets work:
http://groups.google.com/group/netlogo-devel/browse_thread/thread/6ab...
>
> I'd like to setup a separate project just for testing and developing ways to communicate reliably between JavaScript in
> thebrowser to a Java applet. The idea is to have an applet that can respond immediately and also create threads that will
> senddata toJavaScript callbacks and then integrate this with tools which can automatically run integration tests using the
> applet in multiple browsers and multiple operating systems and multiple versions of Java. This is a complicated problem --
> which is why it would be nice to develop and test this in isolation from the actual work and code to communicate with devices.
>
> We plan to integrate probeware using some of the techniques showcased in an early form here:
>
> demo:
http://jnlp.dev.concord.org/goio-temperature-graph.html(works with a GoTemp)
> code:
https://github.com/stepheneb/lightweight-sensor-graphs (*most of the code, see below)
>
> In the short-medium term communication will need to be via an invisible Java applet -- but we have hope for getting access to
> USB in the browser and being able to build up a library for accessing probeware from the browser without using Java.
>
> The existing applet code for communicating to the Vernier GoIO interfaces is located in this project:
>
>
https://github.com/concord-consortium/sensor-applets
>
> This is a git mirror of the code in our subversion repo here:
>
>
http://svn.concord.org/svn/projects/trunk/common/java/sensor/sensor-a...
>
> This code wasn't copied to the new git sensor-projects repo because it also depends on a bunch of code in our much larger
> otrunk framework.
>
> I'd like to recreate an invisible applet using just code available in the sensor-projects repo.
>
> I recently described some of how we communicate between JavaScript <=> Java applet in our sensor-applets code on a threadon
> thenetlogo-devel list:
>
> Here's what we did in our sensor-applets work:
http://groups.google.com/group/netlogo-devel/browse_thread/thread/6ab...