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