Switching a Dataprobe iP-415/815 (basic) using TCP

yaipa yaipa at yahoo.com
Thu Aug 10 20:57:13 EDT 2006


>---<snip>---<snip>---<snip>---<snip>---<snip>---<snip>---<snip>---<
#!/usr/bin/env python

import socket
import sys, time

# ----------------------------------------------------------
# File: dataprobe.py
# Author: Alan Haffner
# Date: 2006-08-10
# Rev. .60
#
# Tested on Linux only
#
#  Usage: dataprobe.py <command>
#
# $>  dataprobe.py 5P 4
# $>  11110111
# $>  11111111
#
# Note: dataprobe uses about 3 different TCP command protocols
# across their product line, so check /w their tech support
# on your model's specific command set.
# ----------------------------------------------------------

# format the escape hexbyte as a type char
esc = chr(int('1b',16))

# Construct the command which gets the status of the
# dataprobe's (iP-415/815) relay array.
# Uses dataprobe default password
getRelayStateInfo = (("%cPASS" % esc)+'O')

HOST = '192.168.1.254' # Default Dataprobe iP-815 address
PORT = 9100         # The same port as used by the server

# connect to dataport TCP server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST,
PORT))
time.sleep(3)

# send command to power stript TCP server
# Uses dataprobe default password
header = "%cPASS" % esc
s.send(header + sys.argv[1].strip())

# sleep for one second longer than powercycle set time.
# -- currently the dataprobe is set to a 3sec. pulse delay
sleep_time = float(sys.argv[2].strip())
time.sleep(sleep_time)

# Get Power Strip Bus Status
#   --  When using the P command, the first read will always
#       show the pulse transition
s.send(getRelayStateInfo)
d = s.recv(16)
print d

time.sleep(2)

s.send(getRelayStateInfo)
d = s.recv(16)
print d

# close TCP connection to dataprobe server
s.close()

>---<snip>---<snip>---<snip>---<snip>---<snip>---<snip>---<snip>---<




More information about the Python-list mailing list