def main(): tx_pckt = tos.Packet([('data', 'int', 2)], []) AM_ID = 6 serial_port = tos.Serial("/dev/ttyUSB0", 115200) am = tos.AM(serial_port) #for i in xrange(10): while 1: raw_input("Press enter to send serial packet\n") am.write(tx_pckt, AM_ID)
def __init__(self, desc, packet=None): self.tos_packet = tos.Packet(desc, packet)
if len(sys.argv) < 2: print "no device specified" print "example:" print " syncedRadioStats.py /dev/ttyUSB5" else: try: # ser = tos.Serial(sys.argv[1], 115200, flush=True, debug=False) ser = tos.Serial(sys.argv[1], 115200) am = tos.AM(ser) except: print "ERROR: Unable to initialize serial port connection to", sys.argv[ 1] sys.exit(-1) AM_HOST_CONTROLLED_TIMING_MSG = 0x7F wpacket = tos.Packet([('msg', 'int', 1)]) #1 byte integer (i.e. uint8_t) wpacket.msg = ord('s') am.write(wpacket, AM_HOST_CONTROLLED_TIMING_MSG) num_received = [] senders_seen = [] num_missed = [] last_count = [] packet_size = [] sending_rate = [] last_time_stamp = [] num_lines = 0 print "Node ID | Sending Rate | Packet size | Num received | Num missed | % missed | Current count" try: while True:
#!/usr/bin/env python import sys import tos #application defined messages tx_pckt = tos.Packet([('type', 'int', 1)],[]) AM_BLINKTORADIO=6 serial_port = tos.Serial("/dev/ttyUSB0",115200) am = tos.AM(serial_port) for i in xrange(10): am.write(tx_pckt,AM_BLINKTORADIO) pckt = am.read(timeout=0.5) if pckt is not None: print pckt.type print pckt.data