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


Python UART.deinit方法代码示例

本文整理汇总了Python中pyb.UART.deinit方法的典型用法代码示例。如果您正苦于以下问题:Python UART.deinit方法的具体用法?Python UART.deinit怎么用?Python UART.deinit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyb.UART的用法示例。


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

示例1: JYMCU

# 需要导入模块: from pyb import UART [as 别名]
# 或者: from pyb.UART import deinit [as 别名]
class JYMCU(object):
  """JY-MCU Bluetooth serial device driver.  This is simply a light UART wrapper
     with addition AT command methods to customize the device."""

  def __init__( self, uart, baudrate ):
    """ uart = uart #1-6, baudrate must match what is set on the JY-MCU.
        Needs to be a #1-C. """
    self._uart = UART(uart, baudrate)

  def __del__( self ) : self._uart.deinit()

  def any( self ) : return self._uart.any()

  def write( self, astring ) : return self._uart.write(astring)
  def writechar( self, achar ) : self._uart.writechar(achar)

  def read( self, num = None ) : return self._uart.read(num)
  def readline( self ) : return self._uart.readline()
  def readchar( self ) : return self._uart.readchar()
  def readall( self ) : return self._uart.readall()
  def readinto( self, buf, count = None ) : return self._uart.readinto(buf, count)

  def _cmd( self, cmd ) :
    """ Send AT command, wait a bit then return result string. """
    self._uart.write("AT+" + cmd)
    udelay(500)
    return self.readline()

  def baudrate( self, rate ) :
    """ Set the baud rate.  Needs to be #1-C. """
    return self._cmd("BAUD" + str(rate))

  def name( self, name ) :
    """ Set the name to show up on the connecting device. """
    return self._cmd("NAME" + name)

  def pin( self, pin ) :
    """ Set the given 4 digit numeric pin. """
    return self._cmd("PIN" + str(pin))

  def version( self ) : return self._cmd("VERSION")

  def setrepl( self ) : repl_uart(self._uart)
开发者ID:rolandvs,项目名称:GuyCarverMicroPythonCode,代码行数:45,代码来源:JYMCU.py

示例2: UART

# 需要导入模块: from pyb import UART [as 别名]
# 或者: from pyb.UART import deinit [as 别名]
    uart0 = UART(0, 1000000)
    uart1 = UART(1, 1000000)

# next ones must raise
try:
    UART(0, 9600, parity=None, pins=('GP12', 'GP13', 'GP7'))
except Exception:
    print('Exception')

try:
    UART(0, 9600, parity=UART.ODD, pins=('GP12', 'GP7'))
except Exception:
    print('Exception')

uart0 = UART(0, 1000000)
uart0.deinit()
try:
    uart0.any()
except Exception:
    print('Exception')

try:
    uart0.read()
except Exception:
    print('Exception')

try:
    uart0.write('abc')
except Exception:
    print('Exception')
开发者ID:rubencabrera,项目名称:micropython,代码行数:32,代码来源:uart.py


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