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