import os from pymodbus.client.sync import ModbusTcpClient cliente = ModbusTcpClient('127.0.0.1','5020') #---------------------------------------------------------------------------# import logging logging.basicConfig() log = logging.getLogger() log.setLevel(logging.DEBUG) #---------------------------------------------------------------------------# os.system('clear') print "Read Coils" request = cliente.read_coils(0x0,0x8,unit=1) print request.bits[0] print request.bits[1] print request.bits[2] print request.bits[3] print request.bits[4] print request.bits[5] print request.bits[6] print request.bits[7] print "Read Discrete Input" request = cliente.read_discrete_inputs(0x0,0x8,unit=1) print request.bits[0] print request.bits[1] print request.bits[2] print request.bits[3] print request.bits[4] print request.bits[5] print request.bits[6] print request.bits[7] print "Read Holding Registers" request = cliente.read_holding_registers(0x0,0x7,unit=1) print request.registers print "Read Input Registers" request = cliente.read_input_registers(0x0,0x7,unit=1) print request.registers cliente.close()
Generated by GNU Enscript 1.6.5.90.