Computing stuff tied to the physical world

JeeMon for early birds

In Software on Nov 25, 2011 at 00:01

Time to dive in. Let’s create a development setup for JeeMon on Mac OSX, in a new folder called “jee”:

    cd ~/Desktop
    git clone git://github.com/jcw/jeerev.git jee
    cd jee
    wget http://jeelabs.org/pub/jeemon/jeemon-macosx.zip
    unzip jeemon-macosx.zip

That gives me the following files:

Screen Shot 2011 11 23 at 23 21 47

There is more here than strictly needed for production use – just ignore most of this for now. The main bits are “jeemon” and the “kit/” sub-folder with all the JeeRev code in it.

On Linux, the commands will be almost the same, but you’ll need to get a different JeeMon zip file.

Since I don’t use Windows myself, I’ll have to rely on help / support from others (yes, you!) to get the details right. Thanks to @tankslappa, here’s a first report of an install on XP SP3:

cd %homepath%\desktop
“C:\Program Files\Git\bin\git” clone git://github.com/jcw/jeerev.git jee
Cloning into jee…
remote: Counting objects: 1810, done.
remote: Compressing objects: 100% (670/670), done.
remote: Total 1810 (delta 1187), reused 1742 (delta 1119)
Receiving objects: 100% (1810/1810), 1.45 MiB | 87 KiB/s, done.
Resolving deltas: 100% (1187/1187), done.
cd jee
wget http://jeelabs.org/pub/jeemon/jeemon-win.zip

Then unzip using your favorite zip manager, and you should be good to go (I’ll optimize further, one day).

Note: on Mac OSX and Linux, if “.” is not in your path, you’ll need to add it or type “./jeemon” i.s.o. “jeemon” everywhere it is mentioned below.

At this point, JeeMon is ready for use. There are a few built-in commands – here’s a quick sanity check:

    jeemon env general

The output provides some general details about the current runtime environment:

    GENERAL:
           JeeMon = v1.5
          Library = /Users/jcw/Desktop/jee/kit
         Encoding = utf-8
        Directory = /Users/jcw/Desktop/jee
       Executable = /Users/jcw/Desktop/jee/jeemon
      Tcl version = 8.6b1.1

If you got this far, then everything is working as intended. If not: you’ve hit a bug – please get in touch.

But the normal procedure is to simply launch it:

    jeemon

If this is the first time, you’ll get something like this:

    No application startup code found.
    21:22:29.157      app is now running in first-time configuration mode
    21:22:29.189      web server starting on http://127.0.0.1:8181/

Where “first-time configuration mode” means that JeeMon didn’t find a “main.tcl” rig, which is normally used to start up. To get past this step, you need to point your web browser to the indicated URL, which’ll show this page:

Screen Shot 2011 11 23 at 21 28 54

There’s not much point in selecting anything else but “YES”at this stage. This creates a 3-line “main.tcl” file:

    # default JeeMon startup file
    Log main.tcl {in [pwd]}
    Jm needs HomeApp

From now on, JeeMon will start up using the built-in “HomeApp” rig when there are no command-line args.

The next steps depend on what you’re after – you can either dive into Tcl programming and explore how JeeRev (i.e. the kit/ area) is structured, or you can try out some examples and get a more top-down impression of it all.

To explore Tcl, the thing to keep in mind is that JeeMon will act as a standard no-frills Tcl 8.6 programming environment when launched with a source file as argument (just like tclsh and tclkit). Here’s how to make a hello-world demo – create a file called “hello.tcl” with your favorite text editor and put the following code in it:

    puts "hello, world"

Then run that code using the command “jeemon hello.tcl“. You can probably guess what it does…

If you want to use a convenient interactive shell with scrollback, history, and debugging support, download the TkCon script and launch it using “jeemon tkcon.tcl” – this uses Tk to create a mini IDE.

For Tcl manuals, books, and demos, see http://www.tcl.tk/. To really dive in, check out this tutorial or this.

But chances are that you just want to get an idea of what JeeMon does in the context of Physical Computing, House Monitoring, or Home Automation. I’ll describe just two simple examples here, and will point to the JeeMon homepage for the rest. Note that everything described below is really part of JeeRev, i.e. the standard library used by JeeMon – or to put it differently, by the source files located inside the “kit/” folder.

First, let’s launch a trivial web server (you can see the code at examples/hello-web/main.tcl):

    jeemon examples/hello-web/

You’ll see a log output line, similar to this:

    18:23:46.744      web server starting on http://127.0.0.1:8181/

JeeMon is now running in async event mode, and keeps running until you force it to stop (with ^C, kill, whatever). Leave it running and go to the indicated URL in your browser. You’ll be greeted with a web page generated by JeeMon. Hit refresh to convince yourself that it really works.

Now quit JeeMon and check out the files in the “examples/hello-rf12/” folder. This example connects to a JeeNode/JeeLink running the RF12demo sketch, and displays incoming packets via its web server. But before launching JeeMon, you have to tell it what serial interface (COM or tty port) to use: copy “config-sample.txt” to “config.txt” and edit it to match your setup. Make sure the JeeNode/JeeLink is plugged in, then start JeeMon:

    jeemon examples/hello-rf12/

The output will look something like this:

    18:37:57.166      web server starting on http://127.0.0.1:8181/
    18:37:58.154    rf12? [RF12demo.8] A i1* g5 @ 868 MHz 
    [...]

And two dozen more lines which you can ignore. Now go to that same URL again with your web browser. If your config file defines the proper net group and you have some JeeNodes sending out packets in that net group, you’ll see them in your browser after a while. This is what I got within a few minutes, here at JeeLabs:

    #1 18:42:21 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #2 18:42:31 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #3 18:42:44 - OK 3 132 43 9 0
    #4 18:42:51 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #5 18:43:11 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #6 18:43:21 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #7 18:43:29 - OK 6 1 95 212 0
    [...]

Now might be a good time to look at the code in examples/hello-rf12/main.tcl – to see how it all works.

Wanna experiment? Easy: quit JeeMon, create a new directory “blah“, and copy the files from the example to it. Edit them as you like, then start JeeMon using “jeemon blah“. Go ahead, try it! – the worst that can happen is that you get error messages. Usually, error tracebacks will refer to JeeRev files in the “kit/” folder.

This concludes my intro for those who want to get their feet wet with JeeMon. We’ve only scratched the surface!

I’ll work out more examples on the JeeRev page as I start building up my own setup here at JeeLabs. If you want to try things and run into trouble (there will be rough edges!) – here are two places to post problems and bugs:

Feel free to ask and post anything else on the forum. If it gets out of hand, I’ll set up a separate area for JeeMon.

A quick note about the Shop: I’m running into some shortages across the board (such as wire jumpers), which also affect the JX and WSP packs. All the missing bits are on order, but some of this might not get in before early December. My apologies for the delay and inconvenience! -jcw

  1. Just a quick addition to the windows instructions. In windows you don’t need the ./ at the beginning of the JeeMon commands. Windows searches the current dir by default before searching the path. *nix just searches the path unless you explicitly tell it to look locally with ./

    You also need git installed. If it’s not installed in

    "c:\program files\git"
    you will need to change the path in the second line to point to the correct git.exe location on your machine.

    For x64 windows systems, change use

    wget http://jeelabs.org/pub/jeemon/jeemon-win64.zip

    I think that’s it!

    TankSlappa likes the new edit feature as it means he can play with the format of his message :-)

    • Thanks. I’ve changed the post to make it the default, with a note about “.” being in the path on Mac OSX and Linux.

    • ooops, I have a confession… I just tried the same on Win7 x64… wget wasn’t recognised. Which puzzled me, so I went investigating how it worked on my XP machine.

      It’s in cygwin which I have installed… Whilst this is not at all a bad thing, it’s not something which many will have, which means the wget command won’t work.

      d’oh!

    • Yee, weird huh, no wget for Windows 7 x64!

      But there is wget64 (from 2005!!), works as a treat:

      C:\>wget64 http://jeelabs.org/pub/jeemon/jeemon-win64.zip –08:56:27– http://jeelabs.org/pub/jeemon/jeemon-win64.zip => `jeemon-win64.zip’ Resolving jeelabs.org… 188.142.57.184 Connecting to jeelabs.org[188.142.57.184]:80… connected. HTTP request sent, awaiting response… 200 OK Length: 2,195,969 [application/zip]

      100%[====================================>] 2,195,969 1.07M/s

      08:56:29 (1.07 MB/s) – `jeemon-win64.zip’ saved [2195969/2195969]

  2. Okay… Minor save… you can get wget for windows here:

    http://sourceforge.net/projects/gnuwin32/files/wget/1.11.4-1/wget-1.11.4-1-setup.exe/download

    Unfortunately it doesn’t add itself to the path, so you either need to do that yourself

  3. You don’t need wget. Use your browser to select the correct Jeemon for your OS/processor from http://jeelabs.org/pub/jeemon/ and it should download the file for you.

    • I know, I was just trying to find a comparable step by step guide for windows. It’s odd really, the windows user has to use the GUI, whereas the Mac users use the command line!

      You end up having to use the GUI in windows to open the zip anyway as there is no built in zip handling from the command line. Even winrar’s command line can’t handle zips, only rars, whereas the winrar GUI can do pretty much everything. Weird eh!

  4. GUI should be fine, since that’s where you are already when reading this post. So a link which downloads and then double-click to unzip would be fine. The trick is to fetch the git area first, so that the instructions can say “move the exe you got into that jeerev checkout you did”.

    At this stage, JeeMon is only for developers, so it’s important to use git (IMO) – command-line or otherwise (isn’t there a tortoise-git or something?). It’d be relatively easy for me to create a zip snapshot with everything in it, and say “unzip and double-click jeemon.exe”. But the goal here is not just to get everything right, but to also get the process in place which supports development, updates, check-ins, patches, diffs, etc.

    Or in short: this isn’t about getting a fish (once), but about learning to fish (forever).

    PS. If a separate page with screenshots etc is needed, fine. Plenty of free bits available on the wiki.

  5. Thanks for the interesting, useful, complex yet nice series of JeeMon. It clarifies various bits involved in the setup nicely.

    About fishing… very grateful, nice to be re-learning to fish again here! This all involves so many different methods, hw/sw/languages that, for someone like me, it’s a totally new adventure. I hope you/we get to share the developments related in the wiki or future blog posts.

    BR, Zooer

Comments are closed.