JeeNodeIoCommander
Code: JeeNodeIoCommander_v20100321.pde (attached)
What:
charlies contribution to the JeeLabs universum:
Easy input output from/to JeeNodes (or JeeLink) using a simple serial command structure.
The command structure allows you to change the state of pin A and D of any JeeNode port.
Whether his is a local or a remote JeeNode port does not matter, this is handled transparently.
The only thing you need is a language which speaks serial, and a JeeNode/Link with the sketch.
No 'low level' programming needed to control the pins of a JeeNode, only serial interaction is needed.
Examples:
send serial: receive serial: Effect:
0.1.A.0! set pin A of port 1 on local JeeNode to 0
0.1.A? 0 returns the value of port 1 pin A
0.1.A.1! set pin A of port 1 on local JeeNode to 1
0.1.A? 1023 returns the value of port 1 pin A
0.3.D.1! set digital pin D on port 3 of local JeeNode to 1
0.3.D? 1 return value of D on port 3 (local JeeNode)
13.1.A.1! set pin A on JeeNode with ID 13 to 1
13.1.A? 1023 return the value of the remote JeeNode 13 port 1 pin A
13.3.A.analog? 1023 idem
0.1.A.digital? 1 return digital value 1 or 0, of analog pin A
0.3.A? 710 returns analog value of port 3 in A
? 712 executes and returns last get action
? 713 idem
? 715 idem
space " " reset the command parser, make it ready for next command
\n idem
Discussion/Feedback
http://talk.jeelabs.net/topic/175#post-859
The Sketch:
Can be found at the top of this page.
You will need to load it in at least one JeeNode. It will also work in JeeLinks, of course no pins can be set there, but you can use it to remote control other JeeNodes. Be sure to use the RF12demo first to set a correct id and group in the JeeNode EEPROM.
Why:
I had/have a home monitoring system up and running using a PIC. Which I want to replace with a, what do you think, JeeNode. The reason for changing something that is working with something else is two fold. One reason is that the current implementation runs off an EasyPIC4 prototype board which is now 'the system'. And it is rather big and clumsy. Two is that JeeNodes offer RF12 which means cheap RF control! So now, I hope to replace all current hardware with a JeeNode or two.
Why:
There is "Firmata" around for Arduino? Did you not hear of that? Sure! It looks nice! And I got to know through one of my posts on JeeTalk [link] But, I was not interested. It has potential, definately, but not for my purpose. I was not after maximizing data throughput, I was just after simple serial control of a JeeNode. It had to be easy to remember, allow for a lot, and do the remote thing.
Why:
This thing implements a PULL system, you need to initiate the transaction before something happens in the JeeNode. This is kind of the opposite of what jcw is doing, there everything is PUSH. The rooms.pde are designed to consume very few power and run of battery for centuries, your JeeNode will drain in a day. Yes, thats true! I won't use the JeeNode only in my PULL-oriented home monitoring system, no, in he back of my mind I was also thinking of a tool which I can use to poke around with in any circuit. The 'poor man's oscilloscope, remote control, remote text...
Why:
I was fascinated by the "firmata" "processing" combination. But I'm not a Java type of person. I like it, but it's not fast enough. Fast is defined as in speed of implementation. If I want to do something, just as a hack, I use Tcl. [link]. As for speed, execution speed, if it really needs to be fast, then neither Java nor Tcl will survive.
And if you do like Java or any other language more then go ahead, it's just serial what you need here! Simple serial input output. No binary parsing involved.
Use PUTTY, HyperTerm or TeraTerm or RealTerm for the 'Real'-nerds if you are into real hands-on JeeNode.
Why:
I know, my code does not look very nice, all suggestions welcome. It was a long time since I did some C/C++, and before that I never really did C/C++
Why:
There is no space or \n between the return values? Indeed, currently not. The idea is that if you issue a "?" something comes back immediately. Any controlling software (talking serial) can read all characters 150ms after the ?, this will contain the answer.
Why:
This will be so slow! Probably, still need to test this. By design it can go much faster (think Firmata again) but I was after functionality.
20100321 charlie - This is an example of a "Closed Loop" communication system as categorised by pbadger in Communication schemes
(From ProjectForum - Created by charlie)