本文整理汇总了Python中serial_manager.SerialManager.flush_output方法的典型用法代码示例。如果您正苦于以下问题:Python SerialManager.flush_output方法的具体用法?Python SerialManager.flush_output怎么用?Python SerialManager.flush_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serial_manager.SerialManager
的用法示例。
在下文中一共展示了SerialManager.flush_output方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: serial_handler
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import flush_output [as 别名]
def serial_handler(connect):
if connect == '1':
# print 'js is asking to connect serial'
if not SerialManager.is_connected():
try:
global SERIAL_PORT, BITSPERSECOND, GUESS_PREFIX
if not SERIAL_PORT:
SERIAL_PORT = SerialManager.match_device(GUESS_PREFIX, BITSPERSECOND)
SerialManager.connect(SERIAL_PORT, BITSPERSECOND)
ret = "Serial connected to %s:%d." % (SERIAL_PORT, BITSPERSECOND) + '<br>'
time.sleep(1.0) # allow some time to receive a prompt/welcome
SerialManager.flush_input()
SerialManager.flush_output()
return ret
except serial.SerialException:
SERIAL_PORT = None
print "Failed to connect to serial."
return ""
elif connect == '0':
# print 'js is asking to close serial'
if SerialManager.is_connected():
if SerialManager.close(): return "1"
else: return ""
elif connect == "2":
# print 'js is asking if serial connected'
if SerialManager.is_connected(): return "1"
else: return ""
else:
print 'ambigious connect request from js: ' + connect
return ""