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()
from xbee import ZigBee import serial import datetime import logging import sys import os import pickle import time from xbee_gateway import XBeeGateway def print_data(d): print "Got data" data = pickle.loads(d) print data['timestamp'] serial_port = "/dev/cu.usbserial-DN01DS4M" baud_rate = 9600 xbg = XBeeGateway() xbg.register_callback(print_data) xbg.setup_xbee(serial_port, baud_rate) xbg.begin()
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()