[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/harvard/spaulding/src/gui/sessions/readSD readSD.c, 1.3, 1.4 downloadSessions.pl, 1.4, NONE

Konrad Lorincz konradlorincz at users.sourceforge.net
Wed Mar 5 12:34:54 PST 2008


Update of /cvsroot/tinyos/tinyos-1.x/contrib/harvard/spaulding/src/gui/sessions/readSD
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7553

Modified Files:
	readSD.c 
Removed Files:
	downloadSessions.pl 
Log Message:
updated readSD so that it no longer requires a call from pearl downloadSession.pl

Index: readSD.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/harvard/spaulding/src/gui/sessions/readSD/readSD.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** readSD.c	21 Dec 2007 04:40:02 -0000	1.3
--- readSD.c	5 Mar 2008 20:34:51 -0000	1.4
***************
*** 8,11 ****
--- 8,12 ----
  #include "MultiChanSampling.h"
  #include "nodeInfo.c"
+ #include <dirent.h>
  
  #define FLASH_BLOCK_SIZE 512ul
***************
*** 22,31 ****
      uint32_t tail;
      uint32_t head;
! } FlashInfo;
  
  typedef struct Block {
      uint32_t sqnNbr;
      uint8_t data[BLOCK_DATA_SIZE];
! } Block;
  
  
--- 23,33 ----
      uint32_t tail;
      uint32_t head;
! } __attribute__((__packed__)) FlashInfo;
! 
  
  typedef struct Block {
      uint32_t sqnNbr;
      uint8_t data[BLOCK_DATA_SIZE];
! } __attribute__((__packed__)) Block;
  
  
***************
*** 42,50 ****
      channelID_t channelIDs[MCS_MAX_NBR_CHANNELS_SAMPLED];            
      sample_t    samples[SAMPLE_CHUNK_NUM_SAMPLES];
! } SampleChunk;         
! 
  
  
- // sudo dd if=/dev/sdd of=out.raw count=1
  
  void getFlashInfo(FlashInfo *flashInfoPtr, FILE *filePtr)
--- 44,50 ----
      channelID_t channelIDs[MCS_MAX_NBR_CHANNELS_SAMPLED];            
      sample_t    samples[SAMPLE_CHUNK_NUM_SAMPLES];
! } __attribute__((__packed__)) SampleChunk;         
  
  
  
  void getFlashInfo(FlashInfo *flashInfoPtr, FILE *filePtr)
***************
*** 80,85 ****
      
      printf("hash= %u, nodeID= %u, tail= %u, head= %u\n", flashInfo.hash, flashInfo.nodeID, flashInfo.tail, flashInfo.head);
-     printf("tail= %u\n", flashInfo.tail);
-     printf("head= %u\n", flashInfo.head);
      fclose(sdFilePtr);
  }
--- 80,83 ----
***************
*** 90,93 ****
--- 88,92 ----
      uint16_t samp = 0;
      SampleChunk *scPtr = (SampleChunk*) blockPtr->data;
+     int nbrChansSampled = 0;
      fprintf(filePtr, "# blockID= %u:  localTime= %u, globalTime= %u, samplingRate= %u, timeSynched= %u, nbrMultiChanSamples= %u, channelIDs= {",
              blockPtr->sqnNbr, scPtr->localTime, scPtr->globalTime, scPtr->samplingRate, scPtr->timeSynched, scPtr->nbrMultiChanSamples);
***************
*** 98,115 ****
          else
              fprintf(filePtr, "%u}", scPtr->channelIDs[i]);
      }    
      
      
      for (samp = 0; samp < scPtr->nbrMultiChanSamples &&
                     samp < SAMPLE_CHUNK_NUM_SAMPLES; ++samp) {
!         if (samp % MCS_MAX_NBR_CHANNELS_SAMPLED == 0) {
              double globalTimeSec = scPtr->globalTime / (double)GLOBALTIME_RATE_HZ;
!             double sampleTimeSec = globalTimeSec + (double)(samp/MCS_MAX_NBR_CHANNELS_SAMPLED)/
                                                     (double)scPtr->samplingRate;
!             fprintf(filePtr, "\n%.4f ", sampleTimeSec);
          }
          fprintf(filePtr, "%u ", scPtr->samples[samp]);
      }
      fprintf(filePtr, "\n");
  
      #if 0
--- 97,119 ----
          else
              fprintf(filePtr, "%u}", scPtr->channelIDs[i]);
+ 
+         if (scPtr->channelIDs[i] != CHAN_INVALID)
+             nbrChansSampled++;
      }    
      
+ 
      
      for (samp = 0; samp < scPtr->nbrMultiChanSamples &&
                     samp < SAMPLE_CHUNK_NUM_SAMPLES; ++samp) {
!         if (samp % nbrChansSampled == 0) {
              double globalTimeSec = scPtr->globalTime / (double)GLOBALTIME_RATE_HZ;
!             double sampleTimeSec = globalTimeSec + (double)(samp/nbrChansSampled)/
                                                     (double)scPtr->samplingRate;
!             fprintf(filePtr, "\n%.6f ", sampleTimeSec);
          }
          fprintf(filePtr, "%u ", scPtr->samples[samp]);
      }
      fprintf(filePtr, "\n");
+     
  
      #if 0
***************
*** 132,146 ****
      }
      #endif
- 
- 
  }
  
  
! int main(int argc, char** argv)
  {
- 
-     char *sessionDir = argv[1];
-     char *sessionInfoFile = argv[2];
-     char *devicePath = argv[3];
      uint16_t nodeID = getNodeID(devicePath);
      uint32_t startBlockID;
--- 136,144 ----
      }
      #endif
  }
  
  
! int downloadSession(char *sessionDir, char *sessionInfoFile, char *devicePath)
  {
      uint16_t nodeID = getNodeID(devicePath);
      uint32_t startBlockID;
***************
*** 185,192 ****
  
  
  
! /* int main(int argc, char** argv) */
! /* { */
! /*     printFlashInfo("/dev/sdd"); */
! /*     return 0; */
! /* } */
--- 183,222 ----
  
  
+ // sudo dd if=/dev/sdd of=out.raw count=1
  
! //char* SD_DEVICE_PATH = "/dev/sda"; // Spaulding device
! char* SD_DEVICE_PATH = "/dev/sdd";   // Konrad's device
! 
! 
! int main(int argc, char** argv)
! {
!     // (1) - Print Header only
!     if (argc == 2 && (strcmp(argv[1],"-h")==0)) {
!         printFlashInfo(SD_DEVICE_PATH);
!         return 0;
!     }
! 
! 
!     // (2) - Download sessions
!     struct dirent **namelist;
!     int nbrFiles = scandir(".", &namelist, 0, alphasort);
!     int i = 0;
!     
!     for (i = 0; i < nbrFiles; ++i) {
!         char* fileName = namelist[i]->d_name;
!         free(namelist[i]);
!         
!         // Check current direcotry
!         if (strcmp(fileName, "sessionInfo.txt") == 0) {
!             downloadSession(".", "sessionInfo.txt", SD_DEVICE_PATH);
!         }
!         // check subdirectory
!         else if (strncmp(fileName, "subj-", 5) == 0) {
!             downloadSession(fileName, "sessionInfo.txt", SD_DEVICE_PATH);
!         }
!     }
!     free(namelist);
! 
!     
!     return 0;
! }

--- downloadSessions.pl DELETED ---



More information about the Tinyos-contrib-commits mailing list