Commit 1aabd463 authored by root's avatar root
Browse files

monitor_battery y network monitor examples update

parent 7574a1e6
......@@ -123,10 +123,9 @@ def print_values_tc(result):
: type result: array
"""
print '----- MEASUREMENT -----'
if len(result) == 3
print "Cell Current: "+str(result[0])+" A"
print "Temperature 1: "+str(result[1])+" C"
print "Temperature 2: "+str(result[2])+" C"
print "Cell Current: "+str(result[0])+" A"
print "Temperature 1: "+str(result[1])+" C"
print "Temperature 2: "+str(result[2])+" C"
print '------------------------'
def print_value_ta(result):
......@@ -138,13 +137,10 @@ def print_value_ta(result):
: type result: array
"""
print '----- MEASUREMENT -----'
if len(result) == 2
print "Cell Voltage: "+str(result[0])+" V"
print "Cell Temperature: "+str(result[1])+" C"
print "Cell Voltage: "+str(result[0])+" V"
print "Cell Temperature: "+str(result[1])+" C"
print '-----------------------'
if __name__ == '__main__':
m=modbus.Modbus()
......@@ -153,27 +149,41 @@ if __name__ == '__main__':
#rx_change_address=m.raw(tx_change_address + m.get_crc(tx_change_address))
#print list (rx_change_address)
#FRAME TA-MODULE
tx_slave_ta = '\x02\x03\x00\x01\x00\x02'
tx_slave_ta = tx_slave_ta + m.get_crc(tx_slave_ta)
#FRAME TC-MODULE
tx_slave_tc = '\x01\x03\x00\x03\x00\x03'
tx_slave_tc = tx_slave_tc + m.get_crc(tx_slave_tc)
while True:
#READ THE PARAMETERS
rx_slave_ta=m.raw(tx_slave_ta)
rx_slave_tc=m.raw(tx_slave_tc)
#FRAME TA-MODULE
address_ta = [2,3,4]
tx_ta = []
for i in range(0,len(address_ta)):
tx_ta.append(struct.pack('B',address_ta[i])+'\x03\x00\x01\x00\x02')
tx_ta[i] += m.get_crc(tx_ta[i])
print list (tx_ta)
#TA-MODULE
result_slave_ta = get_values_ta(rx_slave_ta)
result_slave_ta = scale_data_ta(result_slave_ta)
print_values_ta(result_slave_ta)
while True:
#TC-MODULE
rx_slave_tc=m.raw(tx_slave_tc)
result_slave_tc = get_values_tc(rx_slave_tc)
result_slave_tc = scale_data_tc(result_slave_tc)
print_values_tc(result_slave_tc)
if len (result_slave_tc)==3:
result_slave_tc = scale_data_tc(result_slave_tc)
print_values_tc(result_slave_tc)
else
if len (result_slave_tc)>0
print 'Error en la trama:', i
else
print 'Trama vacia:', i
#TA-MODULE
for i in range(0,len(tx_ta)):
rx_slave_ta=m.raw(tx_ta[i])
result_slave_ta = get_values_ta(rx_slave_ta)
if len (result_slave_ta)==2:
result_slave_ta = scale_data_ta(result_slave_ta)
print_values_ta(result_slave_ta)
else
if len (result_slave_ta)>0
print 'Error en la trama:', i
else
print 'Trama vacia:', i
......@@ -91,13 +91,13 @@ if __name__ == '__main__':
txs=[tx_slave1, tx_slave2]
while True:
for tx in txs:
rx = get_values(tx)
for i in range(0,len(txs)):
rx = get_values(txs[i])
if len(rx)==7:
print_values(rx)
else
if len (rx)>0
print 'Error de trama'
print 'Error en la trama:', i
else
print 'Trama vacia'
print 'Trama vacia:' i
time.sleep(0.5)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment