'com_test.txt
const com_port = 1
'put a call to this in the HS startup script
sub startup()
dim e
e=hs.OpenComPort(com_port,"4800,N,8,1",1,,)
if e<>"" then
hs.WriteLog "comm_test","[Startup] Error opening COM" & com_port & ": " & e
else
hs.WriteLog "comm_test","[Startup] COM" & com_port & " opened."
end if
end sub 'startup
'put a call to this in the HS shutdown script
sub shutdown()
dim e
e = hs.CloseComPort(com_port)
if e<>"" then
hs.Writelog "comm_test","[Shutdown] Error closing COM" & com_port & ": " & e
else
hs.Writelog "comm_test","[Shutdown] COM" & com_port & " closed."
end if
end sub 'shutdown
'You can call this from an event or within another script
'assumes message_string = "address|command"
'address = "1" - "254"
'zone = "1" - "8"
'command = "ON" or "OFF"
'example: "32|1|ON"
sub send_command(message_string)
dim address_command
dim address, command, command_string, zone
address_command = split(message_string,"|")
address = cint(address_command(0))
zone = cint(address_command(1))
command_string = address_command(2)
if command_string = "ON" then
command = 3
else
command = 4
end if
command = command*16 + zone
hs.SendToComPort com_port,chr(64) & chr(address) & chr(command)
end sub 'send_command