From 5ba7b0ecd437160ed98c02ae1fb8c752999a5662 Mon Sep 17 00:00:00 2001 From: Joe Schaack Date: Thu, 3 Dec 2015 20:07:40 -0600 Subject: [PATCH 1/2] Add gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc From 803e3b33450a632e5495f5166ae46f007bf4fcf4 Mon Sep 17 00:00:00 2001 From: Joe Schaack Date: Thu, 3 Dec 2015 20:18:49 -0600 Subject: [PATCH 2/2] swapdmt-cmd: If no hexfile is not set do not try to program Print an error when the user tries to call 'node program' before running 'hexfile '. Previously the swapdmt-cmd program would throw and unhandled exception when this occured. Signed-off-by: Joe Schaack --- swapdmt-cmd/swapmanager.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/swapdmt-cmd/swapmanager.py b/swapdmt-cmd/swapmanager.py index 53e9d89..4844cae 100755 --- a/swapdmt-cmd/swapmanager.py +++ b/swapdmt-cmd/swapmanager.py @@ -266,20 +266,23 @@ def dispatch_command(self, command): else: # Program node if command[2] == "program": - # Create progress bar - self.progress = AnimatedProgressBar(end=self.hexfile.nbof_data_lines, width=50) - # Save address of node being programmed - self.prog_address = addr - # Transmit product code - self.transmit_product_code() - - # Put node in upgrade mode - val = SwapValue(SwapState.UPGRADE, 1) - if mote.cmdRegisterWack(SwapRegId.ID_SYSTEM_STATE, val): - print "Node now in programming mode" - elif self.hexfile_line == 0: - print "Unable to put node in progamming mode" - self.prog_address = None + if (self.hexfile == None): + print "Please set a hexfile before running \"program\"" + else: + # Create progress bar + self.progress = AnimatedProgressBar(end=self.hexfile.nbof_data_lines, width=50) + # Save address of node being programmed + self.prog_address = addr + # Transmit product code + self.transmit_product_code() + + # Put node in upgrade mode + val = SwapValue(SwapState.UPGRADE, 1) + if mote.cmdRegisterWack(SwapRegId.ID_SYSTEM_STATE, val): + print "Node now in programming mode" + elif self.hexfile_line == 0: + print "Unable to put node in progamming mode" + self.prog_address = None # Restart node (if not sleeping) elif command[2] == "restart": if mote.restart():