(self, spec)
return None
Initialise the serial object.
Initialise the serial object.
Initialise the serial object .
def _init_serial(self, spec):
        """Initialise the serial object."""
        addr, val = parse_protocol_string(spec)
        try:
            if not addr and not val:
                pass
            elif addr == u'STDIO' or (not addr and val.upper() == u'STDIO'):
                return SerialStdIO(val.upper() == u'CRLF')
            else:
                if not serial:
                    logging.warning(
                        u'Could not attach %s to COM device. Module `serial` not available: %s',
                        spec, logging_msg
                    )
                    return None
                if addr in (u'SOCKET', u'RFC2217'):
                    # throws ValueError if too many :s, caught below
                    host, socket = val.split(u':')
                    url = u'%s://%s:%s' % (addr.lower(), host, socket)
                    stream = serial.serial_for_url(url, timeout=0, do_not_open=True)
                    # monkey-patch serial object as SocketSerial does not have this property
                    stream.out_waiting = 0
                    return stream
                elif addr == u'PORT':
                    # port can be e.g. /dev/ttyS1 on Linux or COM1 on Windows.
                    return serial.serial_for_url(val, timeout=0, do_not_open=True)
                else:
                    raise ValueError(u'Invalid protocol `%s`' % (addr,))
        except (ValueError, EnvironmentError) as e:
            logging.warning(u'Could not attach %s to COM device: %s', spec, e)
        return None
def _init_serial ( self , spec ) : addr , val = parse_protocol_string ( spec ) try : if not addr and not val : pass elif addr == u'STDIO' or ( not addr and val . upper ( ) == u'STDIO' ) : return SerialStdIO ( val . upper ( ) == u'CRLF' ) else : if not serial : logging . warning ( u'Could not attach %s to COM device. Module `serial` not available: %s' , spec , logging_msg ) return None if addr in ( u'SOCKET' , u'RFC2217' ) : # throws ValueError if too many :s, caught below host , socket = val . split ( u':' ) url = u'%s://%s:%s' % ( addr . lower ( ) , host , socket ) stream = serial . serial_for_url ( url , timeout = 0 , do_not_open = True ) # monkey-patch serial object as SocketSerial does not have this property stream . out_waiting = 0 return stream elif addr == u'PORT' : # port can be e.g. /dev/ttyS1 on Linux or COM1 on Windows. return serial . serial_for_url ( val , timeout = 0 , do_not_open = True ) else : raise ValueError ( u'Invalid protocol `%s`' % ( addr , ) ) except ( ValueError , EnvironmentError ) as e : logging . warning ( u'Could not attach %s to COM device: %s' , spec , e ) return None