Exemplo n.º 1
0
    def ring(self):
        pakbus.send(self.link,
                    pakbus.Link_hdr(self.remote_address, self.local_address))

        pkt = pakbus.recv(self.link)

        print "ring got:", pakbus.decode_pkt(pkt)
Exemplo n.º 2
0
    def ring(self):        
        pakbus.send(self.link, 
            pakbus.Link_hdr(
                self.remote_address, self.local_address))
        
        pkt = pakbus.recv(self.link)

        print "ring got:", pakbus.decode_pkt(pkt)
Exemplo n.º 3
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
Exemplo n.º 4
0
    def hello(self):
        pakbus.send(self.link,
                    pakbus.pkt_hello_cmd(
                        self.remote_address,
                        self.local_address,
                        )[0])
        pkt = pakbus.recv(self.link)

        print "hello got:", pakbus.decode_pkt(pkt)
Exemplo n.º 5
0
    def hello(self):
        pakbus.send(
            self.link,
            pakbus.pkt_hello_cmd(
                self.remote_address,
                self.local_address,
            )[0])
        pkt = pakbus.recv(self.link)

        print "hello got:", pakbus.decode_pkt(pkt)
Exemplo n.º 6
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
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
0
 def unlink(self):
     """ 
         close the link to the data logger
     """
     pakbus.send(self.link, pakbus.pkt_bye_cmd(self.l_id, self.c_id))
     self.link.close()
Exemplo n.º 10
0
# 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)
for file in filedir['files']:
    print file

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

# close socket
s.close()
Exemplo n.º 11
0
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)
for file in filedir['files']:
    print file

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

# close socket
s.close()
Exemplo n.º 12
0
# infinite loop to constantly collect data every minute
while True:	
	time.sleep(time_gap-0.865349040031)
	count = 0
	while count < 4:
		data = pakbus.collect_data(s, NodeId, MyNodeId, tabledef, 'Table', CollectMode = 0x07, P1 = start_time, P2 = start_time+sample_gap)
		start_time += sample_gap
		count += 1


#always check that most recent input is 15 sec before next input


print '\n'
# query data
start = client.now() - 2000000
print client.singleQuery(start, client.now(), BattV)

'''



# say good bye
for i in range(len(device_list)):
        if device_list[i] not in failed_nodes_list:
                pkt = pakbus.pkt_bye_cmd(pakbus_address_list[i], MyNodeId)
                pakbus.send(s, pkt)

# close socket
s.close()
Exemplo n.º 13
0

# infinite loop to constantly collect data every minute
while True:	
	time.sleep(time_gap-0.865349040031)
	count = 0
	while count < 4:
		data = pakbus.collect_data(s, NodeId, MyNodeId, tabledef, 'Table', CollectMode = 0x07, P1 = start_time, P2 = start_time+sample_gap)
		start_time += sample_gap
		count += 1


#always check that most recent input is 15 sec before next input


print '\n'
# query data
start = client.now() - 2000000
print client.singleQuery(start, client.now(), BattV)

'''

# say good bye
for i in range(len(device_list)):
    if device_list[i] not in failed_nodes_list:
        pkt = pakbus.pkt_bye_cmd(pakbus_address_list[i], MyNodeId)
        pakbus.send(s, pkt)

# close socket
s.close()