def __init__(self, port=None, baudrate=None, **kwargs):
        """Initialize a connection to the serial device.

        Kwargs:
            port - optionally override the default virtual COM port
            baudrate - optionally override the default baudrate

        Raises:
            DataSourceError if the serial device cannot be opened.
        """
        super(SerialDataSource, self).__init__(**kwargs)
        port = port or self.DEFAULT_PORT
        baudrate = baudrate or self.DEFAULT_BAUDRATE

        if serial is None:
            raise DataSourceError("pyserial library is not available")

        try:
            self.device = serial.Serial(port, baudrate, rtscts=True)
        except (OSError, serial.SerialException) as e:
            raise DataSourceError("Unable to open serial device at port "
                    "%s: %s" % (port, e))
        else:
            LOG.debug("Opened serial device at %s", port)
def __init__ ( self , port = None , baudrate = None , ** kwargs ) : super ( SerialDataSource , self ) . __init__ ( ** kwargs ) port = port or self . DEFAULT_PORT baudrate = baudrate or self . DEFAULT_BAUDRATE if serial is None : raise DataSourceError ( "pyserial library is not available" ) try : self . device = serial . Serial ( port , baudrate , rtscts = True ) except ( OSError , serial . SerialException ) as e : raise DataSourceError ( "Unable to open serial device at port " "%s: %s" % ( port , e ) ) else : LOG . debug ( "Opened serial device at %s" , port )
Initialize a connection to the serial device.

        Kwargs:
            port - optionally override the default virtual COM port
            baudrate - optionally override the default baudrate

        Raises:
            DataSourceError if the serial device cannot be opened.