Listing 2-Since the device is now accessible via TCP/IP, I can use scripting languages like TCL to control the device from several platforms. This program also runs under Windows or Linux without changes to test the logic engine interface.
# start socket to logic engine
set fd [socket "tmp2" 4321]
# turn on tristate buffers
puts -nonewline $fd "w00ffw01ff" ; flush $fd
puts [read $fd 4]
# now loop through a bunch of numbers
for {set d 0} {$d < 256} {incr d}{
# write the sequence
set p 4
while { $p < 16 } {
puts -nonewline $fd [format "w%02x%02x" $p $d ];
flush $fd; read $fd 2;
incr p;
}
# read and compare
set p 4
while {$p < 16}{
puts -nonewline $fd [format "r%02x00" $p ];
flush $fd
set y [read $fd 2]
set x [format "%02x" $d]
if {$y != $x}{
puts "data at $p read $y doesn't match written $x ."
}
incr p;
}
puts -nonewline "." ; flush stdout
}
puts ""
# OK, all done.
puts -nonewline $fd "q0000" ; flush $fd
puts [read $fd 2]
exit