コード例 #1
0
 def __modbus_init(self):
     port = self.find_port()
     self.pymc = pyRtu(method=MODE,
                       port=port,
                       parity=PARITY,
                       stopbits=STOP_BITS,
                       baudrate=BAUD_RATE,
                       timeout=TIME_OUT)
コード例 #2
0
 def __init__(self, host, unit=1, baud=19200, timeout=1):
     if host.startswith("/"):
         self.pymc = pySerial(
             method="rtu", port=host, baudrate=baud, timeout=timeout
         )
     else:
         self.pymc = pyRtu(host=host, port=502)
     self.unit = unit
コード例 #3
0
ファイル: remotearm.py プロジェクト: UniPiTechnology/evok
 def  __init__(self, host, unit = 1, baud = 19200, timeout = 1):
     if (host.startswith('/')):
         self.pymc=pySerial(method='rtu', port=host, baudrate=baud, timeout=timeout)
     else:
         self.pymc=pyRtu(host=host, port=502)
     self.unit = unit
コード例 #4
0
	def __modbus_init(self):
		port = self.find_port()
		self.pymc = pyRtu(method=MODE, port=port,parity = PARITY,stopbits =STOP_BITS,
		baudrate=BAUD_RATE, timeout=TIME_OUT)
コード例 #5
0
import traceback
import serial

from pymodbus.client.sync import ModbusSerialClient as pyRtu

slavesArr = [1]
iterSp = 100
regsSp = 10
#portNbr = '/dev/ttyUSB0'
portNbr = '/dev/cu.usbserial-1420'
portName = 'com22'
#baudrate = 9600
baudrate = 19200
timeoutSp = 10

pymc = pyRtu(method='rtu', port=portNbr, baudrate=baudrate, timeout=timeoutSp)

errCnt = 0
startTs = time.time()
for i in range(iterSp):
  for slaveId in slavesArr: 
    try:
        hr = pymc.read_holding_registers(0,regsSp,unit=slaveId)
        print(hr)
    except:
        errCnt += 1
        tb = traceback.format_exc()


stopTs = time.time()
timeDiff = stopTs  - startTs