From: razvanm Date: Tue, 15 Jan 2008 20:33:46 +0000 (+0000) Subject: Add a translation between imgNum to volumeId. This should allow non-Deluge images... X-Git-Tag: release_tinyos_2_1_0_0~598 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=041ffc35f76c6bb25838ec4953a5963c10d9328c Add a translation between imgNum to volumeId. This should allow non-Deluge images to peacefully coexist with Deluge. --- 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;