easymodbus/modbusClient.py
def connect(self):
        """
        Connects to a Modbus-TCP Server or a Modbus-RTU Slave with the given Parameters
        """
        if self.__ser is not None:
            serial = importlib.import_module("serial")
            if self.__stopbits == 0:
                self.__ser.stopbits = serial.STOPBITS_ONE
            elif self.__stopbits == 1:
                self.__ser.stopbits = serial.STOPBITS_TWO
            elif self.__stopbits == 2:
                self.__ser.stopbits = serial.STOPBITS_ONE_POINT_FIVE
            if self.__parity == 0:
                self.__ser.parity = serial.PARITY_EVEN
            elif self.__parity == 1:
                self.__ser.parity = serial.PARITY_ODD
            elif self.__parity == 2:
                self.__ser.parity = serial.PARITY_NONE

            self.__ser = serial.Serial(self.serialPort, self.__baudrate, timeout=self.__timeout,
                                       parity=self.__ser.parity, stopbits=self.__ser.stopbits, xonxoff=0, rtscts=0)
            self.__ser.writeTimeout = self.__timeout

            logging.info(
                "Modbus client connected to serial network, Port: {0}, Baudrate: {1}, Parity: {2}, Stopbits: {3}"
                .format(str(self.serialPort), str(self.__baudrate), str(self.__parity), str(self.__stopbits)))

        # print (self.ser)
        if self.__tcpClientSocket is not None:
            self.__tcpClientSocket.settimeout(5)
            self.__tcpClientSocket.connect((self.__ipAddress, self.__port))

            self.__connected = True
            self.__thread = threading.Thread(target=self.__listen, args=())
            self.__thread.start()
            logging.info(
                "Modbus client connected to TCP network, IP Address: {0}, Port: {1}"
                .format(str(self.__ipAddress), str(self.__port)))

        Connects to a Modbus-TCP Server or a Modbus-RTU Slave with the given Parameters
        
Connects to a Modbus-TCP Server or a Modbus-RTU Slave with the given Parameters
Connects to a Modbus - TCP Server or a Modbus - RTU Slave with the given Parameters
def connect(self):
        if self.__ser is not None:
            serial = importlib.import_module("serial")
            if self.__stopbits == 0:
                self.__ser.stopbits = serial.STOPBITS_ONE
            elif self.__stopbits == 1:
                self.__ser.stopbits = serial.STOPBITS_TWO
            elif self.__stopbits == 2:
                self.__ser.stopbits = serial.STOPBITS_ONE_POINT_FIVE
            if self.__parity == 0:
                self.__ser.parity = serial.PARITY_EVEN
            elif self.__parity == 1:
                self.__ser.parity = serial.PARITY_ODD
            elif self.__parity == 2:
                self.__ser.parity = serial.PARITY_NONE
            self.__ser = serial.Serial(self.serialPort, self.__baudrate, timeout=self.__timeout,
                                       parity=self.__ser.parity, stopbits=self.__ser.stopbits, xonxoff=0, rtscts=0)
            self.__ser.writeTimeout = self.__timeout
            logging.info(
                "Modbus client connected to serial network, Port: {0}, Baudrate: {1}, Parity: {2}, Stopbits: {3}"
                .format(str(self.serialPort), str(self.__baudrate), str(self.__parity), str(self.__stopbits)))
        if self.__tcpClientSocket is not None:
            self.__tcpClientSocket.settimeout(5)
            self.__tcpClientSocket.connect((self.__ipAddress, self.__port))
            self.__connected = True
            self.__thread = threading.Thread(target=self.__listen, args=())
            self.__thread.start()
            logging.info(
                "Modbus client connected to TCP network, IP Address: {0}, Port: {1}"
                .format(str(self.__ipAddress), str(self.__port)))
def connect ( self ) : if self . __ser is not None : serial = importlib . import_module ( "serial" ) if self . __stopbits == 0 : self . __ser . stopbits = serial . STOPBITS_ONE elif self . __stopbits == 1 : self . __ser . stopbits = serial . STOPBITS_TWO elif self . __stopbits == 2 : self . __ser . stopbits = serial . STOPBITS_ONE_POINT_FIVE if self . __parity == 0 : self . __ser . parity = serial . PARITY_EVEN elif self . __parity == 1 : self . __ser . parity = serial . PARITY_ODD elif self . __parity == 2 : self . __ser . parity = serial . PARITY_NONE self . __ser = serial . Serial ( self . serialPort , self . __baudrate , timeout = self . __timeout , parity = self . __ser . parity , stopbits = self . __ser . stopbits , xonxoff = 0 , rtscts = 0 ) self . __ser . writeTimeout = self . __timeout logging . info ( "Modbus client connected to serial network, Port: {0}, Baudrate: {1}, Parity: {2}, Stopbits: {3}" . format ( str ( self . serialPort ) , str ( self . __baudrate ) , str ( self . __parity ) , str ( self . __stopbits ) ) ) if self . __tcpClientSocket is not None : self . __tcpClientSocket . settimeout ( 5 ) self . __tcpClientSocket . connect ( ( self . __ipAddress , self . __port ) ) self . __connected = True self . __thread = threading . Thread ( target = self . __listen , args = ( ) ) self . __thread . start ( ) logging . info ( "Modbus client connected to TCP network, IP Address: {0}, Port: {1}" . format ( str ( self . __ipAddress ) , str ( self . __port ) ) )
Connects to a Modbus-TCP Server or a Modbus-RTU Slave with the given Parameters
Connects to a Modbus - TCP Server or a Modbus - RTU Slave with the given Parameters
"""
        Connects to a Modbus-TCP Server or a Modbus-RTU Slave with the given Parameters
        """ # print (self.ser)
self