Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from tinyos import tos
- """
- Jacks Version
- """
- CHANNEL = 6
- class BroadcastPacket(tos.Packet):
- def __init__(self, packet = None):
- print 'Debug: initialised bPacket'
- tos.Packet.__init__(self,
- [('node_id', 'int', 2),
- ('hopCount', 'int', 1),
- ('temperature', 'int', 2),
- ('light', 'int', 2),
- ('humidity', 'int', 2),
- ('TTL', 'int', 1),
- ('TSN', 'int', 2)], packet)
- if '-h' in sys.argv:
- print "Usage:", sys.argv[0], "serial@/dev/ttyUSB0:115200"
- sys.exit()
- am = tos.AM()
- while True:
- p = am.read()
- if p and p.type == CHANNEL:
- msg = BroadcastPacket(p.data)
- print "Payload\nFrom: {}\nHop Count: {}\nTemp: {}\nLight: {}\nHumidity: {}\nTTL: {}\nTSN: {}\n\n".format(
- msg.node_id,
- msg.hopCount,
- msg.temperature,
- msg.light,
- msg.humidity,
- msg.TTL,
- msg.TSN)
Add Comment
Please, Sign In to add comment