Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of merged_code2_20sept_2017_4th_oct_2017 by
Diff: sdcard.cpp
- Revision:
- 49:3ff80c4bc1be
- Parent:
- 46:162ed3f051b2
- Child:
- 50:b42238e7f46d
diff -r f90edb35a20e -r 3ff80c4bc1be sdcard.cpp
--- a/sdcard.cpp Fri Sep 15 07:38:47 2017 +0000
+++ b/sdcard.cpp Fri Sep 15 19:44:48 2017 +0000
@@ -424,6 +424,10 @@
sprintf(buffer3, "/sd/%d_ECG.csv", pid);
success = remove(buffer3);
snd.printf("DELETE STATUS = %d\n", success);
+success = 1;
+ sprintf(buffer3, "/sd/%d_ECG_lpf.csv", pid);
+ success = remove(buffer3);
+ snd.printf("DELETE STATUS = %d\n", success);
}
@@ -495,6 +499,16 @@
snd.printf("\nECG file delete : Successful"); // Checks for SUCCESS
else
snd.printf("\nECG file delete : UnSuccessful");
+
+ success3 = 1;
+ sprintf(buffer3, "/sd/%d_ECG_lpf.csv", pid);
+ success3 = remove(buffer3);
+ snd.printf("DELETE STATUS = %d\n", success3);
+
+ if( success3 == 0 )
+ snd.printf("\nECG_lpf file delete : Successful"); // Checks for SUCCESS
+ else
+ snd.printf("\nECG_lpf file delete : UnSuccessful");
}
@@ -552,4 +566,134 @@
}
+void delete_sdcard(void)
+{
+ FILE *fp;
+ uint32_t pid[2] = {1,1};
+ fp= fopen("/sd/pid_info.txt","w");
+ fwrite(&pid, sizeof(uint32_t),2,fp);
+ fclose(fp);
+
+}
+
+
+/*void read_sdcard_file()
+{
+ uint32_t pid=0;
+ snd.printf("Enter the PID number......!!\n");
+ snd.scanf("%d", &pid);
+ snd.printf("%d\n",pid);
+ readfile(pid);
+ snd.printf("Finished reading\n");
+
+}*/
+
+
+
+void read_sdcard_file(uint32_t pid)
+{
+ FILE *fp_read_sdcard_file ; // PPG and ECG File pointers for BP
+ char buffer[32];
+ sprintf(buffer,"/sd/%d.csv",pid);
+ fp_read_sdcard_file = fopen(buffer, "rb");
+
+ if(fp_read_sdcard_file == NULL)
+ {
+ snd.printf("No FILE Found .... !!\n");
+ }
+
+ else
+ {
+ read_structure(fp_read_sdcard_file);
+ snd.printf("Finished Reading File Content....!!\n");
+ fclose(fp_read_sdcard_file);
+ } //end of else loop
+
+ }
+
+void read_structure(FILE * fp_read_sdcard_file)
+
+ {
+ BLEMsg_info bt_file2;
+ uint32_t buf[1000];
+ uint16_t sample = 0;
+ while (!feof(fp_read_sdcard_file))
+ {
+ fread(&bt_file2,sizeof(BLEMsg_info),1,fp_read_sdcard_file);
+ snd.printf("%d\n",bt_file2.length);
+ snd.printf("%d\n",bt_file2.device_id);
+ snd.printf("%d\n",bt_file2.patient_id);
+ snd.printf("%d\n",bt_file2.date_time.date);
+ snd.printf("%d\n",bt_file2.date_time.month);
+ snd.printf("%d\n",bt_file2.date_time.year);
+ snd.printf("%d\n",bt_file2.date_time.hour);
+ snd.printf("%d\n",bt_file2.date_time.mins);
+ snd.printf("%d\n",bt_file2.date_time.sec);
+ snd.printf("%d\n",bt_file2.test_type);
+ snd.printf("%d\n",bt_file2.sampling_freq);
+ snd.printf("%d\n",bt_file2.num_samples.num_sample_ppg_dummy);
+ snd.printf("%d\n",bt_file2.num_samples.num_sample_ecg_OTtyp);
+ sample=(bt_file2.num_samples.num_sample_ppg_dummy + bt_file2.num_samples.num_sample_ecg_OTtyp);
+ snd.printf("%d\n",bt_file2.cal_data.cal_sbp_dummy);
+ snd.printf("%d\n",bt_file2.cal_data.cal_dbp_OTtyp);
+
+
+ switch(sample)
+ {
+
+ case 2:
+ fread(&buf,sizeof(uint32_t),sample,fp_read_sdcard_file);
+ for(uint16_t file_start1=0;file_start1<sample;file_start1++)
+ {
+ snd.printf("%08x", buf[file_start1]);
+ }
+ break;
+
+ case 2000:
+ for(uint16_t file_start=0;file_start<(sample/1000);file_start++)
+ {
+
+ fread(&buf,sizeof(uint32_t),1000,fp_read_sdcard_file);
+ for(uint16_t file_start1=0;file_start1<(1000);file_start1++)
+ {
+ snd.printf("%08x", buf[file_start1]);
+ }
+
+ }
+ break;
+
+ case 2668:
+ for(uint16_t file_start=0;file_start<(sample/1000);file_start++)
+ {
+
+ fread(&buf,sizeof(uint32_t),1000,fp_read_sdcard_file);
+ for(uint16_t file_start1=0;file_start1<(1000);file_start1++)
+ {
+ snd.printf("%08x", buf[file_start1]);
+ }
+
+ }
+
+
+ for(uint16_t i=0;i<1000;i++)
+ {
+ buf[i]=NULL;
+ }
+
+ fread(&buf,sizeof(uint32_t),(sample-(1000*(sample/1000))),fp_read_sdcard_file);
+
+ for(uint16_t file_start1=0;file_start1<(sample-(1000*(sample/1000)));file_start1++)
+ {
+ snd.printf("%08x", buf[file_start1]);
+ }
+ break;
+ }
+
+
+ }
+
+ }
+
+
+
\ No newline at end of file
