WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Serial
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

X-10 Control Sample Script from User

Keywords:    X10  x 10

See also:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/Serial+X-10~Control~Sample~Script~II.txt

This works for turning ON/OFF a device on A3. It's ugly, but it does work.

*******************************************
AddExtender("wwser34I.dll")
port=pComOpen("COM1",0,4800,"8N1","NONNON")
pTimeout(port,2000) 

pPutByte(port,195) ;House code / Device Code

Header = 4
Send = 6
A3 = 98
ON = 98
OFF = 99

getbyte = -1
while getbyte == -1
pPutByte(port,Header) ;Header -- Address a Unit
pPutByte(port,A3) ;House code / Device Code
Gosub WaitForAck ; Wait for Checksum
EndWhile

pPutByte(port,0) ; Send Ack
Gosub WaitForAck85 ; Wait for 0x55

getbyte = -1
while getbyte == -1
pPutByte(port,Send) ; Header -- Send Function
pPutByte(port,ON); House Code / Function
Gosub WaitForAck ; Wait for Checksum
EndWhile 

pPutByte(port,0) ; Send Ack.
Gosub WaitForAck85 ; Wait For 0x55
pComClose(port,0)
Message("Interface","Complete")
exit

:WaitForAck
start=TimeYmdHms( )
Now=TimeYmdHms( )
diff=TimeDiffSecs(Now, start)

While diff < 4
getbyte=pGetByte(port)
Now=TimeYmdHms( )
diff=TimeDiffSecs(Now, start)
If getbyte > -1 then break
Endwhile
Display(1,"Interface",getbyte)
Return

:WaitForAck85
start=TimeYmdHms( )
Now=TimeYmdHms( )
diff=TimeDiffSecs(Now, start)
While diff < 4
getbyte=pGetByte(port)
Now=TimeYmdHms( )
diff=TimeDiffSecs(Now, start)
If getbyte == 85 then break
Endwhile
Display(1,"Interface","Ready")
Return

Article ID:   W12583
Filename:   X-10 Control Sample Script.txt
File Created: 2014:06:17:14:12:42
Last Updated: 2014:06:17:14:12:42