Code clean up - modify Datatypes
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of merged_code2_3rd_nov_2017_15th_dec_2017_magicno_removal by
sdcard.cpp@61:2143f39103f7, 2017-12-19 (annotated)
- Committer:
- nikitateggi
- Date:
- Tue Dec 19 06:58:44 2017 +0000
- Revision:
- 61:2143f39103f7
- Parent:
- 60:945c4a1e9a13
Code clean up - modify Datatypes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nidhinvarghese | 14:f5c62d30c6fc | 1 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 2 | #include "mbed.h" |
rashmivenkataramaiah | 41:1141a75eacc4 | 3 | #include <stdio.h> |
nikitateggi | 60:945c4a1e9a13 | 4 | #include "SDFileSystem.h" |
rashmivenkataramaiah | 41:1141a75eacc4 | 5 | #include "sdcard.h" |
rashmivenkataramaiah | 41:1141a75eacc4 | 6 | #include "rtc.h" |
rashmivenkataramaiah | 41:1141a75eacc4 | 7 | #include "struct.h" |
rashmivenkataramaiah | 41:1141a75eacc4 | 8 | #include "main.h" |
rashmivenkataramaiah | 41:1141a75eacc4 | 9 | #include "eeprom_pgm.h" |
nidhinvarghese | 14:f5c62d30c6fc | 10 | |
nidhinvarghese | 14:f5c62d30c6fc | 11 | Serial snd(USBTX,USBRX); |
nikitateggi | 1:8316c23ec6b9 | 12 | |
nikitateggi | 24:d992ee8369f4 | 13 | |
nikitateggi | 60:945c4a1e9a13 | 14 | |
nikitateggi | 60:945c4a1e9a13 | 15 | FILE *fpecg; // PPG and ECG File pointers for BP |
nikitateggi | 60:945c4a1e9a13 | 16 | FILE *fpppg; //"" "" |
nikitateggi | 60:945c4a1e9a13 | 17 | |
nikitateggi | 60:945c4a1e9a13 | 18 | FILE *fpmain; // FILE pointer for main file |
nikitateggi | 60:945c4a1e9a13 | 19 | |
nikitateggi | 60:945c4a1e9a13 | 20 | FILE *fpbg; // FILE pointer to BG file |
nikitateggi | 60:945c4a1e9a13 | 21 | FILE *fpeecg; // FILE pointer to ECG file |
nikitateggi | 60:945c4a1e9a13 | 22 | FILE *fpbp; // FILE pointer to BP file |
nikitateggi | 60:945c4a1e9a13 | 23 | |
nikitateggi | 60:945c4a1e9a13 | 24 | FILE *fp; // FILE pointer for random use |
nidhinvarghese | 14:f5c62d30c6fc | 25 | |
nidhinvarghese | 14:f5c62d30c6fc | 26 | |
nikitateggi | 61:2143f39103f7 | 27 | |
nikitateggi | 60:945c4a1e9a13 | 28 | |
nikitateggi | 1:8316c23ec6b9 | 29 | |
nikitateggi | 60:945c4a1e9a13 | 30 | void sd_open_GLCfilee(uint32_t pid) // only opening the glc file after entering TEST screen |
nikitateggi | 60:945c4a1e9a13 | 31 | { |
nikitateggi | 60:945c4a1e9a13 | 32 | char buffer1[32]; |
nikitateggi | 60:945c4a1e9a13 | 33 | sprintf(buffer1,"/sd/%d_GLC.csv",pid); |
nikitateggi | 60:945c4a1e9a13 | 34 | fpbg = fopen(buffer1,"a"); |
nikitateggi | 60:945c4a1e9a13 | 35 | fclose(fpbg); |
nikitateggi | 60:945c4a1e9a13 | 36 | } |
nikitateggi | 1:8316c23ec6b9 | 37 | |
nidhinvarghese | 14:f5c62d30c6fc | 38 | |
nikitateggi | 60:945c4a1e9a13 | 39 | void sd_open_ECGfilee(uint32_t pid) // only opening the ECG file after entering TEST screen |
nikitateggi | 60:945c4a1e9a13 | 40 | { |
nikitateggi | 60:945c4a1e9a13 | 41 | char buffer1[32]; |
nikitateggi | 60:945c4a1e9a13 | 42 | sprintf(buffer1,"/sd/%d_ECG.csv",pid); |
nikitateggi | 60:945c4a1e9a13 | 43 | fpeecg = fopen(buffer1,"a"); |
nikitateggi | 60:945c4a1e9a13 | 44 | } |
nikitateggi | 60:945c4a1e9a13 | 45 | |
nikitateggi | 4:6bd81bb1790d | 46 | |
nikitateggi | 60:945c4a1e9a13 | 47 | void sd_open_BPfilee(uint32_t pid) // only opening the BP file after entering TEST screen |
nikitateggi | 60:945c4a1e9a13 | 48 | { |
nikitateggi | 60:945c4a1e9a13 | 49 | char buffer1[32]; |
nikitateggi | 60:945c4a1e9a13 | 50 | sprintf(buffer1,"/sd/%d_BP.csv",pid); |
nikitateggi | 60:945c4a1e9a13 | 51 | fpbp = fopen(buffer1,"a"); |
nikitateggi | 60:945c4a1e9a13 | 52 | fclose(fpbp); |
nikitateggi | 60:945c4a1e9a13 | 53 | } |
nikitateggi | 60:945c4a1e9a13 | 54 | |
nikitateggi | 61:2143f39103f7 | 55 | |
nikitateggi | 4:6bd81bb1790d | 56 | |
nikitateggi | 61:2143f39103f7 | 57 | uint8_t sd_open_read_bt(uint32_t pid) // opening the file for read //name changed nikita |
nikitateggi | 60:945c4a1e9a13 | 58 | { |
nikitateggi | 60:945c4a1e9a13 | 59 | char buffer1[32] = {}; |
nikitateggi | 60:945c4a1e9a13 | 60 | sprintf(buffer1,"/sd/%d.csv",pid); |
nikitateggi | 60:945c4a1e9a13 | 61 | fp = fopen(buffer1,"r"); |
nikitateggi | 60:945c4a1e9a13 | 62 | if (fp==NULL) |
nikitateggi | 60:945c4a1e9a13 | 63 | { |
nikitateggi | 60:945c4a1e9a13 | 64 | snd.printf("no"); |
nikitateggi | 60:945c4a1e9a13 | 65 | return 0; |
nikitateggi | 60:945c4a1e9a13 | 66 | } |
nikitateggi | 60:945c4a1e9a13 | 67 | else |
nikitateggi | 60:945c4a1e9a13 | 68 | { |
nikitateggi | 60:945c4a1e9a13 | 69 | snd.printf("yes"); |
nikitateggi | 60:945c4a1e9a13 | 70 | return 1; |
nikitateggi | 60:945c4a1e9a13 | 71 | } |
nikitateggi | 60:945c4a1e9a13 | 72 | } |
nikitateggi | 19:1650bbc923cc | 73 | |
nikitateggi | 61:2143f39103f7 | 74 | void sd_read_bt(uint32_t *v1, uint16_t size) //reading the data from the openend file// nikita changed name |
nikitateggi | 60:945c4a1e9a13 | 75 | { |
nikitateggi | 60:945c4a1e9a13 | 76 | fread(v1,sizeof(v1),size,fp); |
nikitateggi | 60:945c4a1e9a13 | 77 | } |
nikitateggi | 19:1650bbc923cc | 78 | |
nikitateggi | 19:1650bbc923cc | 79 | |
nikitateggi | 61:2143f39103f7 | 80 | void setpos_file(uint32_t position) //changed the name nikita |
nikitateggi | 19:1650bbc923cc | 81 | { |
nikitateggi | 60:945c4a1e9a13 | 82 | fseek ( fp , position, SEEK_SET ); |
nikitateggi | 19:1650bbc923cc | 83 | } |
nikitateggi | 19:1650bbc923cc | 84 | |
nikitateggi | 19:1650bbc923cc | 85 | |
nikitateggi | 61:2143f39103f7 | 86 | uint32_t file_size_init() //changed the name nikita// defines the size of the file |
nikitateggi | 60:945c4a1e9a13 | 87 | { |
nikitateggi | 60:945c4a1e9a13 | 88 | uint32_t file_length = 0; |
nikitateggi | 60:945c4a1e9a13 | 89 | |
nikitateggi | 60:945c4a1e9a13 | 90 | fseek (fp, 0, SEEK_END); |
nikitateggi | 60:945c4a1e9a13 | 91 | file_length = ftell(fp); |
nikitateggi | 60:945c4a1e9a13 | 92 | file_length = sizeof(char)*file_length; |
nikitateggi | 60:945c4a1e9a13 | 93 | rewind(fp); |
nikitateggi | 60:945c4a1e9a13 | 94 | return file_length; |
nikitateggi | 60:945c4a1e9a13 | 95 | } |
nikitateggi | 19:1650bbc923cc | 96 | |
nikitateggi | 19:1650bbc923cc | 97 | |
nikitateggi | 61:2143f39103f7 | 98 | uint32_t file_size_sent() //changed the name // defines the file size sent on bluetooth |
nikitateggi | 60:945c4a1e9a13 | 99 | { |
nikitateggi | 60:945c4a1e9a13 | 100 | uint32_t file_length; |
nikitateggi | 60:945c4a1e9a13 | 101 | |
nikitateggi | 60:945c4a1e9a13 | 102 | file_length=ftell(fp); |
nikitateggi | 60:945c4a1e9a13 | 103 | return file_length; |
nikitateggi | 60:945c4a1e9a13 | 104 | } |
nikitateggi | 19:1650bbc923cc | 105 | |
nikitateggi | 61:2143f39103f7 | 106 | void sd_read_struct(BLEMsg_info &f) //changed the function name nikita |
nikitateggi | 19:1650bbc923cc | 107 | { |
nikitateggi | 60:945c4a1e9a13 | 108 | fread(&f,sizeof(BLEMsg_info),1,fp); |
nikitateggi | 19:1650bbc923cc | 109 | } |
nikitateggi | 19:1650bbc923cc | 110 | |
nidhinvarghese | 8:adf2ba7e6412 | 111 | |
nikitateggi | 61:2143f39103f7 | 112 | FILE *sd_BP_ecgwrite (uint32_t *fp_bp_ecg) // writing data into the file NIDHIN //pointer name changed nikita |
nikitateggi | 60:945c4a1e9a13 | 113 | { |
nikitateggi | 61:2143f39103f7 | 114 | fwrite(fp_bp_ecg,sizeof(uint32_t),1, fpecg); // Direct writing to SD card. |
nikitateggi | 60:945c4a1e9a13 | 115 | return fpecg; |
nikitateggi | 60:945c4a1e9a13 | 116 | } |
nikitateggi | 60:945c4a1e9a13 | 117 | |
nikitateggi | 61:2143f39103f7 | 118 | FILE* sd_BP_ppgwrite (uint32_t *fp_bp_ppg) // Direct writing to SD card.// pointer name changed nikita |
nikitateggi | 60:945c4a1e9a13 | 119 | { |
nikitateggi | 61:2143f39103f7 | 120 | fwrite(fp_bp_ppg,sizeof(uint32_t),1, fpppg); //Direct writing to SD card. |
nidhinvarghese | 8:adf2ba7e6412 | 121 | return fpppg; |
nikitateggi | 60:945c4a1e9a13 | 122 | } |
nidhinvarghese | 8:adf2ba7e6412 | 123 | |
nidhinvarghese | 8:adf2ba7e6412 | 124 | |
nidhinvarghese | 8:adf2ba7e6412 | 125 | |
nikitateggi | 60:945c4a1e9a13 | 126 | void sd_open_BP_ECGfile(uint32_t pid) |
nikitateggi | 60:945c4a1e9a13 | 127 | { |
nikitateggi | 60:945c4a1e9a13 | 128 | char buffer1[32]; |
nikitateggi | 60:945c4a1e9a13 | 129 | |
nikitateggi | 60:945c4a1e9a13 | 130 | sprintf(buffer1,"/sd/%d_BP_ECG.csv",pid); |
nikitateggi | 60:945c4a1e9a13 | 131 | fpecg = fopen(buffer1,"a"); |
nikitateggi | 60:945c4a1e9a13 | 132 | if (fpecg == NULL) |
nikitateggi | 60:945c4a1e9a13 | 133 | { |
nikitateggi | 60:945c4a1e9a13 | 134 | exit(1); |
nikitateggi | 60:945c4a1e9a13 | 135 | } |
nikitateggi | 60:945c4a1e9a13 | 136 | } |
nidhinvarghese | 8:adf2ba7e6412 | 137 | |
nidhinvarghese | 8:adf2ba7e6412 | 138 | |
nikitateggi | 60:945c4a1e9a13 | 139 | void sd_open_BP_PPGfile(uint32_t pid) |
nikitateggi | 60:945c4a1e9a13 | 140 | { |
nikitateggi | 60:945c4a1e9a13 | 141 | char buffer1[32]; |
nikitateggi | 60:945c4a1e9a13 | 142 | |
nikitateggi | 60:945c4a1e9a13 | 143 | sprintf(buffer1,"/sd/%d_BP_PPG.csv",pid); |
nikitateggi | 60:945c4a1e9a13 | 144 | fpppg = fopen(buffer1,"a"); |
nikitateggi | 60:945c4a1e9a13 | 145 | if(fpppg == NULL) |
nikitateggi | 60:945c4a1e9a13 | 146 | { |
nikitateggi | 60:945c4a1e9a13 | 147 | exit(1); |
nikitateggi | 60:945c4a1e9a13 | 148 | } |
nikitateggi | 60:945c4a1e9a13 | 149 | |
nikitateggi | 60:945c4a1e9a13 | 150 | } |
nidhinvarghese | 8:adf2ba7e6412 | 151 | |
nidhinvarghese | 14:f5c62d30c6fc | 152 | //FUNCTIONS TO CLOSE FILES |
nikitateggi | 60:945c4a1e9a13 | 153 | |
nikitateggi | 60:945c4a1e9a13 | 154 | void sd_close() //close the file with fp |
nikitateggi | 60:945c4a1e9a13 | 155 | { |
nikitateggi | 60:945c4a1e9a13 | 156 | fclose(fp); |
nikitateggi | 60:945c4a1e9a13 | 157 | } |
nidhinvarghese | 14:f5c62d30c6fc | 158 | |
nikitateggi | 60:945c4a1e9a13 | 159 | void sd_close_ecg() // Closes ECG file pinted by fpeecg |
nikitateggi | 60:945c4a1e9a13 | 160 | { |
nikitateggi | 60:945c4a1e9a13 | 161 | fclose(fpeecg); |
nikitateggi | 60:945c4a1e9a13 | 162 | } |
nikitateggi | 60:945c4a1e9a13 | 163 | |
nikitateggi | 61:2143f39103f7 | 164 | |
nidhinvarghese | 14:f5c62d30c6fc | 165 | |
nikitateggi | 60:945c4a1e9a13 | 166 | //------- FUNCTION TO CREATE SINGLE BP FILE -----------------// |
nikitateggi | 60:945c4a1e9a13 | 167 | void create_single_BPfile(uint32_t pid) |
nikitateggi | 60:945c4a1e9a13 | 168 | { |
nikitateggi | 60:945c4a1e9a13 | 169 | char buffer3[32]; |
nikitateggi | 61:2143f39103f7 | 170 | uint8_t bp_loop = 0; |
nikitateggi | 60:945c4a1e9a13 | 171 | sprintf(buffer3, "/sd/%d_BP.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 172 | fpbp = fopen(buffer3, "a"); // Opens BP file with FILE pointer fpbp in APPEND mode |
nidhinvarghese | 10:aeff3309002a | 173 | |
nikitateggi | 60:945c4a1e9a13 | 174 | sprintf(buffer3, "/sd/%d_BP_ECG.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 175 | fpecg = fopen(buffer3, "r"); // Opens ECG file of BP with FILE pointer fpecg in READ mode |
nidhinvarghese | 10:aeff3309002a | 176 | |
nidhinvarghese | 10:aeff3309002a | 177 | sprintf(buffer3, "/sd/%d_BP_PPG.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 178 | fpppg = fopen(buffer3, "r"); // Opens PPG file of BP with FILE pointer fpppg in READ mode |
nidhinvarghese | 10:aeff3309002a | 179 | |
nikitateggi | 61:2143f39103f7 | 180 | for(bp_loop=0; bp_loop<16; bp_loop++) |
nidhinvarghese | 10:aeff3309002a | 181 | { |
nikitateggi | 61:2143f39103f7 | 182 | uint32_t ecgbuf[64] = {0} ; //changed from int to uint32_t//nikita |
nikitateggi | 60:945c4a1e9a13 | 183 | fread(ecgbuf, sizeof(uint32_t), 64, fpecg); |
nikitateggi | 60:945c4a1e9a13 | 184 | fwrite(ecgbuf, sizeof(uint32_t), 64, fpbp); // Copy ECG data of BP into BP file |
nidhinvarghese | 10:aeff3309002a | 185 | } |
nidhinvarghese | 10:aeff3309002a | 186 | |
nikitateggi | 61:2143f39103f7 | 187 | for(bp_loop=0; bp_loop<26; bp_loop++) //changed from int to uint32_t//nikita |
nidhinvarghese | 10:aeff3309002a | 188 | { |
nikitateggi | 61:2143f39103f7 | 189 | uint32_t ppgbuf[64] = {0} ; |
nikitateggi | 60:945c4a1e9a13 | 190 | fread(ppgbuf, sizeof(uint32_t), 64, fpppg); |
nikitateggi | 60:945c4a1e9a13 | 191 | fwrite(ppgbuf, sizeof(uint32_t), 64, fpbp); // Copy PPG data of BP into BP file |
nidhinvarghese | 10:aeff3309002a | 192 | } |
nidhinvarghese | 10:aeff3309002a | 193 | |
nikitateggi | 60:945c4a1e9a13 | 194 | fclose(fpecg); // Closes the ECG file of BP |
nikitateggi | 60:945c4a1e9a13 | 195 | fclose(fpppg); // Closes the PPG file of BP |
nikitateggi | 60:945c4a1e9a13 | 196 | fclose(fpbp); // Closes the BP file |
nidhinvarghese | 10:aeff3309002a | 197 | |
nidhinvarghese | 14:f5c62d30c6fc | 198 | int status = 1 ; |
nidhinvarghese | 10:aeff3309002a | 199 | sprintf(buffer3, "/sd/%d_BP_ECG.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 200 | status = remove(buffer3); //Removes ECG file of BP and updates status with 0 if successful |
nidhinvarghese | 11:9a6545c2eb5d | 201 | |
nidhinvarghese | 11:9a6545c2eb5d | 202 | |
nidhinvarghese | 10:aeff3309002a | 203 | if( status == 0 ) |
nikitateggi | 60:945c4a1e9a13 | 204 | snd.printf("\nECG file delete : Successful"); // Checks for SUCCESS |
nidhinvarghese | 10:aeff3309002a | 205 | else |
nidhinvarghese | 10:aeff3309002a | 206 | snd.printf("\nECG file delete : UnSuccessful"); |
nidhinvarghese | 11:9a6545c2eb5d | 207 | |
nidhinvarghese | 14:f5c62d30c6fc | 208 | status = 1 ; |
nidhinvarghese | 10:aeff3309002a | 209 | sprintf(buffer3, "/sd/%d_BP_PPG.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 210 | status = remove(buffer3); //Removes PPG file of BP and updates status with 0 if successful |
nidhinvarghese | 11:9a6545c2eb5d | 211 | |
nidhinvarghese | 10:aeff3309002a | 212 | if( status == 0 ) |
nikitateggi | 60:945c4a1e9a13 | 213 | snd.printf("\nPPG file delete : Successful"); // Checks for SUCCESS |
nidhinvarghese | 10:aeff3309002a | 214 | else |
nidhinvarghese | 10:aeff3309002a | 215 | snd.printf("\nPPG file delete : UnSuccessful"); |
nidhinvarghese | 11:9a6545c2eb5d | 216 | |
nidhinvarghese | 14:f5c62d30c6fc | 217 | } |
nidhinvarghese | 14:f5c62d30c6fc | 218 | |
nidhinvarghese | 14:f5c62d30c6fc | 219 | //Creating strcuture file Common to All Functions |
rashmivenkataramaiah | 43:85a7f399cb9d | 220 | void structure_file(BLEMsg_info *ptr, uint32_t pid) |
nidhinvarghese | 14:f5c62d30c6fc | 221 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 222 | char buffer3[32]; |
nikitateggi | 60:945c4a1e9a13 | 223 | sprintf(buffer3, "/sd/%d.csv", pid); //Printing file path to the buffer |
nikitateggi | 60:945c4a1e9a13 | 224 | if(get_filecreated_status() == true) //if file created open in append mode |
rashmivenkataramaiah | 41:1141a75eacc4 | 225 | { |
nikitateggi | 60:945c4a1e9a13 | 226 | fpmain = fopen(buffer3, "a"); // open the file PID.csv with FILE pointer fpmain |
rashmivenkataramaiah | 41:1141a75eacc4 | 227 | snd.printf("\n Append mode\n"); |
rashmivenkataramaiah | 41:1141a75eacc4 | 228 | } |
nikitateggi | 60:945c4a1e9a13 | 229 | else //if file not created, open in write mode |
rashmivenkataramaiah | 41:1141a75eacc4 | 230 | { |
nikitateggi | 60:945c4a1e9a13 | 231 | fpmain = fopen(buffer3, "w"); // open the file PID.csv with FILE pointer fpmain |
rashmivenkataramaiah | 41:1141a75eacc4 | 232 | snd.printf("\n Write mode\n"); |
rashmivenkataramaiah | 41:1141a75eacc4 | 233 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 234 | |
nikitateggi | 60:945c4a1e9a13 | 235 | fwrite(ptr, sizeof(uint8_t),26, fpmain ); // writing the Structure into the file |
nikitateggi | 60:945c4a1e9a13 | 236 | fclose(fpmain); // Close File |
nidhinvarghese | 14:f5c62d30c6fc | 237 | } |
nidhinvarghese | 14:f5c62d30c6fc | 238 | |
nikitateggi | 60:945c4a1e9a13 | 239 | |
nidhinvarghese | 14:f5c62d30c6fc | 240 | |
nikitateggi | 60:945c4a1e9a13 | 241 | void bpfile_mainfile(uint32_t pid) //Copy data of bp file to main |
nidhinvarghese | 14:f5c62d30c6fc | 242 | { |
nidhinvarghese | 14:f5c62d30c6fc | 243 | char buffer3[32]; |
nikitateggi | 61:2143f39103f7 | 244 | uint8_t bp_loop = 0; |
nikitateggi | 61:2143f39103f7 | 245 | int success; |
nidhinvarghese | 14:f5c62d30c6fc | 246 | sprintf(buffer3, "/sd/%d.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 247 | fpmain = fopen(buffer3, "a"); // Opens Main file with FILE pointer "fpmain" in APPEND mode |
nidhinvarghese | 14:f5c62d30c6fc | 248 | |
nidhinvarghese | 14:f5c62d30c6fc | 249 | sprintf(buffer3, "/sd/%d_BP.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 250 | fpbp = fopen(buffer3, "r"); // Opens BP file with FILE pointer "fpbp" in READ mode |
nidhinvarghese | 14:f5c62d30c6fc | 251 | |
nidhinvarghese | 14:f5c62d30c6fc | 252 | |
nikitateggi | 61:2143f39103f7 | 253 | for(bp_loop=0; bp_loop<21; bp_loop++) //changed from int to uint32_t//nikita |
nidhinvarghese | 14:f5c62d30c6fc | 254 | { |
nikitateggi | 61:2143f39103f7 | 255 | uint32_t bigbuf[128] = {0} ; |
nikitateggi | 60:945c4a1e9a13 | 256 | fread(bigbuf, sizeof(uint32_t), 128, fpbp); |
nikitateggi | 60:945c4a1e9a13 | 257 | fwrite(bigbuf, sizeof(uint32_t), 128, fpmain); // Copy BP raw data into main file |
nidhinvarghese | 14:f5c62d30c6fc | 258 | } |
nikitateggi | 60:945c4a1e9a13 | 259 | fclose(fpbp); // Close BP file |
nikitateggi | 60:945c4a1e9a13 | 260 | fclose(fpmain); // Close Main File |
nidhinvarghese | 14:f5c62d30c6fc | 261 | |
nikitateggi | 61:2143f39103f7 | 262 | |
nidhinvarghese | 14:f5c62d30c6fc | 263 | sprintf(buffer3, "/sd/%d_BP.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 264 | success = remove(buffer3); // Should return zero on success |
nikitateggi | 61:2143f39103f7 | 265 | snd.printf("DELETE STATUS = %d\n", success); |
nidhinvarghese | 14:f5c62d30c6fc | 266 | } |
nidhinvarghese | 14:f5c62d30c6fc | 267 | |
nikitateggi | 60:945c4a1e9a13 | 268 | void sd_ecgwrite(uint32_t *ecg_ptr) //function to print ECG data to Sd card using fwrite |
nidhinvarghese | 14:f5c62d30c6fc | 269 | { |
nidhinvarghese | 14:f5c62d30c6fc | 270 | fwrite(ecg_ptr, sizeof(int), 1, fpeecg); |
nidhinvarghese | 14:f5c62d30c6fc | 271 | } |
nidhinvarghese | 14:f5c62d30c6fc | 272 | |
nikitateggi | 60:945c4a1e9a13 | 273 | void ecgfile_mainfile(uint32_t pid) //Function to write ECG data to main file |
nidhinvarghese | 14:f5c62d30c6fc | 274 | { |
nidhinvarghese | 14:f5c62d30c6fc | 275 | char buffer3[32]; |
nikitateggi | 60:945c4a1e9a13 | 276 | int success; |
nikitateggi | 61:2143f39103f7 | 277 | uint8_t ecg_loop = 0; //loop name changed nikita |
nidhinvarghese | 14:f5c62d30c6fc | 278 | sprintf(buffer3, "/sd/%d.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 279 | fpmain = fopen(buffer3, "a"); // Main File is opened in Append mode |
suhasini | 26:53ff13a164f3 | 280 | snd.printf("opening main file\n"); |
nikitateggi | 60:945c4a1e9a13 | 281 | |
nikitateggi | 60:945c4a1e9a13 | 282 | sprintf(buffer3, "/sd/%d_ECG.csv", pid); // ECG file is opened in read mode |
nidhinvarghese | 14:f5c62d30c6fc | 283 | fpeecg = fopen(buffer3, "r"); |
suhasini | 26:53ff13a164f3 | 284 | snd.printf("opening temp file\n"); |
nikitateggi | 60:945c4a1e9a13 | 285 | |
nikitateggi | 61:2143f39103f7 | 286 | for(ecg_loop=0; ecg_loop<20; ecg_loop++) //the loop runs as 20 times of 100 i.e., 2k |
nidhinvarghese | 14:f5c62d30c6fc | 287 | { |
nikitateggi | 61:2143f39103f7 | 288 | uint32_t bigbuf[100] = {0} ; //changed from int to uint32_t//nikita |
nikitateggi | 61:2143f39103f7 | 289 | fread(bigbuf, sizeof(uint32_t),100 , fpeecg); |
nikitateggi | 61:2143f39103f7 | 290 | fwrite(bigbuf, sizeof(uint32_t), 100, fpmain); |
nidhinvarghese | 14:f5c62d30c6fc | 291 | } |
suhasini | 26:53ff13a164f3 | 292 | snd.printf("to close temp file\n"); |
nikitateggi | 60:945c4a1e9a13 | 293 | fclose(fpeecg); // Both files are Closed |
nikitateggi | 60:945c4a1e9a13 | 294 | |
suhasini | 26:53ff13a164f3 | 295 | snd.printf("to come out of main file\n"); |
nidhinvarghese | 14:f5c62d30c6fc | 296 | fclose(fpmain); |
nidhinvarghese | 14:f5c62d30c6fc | 297 | |
suhasini | 26:53ff13a164f3 | 298 | snd.printf("COPY complete Files Closed\n"); |
suhasini | 26:53ff13a164f3 | 299 | |
nikitateggi | 60:945c4a1e9a13 | 300 | sprintf(buffer3, "/sd/%d_ECG.csv", pid); // ECG file is opened in write mode to empty the file |
suhasini | 26:53ff13a164f3 | 301 | fpeecg = fopen(buffer3, "r"); |
nikitateggi | 60:945c4a1e9a13 | 302 | fclose(fpeecg); // File is closed |
nikitateggi | 60:945c4a1e9a13 | 303 | |
nikitateggi | 60:945c4a1e9a13 | 304 | |
nidhinvarghese | 14:f5c62d30c6fc | 305 | sprintf(buffer3, "/sd/%d_ECG.csv", pid); |
suhasini | 26:53ff13a164f3 | 306 | success = remove(buffer3); |
suhasini | 26:53ff13a164f3 | 307 | snd.printf("DELETE STATUS = %d\n", success); |
nikitateggi | 60:945c4a1e9a13 | 308 | |
nikitateggi | 60:945c4a1e9a13 | 309 | success = 1; |
nikitateggi | 60:945c4a1e9a13 | 310 | |
nikitateggi | 49:3ff80c4bc1be | 311 | sprintf(buffer3, "/sd/%d_ECG_lpf.csv", pid); |
nikitateggi | 49:3ff80c4bc1be | 312 | success = remove(buffer3); |
nikitateggi | 49:3ff80c4bc1be | 313 | snd.printf("DELETE STATUS = %d\n", success); |
nidhinvarghese | 14:f5c62d30c6fc | 314 | } |
nidhinvarghese | 14:f5c62d30c6fc | 315 | |
nikitateggi | 60:945c4a1e9a13 | 316 | void sd_glcwrite(uint32_t *glc_ptr, uint32_t pid) // Function to write GLC data to GLC file |
nidhinvarghese | 14:f5c62d30c6fc | 317 | { |
nidhinvarghese | 14:f5c62d30c6fc | 318 | char buffer3[32]; |
nikitateggi | 60:945c4a1e9a13 | 319 | |
nidhinvarghese | 14:f5c62d30c6fc | 320 | sprintf(buffer3, "/sd/%d_GLC.csv", pid); |
nidhinvarghese | 14:f5c62d30c6fc | 321 | fpbg = fopen(buffer3, "a"); |
nidhinvarghese | 14:f5c62d30c6fc | 322 | fwrite(glc_ptr, sizeof(uint32_t), 2, fpbg); |
nidhinvarghese | 14:f5c62d30c6fc | 323 | fclose(fpbg); |
nidhinvarghese | 14:f5c62d30c6fc | 324 | |
nidhinvarghese | 14:f5c62d30c6fc | 325 | } |
nidhinvarghese | 14:f5c62d30c6fc | 326 | |
nikitateggi | 60:945c4a1e9a13 | 327 | void glcfile_mainfile(uint32_t pid) //Fuinction to write GLC data to Main file |
nidhinvarghese | 14:f5c62d30c6fc | 328 | { |
nidhinvarghese | 14:f5c62d30c6fc | 329 | char buffer3[32]; |
nikitateggi | 60:945c4a1e9a13 | 330 | int bigbuf[2] = {0} ; |
nikitateggi | 60:945c4a1e9a13 | 331 | int success; |
nikitateggi | 60:945c4a1e9a13 | 332 | |
nidhinvarghese | 14:f5c62d30c6fc | 333 | sprintf(buffer3, "/sd/%d.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 334 | fpmain = fopen(buffer3, "a"); // Main File is opened in Append mode |
nidhinvarghese | 14:f5c62d30c6fc | 335 | |
nikitateggi | 60:945c4a1e9a13 | 336 | sprintf(buffer3, "/sd/%d_GLC.csv", pid); // BG file is opened in read mode |
nidhinvarghese | 14:f5c62d30c6fc | 337 | fpbg = fopen(buffer3, "r"); |
nidhinvarghese | 14:f5c62d30c6fc | 338 | |
nidhinvarghese | 17:22a87e12fb3a | 339 | for(int i=0; i<1; i++) |
nidhinvarghese | 14:f5c62d30c6fc | 340 | { |
nikitateggi | 60:945c4a1e9a13 | 341 | fread(bigbuf, sizeof(int),2 , fpbg); |
nikitateggi | 60:945c4a1e9a13 | 342 | fwrite(bigbuf, sizeof(int), 2, fpmain); |
nidhinvarghese | 14:f5c62d30c6fc | 343 | } |
nikitateggi | 60:945c4a1e9a13 | 344 | fclose(fpbg); // Both files are Closed |
nidhinvarghese | 14:f5c62d30c6fc | 345 | fclose(fpmain); |
nidhinvarghese | 14:f5c62d30c6fc | 346 | |
nidhinvarghese | 14:f5c62d30c6fc | 347 | sprintf(buffer3, "/sd/%d_GLC.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 348 | success = remove(buffer3); // GLC file is deleted |
nikitateggi | 61:2143f39103f7 | 349 | snd.printf("DELETE STATUS = %d\n", success); |
nidhinvarghese | 14:f5c62d30c6fc | 350 | } |
nidhinvarghese | 14:f5c62d30c6fc | 351 | |
nidhinvarghese | 14:f5c62d30c6fc | 352 | |
rashmivenkataramaiah | 43:85a7f399cb9d | 353 | void delete_subfiles(uint32_t pid) |
nidhinvarghese | 14:f5c62d30c6fc | 354 | { |
nidhinvarghese | 14:f5c62d30c6fc | 355 | char buffer3[32]; |
nidhinvarghese | 14:f5c62d30c6fc | 356 | int success1 , success2, success3; |
nikitateggi | 60:945c4a1e9a13 | 357 | |
nidhinvarghese | 14:f5c62d30c6fc | 358 | success1 = 1 ; |
nidhinvarghese | 14:f5c62d30c6fc | 359 | sprintf(buffer3, "/sd/%d_BP.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 360 | success1 = remove(buffer3); //Removes PPG file of BP and updates status with 0 if successful |
nidhinvarghese | 14:f5c62d30c6fc | 361 | if( success1 == 0 ) |
nikitateggi | 60:945c4a1e9a13 | 362 | snd.printf("\nBP file delete : Successful"); // Checks for SUCCESS |
nidhinvarghese | 14:f5c62d30c6fc | 363 | else |
nidhinvarghese | 14:f5c62d30c6fc | 364 | snd.printf("\nBP file delete : UnSuccessful"); |
nidhinvarghese | 14:f5c62d30c6fc | 365 | |
nidhinvarghese | 14:f5c62d30c6fc | 366 | success2 = 1 ; |
nidhinvarghese | 14:f5c62d30c6fc | 367 | sprintf(buffer3, "/sd/%d_GLC.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 368 | success2 = remove(buffer3); //Removes GLC file and updates status with 0 if successful |
nidhinvarghese | 14:f5c62d30c6fc | 369 | |
nidhinvarghese | 14:f5c62d30c6fc | 370 | if( success2 == 0 ) |
nikitateggi | 60:945c4a1e9a13 | 371 | snd.printf("\nGLC file delete : Successful"); // Checks for SUCCESS |
nidhinvarghese | 14:f5c62d30c6fc | 372 | else |
nidhinvarghese | 14:f5c62d30c6fc | 373 | snd.printf("\nGLC file delete : UnSuccessful"); |
nidhinvarghese | 14:f5c62d30c6fc | 374 | |
nidhinvarghese | 14:f5c62d30c6fc | 375 | success3 = 1 ; |
nidhinvarghese | 14:f5c62d30c6fc | 376 | sprintf(buffer3, "/sd/%d_ECG.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 377 | success3 = remove(buffer3); //Removes ECG file and updates status with 0 if successful |
nidhinvarghese | 14:f5c62d30c6fc | 378 | |
nidhinvarghese | 14:f5c62d30c6fc | 379 | if( success3 == 0 ) |
nikitateggi | 60:945c4a1e9a13 | 380 | snd.printf("\nECG file delete : Successful"); // Checks for SUCCESS |
nidhinvarghese | 14:f5c62d30c6fc | 381 | else |
nidhinvarghese | 14:f5c62d30c6fc | 382 | snd.printf("\nECG file delete : UnSuccessful"); |
nikitateggi | 49:3ff80c4bc1be | 383 | |
nikitateggi | 49:3ff80c4bc1be | 384 | success3 = 1; |
nikitateggi | 49:3ff80c4bc1be | 385 | sprintf(buffer3, "/sd/%d_ECG_lpf.csv", pid); |
nikitateggi | 49:3ff80c4bc1be | 386 | success3 = remove(buffer3); |
nikitateggi | 49:3ff80c4bc1be | 387 | snd.printf("DELETE STATUS = %d\n", success3); |
nikitateggi | 49:3ff80c4bc1be | 388 | |
nikitateggi | 49:3ff80c4bc1be | 389 | if( success3 == 0 ) |
nikitateggi | 60:945c4a1e9a13 | 390 | snd.printf("\nECG_lpf file delete : Successful"); // Checks for SUCCESS |
nikitateggi | 49:3ff80c4bc1be | 391 | else |
nikitateggi | 49:3ff80c4bc1be | 392 | snd.printf("\nECG_lpf file delete : UnSuccessful"); |
nidhinvarghese | 14:f5c62d30c6fc | 393 | |
nikitateggi | 22:ffa88619551d | 394 | } |
nikitateggi | 22:ffa88619551d | 395 | |
nikitateggi | 22:ffa88619551d | 396 | |
rashmivenkataramaiah | 43:85a7f399cb9d | 397 | void del_ppg_ecg_BPfile(uint32_t pid) |
avp2417 | 36:00d96aa14658 | 398 | { |
avp2417 | 36:00d96aa14658 | 399 | int status = 1 ; |
avp2417 | 36:00d96aa14658 | 400 | char buffer3[32]; |
avp2417 | 36:00d96aa14658 | 401 | sprintf(buffer3, "/sd/%d_BP_ECG.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 402 | status = remove(buffer3); //Removes ECG file of BP and updates status with 0 if successful |
avp2417 | 36:00d96aa14658 | 403 | |
avp2417 | 36:00d96aa14658 | 404 | if( status == 0 ) |
nikitateggi | 60:945c4a1e9a13 | 405 | snd.printf("\n temp ECG file delete for error condition: Successful"); // Checks for SUCCESS |
avp2417 | 36:00d96aa14658 | 406 | else |
avp2417 | 36:00d96aa14658 | 407 | snd.printf("\n temp ECG file delete for error condition: UnSuccessful"); |
avp2417 | 36:00d96aa14658 | 408 | |
avp2417 | 36:00d96aa14658 | 409 | status = 1 ; |
avp2417 | 36:00d96aa14658 | 410 | sprintf(buffer3, "/sd/%d_BP_PPG.csv", pid); |
nikitateggi | 60:945c4a1e9a13 | 411 | status = remove(buffer3); //Removes PPG file of BP and updates status with 0 if successful |
avp2417 | 36:00d96aa14658 | 412 | |
avp2417 | 36:00d96aa14658 | 413 | if( status == 0 ) |
nikitateggi | 60:945c4a1e9a13 | 414 | snd.printf("\n temp PPG file delete for error condition: Successful"); // Checks for SUCCESS |
avp2417 | 36:00d96aa14658 | 415 | else |
avp2417 | 36:00d96aa14658 | 416 | snd.printf("\n temp PPG file delete for error condition: UnSuccessful"); |
avp2417 | 36:00d96aa14658 | 417 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 418 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 419 | |
nikitateggi | 60:945c4a1e9a13 | 420 | void sd_read(uint32_t *pid_btpid) //reading the data from the openend file |
nikitateggi | 60:945c4a1e9a13 | 421 | { |
nikitateggi | 60:945c4a1e9a13 | 422 | uint32_t pid[2]={0,0}; |
nikitateggi | 61:2143f39103f7 | 423 | // int success; |
rashmivenkataramaiah | 42:c81673b04b6a | 424 | FILE *fp; |
nikitateggi | 60:945c4a1e9a13 | 425 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 426 | fp= fopen("/sd/pid_info.txt","r"); |
rashmivenkataramaiah | 41:1141a75eacc4 | 427 | if (fp==NULL) |
rashmivenkataramaiah | 41:1141a75eacc4 | 428 | { |
rashmivenkataramaiah | 42:c81673b04b6a | 429 | fp= fopen("/sd/pid_info.txt","w"); |
rashmivenkataramaiah | 42:c81673b04b6a | 430 | fwrite(&pid, sizeof(uint32_t),2,fp); |
rashmivenkataramaiah | 42:c81673b04b6a | 431 | fclose(fp); |
rashmivenkataramaiah | 41:1141a75eacc4 | 432 | fp= fopen("/sd/pid_info.txt","r"); |
rashmivenkataramaiah | 41:1141a75eacc4 | 433 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 434 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 435 | fread(pid_btpid,sizeof(pid_btpid),2,fp); |
rashmivenkataramaiah | 41:1141a75eacc4 | 436 | fclose(fp); |
rashmivenkataramaiah | 41:1141a75eacc4 | 437 | |
nikitateggi | 60:945c4a1e9a13 | 438 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 439 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 440 | |
nikitateggi | 61:2143f39103f7 | 441 | void sd_write_pid(uint32_t *pid_btpid) //reading the data from the openend file |
rashmivenkataramaiah | 41:1141a75eacc4 | 442 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 443 | FILE *fp; |
rashmivenkataramaiah | 41:1141a75eacc4 | 444 | fp= fopen("/sd/pid_info.txt","w"); |
rashmivenkataramaiah | 41:1141a75eacc4 | 445 | fwrite(pid_btpid,sizeof(pid_btpid),2,fp); |
rashmivenkataramaiah | 41:1141a75eacc4 | 446 | fclose(fp); |
rashmivenkataramaiah | 41:1141a75eacc4 | 447 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 448 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 449 | |
nikitateggi | 49:3ff80c4bc1be | 450 | void delete_sdcard(void) |
nikitateggi | 49:3ff80c4bc1be | 451 | { |
nikitateggi | 49:3ff80c4bc1be | 452 | FILE *fp; |
nikitateggi | 53:cc6e65480a67 | 453 | uint32_t pid[2] = {0,0}; |
nikitateggi | 49:3ff80c4bc1be | 454 | fp= fopen("/sd/pid_info.txt","w"); |
nikitateggi | 49:3ff80c4bc1be | 455 | fwrite(&pid, sizeof(uint32_t),2,fp); |
nikitateggi | 49:3ff80c4bc1be | 456 | fclose(fp); |
nikitateggi | 49:3ff80c4bc1be | 457 | |
nikitateggi | 49:3ff80c4bc1be | 458 | } |
nikitateggi | 49:3ff80c4bc1be | 459 | |
nikitateggi | 50:b42238e7f46d | 460 | void read_sdcard_file() |
nikitateggi | 49:3ff80c4bc1be | 461 | { |
nikitateggi | 60:945c4a1e9a13 | 462 | char buffer[32]; |
nikitateggi | 60:945c4a1e9a13 | 463 | uint32_t pid = 0; |
nikitateggi | 60:945c4a1e9a13 | 464 | FILE *fp_read_sdcard_file ; // PPG and ECG File pointers for BP |
nikitateggi | 60:945c4a1e9a13 | 465 | snd.scanf("%d", &pid); |
nikitateggi | 60:945c4a1e9a13 | 466 | snd.printf("%d\n",pid); |
nikitateggi | 60:945c4a1e9a13 | 467 | |
nikitateggi | 60:945c4a1e9a13 | 468 | sprintf(buffer,"/sd/%d.csv",pid); |
nikitateggi | 60:945c4a1e9a13 | 469 | fp_read_sdcard_file = fopen(buffer, "rb"); |
nikitateggi | 60:945c4a1e9a13 | 470 | |
nikitateggi | 60:945c4a1e9a13 | 471 | if(fp_read_sdcard_file == NULL) |
nikitateggi | 60:945c4a1e9a13 | 472 | { |
nikitateggi | 60:945c4a1e9a13 | 473 | snd.printf("No FILE Found .... !!\n"); |
nikitateggi | 60:945c4a1e9a13 | 474 | } |
nikitateggi | 60:945c4a1e9a13 | 475 | |
nikitateggi | 60:945c4a1e9a13 | 476 | else |
nikitateggi | 60:945c4a1e9a13 | 477 | { |
nikitateggi | 49:3ff80c4bc1be | 478 | read_structure(fp_read_sdcard_file); |
nikitateggi | 49:3ff80c4bc1be | 479 | snd.printf("Finished Reading File Content....!!\n"); |
nikitateggi | 49:3ff80c4bc1be | 480 | fclose(fp_read_sdcard_file); |
nikitateggi | 60:945c4a1e9a13 | 481 | } //end of else loop |
nikitateggi | 49:3ff80c4bc1be | 482 | |
nikitateggi | 49:3ff80c4bc1be | 483 | } |
nikitateggi | 49:3ff80c4bc1be | 484 | |
nikitateggi | 49:3ff80c4bc1be | 485 | void read_structure(FILE * fp_read_sdcard_file) |
nikitateggi | 49:3ff80c4bc1be | 486 | |
nikitateggi | 49:3ff80c4bc1be | 487 | { |
nikitateggi | 50:b42238e7f46d | 488 | BLEMsg_info pid_file; |
nikitateggi | 60:945c4a1e9a13 | 489 | uint32_t buf[1] = {0}; // buffer to read the raw data |
nikitateggi | 50:b42238e7f46d | 490 | uint16_t sample = 0; // variable to hold the no of samples |
nikitateggi | 50:b42238e7f46d | 491 | |
nikitateggi | 50:b42238e7f46d | 492 | fread(&pid_file,sizeof(BLEMsg_info),1,fp_read_sdcard_file); // reading the structure data |
nikitateggi | 49:3ff80c4bc1be | 493 | while (!feof(fp_read_sdcard_file)) |
nikitateggi | 50:b42238e7f46d | 494 | { |
nikitateggi | 50:b42238e7f46d | 495 | snd.printf("length = %d\n",pid_file.length); |
nikitateggi | 50:b42238e7f46d | 496 | snd.printf("device_id = %d\n",pid_file.device_id); |
nikitateggi | 50:b42238e7f46d | 497 | snd.printf("patient_id = %d\n",pid_file.patient_id); |
nikitateggi | 50:b42238e7f46d | 498 | snd.printf("date = %d\n",pid_file.date_time.date); |
nikitateggi | 50:b42238e7f46d | 499 | snd.printf("month = %d\n",pid_file.date_time.month); |
nikitateggi | 50:b42238e7f46d | 500 | snd.printf("year = %d\n",pid_file.date_time.year); |
nikitateggi | 50:b42238e7f46d | 501 | snd.printf("hour = %d\n",pid_file.date_time.hour); |
nikitateggi | 50:b42238e7f46d | 502 | snd.printf("mins = %d\n",pid_file.date_time.mins); |
nikitateggi | 50:b42238e7f46d | 503 | snd.printf("sec = %d\n",pid_file.date_time.sec); |
nikitateggi | 50:b42238e7f46d | 504 | snd.printf("test_type = %d\n",pid_file.test_type); |
nikitateggi | 50:b42238e7f46d | 505 | snd.printf("sampling_freq = %d\n",pid_file.sampling_freq); |
nikitateggi | 50:b42238e7f46d | 506 | snd.printf("sample1 = %d\n",pid_file.num_samples.num_sample_ppg_dummy); |
nikitateggi | 50:b42238e7f46d | 507 | snd.printf("samples2 = %d\n",pid_file.num_samples.num_sample_ecg_OTtyp); |
nikitateggi | 50:b42238e7f46d | 508 | sample=(pid_file.num_samples.num_sample_ppg_dummy + pid_file.num_samples.num_sample_ecg_OTtyp); |
nikitateggi | 50:b42238e7f46d | 509 | snd.printf("caldata1 = %d\n",pid_file.cal_data.cal_sbp_dummy); |
nikitateggi | 50:b42238e7f46d | 510 | snd.printf("caldata2 = %d\n",pid_file.cal_data.cal_dbp_OTtyp); |
nikitateggi | 50:b42238e7f46d | 511 | snd.printf("sample=%d\n", sample); |
nikitateggi | 60:945c4a1e9a13 | 512 | for(uint16_t file_start=0;file_start<sample;file_start++) //reading the raw data |
nikitateggi | 60:945c4a1e9a13 | 513 | { |
nikitateggi | 60:945c4a1e9a13 | 514 | fread(buf,sizeof(uint32_t),1,fp_read_sdcard_file); |
nikitateggi | 61:2143f39103f7 | 515 | snd.printf("%d\n", buf[0]); //changed to %d nikita |
nikitateggi | 60:945c4a1e9a13 | 516 | } |
nikitateggi | 50:b42238e7f46d | 517 | fread(&pid_file,sizeof(BLEMsg_info),1,fp_read_sdcard_file); |
nikitateggi | 50:b42238e7f46d | 518 | |
nikitateggi | 60:945c4a1e9a13 | 519 | } |
nikitateggi | 49:3ff80c4bc1be | 520 | |
nikitateggi | 49:3ff80c4bc1be | 521 | } |
nikitateggi | 49:3ff80c4bc1be | 522 | |
nikitateggi | 57:200c42fba01f | 523 | |
nikitateggi | 57:200c42fba01f | 524 | uint8_t dummy_file_create_delete() // create dummy file , write , read and delete |
nikitateggi | 57:200c42fba01f | 525 | { |
nikitateggi | 57:200c42fba01f | 526 | uint8_t dummy_write[5] = {0}; |
nikitateggi | 57:200c42fba01f | 527 | uint8_t dummy_read[5] = {0}; |
nikitateggi | 57:200c42fba01f | 528 | uint8_t i = 0; |
nikitateggi | 57:200c42fba01f | 529 | for(i=0; i<5; i++) |
nikitateggi | 57:200c42fba01f | 530 | { |
nikitateggi | 57:200c42fba01f | 531 | dummy_write[i] = i+i; |
nikitateggi | 57:200c42fba01f | 532 | } |
nikitateggi | 57:200c42fba01f | 533 | fp = fopen("/sd/dummy_file.txt","w"); |
nikitateggi | 57:200c42fba01f | 534 | fwrite(&dummy_write, sizeof(uint8_t),5,fp); |
nikitateggi | 57:200c42fba01f | 535 | fclose(fp); |
nikitateggi | 57:200c42fba01f | 536 | fp = fopen("/sd/dummy_file.txt","r"); |
nikitateggi | 57:200c42fba01f | 537 | rewind(fp); |
nikitateggi | 57:200c42fba01f | 538 | fread(&dummy_read,sizeof(uint8_t),5,fp); |
nikitateggi | 57:200c42fba01f | 539 | for(i=0; i<5; i++) |
nikitateggi | 57:200c42fba01f | 540 | { |
nikitateggi | 57:200c42fba01f | 541 | |
nikitateggi | 57:200c42fba01f | 542 | if (dummy_read[i] != dummy_write[i]) |
nikitateggi | 57:200c42fba01f | 543 | { |
nikitateggi | 57:200c42fba01f | 544 | fclose(fp); |
nikitateggi | 57:200c42fba01f | 545 | remove("/sd/dummy_file.txt"); |
nikitateggi | 57:200c42fba01f | 546 | return 1; |
nikitateggi | 57:200c42fba01f | 547 | } |
nikitateggi | 57:200c42fba01f | 548 | |
nikitateggi | 57:200c42fba01f | 549 | } |
nikitateggi | 57:200c42fba01f | 550 | |
nikitateggi | 57:200c42fba01f | 551 | |
nikitateggi | 57:200c42fba01f | 552 | |
nikitateggi | 57:200c42fba01f | 553 | fclose(fp); |
nikitateggi | 57:200c42fba01f | 554 | remove("/sd/dummy_file.txt"); |
nikitateggi | 57:200c42fba01f | 555 | return 0; |
nikitateggi | 57:200c42fba01f | 556 | } |
nikitateggi | 57:200c42fba01f | 557 | |
nikitateggi | 49:3ff80c4bc1be | 558 | |
rashmivenkataramaiah | 42:c81673b04b6a | 559 |