Exemplo n.º 1
0
    def __init__(self,
                 serial_device,
                 slave_address,
                 debug=False,
                 cache=True,
                 retries=3):
        """Initialize the driver

        Args:
            serial_device (str): The serial device to use
            slave_address (int): The address of the slave device
            debug (bool): Whether debugging output from minimal modbus should be enabled
            cache (bool): Whether system configuration values (which are expected not to
                change within the runtime of the program) should be cached

        """
        LOGGER.info('__init__ called, serial device: %s, slave address: %s',
                    serial_device, slave_address)
        Instrument.__init__(self, serial_device, slave_address)
        self.serial.baudrate = 9600
        self.serial.stopbits = 2
        self.serial.timeout = 2.0
        self.retries = retries
        # Variables
        self.debug = debug
        self.cache = cache
        # Cache
        self.system_conf = {}
        self.channel_conf = {}
        LOGGER.info('__init__ complete')
Exemplo n.º 2
0
    def __init__(self, serial_device, slave_address, debug=False, cache=True, retries=3):
        """Initialize the driver

        Args:
            serial_device (str): The serial device to use
            slave_address (int): The address of the slave device
            debug (bool): Whether debugging output from minimal modbus should be enabled
            cache (bool): Whether system configuration values (which are expected not to
                change within the runtime of the program) should be cached

        """
        LOGGER.info('__init__ called, serial device: %s, slave address: %s',
                    serial_device, slave_address)
        Instrument.__init__(self, serial_device, slave_address)
        self.serial.baudrate = 9600
        self.serial.stopbits = 2
        self.serial.timeout = 2.0
        self.retries = retries
        # Variables
        self.debug = debug
        self.cache = cache
        # Cache
        self.system_conf = {}
        self.channel_conf = {}
        LOGGER.info('__init__ complete')
Exemplo n.º 3
0
 def __init__(self, port, slaveaddress, bimaster=False):
     Instrument.__init__(self, port, slaveaddress)
     self.serial.baudrate = 9600
     self.serial.bytesize = serial.EIGHTBITS
     self.serial.parity = serial.PARITY_NONE
     self.serial.stopbits = serial.STOPBITS_ONE
     self.serial.timeout = 1
     self.mode = MODE_RTU
     self.bimaster = bimaster
Exemplo n.º 4
0
    def __init__(self, port):
        """ inititalizes the ModbusInstrument at a certain COM-Port

            Arguments:
            port -- path to serial port, e.g. for Windows "COM1"
        """
        ModbusInstrument.__init__(self, port, 1)
        self.lock = Lock()
        self.
        self.loops = []

        for i in range(0, 8):
            self.loops.append(Loop(self, i * 256, self.lock))
Exemplo n.º 5
0
 def reconnect(self):
     ModbusInstrument.__init__(self, port, 1)
     print('reconnected')