home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: OtherApp
/
OtherApp.zip
/
cm17ce.zip
/
fcinst.EXE
/
modctrl.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
2000-01-18
|
3KB
|
91 lines
/* MODCTRL.CMD - Controls module whenever this program is run. */
/*
Written by: Lone Peak Automation, LLC
Date: Jan. 15, 2000
This program requires the CM17A Comm Engine.
See http://home.att.net/~ASchw for more information.
Important: The CM17A Comm Engine must be running and be connected
to the X10 FireCracker before using this script.
This is an example to show how to access the CM17A Comm Engine functions.
*/
/* Load CM17A Comm Engine Functions */
call RxFuncAdd 'X10FLLoadFuncs', 'X10FLDLL', 'X10FLLoadFuncs'
call X10FLLoadFuncs
/* Load REXXUTIL.DLL */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
pipename = '\PIPE\CM17ACE' /* single backslashes only when using on single computer */
/* Note: If running over a network, precede the pipe name with the computer name as shown below. */
/* pipename = '\\CLIENT527\PIPE\CM17ACE' */ /* note the _two_ backslashes preceding the computer name */
rc = FCLOpenPipe(pipename)
IF rc = 0 then
DO
rc = FCLPeekPipe('0')
IF Right(rc, 1) = 3 THEN
SAY 'Connected to Comm Engine.'
ELSE
DO
SAY 'Comm Engine unavailable, closing.'
rc = FCLClosePipe('0')
SAY 'Press any key to exit...'
PARSE PULL keyhit
Signal ExitError
END
END
ELSE
DO
SAY 'Comm Engine not available.'
SAY 'Press any key to exit...'
PARSE PULL keyhit
Signal ExitError
END
/* change address, function and dim level here */
Module = 'A1' /* House and device code */
Command = 'ON' /* X-10 function: ON, OFF, DIM, BRI */
temp = '}ID1 ' || Module || ' ' || Command /* send command */
rc = FCLWritePipe(temp) /* write data to pipe */
Loop = 0
DO WHILE Loop < 5 /* wait for confirmation */
call SysSleep(1) /* wait one second */
rc = FCLPeekPipe('0') /* peek into pipe */
PARSE VALUE rc WITH rcPeekNPipe ' ' BytesWait ' ' PipeState
IF BytesWait > 0 THEN /* pipe has data */
DO
rc = FCLReadPipe('0') /* read pipe */
IF POS('{0 }ID1', rc) > 0 THEN /* no error */
DO
SAY rc || ' ' || Module || ' set to ' || Command
Loop = 10
END
ELSE /* Comm Engine reports errors */
DO
SAY 'Direct command ERROR: ' || rc
Loop = 11
END
END
Loop = Loop + 1
END /* While Loop */
IF Loop = 5 THEN
SAY 'Comm Engine did not respond. Time out.'
ExitNow:
rc = FCLClosePipe('0')
ExitError:
call X10FLDropFuncs
EXIT