/
Trigger remotely 6P packets over serial port, openvisualizer and ZMQ
Trigger remotely 6P packets over serial port, openvisualizer and ZMQ
Goal: Send a command through a serial port to a mote to make it send a 6P packet.
Requierements: You need a 6TiSCH network up and running. See Kickstart Linux to get started.
Usually, we would get this working by using the command line of OpenVisualizer:
- set /dev/ttyUSB0 6pAdd [6,7]
This would send the following bytes over the serial bus towards the mote:
- [67, 9, 2, 6, 7] in decimal
Explanation:
- 67 indicates the char 'C', the mote can recognize this is a command, rather a packet send to mote. https://github.com/openwsn-berkeley/openwsn-sw/blob/develop/software/openvisualizer/openvisualizer/moteConnector/OpenParser.py#L22
- 9 is the commandId for 6pAdd https://github.com/openwsn-berkeley/openwsn-sw/blob/develop/software/openvisualizer/openvisualizer/moteState/moteState.py#L416
- 2 is the length of the payload of 6pAdd command (in bytes)
- 6 and 7 are the two bytes of data.
Now we are going to send it over a ZMQ socket. To do that we will use the following script:
#!/usr/bin/env python import zmq zmq_inject_port = 60000 d = {"signal": "cmdToMote", "data": {"action": ["imageCommand", "6pAdd", "[6,7]"], "serialPort": "/dev/ttyUSB0"}, "sender": "mySender"} context = zmq.Context() publisher = context.socket(zmq.REQ) publisher.connect("tcp://localhost:%d" % zmq_inject_port) publisher.send_json(d)
You can tell whether a given 6P request passed or failed depending on its return code. Return codes are documented there:
https://github.com/openwsn-berkeley/openwsn-fw/blob/develop/openstack/02b-MAChigh/sixtop.h
, multiple selections available,
Related content
Sending/Receiving messages on the EventBus using ZMQ
Sending/Receiving messages on the EventBus using ZMQ
More like this
Serial Format
Serial Format
More like this
CoAP Interaction
CoAP Interaction
More like this
How to gather your app data from your mote on your own
How to gather your app data from your mote on your own
More like this
Ring-of-Things
Ring-of-Things
More like this