From 041ffc35f76c6bb25838ec4953a5963c10d9328c Mon Sep 17 00:00:00 2001 From: razvanm Date: Tue, 15 Jan 2008 20:33:46 +0000 Subject: [PATCH] Add a translation between imgNum to volumeId. This should allow non-Deluge images to peacefully coexist with Deluge. --- tos/lib/net/Deluge/DelugeManagerP.nc | 10 +++++++-- .../FlashVolumeManager/FlashVolumeManagerP.nc | 22 +++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tos/lib/net/Deluge/DelugeManagerP.nc b/tos/lib/net/Deluge/DelugeManagerP.nc index 15dbeedc..2417de6c 100644 --- a/tos/lib/net/Deluge/DelugeManagerP.nc +++ b/tos/lib/net/Deluge/DelugeManagerP.nc @@ -55,6 +55,12 @@ implementation message_t serialMsg; DelugeCmd delugeCmd; + uint8_t imgNum2volumeId[] = { + VOLUME_GOLDENIMAGE, + VOLUME_DELUGE1, + VOLUME_DELUGE2, + VOLUME_DELUGE3 + }; void sendReply(error_t error) { @@ -85,14 +91,14 @@ implementation case DELUGE_CMD_ONLY_DISSEMINATE: case DELUGE_CMD_DISSEMINATE_AND_REPROGRAM: if (call Resource.immediateRequest() == SUCCESS) { - call DelugeMetadata.read(request->imgNum); + call DelugeMetadata.read(imgNum2volumeId[request->imgNum]); } else { sendReply(FAIL); } break; case DELUGE_CMD_REPROGRAM: case DELUGE_CMD_REBOOT: - delugeCmd.imgNum = request->imgNum; + delugeCmd.imgNum = imgNum2volumeId[request->imgNum]; call DelayTimer.startOneShot(1024); sendReply(SUCCESS); break; diff --git a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc index 138c6b02..4ed7a64b 100644 --- a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc +++ b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc @@ -87,6 +87,13 @@ implementation nx_uint32_t uidhash; nx_uint16_t nodeid; }; + + uint8_t imgNum2volumeId[] = { + VOLUME_GOLDENIMAGE, + VOLUME_DELUGE1, + VOLUME_DELUGE2, + VOLUME_DELUGE3 + }; void sendReply(error_t error, storage_len_t len) { @@ -179,20 +186,7 @@ implementation } // Converts the image number that the user wants to the real image number - switch (request->imgNum) { - case 0: - imgNum = VOLUME_GOLDENIMAGE; - break; - case 1: - imgNum = VOLUME_DELUGE1; - break; - case 2: - imgNum = VOLUME_DELUGE2; - break; - case 3: - imgNum = VOLUME_DELUGE3; - break; - } + imgNum = imgNum2volumeId[request->imgNum]; if (imgNum != 0xFF) { error = SUCCESS; -- 2.39.2