本文整理汇总了Python中serial_manager.SerialManager.send_queue_as_ready方法的典型用法代码示例。如果您正苦于以下问题:Python SerialManager.send_queue_as_ready方法的具体用法?Python SerialManager.send_queue_as_ready怎么用?Python SerialManager.send_queue_as_ready使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serial_manager.SerialManager
的用法示例。
在下文中一共展示了SerialManager.send_queue_as_ready方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_with_callback
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import send_queue_as_ready [as 别名]
def run_with_callback(host):
""" Start a wsgiref server instance with control over the main loop.
This is a function that I derived from the bottle.py run()
"""
handler = default_app()
server = wsgiref.simple_server.make_server(host, NETWORK_PORT, handler)
server.timeout = 0.01
server.quiet = True
print "-----------------------------------------------------------------------------"
print "Bottle server starting up ..."
print "Serial is set to %d bps" % BITSPERSECOND
print "Point your browser to: "
print "http://%s:%d/ (local)" % ("127.0.0.1", NETWORK_PORT)
if host == "":
print "http://%s:%d/ (public)" % (socket.gethostbyname(socket.gethostname()), NETWORK_PORT)
print "Use Ctrl-C to quit."
print "-----------------------------------------------------------------------------"
print
try:
webbrowser.open_new_tab("http://127.0.0.1:" + str(NETWORK_PORT))
except webbrowser.Error:
print "Cannot open Webbrowser, please do so manually."
sys.stdout.flush() # make sure everything gets flushed
while 1:
try:
SerialManager.send_queue_as_ready()
server.handle_request()
except KeyboardInterrupt:
break
print "\nShutting down..."
SerialManager.close()
示例2: run_with_callback
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import send_queue_as_ready [as 别名]
def run_with_callback(host, port=4444, timeout=0.01):
""" Start a wsgiref server instance with control over the main loop.
This is a function that I derived from the bottle.py run()
"""
handler = default_app()
server = wsgiref.simple_server.make_server(host, port, handler)
server.timeout = timeout
print "-----------------------------------------------------------------------------"
print "Bottle server starting up ..."
print "Serial is set to %d bps" % BITSPERSECOND
print "Point your browser to: "
print "http://%s:%d/ (local)" % ('127.0.0.1', port)
if host == '':
print "http://%s:%d/ (public)" % (socket.gethostbyname(socket.gethostname()), port)
print "Use Ctrl-C to quit."
print "-----------------------------------------------------------------------------"
print
while 1:
try:
SerialManager.send_queue_as_ready()
server.handle_request()
except KeyboardInterrupt:
break
print "\nShutting down..."
SerialManager.close()
示例3: run_with_callback
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import send_queue_as_ready [as 别名]
def run_with_callback(host, port, rfidreader, logger, powertimer):
""" Start a wsgiref server instance with control over the main loop.
This is a function that I derived from the bottle.py run()
"""
debug(True)
handler = default_app()
handler.catchall = False
handler.rfidreader = rfidreader
handler.logger = logger
handler.powertimer = powertimer
server = make_server(host, port, handler, handler_class=HackedWSGIRequestHandler)
server.timeout = 0.01
#server.quiet = True
print "Persistent storage root is: " + storage_dir()
print "-----------------------------------------------------------------------------"
print "Bottle server starting up ..."
print "Serial is set to %d bps" % BITSPERSECOND
print "Point your browser to: "
print "http://%s:%d/ (local)" % ('127.0.0.1', port)
# if host == '':
# try:
# print "http://%s:%d/ (public)" % (socket.gethostbyname(socket.gethostname()), port)
# except socket.gaierror:
# # print "http://beaglebone.local:4444/ (public)"
# pass
print "Use Ctrl-C to quit."
print "-----------------------------------------------------------------------------"
print
# auto-connect on startup
global SERIAL_PORT
if not SERIAL_PORT:
SERIAL_PORT = SerialManager.match_device(GUESS_PREFIX, BITSPERSECOND)
SerialManager.connect(SERIAL_PORT, BITSPERSECOND)
# open web-browser
try:
webbrowser.open_new_tab('http://127.0.0.1:'+str(port))
pass
except webbrowser.Error:
print "Cannot open Webbrowser, please do so manually."
sys.stdout.flush() # make sure everything gets flushed
server.timeout = 0
while 1:
try:
SerialManager.send_queue_as_ready()
server.handle_request()
time.sleep(0.0004)
except KeyboardInterrupt:
break
print "\nShutting down..."
SerialManager.close()
示例4: run_with_callback
# 需要导入模块: from serial_manager import SerialManager [as 别名]
# 或者: from serial_manager.SerialManager import send_queue_as_ready [as 别名]
def run_with_callback(host, port):
""" Start a wsgiref server instance with control over the main loop.
This is a function that I derived from the bottle.py run()
"""
handler = default_app()
server = make_server(host, port, handler, handler_class=HackedWSGIRequestHandler)
if CERTSDIR:
server.socket = ssl.wrap_socket(server.socket,
keyfile=KEYFILE,
certfile=CERTSFILE,
server_side=True,
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=CA_CERTSFILE)
loadAccounts()
server.verify_request = verify_request
server.timeout = 0.01
server.quiet = True
print "Persistent storage root is: " + storage_dir()
print "-----------------------------------------------------------------------------"
print "Bottle server starting up ..."
print "Serial is set to %d bps" % BITSPERSECOND
print "Point your browser to: "
if CERTSDIR:
print "https://%s:%d/" % (COMMON_NAME, port)
elif COMMON_NAME:
print "http://%s:%d/" % (COMMON_NAME, port)
else:
print "http://%s:%d/" % ('127.0.0.1', port)
print "Use Ctrl-C to quit."
print "-----------------------------------------------------------------------------"
print
# auto-connect on startup
global SERIAL_PORT
if not SERIAL_PORT:
SERIAL_PORT = SerialManager.match_device(GUESS_PREFIX, BITSPERSECOND)
SerialManager.connect(SERIAL_PORT, BITSPERSECOND)
# I:Mega Start
time.sleep(1.0)
# I:Mega End
# # open web-browser
# try:
# webbrowser.open_new_tab('http://127.0.0.1:'+str(port))
# pass
# except webbrowser.Error:
# print "Cannot open Webbrowser, please do so manually."
sys.stdout.flush() # make sure everything gets flushed
server.timeout = 0
lastPowerStatus = 0
powerStateChange = 0
while 1:
try:
serial_handler('1')
SerialManager.send_queue_as_ready()
server.handle_request()
if HARDWARE == 'raspberrypi':
powerStatus = RPiPowerControl.interval_check()
if powerStatus != lastPowerStatus:
powerStateChange = 1
lastPowerStatus = powerStatus
if powerStateChange:
powerStateChange = checkStatus()
time.sleep(0.0004)
except KeyboardInterrupt:
if HARDWARE == 'raspberrypi':
RPiPowerControl.gpio_cleanup()
break
except:
import traceback
traceback.print_exc()
break
print "\nShutting down..."
if redirect_pid:
os.kill(redirect_pid, signal.SIGTERM)
SerialManager.close()