From: Padraig Brady (padraig at domain antefacto.com)
Date: Wed 24 Apr 2002 - 12:06:50 IST
John P. Looney wrote:
> On Wed, Apr 24, 2002 at 03:31:34AM +0100, Tim mentioned:
>
>>>Can anyone advise me: How to call a 'C' program from Tcl ?.
>>>Alternatively, how can I add an extra port to the OS. I want to
>>>set/clear the watchdog on my sbc's. This resides at 0x443. I have a
>>>bit of 'C' code which does this, or if it works as a port, I can write
>>>to it directly.
>>
>
> Ah, don't bother with C. You can use 'dd'. Something like
>
> dd if=/dev/zero of=/dev/port skip=1091 count=1 bs=1
>
> should write 0 to port 1091 (0x443). Exec dd from TCL with exec..
>
> Kate
>
In fact we use 0x443 for our watchdogs also.
Here's the shell script (hopefully mozilla
doesn't mangle it).
Padraig.
#!/bin/sh
# Padraig at domain antefacto.com
#
# This supports Ibase MB700 and Advantech PCM9576
#
# You should "pat" this script from another
# every few seconds.
usage() {
echo "Usage: $0 [pat] [playdead]"
exit 1
}
if [ $# != 1 ]; then usage; fi;
if [ $1 != "pat" ]; then
if [ $1 != "playdead" ]; then
usage
fi
fi
HW_VERSION=`cat /var/run/HW_VERSION`
if [ "$HW_VERSION" == "IBASE MB700" ];
ENABLE_PORT=`printf %d 0x443`
DISABLE_PORT=`printf %d 0x441`
if [ $1 == "pat" ]; then
TIMEOUT='\x5' #20 seconds (0=30s, 1=28s, ..., F=0s)
printf "$TIMEOUT" | dd bs=1 seek=$ENABLE_PORT of=/basedev/port
2> /basedev/null
else
#write any value to port to disable
printf "\001" | dd bs=1 seek=$DISABLE_PORT of=/basedev/port 2>
/basedev/null
fi
elif [ "$HW_VERSION" == "Advantech PCM9576" ]; then
ENABLE_DISABLE_PORT=`printf %d 0x443`
if [ $1 == "pat" ]; then
TIMEOUT='\x14' #20 seconds (1=1s, 2=2s, ..., 3E=62s)
printf "$TIMEOUT" | dd bs=1 seek=$ENABLE_DISABLE_PORT
of=/basedev/port 2> /basedev/null
else
#read from port to disable
dd bs=1 count=1 skip=$ENABLE_DISABLE_PORT if=/basedev/port
of=/basedev/null 2> /basedev/null
fi
fi
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:16:21 GMT