本文整理匯總了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))
示例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)
示例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
示例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)
示例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)
示例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
示例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
示例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
示例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 - - - -
示例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]
示例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)