python类write()的实例源码

ACServer.py 文件源码 项目:Hydroponics 作者: toy0605 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __checkType__(self, serial):
        byte = serial.read().decode("utf-8")
        print(byte)
        if byte == "1":
            print("??? ???? ?? : " + serial.port)
            serial.write(b'0')
            self.threads["Sensor"] = SensorThread(serial)
            return self.threads["Sensor"]
        elif byte == "2" :
            print("??? ???? ?? : " + serial.port)
            serial.write(b'0')
            self.threads["Control"] = ControlThread(serial)
            return self.threads["Control"]
        else :
            print("? ? ?? ???? : " + serial.port)
            serial.write(b'1')
            return None

#?? ???
arduino_port.py 文件源码 项目:Project_Automail 作者: ThermoNuclearPanda 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def write(self, value):
        print(value)
        if(value == 0):
            serial.write('0')
        elif(value == 1):
            serial.write('1')
        elif(value == 2):
            serial.write('2')
        elif(value == 3):
            serial.write('3')
        elif(value == 4):
            serial.write('4')

    # Disconnects the Arduino
arduino_port.py 文件源码 项目:Project_Automail 作者: ThermoNuclearPanda 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def showReady(self):
        serial.write('6')
rfc2217.py 文件源码 项目:android3dblendermouse 作者: sketchpunk 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def write(self, data):
        """\
        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        """
        if not self.is_open:
            raise portNotOpenError
        with self._write_lock:
            try:
                self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
            except socket.error as e:
                raise SerialException("connection failed (socket error): %s" % (e,))
        return len(data)
rfc2217.py 文件源码 项目:android3dblendermouse 作者: sketchpunk 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        with self._write_lock:
            self._socket.sendall(data)
rfc2217.py 文件源码 项目:android3dblendermouse 作者: sketchpunk 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def telnetSendOption(self, action, option):
        """Send DO, DONT, WILL, WONT."""
        self.connection.write(to_bytes([IAC, action, option]))
rfc2217.py 文件源码 项目:android3dblendermouse 作者: sketchpunk 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def rfc2217SendSubnegotiation(self, option, value=b''):
        """Subnegotiation of RFC 2217 parameters."""
        value = value.replace(IAC, IAC_DOUBLED)
        self.connection.write(to_bytes([IAC, SB, COM_PORT_OPTION, option] + list(value) + [IAC, SE]))

    # - check modem lines, needs to be called periodically from user to
    # establish polling
rfc2217.py 文件源码 项目:microperi 作者: c0d3st0rm 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def write(self, data):
        """\
        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        """
        if not self.is_open:
            raise portNotOpenError
        with self._write_lock:
            try:
                self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
            except socket.error as e:
                raise SerialException("connection failed (socket error): %s" % (e,))
        return len(data)
rfc2217.py 文件源码 项目:microperi 作者: c0d3st0rm 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        with self._write_lock:
            self._socket.sendall(data)
rfc2217.py 文件源码 项目:microperi 作者: c0d3st0rm 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def telnetSendOption(self, action, option):
        """Send DO, DONT, WILL, WONT."""
        self.connection.write(to_bytes([IAC, action, option]))
rfc2217.py 文件源码 项目:microperi 作者: c0d3st0rm 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def rfc2217SendSubnegotiation(self, option, value=b''):
        """Subnegotiation of RFC 2217 parameters."""
        value = value.replace(IAC, IAC_DOUBLED)
        self.connection.write(to_bytes([IAC, SB, COM_PORT_OPTION, option] + list(value) + [IAC, SE]))

    # - check modem lines, needs to be called periodically from user to
    # establish polling
rfc2217.py 文件源码 项目:gcodeplot 作者: arpruss 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def write(self, data):
        """\
        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        """
        if not self.is_open:
            raise portNotOpenError
        with self._write_lock:
            try:
                self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
            except socket.error as e:
                raise SerialException("connection failed (socket error): {}".format(e))
        return len(data)
rfc2217.py 文件源码 项目:gcodeplot 作者: arpruss 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        with self._write_lock:
            self._socket.sendall(data)
rfc2217.py 文件源码 项目:gcodeplot 作者: arpruss 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def telnet_send_option(self, action, option):
        """Send DO, DONT, WILL, WONT."""
        self.connection.write(to_bytes([IAC, action, option]))
rfc2217.py 文件源码 项目:gcodeplot 作者: arpruss 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def rfc2217_send_subnegotiation(self, option, value=b''):
        """Subnegotiation of RFC 2217 parameters."""
        value = value.replace(IAC, IAC_DOUBLED)
        self.connection.write(to_bytes([IAC, SB, COM_PORT_OPTION, option] + list(value) + [IAC, SE]))

    # - check modem lines, needs to be called periodically from user to
    # establish polling
rfc2217.py 文件源码 项目:bitio 作者: whaleygeek 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def write(self, data):
        """\
        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        """
        if not self.is_open:
            raise portNotOpenError
        with self._write_lock:
            try:
                self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
            except socket.error as e:
                raise SerialException("connection failed (socket error): {}".format(e))
        return len(data)
rfc2217.py 文件源码 项目:bitio 作者: whaleygeek 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        with self._write_lock:
            self._socket.sendall(data)
rfc2217.py 文件源码 项目:bitio 作者: whaleygeek 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def telnet_send_option(self, action, option):
        """Send DO, DONT, WILL, WONT."""
        self.connection.write(IAC + action + option)
rfc2217.py 文件源码 项目:bitio 作者: whaleygeek 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def rfc2217_send_subnegotiation(self, option, value=b''):
        """Subnegotiation of RFC 2217 parameters."""
        value = value.replace(IAC, IAC_DOUBLED)
        self.connection.write(IAC + SB + COM_PORT_OPTION + option + value + IAC + SE)

    # - check modem lines, needs to be called periodically from user to
    # establish polling
rfc2217.py 文件源码 项目:microbit-serial 作者: martinohanlon 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def write(self, data):
        """\
        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        """
        if not self.is_open:
            raise portNotOpenError
        with self._write_lock:
            try:
                self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
            except socket.error as e:
                raise SerialException("connection failed (socket error): %s" % (e,))
        return len(data)
rfc2217.py 文件源码 项目:microbit-serial 作者: martinohanlon 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        with self._write_lock:
            self._socket.sendall(data)
rfc2217.py 文件源码 项目:microbit-serial 作者: martinohanlon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def telnetSendOption(self, action, option):
        """Send DO, DONT, WILL, WONT."""
        self.connection.write(to_bytes([IAC, action, option]))
rfc2217.py 文件源码 项目:microbit-serial 作者: martinohanlon 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def rfc2217SendSubnegotiation(self, option, value=b''):
        """Subnegotiation of RFC 2217 parameters."""
        value = value.replace(IAC, IAC_DOUBLED)
        self.connection.write(to_bytes([IAC, SB, COM_PORT_OPTION, option] + list(value) + [IAC, SE]))

    # - check modem lines, needs to be called periodically from user to
    # establish polling
rfc2217.py 文件源码 项目:ddt4all 作者: cedricp 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def write(self, data):
        """\
        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        """
        if not self.is_open:
            raise portNotOpenError
        with self._write_lock:
            try:
                self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
            except socket.error as e:
                raise SerialException("connection failed (socket error): {}".format(e))
        return len(data)
rfc2217.py 文件源码 项目:ddt4all 作者: cedricp 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        with self._write_lock:
            self._socket.sendall(data)
rfc2217.py 文件源码 项目:ddt4all 作者: cedricp 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def telnet_send_option(self, action, option):
        """Send DO, DONT, WILL, WONT."""
        self.connection.write(to_bytes([IAC, action, option]))
rfc2217.py 文件源码 项目:ddt4all 作者: cedricp 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def rfc2217_send_subnegotiation(self, option, value=b''):
        """Subnegotiation of RFC 2217 parameters."""
        value = value.replace(IAC, IAC_DOUBLED)
        self.connection.write(to_bytes([IAC, SB, COM_PORT_OPTION, option] + list(value) + [IAC, SE]))

    # - check modem lines, needs to be called periodically from user to
    # establish polling
rfc2217.py 文件源码 项目:mt7687-serial-uploader 作者: will127534 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def write(self, data):
        """\
        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        """
        if not self.is_open:
            raise portNotOpenError
        with self._write_lock:
            try:
                self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
            except socket.error as e:
                raise SerialException("connection failed (socket error): {}".format(e))
        return len(data)
rfc2217.py 文件源码 项目:mt7687-serial-uploader 作者: will127534 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        with self._write_lock:
            self._socket.sendall(data)
rfc2217.py 文件源码 项目:mt7687-serial-uploader 作者: will127534 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def telnet_send_option(self, action, option):
        """Send DO, DONT, WILL, WONT."""
        self.connection.write(to_bytes([IAC, action, option]))


问题


面经


文章

微信
公众号

扫码关注公众号