import os from pymodbus.client.sync import ModbusSerialClient as ModbusClient #---------------------------------------------------------------------------# import logging logging.basicConfig() log = logging.getLogger() log.setLevel(logging.DEBUG) #---------------------------------------------------------------------------# cliente = ModbusClient(method='rtu', port='/dev/ttyUSB0', timeout=1, stopbits = 1, bytesize = 8, parity='N', baudrate= 9600) cliente.connect() 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 "Read Discrete Input" request = cliente.read_discrete_inputs(0x0,0x8,unit=1) print request 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
Generated by GNU Enscript 1.6.5.90.
No hay comentarios:
Publicar un comentario