Exemple #1
0
 def get_program_status (self):
     """ Function doc """
     packet, trans_no = pkb.pkt_getprogstat_cmd(self.logger_id, self.cpu_id)
     pkb.send(self.socket, packet)
     header, message = pkb.wait_pkt(self.socket, 
                                   self.logger_id, 
                                   self.cpu_id, 
                                   trans_no)
     return message
Exemple #2
0
 def progstat(self):
     """
         gets the status of the program running on the logger
          
     return: 
         the status of the running program as a string
     """
     self.ping()
     pkt, TranNbr = pakbus.pkt_getprogstat_cmd(self.l_id, self.c_id)
     pakbus.send(self.link, pkt)
     hdr, msg = pakbus.wait_pkt(self.link, self.l_id, self.c_id, TranNbr)
     return msg
Exemple #3
0
 def control (self, file_name, action):
     """ Function doc """
     packet, trans_no = pkb.pkt_filecontrol_cmd(self.logger_id,
                                                self.cpu_id,
                                                file_name, 
                                                action, 
                                                self.security_code, 
                                                None)
     pkb.send(self.socket, packet)
     header, message = pkb.wait_pkt(self.socket,
                                self.logger_id,
                                self.cpu_id, 
                                trans_no)
     return message
Exemple #4
0
 def progctrl(self, FileName, FileCmd, SecurityCode = 0x0000
                  , TranNbr = None):
     """ 
         allows for commands to be sent to the data logger to control
     the program
     
     arguments:
         FileName:   (string) the file to start
         FileCmd:    <0|1> (int) 0 turns off program, 1 starts a program
         SecurityCode:   (int) security code
         TranNbr:        best left to default
     """
     pkt, t = pakbus.pkt_filecontrol_cmd(self.l_id, self.c_id,  FileName, 
                         FileCmd, SecurityCode, TranNbr)
     pakbus.send(self.link, pkt)
     hdr, msg = pakbus.wait_pkt(self.link,self.l_id, self.c_id, TranNbr)
     
     return msg
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
#

pkt, TranNbr = pakbus.pkt_getprogstat_cmd(NodeId, MyNodeId)
pakbus.send(s, pkt)
hdr, msg = pakbus.wait_pkt(s, NodeId, MyNodeId, TranNbr)
print msg

# say good bye
pakbus.send(s, pakbus.pkt_bye_cmd(NodeId, MyNodeId))

# close socket
s.close()
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
#

pkt, TranNbr = pakbus.pkt_getprogstat_cmd(NodeId, MyNodeId)
pakbus.send(s, pkt)
hdr, msg = pakbus.wait_pkt(s, NodeId, MyNodeId, TranNbr)
print msg

# say good bye
pakbus.send(s, pakbus.pkt_bye_cmd(NodeId, MyNodeId))

# close socket
s.close()