Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Goal: Send a command through a serial port to a mote to make it send a 6P packet.

Usually, we would get this working by using the command line of OpenVisualizer:

  • set /dev/myAwesomeMote 6pAdd [6,7]

This would send the following bytes over the serial bus towards the mote:

  • [67, 9, 2, 6, 7] in decimal 

Explanation:
Now we are going to send it over a ZMQ socket:


#!/usr/bin/env python
import zmq

d = {"signal": "cmdToMote",
     "data": {"action": ["imageCommand", "6pAdd", "[6,7]"],
              "serialPort": "/dev/ttyUSB1"},
     "sender": "mySender"}
context = zmq.Context()
publisher = context.socket(zmq.REQ)
publisher.connect("tcp://localhost:60000")
publisher.send_json(d)


You can tell whether a given 6P request passed or failed depending on the return code that are documented there:

https://github.com/openwsn-berkeley/openwsn-fw/blob/develop/openstack/02b-MAChigh/sixtop.h

  • No labels