當前位置: 首頁>>代碼示例>>Python>>正文


Python FCNTL.ioctl方法代碼示例

本文整理匯總了Python中FCNTL.ioctl方法的典型用法代碼示例。如果您正苦於以下問題:Python FCNTL.ioctl方法的具體用法?Python FCNTL.ioctl怎麽用?Python FCNTL.ioctl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FCNTL的用法示例。


在下文中一共展示了FCNTL.ioctl方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: set_special_baudrate

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def set_special_baudrate(port, baudrate):
        # right size is 44 on x86_64, allow for some growth
        import array
        buf = array.array('i', [0] * 64)

        try:
            # get serial_struct
            FCNTL.ioctl(port.fd, TCGETS2, buf)
            # set custom speed
            buf[2] &= ~TERMIOS.CBAUD
            buf[2] |= BOTHER
            buf[9] = buf[10] = baudrate

            # set serial_struct
            res = FCNTL.ioctl(port.fd, TCSETS2, buf)
        except IOError, e:
            raise ValueError('Failed to set custom baud rate (%s): %s' % (baudrate, e)) 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:19,代碼來源:serialposix.py

示例2: set_special_baudrate

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def set_special_baudrate(port, baudrate):
        import array
        buf = array.array('i', [0] * 32)

        # get serial_struct
        FCNTL.ioctl(port.fd, TERMIOS.TIOCGSERIAL, buf)

        # set custom divisor
        buf[6] = buf[7] / baudrate

        # update flags
        buf[4] &= ~ASYNC_SPD_MASK
        buf[4] |= ASYNC_SPD_CUST

        # set serial_struct
        try:
            res = FCNTL.ioctl(port.fd, TERMIOS.TIOCSSERIAL, buf)
        except IOError:
            raise ValueError('Failed to set custom baud rate: %r' % baudrate) 
開發者ID:respeaker,項目名稱:get_started_with_respeaker,代碼行數:21,代碼來源:serialposix.py

示例3: inWaiting

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def inWaiting(self):
        """Return the number of characters currently in the input buffer."""
        #~ s = fcntl.ioctl(self.fd, TERMIOS.FIONREAD, TIOCM_zero_str)
        s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
        return struct.unpack('I',s)[0]

    # select based implementation, proved to work on many systems 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:9,代碼來源:serialposix.py

示例4: setBreak

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def setBreak(self, level=1):
        """Set break: Controls TXD. When active, no transmitting is possible."""
        if self.fd is None: raise portNotOpenError
        if level:
            fcntl.ioctl(self.fd, TIOCSBRK)
        else:
            fcntl.ioctl(self.fd, TIOCCBRK) 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:9,代碼來源:serialposix.py

示例5: setRTS

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def setRTS(self, level=1):
        """Set terminal status line: Request To Send"""
        if not self._isOpen: raise portNotOpenError
        if level:
            fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_RTS_str)
        else:
            fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_RTS_str) 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:9,代碼來源:serialposix.py

示例6: getCTS

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def getCTS(self):
        """Read terminal status line: Clear To Send"""
        if not self._isOpen: raise portNotOpenError
        s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
        return struct.unpack('I',s)[0] & TIOCM_CTS != 0 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:7,代碼來源:serialposix.py

示例7: getDSR

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def getDSR(self):
        """Read terminal status line: Data Set Ready"""
        if not self._isOpen: raise portNotOpenError
        s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
        return struct.unpack('I',s)[0] & TIOCM_DSR != 0 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:7,代碼來源:serialposix.py

示例8: getRI

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def getRI(self):
        """Read terminal status line: Ring Indicator"""
        if not self._isOpen: raise portNotOpenError
        s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
        return struct.unpack('I',s)[0] & TIOCM_RI != 0 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:7,代碼來源:serialposix.py

示例9: getCD

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def getCD(self):
        """Read terminal status line: Carrier Detect"""
        if not self._isOpen: raise portNotOpenError
        s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
        return struct.unpack('I',s)[0] & TIOCM_CD != 0

    # - - platform specific - - - - 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:9,代碼來源:serialposix.py

示例10: outWaiting

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def outWaiting(self):
        """Return the number of characters currently in the output buffer."""
        #~ s = fcntl.ioctl(self.fd, TERMIOS.FIONREAD, TIOCM_zero_str)
        s = fcntl.ioctl(self.fd, TIOCOUTQ, TIOCM_zero_str)
        return struct.unpack('I',s)[0] 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:7,代碼來源:serialposix.py

示例11: setBreak

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import ioctl [as 別名]
def setBreak(self, level=1):
        """\
        Set break: Controls TXD. When active, no transmitting is possible.
        """
        if self.fd is None: raise portNotOpenError
        if level:
            fcntl.ioctl(self.fd, TIOCSBRK)
        else:
            fcntl.ioctl(self.fd, TIOCCBRK) 
開發者ID:nortd,項目名稱:driveboardapp,代碼行數:11,代碼來源:serialposix.py


注:本文中的FCNTL.ioctl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。