From 36379087c4459259cb05c00f0b9f125adf7b7266 Mon Sep 17 00:00:00 2001 From: razvanm Date: Thu, 20 Dec 2007 21:23:51 +0000 Subject: [PATCH] Improve Deluge to report the UID of the running application. tos-deluge script from the tools package was affected by this change. --- tools/tinyos/misc/tos-deluge | 13 +++++++++++++ .../Deluge/FlashVolumeManager/FlashVolumeManager.h | 1 + .../FlashVolumeManager/FlashVolumeManagerP.nc | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/tools/tinyos/misc/tos-deluge b/tools/tinyos/misc/tos-deluge index f3fa9765..5c593b97 100755 --- a/tools/tinyos/misc/tos-deluge +++ b/tools/tinyos/misc/tos-deluge @@ -54,6 +54,7 @@ MSG_REPROG = 5 MSG_DISS = 6 MSG_REPROG_BS = 7 MSG_SYNC = 8 +MSG_IDENT = 9 ERROR_SUCCESS = 0 # T2-compatible ERROR_FAIL = 1 # T2-compatible @@ -186,6 +187,15 @@ def op_read(s, img_num, offset, length): sreqpkt['len'] = (offset + length) - sreqpkt['offset'] return r + +def op_ident(s): + sreqpkt = SerialReqPacket((MSG_IDENT, 0, 0, 0, [])) + if s.write_packet(SERIAL_AMGROUP, SERIAL_AMID, sreqpkt.payload()): + packet = s.read_packet(SERIAL_AMGROUP, SERIAL_AMID) + sreplypkt = SerialReplyPacket(packet[1]) + if sreplypkt.error == ERROR_SUCCESS: + return toInt(sreplypkt.data) + return 0 # Checks for valid CRC and image timestamp def verifyMetaData(r): @@ -215,12 +225,15 @@ def getMetaData(s, img_num): # Prints status of the image in the external flash def op_ping(s, img_num): + uid = op_ident(s) metadata = getMetaData(s, img_num) if not metadata == None: if verifyMetaData(metadata) == True: print "Connected to Deluge node." # Prints out image status print "--------------------------------------------------" + print "Currently Executing:" + print " UID: %d" % (uid) print "Stored image %d" % img_num print toStatusStr(2, metadata) print "--------------------------------------------------" diff --git a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h index 35c1a188..9af71b10 100644 --- a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h +++ b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManager.h @@ -36,6 +36,7 @@ #define SERIALMSG_DISS 6 #define SERIALMSG_REPROG_BS 7 #define SERIALMSG_SYNC 8 +#define SERIALMSG_IDENT 9 typedef nx_struct SerialReqPacket { nx_uint8_t msg_type; diff --git a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc index bf29d2b3..c728b11f 100644 --- a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc +++ b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc @@ -223,6 +223,12 @@ implementation signal ReprogNotify.notify(img_num); sendReply(SUCCESS, sizeof(SerialReplyPacket)); break; + case SERIALMSG_IDENT: + // This is not send using nx_uint32 in order to maintain + // consistency with data from the Deluge image. + *(uint32_t*)(&serialMsg_payload->data) = IDENT_UID_HASH; + sendReply(SUCCESS, sizeof(SerialReplyPacket) + 4); + break; #endif } } else { -- 2.39.2