nikita teggi / Mbed 2 deprecated merged_code2_3rd_nov_2017

Dependencies:   SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217

Fork of merged_code2_20sept_2017_4th_oct_2017 by nikita teggi

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sdcard.cpp Source File

sdcard.cpp

00001  // Exisiting code in Int_Demo_09May2017_suhasini/sdcard.cpp is deleted and replaced by new code 
00002  //Nidhin 1/6/2017
00003  
00004  
00005 #include "mbed.h"
00006 #include <stdio.h>
00007 #include "SDFileSystem.h"
00008 #include "sdcard.h"
00009 #include "rtc.h"
00010 #include "struct.h"
00011 #include "main.h"
00012 #include "eeprom_pgm.h"
00013   
00014   Serial snd(USBTX,USBRX);
00015   SDFileSystem sd(PTE1, PTE3, PTE2, PTE4, "sd");
00016 
00017 
00018   
00019   FILE *fpecg;  // PPG and ECG File pointers for BP
00020   FILE *fpppg;  //""          ""
00021   
00022   FILE *fpmain; // FILE pointer for main file
00023   
00024   FILE *fpbg;   // FILE pointer to BG file
00025   FILE *fpeecg; // FILE pointer to ECG file
00026   FILE *fpbp;   // FILE pointer to BP file
00027   
00028   FILE *fp;    // FILE pointer for random use
00029   
00030   //Function Added on 16/5/2017 by Nidhin
00031  void sd_open_mainfile(int32_t pid)
00032  {
00033  char buffer1[32];
00034  sprintf(buffer1,"/sd/%d.csv",pid);
00035   fp = fopen(buffer1,"a"); 
00036     }
00037   //------------------------------------------
00038   
00039   
00040   
00041  /*void sd_open_GLCfile(int pid)     // opening the glc file
00042  {
00043      
00044   char buffer[32];
00045   char buffer1[32];
00046   time_t  epoch_time1;
00047   epoch_time1=rtc_read();
00048  // strftime(buffer, 32, "GLC_%s", pid);
00049   
00050  sprintf(buffer1,"/sd/%d_GLC.csv",pid);   
00051   fp = fopen(buffer1,"a"); 
00052   fprintf(fp,"%s\n",ctime(&epoch_time1) );  //writing the date, time into the file
00053   
00054  
00055  }   */
00056  
00057   void sd_open_GLCfilee(uint32_t pid)    // only opening the glc file after entering TEST screen
00058  {
00059   char buffer1[32];
00060   sprintf(buffer1,"/sd/%d_GLC.csv",pid);
00061   fpbg = fopen(buffer1,"a"); 
00062   fclose(fpbg);
00063  } 
00064  
00065  
00066   void sd_open_ECGfilee(uint32_t pid)          // only opening the ECG file after entering TEST screen
00067  {
00068      
00069   char buffer1[32];
00070   sprintf(buffer1,"/sd/%d_ECG.csv",pid);
00071   fpeecg = fopen(buffer1,"a"); 
00072   //fclose(fpeecg);
00073  
00074  } 
00075  
00076  
00077 void sd_open_BPfilee(uint32_t pid)          // only opening the BP file after entering TEST screen
00078  {
00079      
00080  
00081   char buffer1[32];
00082   sprintf(buffer1,"/sd/%d_BP.csv",pid);
00083   fpbp = fopen(buffer1,"a"); 
00084   //fprintf(fp,"PATIENT ID %d\n",pid );        Not required in new code as writing in hex
00085  fclose(fpbp);
00086  } 
00087   
00088  void sd_write (int value)      // writing data into the file
00089  {
00090     fprintf(fp,"%d\n", value);
00091  }
00092  
00093  
00094 uint8_t sd_open_read(uint32_t pid)          // opening the file for read    // CHNAGED to return value
00095  {
00096      
00097   char buffer1[32];
00098    sprintf(buffer1,"/sd/%d.csv",pid);
00099   fp = fopen(buffer1,"r"); 
00100   if (fp==NULL)
00101   {
00102       snd.printf("no");
00103       return 0;
00104       }
00105       
00106       else 
00107       {
00108           snd.printf("yes");
00109           return 1;
00110           }
00111  }
00112  
00113  void sd_read(uint32_t  *v1, uint16_t size)          //reading the data from the openend file
00114  {
00115      fread(v1,sizeof(v1),size,fp);
00116  }
00117 
00118 void setpos()
00119 {
00120      //fseek ( fp , 1 , SEEK_SET );
00121      rewind (fp);
00122 }
00123 
00124 void setpos1(uint32_t position)
00125 {
00126      fseek ( fp , position, SEEK_SET );
00127      //rewind (fp);
00128 }
00129 
00130 
00131 uint32_t file_size()    
00132    {
00133      uint32_t file_length;
00134      fseek (fp, 0, SEEK_END);
00135      file_length=ftell(fp);
00136      file_length=sizeof(char)*file_length;
00137         rewind(fp);
00138      return   file_length;
00139      }  
00140      
00141      
00142 uint32_t file_size1()    
00143    {
00144      uint32_t file_length;
00145     // fseek (fp, 0, SEEK_END);
00146 
00147      file_length=ftell(fp);
00148       // file_length=sizeof(char)*file_length;
00149       //  rewind(fp);
00150      return   file_length;
00151      }  
00152   
00153 
00154 
00155 
00156  
00157      void sd_read1(BLEMsg_info &f)
00158 {
00159      fread(&f,sizeof(BLEMsg_info),1,fp);
00160       //fscanf(fp,"%08x",&v1);
00161 }
00162  
00163  
00164  
00165  
00166  
00167  
00168  
00169  
00170  
00171  //------------------------------------------------------
00172   
00173 //FILE *sd_BP_ecgwrite (int value)      // writing data into the file NIDHIN
00174 FILE *sd_BP_ecgwrite (uint32_t *fpdrum11)      // writing data into the file NIDHIN  
00175   {
00176         fwrite(fpdrum11,sizeof(uint32_t),1, fpecg); //Change by Nidhin 30/5/2017 Direct writing to SD card. Org Val 64
00177         return fpecg;
00178   }
00179     
00180 FILE* sd_BP_ppgwrite (uint32_t *fpdrum21)      // //Change by Nidhin 30/5/2017 Direct writing to SD card.
00181   {
00182        fwrite(fpdrum21,sizeof(uint32_t),1, fpppg); //Change by Nidhin 30/5/2017 Direct writing to SD card. OR Val 64
00183     return fpppg;
00184   }
00185   //-----------------------------------------------SD Read
00186   
00187   void sd_reopen_BPfilee(uint32_t pid)          // only opening the BP file after entering TEST screen
00188  {
00189      
00190  
00191   char buffer1[32];
00192   sprintf(buffer1,"/sd/%d_BP.csv",pid);
00193   fp = fopen(buffer1,"r"); 
00194   //fprintf(fp,"PATIENT ID %d\n",pid );
00195  
00196  
00197  } 
00198   //-------------------------------------------------
00199 
00200 
00201 //---------------------------------------
00202 
00203 
00204    void sd_open_BP_ECGfile(uint32_t pid)         
00205  {
00206      
00207   //char buffer[32];
00208   char buffer1[32];
00209   //time_t  epoch_time1;
00210   //epoch_time1=rtc_read();
00211   // strftime(buffer, 32, "ECG_%d", pid);
00212   
00213   sprintf(buffer1,"/sd/%d_BP_ECG.csv",pid);
00214   fpecg = fopen(buffer1,"a"); 
00215   if (fpecg == NULL)
00216   {
00217       exit(1);
00218   }   
00219   //fprintf(fpecg,"%s\n",ctime(&epoch_time1) );
00220   
00221  } 
00222  
00223   
00224    void sd_open_BP_PPGfile(uint32_t pid)         
00225  {
00226      
00227   char buffer1[32];
00228   //time_t  epoch_time1;
00229   //epoch_time1=rtc_read();
00230   // strftime(buffer, 32, "ECG_%d", pid);
00231   
00232   sprintf(buffer1,"/sd/%d_BP_PPG.csv",pid);
00233   fpppg = fopen(buffer1,"a"); 
00234   if(fpppg == NULL)
00235   {
00236             exit(1);
00237   }
00238   
00239   //fprintf(fpppg,"%s\n",ctime(&epoch_time1) );
00240   
00241  } 
00242   
00243   
00244   
00245   //--------------------------------------------------
00246   
00247 //FUNCTIONS TO CLOSE FILES
00248 //__________________________________________________  
00249 void sd_close()            //close the file with fp
00250   {
00251    
00252       fclose(fp);
00253    }
00254 //______________________________________________________   
00255  void sd_close_ecg()          // Closes ECG file pinted by fpeecg
00256  {
00257    
00258       fclose(fpeecg);
00259  }
00260 //______________________________________________________
00261  void sd_close_glc()          // Closes GLC file pinted by fpbg
00262  {
00263    
00264       fclose(fpbg);
00265  }
00266  //_____________________________________________________
00267  
00268  
00269  
00270  
00271  
00272  
00273 //fread(buffer, 1, size, fp)
00274 //fwrite(&buffer, ,   
00275  //----------------------------------------------------28/4/2017---------------------------------
00276  //----------------------------------------------------------------------------------------------
00277  
00278  
00279  
00280   //------- FUNCTION TO CREATE SINGLE BP FILE --------2/5/2017 (NIDHIN)---------------//
00281  void create_single_BPfile(uint32_t pid)
00282 {
00283     
00284     //int ecgbuf[64] = {0};
00285     //uint32_t ppgbuf[64] = {0};
00286     
00287     char buffer3[32];
00288     sprintf(buffer3, "/sd/%d_BP.csv", pid);
00289     fpbp = fopen(buffer3, "a");                   // Opens BP file with FILE pointer fpbp in APPEND mode
00290 
00291     //buffer1[32] = ""; 
00292     sprintf(buffer3, "/sd/%d_BP_ECG.csv", pid);   
00293     fpecg = fopen(buffer3, "r");                  // Opens ECG file of BP with FILE pointer fpecg in READ mode
00294 
00295     //char buffer1[32] = "";
00296     sprintf(buffer3, "/sd/%d_BP_PPG.csv", pid);
00297     fpppg = fopen(buffer3, "r");                  // Opens PPG file of BP with FILE pointer fpppg in READ mode
00298 
00299     for(int i=0; i<16; i++)
00300     {
00301     int ecgbuf[64] = {0} ;
00302     fread(ecgbuf, sizeof(uint32_t), 64, fpecg);
00303     fwrite(ecgbuf, sizeof(uint32_t), 64, fpbp);   // Copy ECG data of BP into BP file
00304     }
00305 
00306     for(int i=0; i<26; i++)
00307     {
00308     int ppgbuf[64] = {0} ;
00309     fread(ppgbuf, sizeof(uint32_t), 64, fpppg);
00310     fwrite(ppgbuf, sizeof(uint32_t), 64, fpbp);  // Copy PPG data of BP into BP file
00311     }
00312 
00313     fclose(fpecg);                                  // Closes the ECG file of BP
00314     fclose(fpppg);                                  // Closes the PPG file of BP
00315     fclose(fpbp);                                   // Closes the BP file
00316 
00317     //char buffer1[32] = "";
00318     int status = 1 ;
00319     sprintf(buffer3, "/sd/%d_BP_ECG.csv", pid);
00320     status = remove(buffer3);                         //Removes ECG file of BP and updates status with 0 if successful
00321     
00322     
00323     if( status == 0 )
00324         snd.printf("\nECG file delete : Successful");   // Checks for SUCCESS
00325     else 
00326         snd.printf("\nECG file delete : UnSuccessful");
00327    
00328     
00329     //char buffer1[32] = "";
00330     status = 1 ;
00331     sprintf(buffer3, "/sd/%d_BP_PPG.csv", pid);
00332     status = remove(buffer3);                           //Removes PPG file of BP and updates status with 0 if successful
00333     
00334     if( status == 0 )
00335         snd.printf("\nPPG file delete : Successful");   // Checks for SUCCESS
00336     else 
00337         snd.printf("\nPPG file delete : UnSuccessful");
00338        
00339 }
00340 
00341 
00342 
00343 //Creating strcuture file Common to All Functions
00344 void structure_file(BLEMsg_info *ptr, uint32_t pid)
00345 {
00346     char buffer3[32];
00347     sprintf(buffer3, "/sd/%d.csv", pid);            //Printing file path to the buffer
00348     if(get_filecreated_status() == true)                    //if file created open in append mode
00349     {
00350         fpmain = fopen(buffer3, "a");               // open the file PID.csv with FILE pointer fpmain
00351         snd.printf("\n Append mode\n");
00352     }
00353     else                                            //if file not created, open in write mode
00354     {
00355         fpmain = fopen(buffer3, "w");               // open the file PID.csv with FILE pointer fpmain 
00356         snd.printf("\n Write mode\n"); 
00357     }    
00358         
00359 fwrite(ptr, sizeof(uint8_t),26, fpmain );   // writing the Structure into the file
00360 fclose(fpmain);                             // Close File
00361 }
00362 
00363 //Copy Data into file.
00364 
00365 void bpfile_mainfile(uint32_t pid)                       //Copy data of bp file to main
00366 {
00367     char buffer3[32];
00368     sprintf(buffer3, "/sd/%d.csv", pid);
00369     fpmain = fopen(buffer3, "a");                   // Opens Main file with FILE pointer "fpmain" in APPEND mode
00370     
00371     sprintf(buffer3, "/sd/%d_BP.csv", pid);
00372     fpbp = fopen(buffer3, "r");                     // Opens BP file with FILE pointer "fpbp" in READ mode
00373     
00374     
00375     for(int i=0; i<21; i++)
00376     {
00377     int bigbuf[128] = {0} ;
00378     fread(bigbuf, sizeof(uint32_t), 128, fpbp);
00379     fwrite(bigbuf, sizeof(uint32_t), 128, fpmain);  // Copy BP raw data into main file 
00380     }
00381     fclose(fpbp);                                   // Close BP file
00382     fclose(fpmain);                                 // Close Main File
00383     
00384     int success;
00385     sprintf(buffer3, "/sd/%d_BP.csv", pid);
00386     success = remove(buffer3);                      // Should return zero on success
00387 }
00388 
00389 //------------New function added to print ECG data to Sd card using fwrite
00390 void sd_ecgwrite(uint32_t *ecg_ptr)
00391 {
00392    fwrite(ecg_ptr, sizeof(int), 1, fpeecg); 
00393 }
00394 
00395 
00396 //------------ Function to write ECG data to main file
00397 void ecgfile_mainfile(uint32_t pid)
00398 {
00399     char buffer3[32];
00400     sprintf(buffer3, "/sd/%d.csv", pid);       
00401     fpmain = fopen(buffer3, "a");             // Main File is opened in Append mode
00402     snd.printf("opening main file\n");
00403     sprintf(buffer3, "/sd/%d_ECG.csv", pid);  // ECG file is opened in read mode
00404     fpeecg = fopen(buffer3, "r");
00405     snd.printf("opening temp file\n");
00406     for(int i=0; i<20; i++) //the loop runs as 20 times of 100 i.e., 2k
00407     {
00408     int bigbuf[100] = {0} ;
00409     fread(bigbuf, sizeof(int),100 , fpeecg);
00410     fwrite(bigbuf, sizeof(int), 100, fpmain);
00411     }
00412     snd.printf("to close temp file\n");
00413     fclose(fpeecg);                               // Both files are Closed
00414     snd.printf("to come out of main file\n");
00415     fclose(fpmain);
00416     
00417     snd.printf("COPY complete Files Closed\n"); 
00418     
00419     sprintf(buffer3, "/sd/%d_ECG.csv", pid);  // ECG file is opened in write mode to empty the file
00420     fpeecg = fopen(buffer3, "r");
00421     fclose(fpeecg);  
00422                               // File is closed
00423     int success;
00424     sprintf(buffer3, "/sd/%d_ECG.csv", pid);
00425     success = remove(buffer3); 
00426     snd.printf("DELETE STATUS = %d\n", success); 
00427 success = 1;
00428     sprintf(buffer3, "/sd/%d_ECG_lpf.csv", pid);
00429     success = remove(buffer3); 
00430     snd.printf("DELETE STATUS = %d\n", success);
00431 }
00432 
00433 
00434 //---------------------- Function to write GLC data to GLC file
00435 void sd_glcwrite(uint32_t *glc_ptr, uint32_t pid)
00436 {
00437     char buffer3[32];
00438     sprintf(buffer3, "/sd/%d_GLC.csv", pid);       
00439     fpbg = fopen(buffer3, "a");  
00440     
00441     fwrite(glc_ptr, sizeof(uint32_t), 2, fpbg);
00442     fclose(fpbg);
00443    
00444 }
00445 
00446 // --------------------------Fuinction to write GLC data to Main file
00447 
00448 void glcfile_mainfile(uint32_t pid)
00449 {
00450     char buffer3[32];
00451     sprintf(buffer3, "/sd/%d.csv", pid);       
00452     fpmain = fopen(buffer3, "a");             // Main File is opened in Append mode
00453     
00454     sprintf(buffer3, "/sd/%d_GLC.csv", pid);  // BG file is opened in read mode
00455     fpbg = fopen(buffer3, "r");
00456     
00457     for(int i=0; i<1; i++)
00458     {
00459     int bigbuf[2] = {0} ;
00460     fread(bigbuf, sizeof(int),2 , fpbg);      
00461     fwrite(bigbuf, sizeof(int), 2, fpmain);
00462     }
00463     fclose(fpbg);                               // Both files are Closed
00464     fclose(fpmain);
00465     
00466     int success;
00467     sprintf(buffer3, "/sd/%d_GLC.csv", pid);  
00468     success = remove(buffer3);                           // GLC file is deleted
00469 }
00470 
00471 
00472 void delete_subfiles(uint32_t pid)
00473 {
00474     char buffer3[32];  
00475     int success1 , success2, success3;
00476     success1 = 1 ;
00477     sprintf(buffer3, "/sd/%d_BP.csv", pid);
00478     success1 = remove(buffer3);                           //Removes PPG file of BP and updates status with 0 if successful
00479     
00480     if( success1 == 0 )
00481         snd.printf("\nBP file delete : Successful");   // Checks for SUCCESS
00482     else 
00483         snd.printf("\nBP file delete : UnSuccessful");
00484 
00485     success2 = 1 ;
00486     sprintf(buffer3, "/sd/%d_GLC.csv", pid);
00487     success2 = remove(buffer3);                           //Removes GLC file and updates status with 0 if successful
00488     
00489     if( success2 == 0 )
00490         snd.printf("\nGLC file delete : Successful");   // Checks for SUCCESS
00491     else 
00492         snd.printf("\nGLC file delete : UnSuccessful");
00493 
00494     success3 = 1 ;
00495     sprintf(buffer3, "/sd/%d_ECG.csv", pid);
00496     success3 = remove(buffer3);                           //Removes ECG file and updates status with 0 if successful
00497     
00498     if( success3 == 0 )
00499         snd.printf("\nECG file delete : Successful");   // Checks for SUCCESS
00500     else 
00501         snd.printf("\nECG file delete : UnSuccessful");
00502         
00503     success3 = 1;
00504     sprintf(buffer3, "/sd/%d_ECG_lpf.csv", pid);
00505     success3 = remove(buffer3); 
00506     snd.printf("DELETE STATUS = %d\n", success3);
00507     
00508     if( success3 == 0 )
00509         snd.printf("\nECG_lpf file delete : Successful");   // Checks for SUCCESS
00510     else 
00511         snd.printf("\nECG_lpf file delete : UnSuccessful");
00512 
00513 }
00514 
00515 
00516 void del_ppg_ecg_BPfile(uint32_t pid)
00517 {
00518     int status = 1 ;
00519     char buffer3[32];
00520     sprintf(buffer3, "/sd/%d_BP_ECG.csv", pid);
00521     status = remove(buffer3);                         //Removes ECG file of BP and updates status with 0 if successful
00522         
00523     if( status == 0 )
00524         snd.printf("\n temp ECG file delete for error condition: Successful");   // Checks for SUCCESS
00525     else 
00526         snd.printf("\n temp ECG file delete for error condition: UnSuccessful");
00527    
00528     
00529     //char buffer1[32] = "";
00530     status = 1 ;
00531     sprintf(buffer3, "/sd/%d_BP_PPG.csv", pid);
00532     status = remove(buffer3);                           //Removes PPG file of BP and updates status with 0 if successful
00533     
00534     if( status == 0 )
00535         snd.printf("\n temp PPG file delete for error condition: Successful");   // Checks for SUCCESS
00536     else 
00537         snd.printf("\n temp PPG file delete for error condition: UnSuccessful");
00538        
00539 }
00540 
00541 void sd_read(uint32_t  *pid_btpid)          //reading the data from the openend file
00542  {
00543     FILE *fp;
00544     uint32_t pid[2]={0,0};
00545     fp= fopen("/sd/pid_info.txt","r");
00546      if (fp==NULL)
00547     {
00548        fp= fopen("/sd/pid_info.txt","w");
00549        fwrite(&pid, sizeof(uint32_t),2,fp);
00550        fclose(fp);
00551        fp= fopen("/sd/pid_info.txt","r");
00552     }
00553      
00554      fread(pid_btpid,sizeof(pid_btpid),2,fp);
00555      fclose(fp);
00556      
00557  }
00558  
00559  
00560 void sd_write(uint32_t  *pid_btpid)          //reading the data from the openend file
00561 {
00562      FILE *fp;
00563      fp= fopen("/sd/pid_info.txt","w");
00564      fwrite(pid_btpid,sizeof(pid_btpid),2,fp);
00565      fclose(fp);
00566      
00567 }
00568 
00569 void delete_sdcard(void)
00570 {
00571     FILE *fp;
00572     uint32_t pid[2] = {0,0};
00573     fp= fopen("/sd/pid_info.txt","w");
00574     fwrite(&pid, sizeof(uint32_t),2,fp);
00575     fclose(fp);
00576         
00577 }
00578 
00579 
00580 /*void  read_sdcard_file()
00581 {
00582     uint32_t pid=0;
00583     snd.printf("Enter the PID number......!!\n");
00584     snd.scanf("%d", &pid);
00585     snd.printf("%d\n",pid);
00586     readfile(pid);
00587     snd.printf("Finished reading\n");
00588 
00589 }*/
00590 
00591 
00592 
00593 void read_sdcard_file()
00594 {      
00595      
00596       
00597       
00598       FILE *fp_read_sdcard_file ; // PPG and ECG File pointers for BP
00599       char buffer[32];
00600       uint32_t pid = 0;
00601       snd.scanf("%d", &pid);
00602       snd.printf("%d\n",pid);
00603       
00604       
00605       
00606       sprintf(buffer,"/sd/%d.csv",pid);
00607       fp_read_sdcard_file = fopen(buffer, "rb");
00608       
00609       if(fp_read_sdcard_file == NULL)
00610       {
00611           snd.printf("No FILE Found .... !!\n");
00612       }    
00613       
00614       else
00615       {
00616         read_structure(fp_read_sdcard_file);
00617         snd.printf("Finished Reading File Content....!!\n");
00618         fclose(fp_read_sdcard_file);
00619       }                                                                           //end of else loop 
00620      
00621  }  
00622    
00623 void read_structure(FILE * fp_read_sdcard_file)
00624  
00625  {
00626    BLEMsg_info pid_file;     
00627    uint32_t buf[1];                                                             // buffer to read the raw data
00628    uint16_t sample = 0;                                                         // variable to hold the no of samples
00629 
00630     fread(&pid_file,sizeof(BLEMsg_info),1,fp_read_sdcard_file);                 // reading the structure data
00631     while (!feof(fp_read_sdcard_file))
00632     {       
00633         snd.printf("length = %d\n",pid_file.length); 
00634         snd.printf("device_id = %d\n",pid_file.device_id); 
00635         snd.printf("patient_id = %d\n",pid_file.patient_id);    
00636         snd.printf("date = %d\n",pid_file.date_time.date);     
00637         snd.printf("month = %d\n",pid_file.date_time.month);  
00638         snd.printf("year = %d\n",pid_file.date_time.year);  
00639         snd.printf("hour = %d\n",pid_file.date_time.hour);      
00640         snd.printf("mins = %d\n",pid_file.date_time.mins);  
00641         snd.printf("sec = %d\n",pid_file.date_time.sec);  
00642         snd.printf("test_type = %d\n",pid_file.test_type);   
00643         snd.printf("sampling_freq = %d\n",pid_file.sampling_freq); 
00644         snd.printf("sample1 = %d\n",pid_file.num_samples.num_sample_ppg_dummy); 
00645         snd.printf("samples2 = %d\n",pid_file.num_samples.num_sample_ecg_OTtyp); 
00646         sample=(pid_file.num_samples.num_sample_ppg_dummy + pid_file.num_samples.num_sample_ecg_OTtyp);
00647         snd.printf("caldata1 = %d\n",pid_file.cal_data.cal_sbp_dummy);   
00648         snd.printf("caldata2  = %d\n",pid_file.cal_data.cal_dbp_OTtyp); 
00649         snd.printf("sample=%d\n", sample);
00650         for(uint16_t file_start=0;file_start<sample;file_start++)                                       //reading the raw data
00651                         {     
00652                             fread(buf,sizeof(uint32_t),1,fp_read_sdcard_file);
00653                             snd.printf("%08x\n", buf[0]);
00654                         }
00655       /* switch(sample)
00656             {
00657        
00658                 case 2:
00659                          fread(&buf,sizeof(uint32_t),sample,fp_read_sdcard_file);
00660                          for(uint16_t file_start1=0;file_start1<sample;file_start1++)
00661                         {     
00662                             snd.printf("%08x\n", buf[file_start1]);
00663                         }
00664                         break;
00665                 
00666                 case 2000:
00667                          for(uint16_t file_start=0;file_start<(sample/1000);file_start++)
00668                           {     
00669                        
00670                             fread(&buf,sizeof(uint32_t),1000,fp_read_sdcard_file);
00671                             for(uint16_t file_start1=0;file_start1<(1000);file_start1++)
00672                              {     
00673                                 snd.printf("%08x\n", buf[file_start1]);
00674                              }
00675                     
00676                          }
00677                         break;
00678                 
00679                 case 2688:
00680                          for(uint16_t file_start=0;file_start<(sample/1000);file_start++)
00681                         {     
00682                             
00683                             fread(&buf,sizeof(uint32_t),1000,fp_read_sdcard_file);
00684                             for(uint16_t file_start1=0;file_start1<(1000);file_start1++)
00685                             {     
00686                                 snd.printf("%08x\n", buf[file_start1]);
00687                             }
00688                     
00689                         }                  
00690                     
00691                 
00692                         for(uint16_t i=0;i<1000;i++)
00693                         {     
00694                         buf[i]=NULL;
00695                         }
00696                         
00697                         fread(&buf,sizeof(uint32_t),(sample-(1000*(sample/1000))),fp_read_sdcard_file);
00698                     
00699                         for(uint16_t file_start1=0;file_start1<(sample-(1000*(sample/1000)));file_start1++)
00700                         {     
00701                         snd.printf("%08x\n", buf[file_start1]);
00702                         }
00703                         break;
00704                         
00705                         
00706                 default: snd.printf("End\n");
00707                             break;
00708                                     
00709                     }
00710                   */
00711         fread(&pid_file,sizeof(BLEMsg_info),1,fp_read_sdcard_file);
00712            
00713    }    
00714  
00715  }
00716  
00717       
00718       
00719