From b8776cf30e246935d0b671264967c7b6985933f7 Mon Sep 17 00:00:00 2001 From: razvanm Date: Mon, 16 Jul 2007 22:11:02 +0000 Subject: [PATCH] Add checks for the image format from tos_image.xml (problem reported by Jonathan Hui), fix a small bug in handling the numeric baudrate for tos-deluge and add manuals for tos-deluge and tos-build-deluge-image. --- tools/tinyos/misc/Makefile.am | 4 +- tools/tinyos/misc/tinyos.py | 2 +- tools/tinyos/misc/tos-build-deluge-image | 12 ++++- tools/tinyos/misc/tos-build-deluge-image.1 | 12 +++++ tools/tinyos/misc/tos-deluge | 5 +- tools/tinyos/misc/tos-deluge.1 | 55 ++++++++++++++++++++++ 6 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 tools/tinyos/misc/tos-build-deluge-image.1 create mode 100644 tools/tinyos/misc/tos-deluge.1 diff --git a/tools/tinyos/misc/Makefile.am b/tools/tinyos/misc/Makefile.am index 61303b5b..6c2ee153 100644 --- a/tools/tinyos/misc/Makefile.am +++ b/tools/tinyos/misc/Makefile.am @@ -11,7 +11,9 @@ dist_man_MANS = tos-check-env.1 \ tos-set-symbols.1 \ tos-storage-at45db.1 \ tos-storage-stm25p.1 \ - tos-write-image.1 + tos-write-image.1 \ + tos-build-deluge-image.1 \ + tos-deluge.1 bin_SCRIPTS = tos-ident-flags \ diff --git a/tools/tinyos/misc/tinyos.py b/tools/tinyos/misc/tinyos.py index b2b25478..cf521e5f 100644 --- a/tools/tinyos/misc/tinyos.py +++ b/tools/tinyos/misc/tinyos.py @@ -54,7 +54,7 @@ class Serial: # Converts baud rate from platform name to value, if necessary try: - int(baudrate) + baudrate = int(baudrate) except: baudrate = __baud_rate.get(baudrate) diff --git a/tools/tinyos/misc/tos-build-deluge-image b/tools/tinyos/misc/tos-build-deluge-image index c6af4484..1219fa46 100755 --- a/tools/tinyos/misc/tos-build-deluge-image +++ b/tools/tinyos/misc/tos-build-deluge-image @@ -132,7 +132,17 @@ for (k, v) in ident_list: ident[k] = v for p in ['unix_time', 'user_hash', 'uid_hash']: ident[p] = int(ident[p][:-1], 16) -image = dom.getElementsByTagName('image')[0].firstChild.nodeValue + +error = "ERROR: getting the image from the XML file failed." +try: + image_element = dom.getElementsByTagName('image')[0] + if image_element.getAttribute('format') != 'ihex': + error = "ERROR: image format is %s instead of ihex" % image_element.getAttribute('format') + sys.exit() + image = image_element.firstChild.nodeValue +except: + sys.stderr.write(error + '\n') + sys.exit() all = [] section = [] diff --git a/tools/tinyos/misc/tos-build-deluge-image.1 b/tools/tinyos/misc/tos-build-deluge-image.1 new file mode 100644 index 00000000..4a40bc60 --- /dev/null +++ b/tools/tinyos/misc/tos-build-deluge-image.1 @@ -0,0 +1,12 @@ +.TH tos-build-deluge-image 1 "Jul 16, 2007" +.LO 1 +.SH NAME + +tos-build-deluge-image \- internal tool for Deluge T2 + +.SH DESCRIPTION + +\fBtos-build-deluge-image\fR is used by \fBtos-deluge\fR to construct the binary image needed by tosboot. + +.SH "SEE ALSO" +\fItos-deluge\fR(1) \ No newline at end of file diff --git a/tools/tinyos/misc/tos-deluge b/tools/tinyos/misc/tos-deluge index aedea410..f3fa9765 100755 --- a/tools/tinyos/misc/tos-deluge +++ b/tools/tinyos/misc/tos-deluge @@ -345,8 +345,9 @@ def op_inject(s, img_num, tos_image_xml): print "--------------------------------------------------" # Writes the new binary image - if op_erase(s, img_num): - if op_write(s, img_num, p.stdout.read()): + image = p.stdout.read() + if len(image) > 0 and op_erase(s, img_num): + if op_write(s, img_num, image): if op_sync(s, img_num): print "--------------------------------------------------" metadata = getMetaData(s, img_num) diff --git a/tools/tinyos/misc/tos-deluge.1 b/tools/tinyos/misc/tos-deluge.1 new file mode 100644 index 00000000..33813baa --- /dev/null +++ b/tools/tinyos/misc/tos-deluge.1 @@ -0,0 +1,55 @@ +.TH tos-deluge 1 "Jul 16, 2007" +.SH NAME +tos-deluge \- Management tool for Deluge T2 + +.SH SYNOPSIS +\fBtos-deluge\fR \fIdevice\fR \fIbaudrate\fR <\fB-p\fR|\fB-r\fR|\fB-d\fR|\fB-e\fR|\fB-s\fR> \fIimage_number\fR + +\fBtos-deluge\fR \fIdevice\fR \fIbaudrate\fR \fB-i\fR \fIimage_number\fR \fItos_image.xml\fR + +.SH DESCRIPTION + +\fBtos-deluge\fR is the management tool for Deluge T2. The available operations are: + +.SH ARGUMENTS +.TP +.I device +Any device accepted by PySerial. Examples: +.RS +.IP \(bu 4 +/dev/ttyUSB0 +.IP \(bu 4 +COM10 +.IP \(bu 4 +11 +.RE + +.TP +.I baudrate +Two shortcuts are available: \fBmicaz\fR for 57600 and \fBtelosb\fR for 115200. +.TP +.I image_number +A integer number. 0 is the first image. + +.SH OPTIONS +.TP +.B -p, --ping +Provide status of the image in the external flash +.TP +.B -i, --inject +Inject a compiled TinyOS application. The tos_image.xml file path +.TP +.B -r, --reprogram +Reprogram the network +.TP +.B -b, --reprogram_bs +Reprogram only the directly-connected mote +.TP +.B -d, --dissemination +Disseminate the image in the external flash to the network +.TP +.B -e, --erase +Erase an image in the external flash +.TP +.B -s, --reset +Reset the versioning information for a given image -- 2.39.2