当前位置: 首页>>代码示例>>Python>>正文


Python termios.tcdrain函数代码示例

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


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

示例1: flush

 def flush(self):
     """\
     Flush of file like objects. In this case, wait until all data
     is written.
     """
     if not self.is_open:
         raise portNotOpenError
     termios.tcdrain(self.fd)
开发者ID:AlfredHunter,项目名称:pyserialTest,代码行数:8,代码来源:serialposix.py

示例2: doGo

def doGo(options, param):
  checkDevOpen(options)
  os.write(options.dev, "G%x#" % tuple(param))

  # This tcdrain() seems to be necessary on some machines when the 'go'
  # command is the last one on the command line. It seems that the command
  # isn't fully sent by the time the program exits.
  termios.tcdrain(options.dev)

  return
开发者ID:Linux-enCaja,项目名称:robotica,代码行数:10,代码来源:sambaif.py

示例3: read_error_status

def read_error_status(board):
   # To do : check the arguments
   dest = board<<2
   wrtbuf = [PRE, CMD_GET_ERROR, dest, POST, POST, POST, POST]
   os.write(filehandle,bytes(wrtbuf))
   termios.tcdrain(filehandle)
   ok , data = read_uart(4)
   if (not ok) : # or wrtbuf[0]!=CMD_GET_ERROR or wrtbuf[1]!=dest) :
     return -1
   val = (data[2]<<8) | data[3]
   return val
开发者ID:oatmeal3000,项目名称:qupy,代码行数:11,代码来源:gertbot.py

示例4: get_version

def get_version(board) :
   dest = (board<<2)
   wrtbuf = [0xA0, CMD_VERSION, dest, POST, POST, POST, POST]
   os.write(filehandle,bytearray(wrtbuf))
   termios.tcdrain(filehandle)
   ok , data = read_uart(4)
   if (not ok) : # or wrtbuf[0]!=CMD_GET_ERROR or wrtbuf[1]!=dest) :
     return 0
   # convert xx.yy into xx*100+yy 
   # thus version 2.5 comes out as 205
   val = data[2]*100 + data[3]
   return val
开发者ID:kris-sum,项目名称:gertbot,代码行数:12,代码来源:gertbot2.py

示例5: flush

    def flush(self):
        """Flush the write buffer of the serial port, blocking until all bytes
        are written.

        Raises:
            SerialError: if an I/O or OS error occurs.

        """
        try:
            termios.tcdrain(self._fd)
        except termios.error as e:
            raise SerialError(e.errno, "Flushing serial port: " + e.strerror)
开发者ID:enzochiau,项目名称:python-periphery,代码行数:12,代码来源:serial.py

示例6: read_adc

def read_adc(board,adc) :            
   # To do : check the arguments
   dest = (board<<2) | adc
   wrtbuf = [PRE, CMD_GET_ADC, dest, POST, POST, POST, POST]
   os.write(filehandle,bytes(wrtbuf))
   termios.tcdrain(filehandle)
   ok , data = read_uart(4)
   if (not ok) : # or data[0]!=CMD_GET_ERROR or data[1]!=dest) :
      return -1
   ival = (data[2]<<8) | data[3]
   ## convert integer to float in range 0..3.3V
   return ival*(3.3/4095.0)
开发者ID:oatmeal3000,项目名称:qupy,代码行数:12,代码来源:gertbot.py

示例7: thread_send_stop

 def thread_send_stop(self):
     if (self.fd > 0):
         if ENABLE_RTS_LINE:
             self.portLock.acquire()
             if ENABLE_TCDRAIN:
                 termios.tcdrain(self.fd)
             time.sleep(SERIAL_PORT_COOLDOWN_TIME)
             # set RTS to off
             self.setRTS(False)
             self.portLock.release()
     # use the message queue to send self.sentPackets
     if self.msgQueue is not None:
         self.msgQueue.put((self.txThread.threadID, self.sentPackets, REPORT_DATA_RECIEVED))
开发者ID:JosephLutz,项目名称:serialCommTest,代码行数:13,代码来源:serialData.py

示例8: read_inputs

def read_inputs(board) :
#  GB_CHECKN(board>=0 && board<=3, "read_inputs illegal board\n")
   dest = (board << 2)
   wrtbuf = [PRE, CMD_READIO, dest, POST, POST, POST, POST, POST]
   os.write(filehandle,bytes(wrtbuf))
   termios.tcdrain(filehandle)
   ok , rec_data = read_uart(5)
   if (not ok) : # or data[0]!=CMD_GET_ADC or data[1]!=dest) :
      return -1
   i_value  = rec_data[4]
   i_value |= rec_data[3]<<8
   i_value |= rec_data[2]<<16
   return i_value
开发者ID:oatmeal3000,项目名称:qupy,代码行数:13,代码来源:gertbot.py

示例9: get_motor_status

def get_motor_status(brd,mot) :
   id = (brd<<2) | mot
   wrtbuf = [PRE, CMD_MOT_STATUS, id, POST, POST, POST, POST, POST, POST]
   os.write(filehandle,bytes(wrtbuf))
   # returns 6 bytes:
   # ID, CMD, move,
   # step_count:MS, step_count:MM, step_count:LS
   termios.tcdrain(filehandle)
   ok , rec_data = read_uart(6)
   if (not ok) : # or rec_data[0]!=CMD_MOT_STATUS or rec_data[1]!=dest) :
      return []
   motor_data = [0]*2
   motor_data[0] = rec_data[2] & 0x0F
   motor_data[1] =(rec_data[3]<<16) + (rec_data[4]<<8)+rec_data[5]
   return motor_data 
开发者ID:oatmeal3000,项目名称:qupy,代码行数:15,代码来源:gertbot.py

示例10: _open

 def _open(self, port, speed):
     self._fd = os.open(port, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
     self.port = os.fdopen(self._fd, "r+b", buffering=0)
     iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(self._fd)
     iflag = termios.IGNBRK | termios.IGNPAR
     oflag = 0
     cflag |= termios.CLOCAL | termios.CREAD | termios.CS8
     lflag = 0
     ispeed = ospeed = getattr(termios, "B%s" % speed)
     cc[termios.VMIN] = 1
     cc[termios.VTIME] = 0
     termios.tcsetattr(self._fd, termios.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
     termios.tcdrain(self._fd)
     termios.tcflush(self._fd, termios.TCOFLUSH)
     termios.tcflush(self._fd, termios.TCIFLUSH)
开发者ID:jordens,项目名称:ventilator,代码行数:15,代码来源:kernel.py

示例11: set_baud

 def set_baud(self, baud):
     iflag, oflag, cflag, lflag, ispeed, ospeed, cc = \
         termios.tcgetattr(self._fd)
     iflag = termios.IGNBRK | termios.IGNPAR
     oflag = 0
     cflag |= termios.CLOCAL | termios.CREAD | termios.CS8
     lflag = 0
     ispeed = ospeed = getattr(termios, "B"+str(baud))
     cc[termios.VMIN] = 1
     cc[termios.VTIME] = 0
     termios.tcsetattr(self._fd, termios.TCSANOW, [
         iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
     termios.tcdrain(self._fd)
     termios.tcflush(self._fd, termios.TCOFLUSH)
     termios.tcflush(self._fd, termios.TCIFLUSH)
     logger.debug("baud rate set to".format(baud))
开发者ID:yuyichao,项目名称:artiq,代码行数:16,代码来源:comm_serial.py

示例12: get_motor_missed

def get_motor_missed(brd,mot) :
   id = (brd<<2) | mot
   wrtbuf = [PRE, CMD_MOT_MISSED, id, POST, POST, POST, POST, POST, POST]
   os.write(filehandle,bytes(wrtbuf))
   # returns 8 bytes:
   # ID, CMD,
   # missed:MS, missed:MM, missed:LS
   # three times 0 
   termios.tcdrain(filehandle)
   ok , rec_data = read_uart(8)
   if (not ok) : # or rec_data[0]!=CMD_MOT_MISSED or rec_data[1]!=dest) :
      return []
   motor_data = [0]*2
   motor_data[0] =(rec_data[2]<<16) + (rec_data[3]<<8)+rec_data[4]
   # Next should be zero 
   motor_data[1] =(rec_data[5]<<16) + (rec_data[6]<<8)+rec_data[7]
   return motor_data 
开发者ID:oatmeal3000,项目名称:qupy,代码行数:17,代码来源:gertbot.py

示例13: get_motor_config

def get_motor_config(brd,mot) :
   id = (brd<<2) | mot
   wrtbuf = [PRE, CMD_MOT_CONFIG, id, POST, POST, POST, POST, POST,
             POST, POST, POST, POST, POST, POST, POST, POST]
   os.write(filehandle,bytes(wrtbuf))
   termios.tcdrain(filehandle)
   ok , rec_data = read_uart(13)
   if (not ok) : # or rec_data[0]!=CMD_MOT_CONFIG or rec_data[1]!=dest) :
      return []
   motor_data = [0]*8
   motor_data[0] = rec_data[2] & 0x1F
   motor_data[1] = rec_data[3] & 0xF
   motor_data[2] = rec_data[3]>>4
   motor_data[3] =(rec_data[4]<<16) + (rec_data[5]<<8)+rec_data[6]
   motor_data[4] =(rec_data[7]<<8)  + rec_data[8]
   motor_data[5] =(rec_data[9] & 0x0F)
   motor_data[6] =(rec_data[9] >>4)
   motor_data[7] =(rec_data[10] & 0x0F)
   return motor_data
开发者ID:oatmeal3000,项目名称:qupy,代码行数:19,代码来源:gertbot.py

示例14: flush

 def flush(self):
     termios.tcdrain(self.fd)
开发者ID:amlinux,项目名称:rcrobot,代码行数:2,代码来源:rcserial.py

示例15: tcdrain

def tcdrain(space, w_fd):
    fd = space.c_filedescriptor_w(w_fd)
    try:
        termios.tcdrain(fd)
    except OSError, e:
        raise convert_error(space, e)
开发者ID:yuyichao,项目名称:pypy,代码行数:6,代码来源:interp_termios.py


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