some demo code you can try

bob fcsoft-3Emkkp+1Olsmp8TqCH86vg at public.gmane.org
Mon Aug 8 20:43:42 UTC 2005


Some of you may have attended our presentation at KWLUG back in May.

Graham (the engineer at IO Anywhere) has informed me that the latest IOA box 
installed at the "Try Me" tab on the IOA webpage (http://www.io-anywhere.ca) 
is their microIOA.     This has been setup to read a temperature in their 
offices in Kitchener.

This microIOA box is also accessable via the SIMPL protocol 
(https://sourceforge.net/projects/simpl) so you can actually write local code 
to read this temperature across the Internet.

For the demo code below to run you'll need to be certain to have the 
following packages installed on your Linux box:

a) Tcl/Tk
b) SIMPL
c) IOA library (http://www.allstream.net/~fcsoft/ioanywhere)

b) and c) are very basic source tarballs that require that you create a 
couple of environment variables to allow them to operate.

You can check out lesson #12 at for more info on how to do this:

        http://www.icanprogram.com/34ux/main.html

To get this demo to work all you need to do is run the SIMPL network 
surrogate processes as they are described in the lesson  (you'll may need to 
open up ports 8000-8002) .

Once these are up and running you should be able to run the program below as:

        wish    whateveryoucalledit.tcl

As you can see this code is really very small,   which is testimony to the 
powerful encapsulation offered by the SIMPL library itself.

Have fun.

bob
PS.
SIMPL has Python hooks built into it.     I'd love to see someone create the 
equivalent Python demo.


============= code snip starts here ================

#!/usr/bin/wish
#=================================================
# demo script for temperature reading
# version 1
#=================================================

set this "kwlug"
set TRACE_MASK(MISC)    0x10
set logMask 0xff

set myparam(temp.value) 0x0
set myparam(temp.label) .label
set myparam(temp.button) .ioa

lappend auto_path $env(SIMPL_HOME)/lib
lappend auto_path $env(IOANYWHERE_HOME)/library/lib
package require Fctclx
package require ioalib

#========================================
# read the temperature
#========================================
proc readTemp { } {
global myparam

read_tc_IOA 1 2 retVal

binary scan $retVal s1 mytemp

$myparam(temp.label) config -text [format "%d C" $mytemp ]

} ;#end readTemp

#============================================
# main
#============================================
wm geometry . 200x100+200+0
wm title . "Temperature Demo"
wm resizable . 0 0

label $myparam(temp.label) -text "0 C"
place $myparam(temp.label) -x 40 -y 20
button $myparam(temp.button) -text "grab temperature" -command [list 
readTemp] 
place $myparam(temp.button) -x 40 -y 40

button .quit -text Quit -command {set x 1}
place .quit -x 150 -y 75

name_attach KWLUG

set loggerID [name_locate LOGGER]

#init_IOA BOBS
init_IOA 65.48.172.249:IOA_temperature

vwait x

name_detach

exit

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list