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


Python Decoder.register_callback方法代码示例

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


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

示例1: Decoder

# 需要导入模块: from decoder import Decoder [as 别名]
# 或者: from decoder.Decoder import register_callback [as 别名]
from xbee import ZigBee
import sys
import serial
import datetime
import struct
import collections

from decoder import Decoder
from xbee_gateway import XBeeGateway

decoder = Decoder()
xbg = XBeeGateway()

decoder.register_callback(decoder.print_dictionary)
decoder.register_callback(decoder.write_to_file)
#decoder.register_callback(decoder.write_to_db)
xbg.register_callback(decoder.decode_data)


port = raw_input("Please enter your serial port path/name: ")
baud_rate = 9600

xbg.setup_xbee(port, baud_rate)
xbg.begin_test()
开发者ID:scel-hawaii,项目名称:data-gateway,代码行数:26,代码来源:packet_tester.py

示例2: Thread

# 需要导入模块: from decoder import Decoder [as 别名]
# 或者: from decoder.Decoder import register_callback [as 别名]
    fake_xbee.start_loop()

test_packet_thread = Thread(target=start_test_packet)
test_packet_thread.start()

#
# SETUP PACKET TESTER
#
# This is the python script that normally runs on the laptop
#
# subprocess.call("cd ../src && python packet_tester.py", shell=True)

def print_data(data, timestamp):
    print(timestamp)
    print(data)

decoder = Decoder()
decoder.register_callback(decoder.print_dictionary)

gateway = XBeeGateway()
gateway.register_callback(decoder.decode_data)
gateway.setup_xbee('./ttyV2', 9600)
gateway.begin_loop()


#
# BLOCK UNTIL CONTROL-C
#
test_packet_thread.join()
tty_bridge.wait()
开发者ID:scel-hawaii,项目名称:control-tower,代码行数:32,代码来源:integration_test.py


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