Commit 7574a1e6 authored by root's avatar root
Browse files

update network monitor

parent 575f612c
......@@ -52,10 +52,10 @@ def get_values(tx):
: type tx: Buffer of bytes
"""
result = []
rx=m.raw(tx + m.get_crc(tx))
rx=m.raw(tx)
i=len(rx)-5
j=3
result.append(struct.unpack('<B',rx[0])[0])
while (i>0):
result.append(struct.unpack('<H',rx[j:j+2])[0])
j=j+2
......@@ -72,32 +72,32 @@ def print_values(result):
: type result: array
"""
print '----- MEASUREMENT -----'
if len (result)==6
print 'Voltage of phase A', result[0]
print 'Current of phase A', result[1]
print 'Voltage of phase B', result[2]
print 'Current of phase B', result[3]
print 'Voltage of phase C', result[4]
print 'Current of phase C', result[5]
print 'Sensor ', result[0]
print 'Voltage of phase A', result[1]
print 'Current of phase A', result[2]
print 'Voltage of phase B', result[3]
print 'Current of phase B', result[4]
print 'Voltage of phase C', result[5]
print 'Current of phase C', result[6]
print '------------------------'
if __name__ == '__main__':
m=modbus.Modbus()
tx_slave1='\x01\x03\x00\x10\x00\x06'
tx_slave2='\x02\x03\x00\x10\x00\x06'
tx_slave1 += m.get_crc(tx_slave1)
tx_slave2 += m.get_crc(tx_slave2)
txs=[tx1, ...]
txs=[tx_slave1, tx_slave2]
while True:
for tx in txs:
rx = get_values(tx)
if (len )
if len(rx)==7:
print_values(rx)
print 'Sensor 1'
print_values(get_values(tx_slave1))
print '------'
print 'Sensor 2'
print_values(get_values(tx_slave2))
print '------'
time.sleep(0.5)
else
if len (rx)>0
print 'Error de trama'
else
print 'Trama vacia'
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