+def disseminate(imgNum):
+ sreqpkt = DMReqPacket((DM_CMD_ONLY_DISSEMINATE, imgNum))
+ success = am.write(sreqpkt, DM_AMID)
+ return handleResponse(success, "ERROR: Unable to disseminate")
+
+def disseminateAndReboot(imgNum):
+ sreqpkt = DMReqPacket((DM_CMD_DISSEMINATE_AND_REPROGRAM, imgNum))
+ success = am.write(sreqpkt, DM_AMID)
+ return handleResponse(success, "ERROR: Unable to disseminate-and-reboot")
+
+def stop():
+ sreqpkt = DMReqPacket((DM_CMD_STOP, 0))
+ success = am.write(sreqpkt, DM_AMID)
+ return handleResponse(success, "ERROR: Unable to initiate the stop")
+
+def localstop():
+ sreqpkt = DMReqPacket((DM_CMD_LOCAL_STOP, 0))
+ success = am.write(sreqpkt, DM_AMID)
+ return handleResponse(success, "ERROR: Unable to initiate the local stop")
+
+def print_usage():
+ print "Usage: %s <source> <-p|-i|-r|-d|-e|-s> image_number [options]" % sys.argv[0]
+ print " <source> can be:"
+ print " serial@PORT:SPEED Serial ports"
+ print " network@HOST:PORT MIB600"
+ print " -p --ping Provide status of the image in the external flash"
+ print " -i --inject Inject a compiled TinyOS application"
+ print " [options]: tos_image.xml file path"
+ print " -e --erase Erase an image in the external flash"
+ print " -b --boot Force a reboot of the mote"
+ print " -r --reprogram Reprogram the mote"
+ print " -d --disseminate Disseminate the image in the external flash to the network"
+ print " -dr --disseminate-and-reprogram"
+ print " -s --stop Stop the dissemination "
+ print " -ls --local-stop Stop the dissemination only on the local mote"
+
+# print " -b --reprogram_bs\n Reprogram only the directly-connected mote"
+# print " -s --reset\n Reset the versioning information for a given image"
+
+def checkImgNum():
+ global imgNum