def __init__(self, controller=1, device='/dev/ttyS0', baudrate=9600): """ controller : MTCA controller ID device : serial port you're using to connect to the controller baudrate : baud rate for which you've configured your controller """ # the rated max current from controller specs self._spec_max_current = 4.0 # Amps self._controller = controller # from the Melcor Manual, A.4 (p96), messages should be coded # in eight-bit bytes, with no parity bit, and one stop bit # (8N1). self._client = _ModbusSerialClient( method='rtu', port=device, # '/dev/ttyS0' or 0 bytesize=_serial.EIGHTBITS, parity=_serial.PARITY_NONE, stopbits=_serial.STOPBITS_ONE, baudrate=baudrate, timeout=0.5, ) self._decimal = None
def __init__(self, controller=1, device='/dev/ttyS0', baudrate=9600): """ controller : MTCA controller ID device : serial port you're using to connect to the controller baudrate : baud rate for which you've configured your controller """ # the rated max current from controller specs self._spec_max_current = 4.0 # Amps self._controller = controller # from the Melcor Manual, A.4 (p96), messages should be coded # in eight-bit bytes, with no parity bit, and one stop bit # (8N1). self._client = _ModbusSerialClient( method='rtu', port=device, # '/dev/ttyS0' or 0 bytesize=_serial.EIGHTBITS, parity=_serial.PARITY_NONE, stopbits=_serial.STOPBITS_ONE, baudrate=baudrate, timeout=0.5, ) self._decimal = None
def client(self): if self._client is None: self._client = _ModbusSerialClient(method='rtu', port=self.port, baudrate=self.baudrate, timeout=self.timeout) return self._client