• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python termios.tcsendbreak函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中termios.tcsendbreak函数的典型用法代码示例。如果您正苦于以下问题:Python tcsendbreak函数的具体用法?Python tcsendbreak怎么用?Python tcsendbreak使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tcsendbreak函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: getchar

def getchar(prompt, hidden=False, end='\n'):
  '''读取一个字符'''
  import termios
  sys.stdout.write(prompt)
  sys.stdout.flush()
  fd = sys.stdin.fileno()

  if os.isatty(fd):
    old = termios.tcgetattr(fd)
    new = termios.tcgetattr(fd)
    if hidden:
      new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
    else:
      new[3] = new[3] & ~termios.ICANON
    new[6][termios.VMIN] = 1
    new[6][termios.VTIME] = 0
    try:
      termios.tcsetattr(fd, termios.TCSANOW, new)
      termios.tcsendbreak(fd, 0)
      ch = os.read(fd, 7)
    finally:
      termios.tcsetattr(fd, termios.TCSAFLUSH, old)
  else:
    ch = os.read(fd, 7)

  sys.stdout.write(end)
  return(ch.decode())
开发者ID:Vayn,项目名称:winterpy,代码行数:27,代码来源:myutils.py


示例2: sendBreak

 def sendBreak(self, duration=0.25):
     """\
     Send break condition. Timed, returns to idle state after given
     duration.
     """
     if not self._isOpen: raise portNotOpenError
     termios.tcsendbreak(self.fd, int(duration/0.25))
开发者ID:kiltyj,项目名称:serial_monitor,代码行数:7,代码来源:serialposix.py


示例3: configure

    def configure(self):
        flags = termios.tcgetattr(self.fh)

        # flags is [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
        # the following is basically the same as 'raw' mode.

        flags[0] &= ~(termios.IGNBRK | termios.BRKINT) # line breaks read as \0
        flags[0] &= ~(termios.PARMRK) # parity errors read as \0
        flags[0] &= ~(termios.ISTRIP) # don't strip 8th bit
        # don't mess with CR/NL
        flags[0] &= ~(termios.INLCR | termios.IGNCR | termios.ICRNL)
        flags[0] &= ~(termios.IXON) # ignore XON/XOFF

        flags[1] &= ~(termios.OPOST) # don't do output processing
        # don't mess with CR/NL
        flags[1] &= ~(termios.ONLCR | termios.OCRNL)

        # set the line discipline
        flags[2] &= ~(termios.CSIZE | termios.PARENB | termios.CSTOPB)
        flags[2] |= termios.CS8

        # disable most special-character processing
        flags[3] &= ~(termios.ECHO | termios.ECHONL | termios.ICANON
                         | termios.ISIG | termios.IEXTEN)

        # disable CTS/RTS for now (we probably ought to be able to make this
        # work?
        flags[2] &= ~termios.CRTSCTS
        flags[4] = termios.B9600 # ispeed
        flags[5] = termios.B9600 # ospeed

        termios.tcsetattr(self.fh, termios.TCSANOW, flags)
        termios.tcsendbreak(self.fh, 0)
开发者ID:richvdh,项目名称:xbee,代码行数:33,代码来源:xbee_controller.py


示例4: getchar

def getchar(prompt, hidden=False, end='\n', timeout=None):
  '''读取一个字符'''
  import termios
  sys.stdout.write(prompt)
  sys.stdout.flush()
  fd = sys.stdin.fileno()

  def _read():
    if timeout is None:
      ch = sys.stdin.read(1)
    else:
      ch = _timed_read(sys.stdin, timeout)
    return ch

  if os.isatty(fd):
    old = termios.tcgetattr(fd)
    new = termios.tcgetattr(fd)
    if hidden:
      new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
    else:
      new[3] = new[3] & ~termios.ICANON
    new[6][termios.VMIN] = 1
    new[6][termios.VTIME] = 0
    try:
      termios.tcsetattr(fd, termios.TCSANOW, new)
      termios.tcsendbreak(fd, 0)
      ch = _read()
    finally:
      termios.tcsetattr(fd, termios.TCSAFLUSH, old)
  else:
    ch = _read()

  sys.stdout.write(end)
  return ch
开发者ID:EvanHongYousan,项目名称:spiders-python,代码行数:34,代码来源:myutils.py


示例5: getchar

def getchar():
	'''
	Equivale al comando getchar() di C
	'''

	fd = sys.stdin.fileno()
	
	if os.isatty(fd):
		
		old = termios.tcgetattr(fd)
		new = termios.tcgetattr(fd)
		new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
		new[6] [termios.VMIN] = 1
		new[6] [termios.VTIME] = 0
		
		try:
			termios.tcsetattr(fd, termios.TCSANOW, new)
			termios.tcsendbreak(fd,0)
			ch = os.read(fd,7)

		finally:
			termios.tcsetattr(fd, termios.TCSAFLUSH, old)
	else:
		ch = os.read(fd,7)
	
	return(ch)
开发者ID:pedosb,项目名称:apresentacoes,代码行数:26,代码来源:time.py


示例6: sendBreak

 def sendBreak(self, duration=0.25):
     """Send break condition. Timed, returns to idle state after given duration."""
     if not self._isOpen: raise portNotOpenError
     try:
         termios.tcsendbreak(self.fd, int(duration/0.25))
     except termios.error as err:
         raise SerialException("sendBreak failed: %s" % err)
开发者ID:Gudui,项目名称:tinypacks,代码行数:7,代码来源:serialposix.py


示例7: get_char

     def get_char(self, timeout = 0):
       ch = '' 
       fd = sys.stdin.fileno()
       if os.isatty(fd):
         oldterm = termios.tcgetattr(fd)
         term = termios.tcgetattr(fd)
         term[3] = term[3] & ~termios.ICANON & ~termios.ECHO
	 if not timeout:
           term[6] [termios.VMIN] = 1
           term[6] [termios.VTIME] = timeout
	 else:
           term[6] [termios.VMIN] = 0 
           term[6] [termios.VTIME] = timeout
         try :
           termios.tcsetattr(fd, termios.TCSANOW, term)
           import platform
           if platform.system().find('BSD') == -1:
# Fix for BSD, avoid sendbreack : termios.error: (25, 'Inappropriate ioctl for device')
             termios.tcsendbreak(fd, 0)
	   try :
	     ch = os.read(fd, 7) 
	   except OSError:
	     pass
         finally :	
	   termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
       else: 
	  try :	
             ch = os.read(fd, 7)
	  except OSError:
		pass
       if len(ch) == 1:
         if ch in string.printable:
           return ch
         elif ch == '\b' or ch == '\x7f':
           self.delchar()
       elif ch == self.MOVE_LEFT: #left arrow
         if self.cursor > 0:	
	   self.print_text(ch)
	   self.cursor -= 1	
       elif ch == self.MOVE_RIGHT:
         if self.cursor < len(self.line):
	   self.print_text(ch)
	   self.cursor += 1
       elif ch == self.MOVE_UP:
	   self.clear_line()
	   cmd = self.history.getnext()
	   if cmd:
             self.insert_text(cmd)	
       elif ch == self.MOVE_DOWN:
	   self.clear_line()
           cmd = self.history.getprev()
	   if cmd:
	    self.insert_text(cmd)
       return None	
开发者ID:halbbob,项目名称:dff,代码行数:54,代码来源:complete_raw_input.py


示例8: setterm

def setterm():
  old = termios.tcgetattr(sys.stdin)
  new = termios.tcgetattr(sys.stdin)
  #new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
  new[3] = new[3] & ~termios.ICANON
  new[6] [termios.VMIN] = 1
  new[6] [termios.VTIME] = 0

  termios.tcsetattr(sys.stdin, termios.TCSANOW, new)
  termios.tcsendbreak(sys.stdin,0)

  atexit.register(termios.tcsetattr, sys.stdin, termios.TCSAFLUSH, old)
开发者ID:danielinux,项目名称:vde3,代码行数:12,代码来源:test_console.py


示例9: setTtyNoncanonical

def setTtyNoncanonical(fd, timeout=0):
	import termios
	old = termios.tcgetattr(fd)
	new = termios.tcgetattr(fd)
	new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
	# http://www.unixguide.net/unix/programming/3.6.2.shtml
	#new[6] [termios.VMIN] = 1
	#new[6] [termios.VTIME] = 0
	new[6] [termios.VMIN] = 0 if timeout > 0 else 1
	timeout *= 10 # 10ths of second
	if timeout > 0 and timeout < 1: timeout = 1
	new[6] [termios.VTIME] = timeout
		
	termios.tcsetattr(fd, termios.TCSANOW, new)
	termios.tcsendbreak(fd,0)
开发者ID:iamnilay3,项目名称:music-player,代码行数:15,代码来源:utils.py


示例10: prepareStdin

def prepareStdin():
	fd = sys.stdin.fileno()
	
	if os.isatty(fd):		
		old = termios.tcgetattr(fd)
		new = termios.tcgetattr(fd)
		new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
		# http://www.unixguide.net/unix/programming/3.6.2.shtml
		#new[6] [termios.VMIN] = 1
		#new[6] [termios.VTIME] = 0
		new[6] [termios.VMIN] = 0
		#timeout *= 10 # 10ths of second
		#if timeout > 0 and timeout < 1: timeout = 1
		timeout = 1
		new[6] [termios.VTIME] = timeout
		
		termios.tcsetattr(fd, termios.TCSANOW, new)
		termios.tcsendbreak(fd,0)
开发者ID:iamnilay3,项目名称:music-player,代码行数:18,代码来源:test_ffmpeg.py


示例11: getchar

def getchar():
    """ Works like C getchar()

    http://snippets.dzone.com/posts/show/3084 
    """
    fd = sys.stdin.fileno()
    if os.isatty(fd):
        old, new = termios.tcgetattr(fd), termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0
        try:
            termios.tcsetattr(fd, termios.TCSANOW, new)
            termios.tcsendbreak(fd,0)
            ch = os.read(fd, 7)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
    else:
        ch = os.read(fd, 7)
    return ch
开发者ID:andreisavu,项目名称:remotecontrol,代码行数:20,代码来源:cli.py


示例12: getchar

def getchar():
    """
    getchar in C
    """
    fd = sys.stdin.fileno()
    if os.isatty(fd):
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0
        try:
            termios.tcsetattr(fd, termios.TCSANOW, new)
            termios.tcsendbreak(fd, 0)
            ch = os.read(fd, 2)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
    else:
        ch = os.read(fd, 2)
    return ch.decode("utf-8")
开发者ID:baniuyao,项目名称:SongPwd,代码行数:20,代码来源:getchar.py


示例13: get_char

     def get_char(self):
       fd = sys.stdin.fileno()
       if os.isatty(fd):
         oldterm = termios.tcgetattr(fd)
         term = termios.tcgetattr(fd)
         term[3] = term[3] & ~termios.ICANON & ~termios.ECHO
         term[6] [termios.VMIN] = 1
         term[6] [termios.VTIME] = 0
         try :
           termios.tcsetattr(fd, termios.TCSANOW, term)
           termios.tcsendbreak(fd, 0)
	   ch = os.read(fd, 7) 
         finally :	
	   termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
       else: 	
           ch = os.read(fd, 7)
       if len(ch) == 1:
         if ch in string.printable:
           return ch
         elif ch == '\b' or ch == '\x7f':
           self.delchar()
       elif ch == self.MOVE_LEFT: #left arrow
         if self.cursor > 0:	
	   self.print_text(ch)
	   self.cursor -= 1	
       elif ch == self.MOVE_RIGHT:
         if self.cursor < len(self.line):
	   self.print_text(ch)
	   self.cursor += 1
       elif ch == self.MOVE_UP:
	   self.clear_line()
	   cmd = self.history.getnext()
	   if cmd:
             self.insert_text(cmd)	
       elif ch == self.MOVE_DOWN:
	   self.clear_line()
           cmd = self.history.getprev()
	   if cmd:
	    self.insert_text(cmd)
       return None	
开发者ID:alepee,项目名称:dff,代码行数:40,代码来源:complete_raw_input.py


示例14: prepareStdin

def prepareStdin():
	fd = sys.stdin.fileno()
	
	if os.isatty(fd):		
		old = termios.tcgetattr(fd)
		new = termios.tcgetattr(fd)
		new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
		# http://www.unixguide.net/unix/programming/3.6.2.shtml
		new[6][termios.VMIN] = 0
		new[6][termios.VTIME] = 1
		
		termios.tcsetattr(fd, termios.TCSANOW, new)
		termios.tcsendbreak(fd, 0)

		import atexit
		atexit.register(lambda: termios.tcsetattr(fd, termios.TCSANOW, old))	

		print "Console control:"
		print "  <space>:        play / pause"
		print "  <left>/<right>: seek back/forward by 10 secs"
		print "  <return>:       next song"
		print "  <q>:            quit"
开发者ID:HikaruLim,项目名称:music-player-core,代码行数:22,代码来源:demo-console-player.py


示例15: __init__

    def __init__(self,port='/dev/ttyUSB0',windings=None):
        self._port = serial.Serial(port,115200,timeout=0)
        self.windings = windings
        self.statusTimeout = time.time() + 5.0
        self.modalTimeout = time.time() + 5.0
        self.buffer = ""
        self.keybuffer = ""
        self.status = {'lastPn':"",'Pn':""}
        self.running = True
        self.wire = None
        self.debug=False
        self.direction = 1
        self.leadin = True
        self.windingNextUpdate = 0

        self.fd = sys.stdin.fileno()
        self.old = termios.tcgetattr(self.fd)
        new = termios.tcgetattr(self.fd)
        new[3] = (new[3] & ~termios.ICANON) & ~termios.ECHO
        new[6][termios.VMIN] = 0
        new[6][termios.VTIME] = 0
        termios.tcsetattr(self.fd, termios.TCSANOW, new)
        termios.tcsendbreak(self.fd,0)

        self.wires = []
        f = open('wire table.csv','rb')
        reader = csv.DictReader(f)
        for r in reader:
            for k in r:
                try:
                    r[k] = float(r[k])
                except:
                    pass
            self.wires.append(r)
            if int(r['size']) == 22:
                self.wire = r

        self.windingSetup()
开发者ID:holla2040,项目名称:valvestudio,代码行数:38,代码来源:Machine.py


示例16: getchar

def getchar():
    """Get single char from terminal, much like getchar() in C"""
    import os
    import sys
    import termios

    fd = sys.stdin.fileno()
    if os.isatty(fd):
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0

        try:
            termios.tcsetattr(fd, termios.TCSANOW, new)
            termios.tcsendbreak(fd, 0)
            ch = os.read(fd, 7)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
    else:
        ch = os.read(fd, 7)

    return ch
开发者ID:iosonofabio,项目名称:hivwholeseq,代码行数:24,代码来源:generic.py


示例17: tcsendbreak

def tcsendbreak(space, fd, duration):
    try:
        termios.tcsendbreak(fd, duration)
    except OSError, e:
        raise convert_error(space, e)
开发者ID:ieure,项目名称:pypy,代码行数:5,代码来源:interp_termios.py


示例18:

	
attr = termios.tcgetattr(port)

# iflag
attr[0] = attr[0] & ~(termios.IXON | termios.IXOFF | termios.IXANY | termios.INLCR | termios.IGNCR | termios.ICRNL)

# oflag
attr[1] = attr[1] & ~(termios.OPOST)

# cflag
attr[2] = attr[2] & ~(termios.CSIZE | termios.CSTOPB | termios.CRTSCTS | termios.PARODD)
attr[2] = attr[2] | (termios.CS7 | termios.PARENB | termios.CLOCAL)

# lflag
attr[3] = attr[3] & ~(termios.ICANON | termios.ECHO | termios.ECHOE | termios.ISIG)

# speed
attr[4] = termios.B9600
attr[5] = termios.B9600

# async
attr[6][termios.VMIN] = 0
attr[6][termios.VTIME] = 0

termios.tcsetattr(port, termios.TCSANOW, attr)

termios.tcsendbreak(port, 0)
port.write(configureString)

port.close()
开发者ID:hyrant,项目名称:fulcrum,代码行数:29,代码来源:moduleconfig.py


示例19: initialization

import termios
import time
import comware

__author__ = 'Yannick Castano'

#******************************************************************************
# Terminal input initialization (thanks to Dobias van Ingen)
#******************************************************************************
fd = sys.stdin.fileno();
new = termios.tcgetattr(fd)
new[3] = new[3] | termios.ICANON | termios.ECHO
new[6] [termios.VMIN] = 1
new[6] [termios.VTIME] = 0
termios.tcsetattr(fd, termios.TCSANOW, new)
termios.tcsendbreak(fd,0)

#******************************************************************************
# Global variables
#******************************************************************************

CLIENTPORT = 50001
SERVERPORT = 50000
TIMEOUT = 60 # seconds

#******************************************************************************
# Procedures
#******************************************************************************
def main_menu( ):
	while True:
		print "\n"
开发者ID:HPENetworking,项目名称:scriptsonly,代码行数:31,代码来源:PathFinder-Client.py


示例20: sendbreak

 def sendbreak(self):
     termios.tcsendbreak(self.fd, 0)
开发者ID:coolzc,项目名称:port,代码行数:2,代码来源:port.py



注:本文中的termios.tcsendbreak函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python termios.tcsetattr函数代码示例发布时间:2022-05-27
下一篇:
Python termios.tcgetattr函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap