def __init__(self, host = 'localhost', port = 7809, timeout = 30, logger_id = 0x001, computer_id = 0x802 ): """ this initilizer function sets up the connection arguments: host: (string) a string repesenting the ip for the connection port: (int) the port number timeout: (int) timeout value logger_id: (int) the ID of the logger computer_id:(int) the id of the computer """ self.host = host self.port = port self.timeout = timeout self.l_id = logger_id self.c_id = computer_id self.link = pakbus.open_socket(self.host, self.port , self.timeout) self.ping() self.progs = [] self.table_list = [] FileData, Response = pakbus.fileupload(self.link, self.l_id, self.c_id , '.TDF') self.tabledef = pakbus.parse_tabledef(FileData) self.fetchprogs()
def __init__(self, host, remote_pakbus_address, local_pakbus_address = 4085, timeout = 6): """Connect to a remote datalogger @param host/port to connect to: eg: 60e90457.eairlink.com:6785, @param remote_pakbus_address: the address/node id to connect to @param local_pakbus_address: this stations node id/pakbus address [0...4095], Loggernet uses 4095 """ self.local_address = local_pakbus_address self.link_state = DataLogger.LinkState.OFF_LINE self.remote_address = remote_pakbus_address host,port = host.split(":") self.link = pakbus.open_socket(host,int(port)) self.timeout = timeout
def __init__(self, host, remote_pakbus_address, local_pakbus_address=4085, timeout=6): """Connect to a remote datalogger @param host/port to connect to: eg: 60e90457.eairlink.com:6785, @param remote_pakbus_address: the address/node id to connect to @param local_pakbus_address: this stations node id/pakbus address [0...4095], Loggernet uses 4095 """ self.local_address = local_pakbus_address self.link_state = DataLogger.LinkState.OFF_LINE self.remote_address = remote_pakbus_address host, port = host.split(":") self.link = pakbus.open_socket(host, int(port)) self.timeout = timeout
def relink(self): """reestiblish the link with the data logger""" self.link = pakbus.open_socket(self.host, self.port , self.timeout)
def open_socket (self): """ opens a socket for listening to the logger on. """ self.socket = pkb.open_socket(self.host, self.port, self.timeout)
parser = optparse.OptionParser() parser.add_option('-c', '--config', help = 'read configuration from FILE [default: %default]', metavar = 'FILE', default = 'pakbus.conf') (options, args) = parser.parse_args() # Read configuration file import ConfigParser, StringIO cf = ConfigParser.SafeConfigParser() print 'configuration read from %s' % cf.read(options.config) # Data logger PakBus Node Id NodeId = str2int(cf.get('pakbus', 'node_id')) # My PakBus Node Id MyNodeId = str2int(cf.get('pakbus', 'my_node_id')) # Open socket s = pakbus.open_socket(cf.get('pakbus', 'host'), cf.getint('pakbus', 'port'), cf.getint('pakbus', 'timeout')) # check if remote node is up msg = pakbus.ping_node(s, NodeId, MyNodeId) if not msg: raise Warning('no reply from PakBus node 0x%.3x' % NodeId) # # Main program # # Upload directory data FileData, Response = pakbus.fileupload(s, NodeId, MyNodeId, '.DIR') # List files in directory filedir = pakbus.parse_filedir(FileData)
) (options, args) = parser.parse_args() # Read configuration file import ConfigParser, StringIO cf = ConfigParser.SafeConfigParser() print "configuration read from %s" % cf.read(options.config) # Data logger PakBus Node Id NodeId = str2int(cf.get("pakbus", "node_id")) # My PakBus Node Id MyNodeId = str2int(cf.get("pakbus", "my_node_id")) # Open socket s = pakbus.open_socket(cf.get("pakbus", "host"), cf.getint("pakbus", "port"), cf.getint("pakbus", "timeout")) # check if remote node is up msg = pakbus.ping_node(s, NodeId, MyNodeId) if not msg: raise Warning("no reply from PakBus node 0x%.3x" % NodeId) # # Main program # # Upload directory data FileData, Response = pakbus.fileupload(s, NodeId, MyNodeId, ".DIR") # print FileData # print '\n'
metavar='FILE', default='pakbus.conf') (options, args) = parser.parse_args() # Read configuration file import ConfigParser, StringIO cf = ConfigParser.SafeConfigParser() print 'configuration read from %s' % cf.read(options.config) # Data logger PakBus Node Id NodeId = str2int(cf.get('pakbus', 'node_id')) # My PakBus Node Id MyNodeId = str2int(cf.get('pakbus', 'my_node_id')) # Open socket s = pakbus.open_socket(cf.get('pakbus', 'host'), cf.getint('pakbus', 'port'), cf.getint('pakbus', 'timeout')) # check if remote node is up msg = pakbus.ping_node(s, NodeId, MyNodeId) if not msg: raise Warning('no reply from PakBus node 0x%.3x' % NodeId) # # Main program # # Upload directory data FileData, Response = pakbus.fileupload(s, NodeId, MyNodeId, '.DIR') # List files in directory filedir = pakbus.parse_filedir(FileData)