本文整理汇总了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)