File manager
FileManager.cpp@13:d83e2dcc882d, 2016-05-18 (annotated)
- Committer:
- nsrwsurasak
- Date:
- Wed May 18 12:55:07 2016 +0000
- Revision:
- 13:d83e2dcc882d
- Parent:
- 12:0045fca3c160
- Child:
- 14:4ba6147f067b
include main.h and fix bug
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lucyjungz | 1:1f1f2b99756b | 1 | #include "mbed.h" |
nsrwsurasak | 0:a27e0d3581d1 | 2 | #include "FileManager.h" |
nsrwsurasak | 0:a27e0d3581d1 | 3 | #include "SDFileSystem.h" |
nsrwsurasak | 13:d83e2dcc882d | 4 | #include "main.h" |
nsrwsurasak | 0:a27e0d3581d1 | 5 | |
Lucyjungz | 3:6e08d0bba1bb | 6 | char m_GpsInterval[XMLTEXT_SIZE]; // GPS Interval |
Lucyjungz | 3:6e08d0bba1bb | 7 | char m_DataInterval[XMLTEXT_SIZE]; // Data Interval |
Lucyjungz | 3:6e08d0bba1bb | 8 | Variable_Data_TypeDef m_varList[MAX_VAR]; // Variable List |
Lucyjungz | 3:6e08d0bba1bb | 9 | unsigned int m_amountVarList = 0; // Amount of variable list |
Lucyjungz | 3:6e08d0bba1bb | 10 | |
Lucyjungz | 11:e21d4c5bfd1b | 11 | #ifdef LED_SDCARD |
Lucyjungz | 11:e21d4c5bfd1b | 12 | DigitalOut ledStatus(LED_SDCARD); |
Lucyjungz | 11:e21d4c5bfd1b | 13 | #else |
Lucyjungz | 11:e21d4c5bfd1b | 14 | DigitalOut ledStatus(NC); |
Lucyjungz | 11:e21d4c5bfd1b | 15 | #endif |
Lucyjungz | 11:e21d4c5bfd1b | 16 | |
Lucyjungz | 3:6e08d0bba1bb | 17 | /* ############### Static function prototype ################## */ |
nsrwsurasak | 0:a27e0d3581d1 | 18 | |
Lucyjungz | 4:ec62bf823914 | 19 | static void FileManager_RemoveSpaces(char* s , int size); |
Lucyjungz | 4:ec62bf823914 | 20 | static void FileManager_GetXmlText(char *str, char *ret); |
Lucyjungz | 4:ec62bf823914 | 21 | static void FileManager_GenerateFileNameWithTime(time_t timestamp, char * file_name); |
Lucyjungz | 11:e21d4c5bfd1b | 22 | static void FileManager_SetLedStatus(bool on); |
Lucyjungz | 3:6e08d0bba1bb | 23 | |
Lucyjungz | 3:6e08d0bba1bb | 24 | /** |
Lucyjungz | 3:6e08d0bba1bb | 25 | * @brief Utility function to Remove space charector from given char array |
Lucyjungz | 3:6e08d0bba1bb | 26 | * @note |
Lucyjungz | 3:6e08d0bba1bb | 27 | * @param char array to process remove spaces |
Lucyjungz | 3:6e08d0bba1bb | 28 | * @param size of char array |
Lucyjungz | 3:6e08d0bba1bb | 29 | * @retval space removed char array |
Lucyjungz | 3:6e08d0bba1bb | 30 | */ |
Lucyjungz | 4:ec62bf823914 | 31 | static void FileManager_RemoveSpaces(char* s , int size) |
nsrwsurasak | 0:a27e0d3581d1 | 32 | { |
nsrwsurasak | 0:a27e0d3581d1 | 33 | char* cpy = s; // an alias to iterate through s without moving s |
nsrwsurasak | 0:a27e0d3581d1 | 34 | char* temp = s; |
nsrwsurasak | 0:a27e0d3581d1 | 35 | |
nsrwsurasak | 0:a27e0d3581d1 | 36 | for (int i = 0 ; i < size ; i++) { |
nsrwsurasak | 0:a27e0d3581d1 | 37 | if (*cpy != ' ') |
nsrwsurasak | 0:a27e0d3581d1 | 38 | *temp++ = *cpy; |
nsrwsurasak | 0:a27e0d3581d1 | 39 | cpy++; |
nsrwsurasak | 0:a27e0d3581d1 | 40 | } |
nsrwsurasak | 0:a27e0d3581d1 | 41 | *temp = 0; |
nsrwsurasak | 0:a27e0d3581d1 | 42 | return; |
nsrwsurasak | 0:a27e0d3581d1 | 43 | } |
Lucyjungz | 3:6e08d0bba1bb | 44 | /** |
Lucyjungz | 3:6e08d0bba1bb | 45 | * @brief Utility function to get XML tag |
Lucyjungz | 3:6e08d0bba1bb | 46 | * @note Only First tag will be returned |
Lucyjungz | 3:6e08d0bba1bb | 47 | * @param char array to get XML Text |
Lucyjungz | 3:6e08d0bba1bb | 48 | * @param char array to be populate XML text |
Lucyjungz | 3:6e08d0bba1bb | 49 | * @retval XML text |
Lucyjungz | 3:6e08d0bba1bb | 50 | */ |
Lucyjungz | 4:ec62bf823914 | 51 | static void FileManager_GetXmlText(char *str, char *ret) |
nsrwsurasak | 0:a27e0d3581d1 | 52 | { |
nsrwsurasak | 0:a27e0d3581d1 | 53 | int size = strlen(str); |
nsrwsurasak | 0:a27e0d3581d1 | 54 | int i; |
nsrwsurasak | 0:a27e0d3581d1 | 55 | bool begin_text = false; |
nsrwsurasak | 0:a27e0d3581d1 | 56 | char * ret_addr = ret; |
Lucyjungz | 3:6e08d0bba1bb | 57 | /* initialized our return value */ |
nsrwsurasak | 0:a27e0d3581d1 | 58 | memset (ret,' ',XMLTEXT_SIZE); |
nsrwsurasak | 0:a27e0d3581d1 | 59 | |
Lucyjungz | 3:6e08d0bba1bb | 60 | /* Loop to check XML tag symbols */ |
nsrwsurasak | 0:a27e0d3581d1 | 61 | for(i = 0; i < size ; i++) { |
nsrwsurasak | 0:a27e0d3581d1 | 62 | |
nsrwsurasak | 0:a27e0d3581d1 | 63 | if (*str == '>') { |
Lucyjungz | 3:6e08d0bba1bb | 64 | /* Found begining of the tag */ |
nsrwsurasak | 0:a27e0d3581d1 | 65 | begin_text = true; |
nsrwsurasak | 0:a27e0d3581d1 | 66 | } else if (begin_text && *str == '<') { |
Lucyjungz | 3:6e08d0bba1bb | 67 | /* Reach the end of text message */ |
nsrwsurasak | 0:a27e0d3581d1 | 68 | begin_text = false; |
nsrwsurasak | 0:a27e0d3581d1 | 69 | break; |
nsrwsurasak | 0:a27e0d3581d1 | 70 | } else if (begin_text && *str != ' ') { |
Lucyjungz | 3:6e08d0bba1bb | 71 | /* Populate the return value */ |
nsrwsurasak | 0:a27e0d3581d1 | 72 | *ret = *str; |
nsrwsurasak | 0:a27e0d3581d1 | 73 | ret++; |
nsrwsurasak | 0:a27e0d3581d1 | 74 | } |
Lucyjungz | 3:6e08d0bba1bb | 75 | /* Move to next char */ |
nsrwsurasak | 0:a27e0d3581d1 | 76 | str++; |
nsrwsurasak | 0:a27e0d3581d1 | 77 | } |
Lucyjungz | 3:6e08d0bba1bb | 78 | |
Lucyjungz | 3:6e08d0bba1bb | 79 | /* Remove space from return value */ |
Lucyjungz | 4:ec62bf823914 | 80 | FileManager_RemoveSpaces(ret_addr, XMLTEXT_SIZE); |
nsrwsurasak | 0:a27e0d3581d1 | 81 | } |
Lucyjungz | 3:6e08d0bba1bb | 82 | /** |
Lucyjungz | 3:6e08d0bba1bb | 83 | * @brief Utility function to get File Name with Date |
Lucyjungz | 3:6e08d0bba1bb | 84 | * @note Format file will be YYYY-MM-DD.filename |
Lucyjungz | 3:6e08d0bba1bb | 85 | * @param timestamp - time structure to get Date |
Lucyjungz | 3:6e08d0bba1bb | 86 | * @param file_name - char array to file name |
Lucyjungz | 3:6e08d0bba1bb | 87 | * @retval renamed file name |
Lucyjungz | 3:6e08d0bba1bb | 88 | */ |
Lucyjungz | 4:ec62bf823914 | 89 | static void FileManager_GenerateFileNameWithTime(time_t timestamp, char * file_name) |
Lucyjungz | 1:1f1f2b99756b | 90 | { |
Lucyjungz | 1:1f1f2b99756b | 91 | char str[5]; |
Lucyjungz | 1:1f1f2b99756b | 92 | struct tm * ptm; |
Lucyjungz | 1:1f1f2b99756b | 93 | |
Lucyjungz | 3:6e08d0bba1bb | 94 | /* Convert timestamp to readable format */ |
Lucyjungz | 3:6e08d0bba1bb | 95 | ptm = localtime ( ×tamp ); |
Lucyjungz | 3:6e08d0bba1bb | 96 | |
Lucyjungz | 3:6e08d0bba1bb | 97 | /* Replacing YYYY to the converted year */ |
Lucyjungz | 1:1f1f2b99756b | 98 | sprintf(str,"%04d", ptm->tm_year-100 + 2000); |
Lucyjungz | 1:1f1f2b99756b | 99 | memcpy(&file_name[4], str, 4); |
Lucyjungz | 1:1f1f2b99756b | 100 | |
Lucyjungz | 3:6e08d0bba1bb | 101 | /* Replacing MM to converted month */ |
Lucyjungz | 1:1f1f2b99756b | 102 | sprintf(str,"%02d", ptm->tm_mon+1); |
Lucyjungz | 1:1f1f2b99756b | 103 | memcpy(&file_name[9], str, 2); |
Lucyjungz | 1:1f1f2b99756b | 104 | |
Lucyjungz | 3:6e08d0bba1bb | 105 | /* Replacing DD to converted date */ |
Lucyjungz | 1:1f1f2b99756b | 106 | sprintf(str,"%02d", ptm->tm_mday); |
Lucyjungz | 1:1f1f2b99756b | 107 | memcpy(&file_name[12], str, 2); |
Lucyjungz | 1:1f1f2b99756b | 108 | } |
Lucyjungz | 3:6e08d0bba1bb | 109 | /** |
Lucyjungz | 3:6e08d0bba1bb | 110 | * @brief Function to perform read setup file |
Lucyjungz | 3:6e08d0bba1bb | 111 | * @note filename must be defined in FileManager.h, GPS/ Data interval will be stored in dedicated variable |
Lucyjungz | 3:6e08d0bba1bb | 112 | * @param None |
Lucyjungz | 3:6e08d0bba1bb | 113 | * @retval None |
Lucyjungz | 3:6e08d0bba1bb | 114 | */ |
Lucyjungz | 4:ec62bf823914 | 115 | void FileManager_ReadSetupFile() |
nsrwsurasak | 0:a27e0d3581d1 | 116 | { |
Lucyjungz | 3:6e08d0bba1bb | 117 | /* Open file in reading mode */ |
nsrwsurasak | 0:a27e0d3581d1 | 118 | FILE *fp = fopen(SETUP_FILE_NAME, "r"); |
nsrwsurasak | 0:a27e0d3581d1 | 119 | |
Lucyjungz | 3:6e08d0bba1bb | 120 | if (fp == NULL) { |
Lucyjungz | 3:6e08d0bba1bb | 121 | /* In case of error, print the message */ |
nsrwsurasak | 0:a27e0d3581d1 | 122 | printf("\nError! Unable to open file! %s \n", SETUP_FILE_NAME); |
Lucyjungz | 11:e21d4c5bfd1b | 123 | |
Lucyjungz | 11:e21d4c5bfd1b | 124 | /* Indicate LED Status (OFF)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 125 | FileManager_SetLedStatus(false); |
Lucyjungz | 3:6e08d0bba1bb | 126 | } else { |
nsrwsurasak | 0:a27e0d3581d1 | 127 | |
Lucyjungz | 3:6e08d0bba1bb | 128 | /* Initialized state */ |
nsrwsurasak | 0:a27e0d3581d1 | 129 | ReadingFileState state = STATE_FINDING; |
Lucyjungz | 3:6e08d0bba1bb | 130 | |
Lucyjungz | 3:6e08d0bba1bb | 131 | /* Allocate buffer for reading file */ |
nsrwsurasak | 0:a27e0d3581d1 | 132 | char buf[1024]; |
Lucyjungz | 3:6e08d0bba1bb | 133 | |
Lucyjungz | 11:e21d4c5bfd1b | 134 | /* Indicate LED Status (ON)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 135 | FileManager_SetLedStatus(true); |
Lucyjungz | 11:e21d4c5bfd1b | 136 | |
Lucyjungz | 3:6e08d0bba1bb | 137 | /* Read line from the file */ |
nsrwsurasak | 0:a27e0d3581d1 | 138 | while (fgets(buf, sizeof(buf), fp) != NULL) { |
Lucyjungz | 3:6e08d0bba1bb | 139 | |
Lucyjungz | 3:6e08d0bba1bb | 140 | /* Check the TAG */ |
Lucyjungz | 3:6e08d0bba1bb | 141 | if (strstr (buf,DATA_TAG)) |
Lucyjungz | 3:6e08d0bba1bb | 142 | { |
Lucyjungz | 3:6e08d0bba1bb | 143 | /* Found the DATA TAG */ |
nsrwsurasak | 0:a27e0d3581d1 | 144 | state = STATE_FOUND_DATA; |
Lucyjungz | 3:6e08d0bba1bb | 145 | } else if (strstr (buf,GPS_TAG)) |
Lucyjungz | 3:6e08d0bba1bb | 146 | { |
Lucyjungz | 3:6e08d0bba1bb | 147 | /* Found GPS TAG */ |
nsrwsurasak | 0:a27e0d3581d1 | 148 | state = STATE_FOUND_GPS; |
Lucyjungz | 3:6e08d0bba1bb | 149 | } else if (strstr (buf,UPDATE_INTERVAL_TAG)) |
Lucyjungz | 3:6e08d0bba1bb | 150 | { |
Lucyjungz | 3:6e08d0bba1bb | 151 | /* Found Interval TAG */ |
Lucyjungz | 3:6e08d0bba1bb | 152 | if (state == STATE_FOUND_GPS) |
Lucyjungz | 3:6e08d0bba1bb | 153 | { |
Lucyjungz | 3:6e08d0bba1bb | 154 | /* Get XML text for GPS Interval */ |
Lucyjungz | 4:ec62bf823914 | 155 | FileManager_GetXmlText(buf, m_GpsInterval); |
Lucyjungz | 8:5af4e12c43b2 | 156 | #if DEBUG |
nsrwsurasak | 0:a27e0d3581d1 | 157 | printf("\r\n-found GPS interval %s ", m_GpsInterval); |
Lucyjungz | 8:5af4e12c43b2 | 158 | #endif |
Lucyjungz | 8:5af4e12c43b2 | 159 | |
Lucyjungz | 8:5af4e12c43b2 | 160 | /* Set state to indicate that we are finding */ |
nsrwsurasak | 0:a27e0d3581d1 | 161 | state = STATE_FINDING; |
Lucyjungz | 3:6e08d0bba1bb | 162 | } |
Lucyjungz | 3:6e08d0bba1bb | 163 | else if(state == STATE_FOUND_DATA) |
Lucyjungz | 3:6e08d0bba1bb | 164 | { |
Lucyjungz | 3:6e08d0bba1bb | 165 | /* Get XML text for Data Interval */ |
Lucyjungz | 4:ec62bf823914 | 166 | FileManager_GetXmlText(buf, m_DataInterval); |
Lucyjungz | 8:5af4e12c43b2 | 167 | |
Lucyjungz | 8:5af4e12c43b2 | 168 | #if DEBUG |
nsrwsurasak | 0:a27e0d3581d1 | 169 | printf("\r\n-found Data interval %s ", m_DataInterval); |
Lucyjungz | 8:5af4e12c43b2 | 170 | #endif |
Lucyjungz | 8:5af4e12c43b2 | 171 | |
Lucyjungz | 8:5af4e12c43b2 | 172 | /* Set state to indicate that we are finding */ |
nsrwsurasak | 0:a27e0d3581d1 | 173 | state = STATE_FINDING; |
nsrwsurasak | 0:a27e0d3581d1 | 174 | } |
nsrwsurasak | 0:a27e0d3581d1 | 175 | } |
nsrwsurasak | 0:a27e0d3581d1 | 176 | } |
Lucyjungz | 3:6e08d0bba1bb | 177 | /* Ensure file is closed */ |
Lucyjungz | 3:6e08d0bba1bb | 178 | fclose(fp); |
nsrwsurasak | 0:a27e0d3581d1 | 179 | } |
nsrwsurasak | 0:a27e0d3581d1 | 180 | } |
Lucyjungz | 3:6e08d0bba1bb | 181 | /** |
Lucyjungz | 3:6e08d0bba1bb | 182 | * @brief Function to log GPS Data |
Lucyjungz | 3:6e08d0bba1bb | 183 | * @note |
Lucyjungz | 3:6e08d0bba1bb | 184 | * @param timestamp - time structure to get Date |
Lucyjungz | 3:6e08d0bba1bb | 185 | * @param lat - char array for lattitude |
Lucyjungz | 3:6e08d0bba1bb | 186 | * @param longti - char array for longtitude |
Lucyjungz | 3:6e08d0bba1bb | 187 | * @retval None |
Lucyjungz | 3:6e08d0bba1bb | 188 | */ |
Lucyjungz | 4:ec62bf823914 | 189 | void FileManager_LogGPSData(time_t timestamp ,char lat[], char longti[]) |
nsrwsurasak | 0:a27e0d3581d1 | 190 | { |
Lucyjungz | 3:6e08d0bba1bb | 191 | /* Get File name */ |
Lucyjungz | 1:1f1f2b99756b | 192 | char file_name[] = GPS_LOG_FILE_NAME; |
Lucyjungz | 1:1f1f2b99756b | 193 | |
Lucyjungz | 3:6e08d0bba1bb | 194 | /* Generate file name with time stamp */ |
Lucyjungz | 4:ec62bf823914 | 195 | FileManager_GenerateFileNameWithTime(timestamp,file_name); |
Lucyjungz | 3:6e08d0bba1bb | 196 | |
Lucyjungz | 3:6e08d0bba1bb | 197 | /* Open file with "APPEND" mode */ |
Lucyjungz | 1:1f1f2b99756b | 198 | FILE *fp = fopen(file_name, "a"); |
Lucyjungz | 1:1f1f2b99756b | 199 | |
Lucyjungz | 3:6e08d0bba1bb | 200 | if (fp == NULL) |
Lucyjungz | 3:6e08d0bba1bb | 201 | { |
Lucyjungz | 3:6e08d0bba1bb | 202 | /* if it can't open the file then print error message */ |
Lucyjungz | 1:1f1f2b99756b | 203 | printf("Error! Unable to open file %s!\n",file_name); |
Lucyjungz | 11:e21d4c5bfd1b | 204 | |
Lucyjungz | 11:e21d4c5bfd1b | 205 | /* Indicate LED Status (OFF)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 206 | FileManager_SetLedStatus(false); |
Lucyjungz | 3:6e08d0bba1bb | 207 | } |
Lucyjungz | 11:e21d4c5bfd1b | 208 | else |
Lucyjungz | 11:e21d4c5bfd1b | 209 | { |
Lucyjungz | 11:e21d4c5bfd1b | 210 | /* Indicate LED Status (ON)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 211 | FileManager_SetLedStatus(true); |
Lucyjungz | 11:e21d4c5bfd1b | 212 | |
Lucyjungz | 3:6e08d0bba1bb | 213 | /* Print some message for information */ |
Lucyjungz | 1:1f1f2b99756b | 214 | printf("\r\n Writing to Gps Log File (%s)....",file_name); |
Lucyjungz | 1:1f1f2b99756b | 215 | |
Lucyjungz | 3:6e08d0bba1bb | 216 | /* Write the line with lattitude and longtitude */ |
Lucyjungz | 3:6e08d0bba1bb | 217 | fprintf(fp, "%d,%s,%s\n",timestamp,lat,longti); |
Lucyjungz | 1:1f1f2b99756b | 218 | |
Lucyjungz | 1:1f1f2b99756b | 219 | printf("Done"); |
Lucyjungz | 3:6e08d0bba1bb | 220 | /* Close file once it done */ |
Lucyjungz | 3:6e08d0bba1bb | 221 | fclose(fp); |
Lucyjungz | 1:1f1f2b99756b | 222 | } |
Lucyjungz | 1:1f1f2b99756b | 223 | } |
Lucyjungz | 3:6e08d0bba1bb | 224 | /** |
Lucyjungz | 3:6e08d0bba1bb | 225 | * @brief Function to log RMS Data |
Lucyjungz | 3:6e08d0bba1bb | 226 | * @note sequence must be in the same order with variableList |
Lucyjungz | 3:6e08d0bba1bb | 227 | * @param timestamp - time structure to get Date |
Lucyjungz | 3:6e08d0bba1bb | 228 | * @param var - float array to be log in the file |
Lucyjungz | 3:6e08d0bba1bb | 229 | * @param size - size of the float array |
Lucyjungz | 3:6e08d0bba1bb | 230 | * @retval None |
Lucyjungz | 3:6e08d0bba1bb | 231 | */ |
Lucyjungz | 4:ec62bf823914 | 232 | void FileManager_LogRMSData(time_t timestamp ,float * var, int size) |
Lucyjungz | 1:1f1f2b99756b | 233 | { |
Lucyjungz | 3:6e08d0bba1bb | 234 | /* Get File name */ |
Lucyjungz | 1:1f1f2b99756b | 235 | char file_name[] = RTL_LOG_FILE_NAME; |
Lucyjungz | 1:1f1f2b99756b | 236 | |
Lucyjungz | 3:6e08d0bba1bb | 237 | /* Generate File name with timestamp */ |
Lucyjungz | 4:ec62bf823914 | 238 | FileManager_GenerateFileNameWithTime(timestamp,file_name); |
Lucyjungz | 4:ec62bf823914 | 239 | if (!FileManager_IsFileExist(file_name)) |
Lucyjungz | 1:1f1f2b99756b | 240 | { |
Lucyjungz | 3:6e08d0bba1bb | 241 | /* If file is not exist, log the header */ |
Lucyjungz | 4:ec62bf823914 | 242 | FileManager_LogRMSHeader(timestamp); |
Lucyjungz | 1:1f1f2b99756b | 243 | } |
Lucyjungz | 3:6e08d0bba1bb | 244 | /* Open file with "APPEND" mode */ |
Lucyjungz | 1:1f1f2b99756b | 245 | FILE *fp = fopen(file_name, "a"); |
nsrwsurasak | 0:a27e0d3581d1 | 246 | |
Lucyjungz | 3:6e08d0bba1bb | 247 | if (fp == NULL) |
Lucyjungz | 3:6e08d0bba1bb | 248 | { |
Lucyjungz | 3:6e08d0bba1bb | 249 | /* In case of error, print the error message */ |
Lucyjungz | 1:1f1f2b99756b | 250 | printf("Error! Unable to open file %s!\n",file_name); |
Lucyjungz | 11:e21d4c5bfd1b | 251 | |
Lucyjungz | 11:e21d4c5bfd1b | 252 | /* Indicate LED Status (OFF)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 253 | FileManager_SetLedStatus(false); |
Lucyjungz | 3:6e08d0bba1bb | 254 | } |
Lucyjungz | 3:6e08d0bba1bb | 255 | else |
Lucyjungz | 3:6e08d0bba1bb | 256 | { |
Lucyjungz | 11:e21d4c5bfd1b | 257 | /* Indicate LED Status (ON)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 258 | FileManager_SetLedStatus(true); |
Lucyjungz | 11:e21d4c5bfd1b | 259 | |
Lucyjungz | 3:6e08d0bba1bb | 260 | /* Print some message for information */ |
Lucyjungz | 1:1f1f2b99756b | 261 | printf("\r\n Writing to Log File (%s)....",file_name); |
Lucyjungz | 1:1f1f2b99756b | 262 | |
Lucyjungz | 3:6e08d0bba1bb | 263 | /* Write timestamp */ |
Lucyjungz | 3:6e08d0bba1bb | 264 | fprintf(fp, "%d",timestamp); |
Lucyjungz | 7:ab015947e368 | 265 | |
Lucyjungz | 7:ab015947e368 | 266 | /* Write MSecond */ |
Lucyjungz | 7:ab015947e368 | 267 | fprintf(fp, "%d",0); |
Lucyjungz | 1:1f1f2b99756b | 268 | |
Lucyjungz | 3:6e08d0bba1bb | 269 | /* Write variable data */ |
Lucyjungz | 1:1f1f2b99756b | 270 | for(int i = 0; i < size; i++) |
Lucyjungz | 1:1f1f2b99756b | 271 | { |
Lucyjungz | 3:6e08d0bba1bb | 272 | fprintf(fp, ",%f",var[i]); |
Lucyjungz | 1:1f1f2b99756b | 273 | } |
Lucyjungz | 3:6e08d0bba1bb | 274 | /* Write new line as we done */ |
Lucyjungz | 3:6e08d0bba1bb | 275 | fprintf(fp, "\n"); |
nsrwsurasak | 0:a27e0d3581d1 | 276 | |
Lucyjungz | 1:1f1f2b99756b | 277 | printf("Done"); |
Lucyjungz | 3:6e08d0bba1bb | 278 | /* Close the file */ |
Lucyjungz | 3:6e08d0bba1bb | 279 | fclose(fp); |
Lucyjungz | 3:6e08d0bba1bb | 280 | } |
Lucyjungz | 3:6e08d0bba1bb | 281 | } |
Lucyjungz | 3:6e08d0bba1bb | 282 | /** |
Lucyjungz | 3:6e08d0bba1bb | 283 | * @brief Function to log RMS Header |
Lucyjungz | 3:6e08d0bba1bb | 284 | * @note sequence must be in the same order with variableList |
Lucyjungz | 3:6e08d0bba1bb | 285 | * @param timestamp - time structure to get Date |
Lucyjungz | 3:6e08d0bba1bb | 286 | * @retval None |
Lucyjungz | 3:6e08d0bba1bb | 287 | */ |
Lucyjungz | 4:ec62bf823914 | 288 | void FileManager_LogRMSHeader(time_t timestamp) |
Lucyjungz | 3:6e08d0bba1bb | 289 | { |
Lucyjungz | 3:6e08d0bba1bb | 290 | /* Get File name */ |
Lucyjungz | 3:6e08d0bba1bb | 291 | char file_name[] = RTL_LOG_FILE_NAME; |
Lucyjungz | 3:6e08d0bba1bb | 292 | |
Lucyjungz | 3:6e08d0bba1bb | 293 | /* Generate file name with time */ |
Lucyjungz | 4:ec62bf823914 | 294 | FileManager_GenerateFileNameWithTime(timestamp,file_name); |
Lucyjungz | 3:6e08d0bba1bb | 295 | |
Lucyjungz | 3:6e08d0bba1bb | 296 | /* Open file in append mode */ |
Lucyjungz | 3:6e08d0bba1bb | 297 | FILE *fp = fopen(file_name, "a"); |
Lucyjungz | 3:6e08d0bba1bb | 298 | |
Lucyjungz | 3:6e08d0bba1bb | 299 | if (fp == NULL) |
Lucyjungz | 3:6e08d0bba1bb | 300 | { |
Lucyjungz | 3:6e08d0bba1bb | 301 | /* In case of error, print the error message */ |
Lucyjungz | 3:6e08d0bba1bb | 302 | printf("Error! Unable to open file %s!\n",file_name); |
Lucyjungz | 11:e21d4c5bfd1b | 303 | |
Lucyjungz | 11:e21d4c5bfd1b | 304 | /* Indicate LED Status (OFF)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 305 | FileManager_SetLedStatus(false); |
Lucyjungz | 3:6e08d0bba1bb | 306 | } |
Lucyjungz | 3:6e08d0bba1bb | 307 | else |
Lucyjungz | 3:6e08d0bba1bb | 308 | { |
Lucyjungz | 11:e21d4c5bfd1b | 309 | /* Indicate LED Status (ON)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 310 | FileManager_SetLedStatus(true); |
Lucyjungz | 11:e21d4c5bfd1b | 311 | |
Lucyjungz | 3:6e08d0bba1bb | 312 | /* opened file so can write */ |
Lucyjungz | 3:6e08d0bba1bb | 313 | printf("\r\n Writing to Log File (%s)....",file_name); |
Lucyjungz | 3:6e08d0bba1bb | 314 | |
Lucyjungz | 3:6e08d0bba1bb | 315 | /* Write the header to the file */ |
Lucyjungz | 7:ab015947e368 | 316 | fprintf(fp, "%s",RMS_HEADER_TIME); |
Lucyjungz | 7:ab015947e368 | 317 | |
Lucyjungz | 11:e21d4c5bfd1b | 318 | fprintf(fp, "%s",RMS_HEADER_MSECOND); |
Lucyjungz | 3:6e08d0bba1bb | 319 | for(int i = 0; i < m_amountVarList; i++) |
Lucyjungz | 3:6e08d0bba1bb | 320 | { |
Lucyjungz | 3:6e08d0bba1bb | 321 | fprintf(fp, ",%s",m_varList[i].varName); |
Lucyjungz | 3:6e08d0bba1bb | 322 | } |
Lucyjungz | 3:6e08d0bba1bb | 323 | /* Write new line as done */ |
Lucyjungz | 3:6e08d0bba1bb | 324 | fprintf(fp, "\n"); |
Lucyjungz | 3:6e08d0bba1bb | 325 | |
Lucyjungz | 3:6e08d0bba1bb | 326 | printf("Done"); |
Lucyjungz | 3:6e08d0bba1bb | 327 | |
Lucyjungz | 3:6e08d0bba1bb | 328 | /* Close the file */ |
Lucyjungz | 3:6e08d0bba1bb | 329 | fclose(fp); |
Lucyjungz | 3:6e08d0bba1bb | 330 | } |
Lucyjungz | 3:6e08d0bba1bb | 331 | } |
Lucyjungz | 3:6e08d0bba1bb | 332 | /** |
Lucyjungz | 3:6e08d0bba1bb | 333 | * @brief Function to log Mini RMS System Data |
Lucyjungz | 3:6e08d0bba1bb | 334 | * @note this file is only for debug |
Lucyjungz | 3:6e08d0bba1bb | 335 | * @param gps_interval - |
Lucyjungz | 3:6e08d0bba1bb | 336 | * @retval None |
Lucyjungz | 3:6e08d0bba1bb | 337 | */ |
Lucyjungz | 4:ec62bf823914 | 338 | void FileManager_LogSystemData(float gps_interval) |
Lucyjungz | 3:6e08d0bba1bb | 339 | { |
Lucyjungz | 3:6e08d0bba1bb | 340 | /* Open the file in append mode */ |
Lucyjungz | 3:6e08d0bba1bb | 341 | FILE *fp = fopen(MINIRMS_LOG_FILE_NAME, "a"); |
Lucyjungz | 3:6e08d0bba1bb | 342 | |
Lucyjungz | 3:6e08d0bba1bb | 343 | if (fp == NULL) { |
Lucyjungz | 3:6e08d0bba1bb | 344 | /* In case of error, print the msg */ |
Lucyjungz | 3:6e08d0bba1bb | 345 | printf("Error! Unable to open file!\n"); |
Lucyjungz | 11:e21d4c5bfd1b | 346 | |
Lucyjungz | 11:e21d4c5bfd1b | 347 | /* Indicate LED Status (OFF)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 348 | FileManager_SetLedStatus(false); |
Lucyjungz | 3:6e08d0bba1bb | 349 | } |
Lucyjungz | 3:6e08d0bba1bb | 350 | else |
Lucyjungz | 3:6e08d0bba1bb | 351 | { |
Lucyjungz | 11:e21d4c5bfd1b | 352 | /* Indicate LED Status (ON)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 353 | FileManager_SetLedStatus(true); |
Lucyjungz | 11:e21d4c5bfd1b | 354 | |
Lucyjungz | 3:6e08d0bba1bb | 355 | /* Write some message, which is TBD */ |
Lucyjungz | 3:6e08d0bba1bb | 356 | fprintf(fp, "\nStart Mini-RMS System with Gps Interval = %f",gps_interval); |
Lucyjungz | 1:1f1f2b99756b | 357 | fclose(fp); // ensure you close the file after writing |
Lucyjungz | 1:1f1f2b99756b | 358 | } |
Lucyjungz | 1:1f1f2b99756b | 359 | } |
Lucyjungz | 3:6e08d0bba1bb | 360 | /** |
Lucyjungz | 3:6e08d0bba1bb | 361 | * @brief Utility to delete file |
Lucyjungz | 3:6e08d0bba1bb | 362 | * @note |
Lucyjungz | 3:6e08d0bba1bb | 363 | * @param filename - file name to be deleted |
Lucyjungz | 3:6e08d0bba1bb | 364 | * @retval None |
Lucyjungz | 3:6e08d0bba1bb | 365 | */ |
Lucyjungz | 4:ec62bf823914 | 366 | void FileManager_Deletefile(char filename[]) |
nsrwsurasak | 0:a27e0d3581d1 | 367 | { |
nsrwsurasak | 0:a27e0d3581d1 | 368 | printf("Deleting file '%s'...",filename); |
nsrwsurasak | 0:a27e0d3581d1 | 369 | FILE *fp = fopen(filename, "r"); // try and open file |
nsrwsurasak | 0:a27e0d3581d1 | 370 | if (fp != NULL) { // if it does open... |
nsrwsurasak | 0:a27e0d3581d1 | 371 | fclose(fp); // close it |
nsrwsurasak | 0:a27e0d3581d1 | 372 | remove(filename); // and then delete |
nsrwsurasak | 0:a27e0d3581d1 | 373 | printf("Done!\n"); |
nsrwsurasak | 0:a27e0d3581d1 | 374 | } |
nsrwsurasak | 0:a27e0d3581d1 | 375 | // if we can't open it, it doesn't exist and so we can't delete it |
nsrwsurasak | 0:a27e0d3581d1 | 376 | } |
Lucyjungz | 3:6e08d0bba1bb | 377 | /** |
Lucyjungz | 3:6e08d0bba1bb | 378 | * @brief Utility to check file available |
Lucyjungz | 3:6e08d0bba1bb | 379 | * @note |
Lucyjungz | 3:6e08d0bba1bb | 380 | * @param filename - file name to be checked |
Lucyjungz | 3:6e08d0bba1bb | 381 | * @retval true - file is exist , false - file is not exist |
Lucyjungz | 3:6e08d0bba1bb | 382 | */ |
Lucyjungz | 4:ec62bf823914 | 383 | bool FileManager_IsFileExist(char filename[]) |
Lucyjungz | 1:1f1f2b99756b | 384 | { |
Lucyjungz | 1:1f1f2b99756b | 385 | bool exist = false; |
Lucyjungz | 1:1f1f2b99756b | 386 | FILE *fp = fopen(filename, "r"); // try and open file |
Lucyjungz | 1:1f1f2b99756b | 387 | if (fp != NULL) { // if it does open... |
Lucyjungz | 1:1f1f2b99756b | 388 | fclose(fp); // close it |
Lucyjungz | 1:1f1f2b99756b | 389 | exist = true; |
Lucyjungz | 1:1f1f2b99756b | 390 | } |
Lucyjungz | 1:1f1f2b99756b | 391 | |
Lucyjungz | 1:1f1f2b99756b | 392 | return exist; |
Lucyjungz | 1:1f1f2b99756b | 393 | } |
Lucyjungz | 3:6e08d0bba1bb | 394 | /** |
Lucyjungz | 3:6e08d0bba1bb | 395 | * @brief Utility to get GPS Interval |
Lucyjungz | 3:6e08d0bba1bb | 396 | * @note must be after read the setup file |
Lucyjungz | 3:6e08d0bba1bb | 397 | * @param None |
Lucyjungz | 3:6e08d0bba1bb | 398 | * @retval GPS interval |
Lucyjungz | 3:6e08d0bba1bb | 399 | */ |
Lucyjungz | 4:ec62bf823914 | 400 | int FileManager_GPSInterval() |
nsrwsurasak | 0:a27e0d3581d1 | 401 | { |
Lucyjungz | 3:6e08d0bba1bb | 402 | /* Return interval in int */ |
nsrwsurasak | 0:a27e0d3581d1 | 403 | return atoi( m_GpsInterval ); |
nsrwsurasak | 0:a27e0d3581d1 | 404 | } |
Lucyjungz | 3:6e08d0bba1bb | 405 | /** |
Lucyjungz | 3:6e08d0bba1bb | 406 | * @brief Utility to get Data Interval |
Lucyjungz | 3:6e08d0bba1bb | 407 | * @note must be after read the setup file |
Lucyjungz | 3:6e08d0bba1bb | 408 | * @param None |
Lucyjungz | 3:6e08d0bba1bb | 409 | * @retval Data interval |
Lucyjungz | 3:6e08d0bba1bb | 410 | */ |
Lucyjungz | 4:ec62bf823914 | 411 | int FileManager_DataInterval() |
nsrwsurasak | 0:a27e0d3581d1 | 412 | { |
Lucyjungz | 3:6e08d0bba1bb | 413 | /* Return interval in int */ |
nsrwsurasak | 0:a27e0d3581d1 | 414 | return atoi( m_DataInterval ); |
nsrwsurasak | 0:a27e0d3581d1 | 415 | } |
Lucyjungz | 3:6e08d0bba1bb | 416 | /** |
Lucyjungz | 3:6e08d0bba1bb | 417 | * @brief Function to read the variable list file |
Lucyjungz | 3:6e08d0bba1bb | 418 | * @note Recommended to call this function at initilization phase |
Lucyjungz | 3:6e08d0bba1bb | 419 | * @param None |
Lucyjungz | 3:6e08d0bba1bb | 420 | * @retval pointer to variable list |
Lucyjungz | 3:6e08d0bba1bb | 421 | */ |
Lucyjungz | 4:ec62bf823914 | 422 | Variable_Data_TypeDef * FileManager_ReadVarFile() |
nsrwsurasak | 0:a27e0d3581d1 | 423 | { |
Lucyjungz | 3:6e08d0bba1bb | 424 | /* Open the file with reading mode */ |
nsrwsurasak | 0:a27e0d3581d1 | 425 | FILE *fp = fopen(VARIABLE_FILE_NAME, "r"); |
nsrwsurasak | 0:a27e0d3581d1 | 426 | |
Lucyjungz | 3:6e08d0bba1bb | 427 | if (fp == NULL) |
Lucyjungz | 3:6e08d0bba1bb | 428 | { |
Lucyjungz | 3:6e08d0bba1bb | 429 | /* if it can't open the file then print error message */ |
nsrwsurasak | 0:a27e0d3581d1 | 430 | printf("\nError! Unable to open file! %s \n", VARIABLE_FILE_NAME); |
Lucyjungz | 11:e21d4c5bfd1b | 431 | /* Indicate LED Status (OFF)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 432 | FileManager_SetLedStatus(false); |
Lucyjungz | 11:e21d4c5bfd1b | 433 | |
nsrwsurasak | 0:a27e0d3581d1 | 434 | return NULL; |
Lucyjungz | 3:6e08d0bba1bb | 435 | } |
Lucyjungz | 3:6e08d0bba1bb | 436 | else |
Lucyjungz | 3:6e08d0bba1bb | 437 | { |
Lucyjungz | 11:e21d4c5bfd1b | 438 | /* Indicate LED Status (ON)*/ |
Lucyjungz | 11:e21d4c5bfd1b | 439 | FileManager_SetLedStatus(true); |
nsrwsurasak | 0:a27e0d3581d1 | 440 | |
Lucyjungz | 3:6e08d0bba1bb | 441 | /* Allocate buffer for reading */ |
nsrwsurasak | 0:a27e0d3581d1 | 442 | char buf[1024]; |
nsrwsurasak | 0:a27e0d3581d1 | 443 | int index = 0; |
Lucyjungz | 3:6e08d0bba1bb | 444 | |
Lucyjungz | 3:6e08d0bba1bb | 445 | /* Initialize return value */ |
nsrwsurasak | 0:a27e0d3581d1 | 446 | memset(m_varList, ' ', sizeof(m_varList)); |
Lucyjungz | 3:6e08d0bba1bb | 447 | |
Lucyjungz | 3:6e08d0bba1bb | 448 | /* Read line from the file */ |
Lucyjungz | 3:6e08d0bba1bb | 449 | while (fgets(buf, sizeof(buf), fp) != NULL) |
Lucyjungz | 3:6e08d0bba1bb | 450 | { |
Lucyjungz | 3:6e08d0bba1bb | 451 | /* Check the TAG */ |
Lucyjungz | 3:6e08d0bba1bb | 452 | if (strstr (buf,VAR_NAME_TAG)) |
Lucyjungz | 3:6e08d0bba1bb | 453 | { |
Lucyjungz | 3:6e08d0bba1bb | 454 | /* Found variable TAG, populate it*/ |
Lucyjungz | 4:ec62bf823914 | 455 | FileManager_GetXmlText(buf , m_varList[index].varName); |
Lucyjungz | 3:6e08d0bba1bb | 456 | } |
Lucyjungz | 3:6e08d0bba1bb | 457 | else if (strstr (buf,VAR_ADDR_TAG)) |
Lucyjungz | 3:6e08d0bba1bb | 458 | { |
Lucyjungz | 3:6e08d0bba1bb | 459 | /* Found variable address TAG, populate it*/ |
Lucyjungz | 4:ec62bf823914 | 460 | FileManager_GetXmlText(buf , m_varList[index].varAddress); |
Lucyjungz | 5:7c513eee7b2b | 461 | } |
Lucyjungz | 10:a8003d357cf2 | 462 | else if (strstr (buf,VAR_TYPE_TAG)) |
Lucyjungz | 10:a8003d357cf2 | 463 | { |
Lucyjungz | 10:a8003d357cf2 | 464 | /* Found variable type TAG, populate it*/ |
Lucyjungz | 10:a8003d357cf2 | 465 | FileManager_GetXmlText(buf , m_varList[index].varType); |
Lucyjungz | 10:a8003d357cf2 | 466 | } |
Lucyjungz | 6:5bd75c0f607c | 467 | else if (strstr (buf,VAR_LSB1_TAG)) |
Lucyjungz | 6:5bd75c0f607c | 468 | { |
Lucyjungz | 6:5bd75c0f607c | 469 | /* Found variable LSB1 TAG, populate it*/ |
Lucyjungz | 6:5bd75c0f607c | 470 | FileManager_GetXmlText(buf , m_varList[index].varLSB1); |
Lucyjungz | 6:5bd75c0f607c | 471 | } |
Lucyjungz | 6:5bd75c0f607c | 472 | else if (strstr (buf,VAR_LSB2_TAG)) |
Lucyjungz | 5:7c513eee7b2b | 473 | { |
Lucyjungz | 6:5bd75c0f607c | 474 | /* Found variable LSB2 TAG, populate it*/ |
Lucyjungz | 6:5bd75c0f607c | 475 | FileManager_GetXmlText(buf , m_varList[index].varLSB2); |
Lucyjungz | 6:5bd75c0f607c | 476 | } |
Lucyjungz | 6:5bd75c0f607c | 477 | else if (strstr (buf,VAR_BITMASK_TAG)) |
Lucyjungz | 6:5bd75c0f607c | 478 | { |
Lucyjungz | 6:5bd75c0f607c | 479 | /* Found variable BitMask TAG, populate it*/ |
Lucyjungz | 6:5bd75c0f607c | 480 | FileManager_GetXmlText(buf , m_varList[index].varBitMask); |
Lucyjungz | 5:7c513eee7b2b | 481 | } |
Lucyjungz | 5:7c513eee7b2b | 482 | else if (strstr (buf,VAR_UNIT_TAG)) |
Lucyjungz | 5:7c513eee7b2b | 483 | { |
Lucyjungz | 5:7c513eee7b2b | 484 | /* Found variable unit TAG, populate it*/ |
Lucyjungz | 5:7c513eee7b2b | 485 | FileManager_GetXmlText(buf , m_varList[index].varUnit); |
nsrwsurasak | 0:a27e0d3581d1 | 486 | index++; |
nsrwsurasak | 0:a27e0d3581d1 | 487 | } |
nsrwsurasak | 0:a27e0d3581d1 | 488 | |
nsrwsurasak | 0:a27e0d3581d1 | 489 | } |
Lucyjungz | 3:6e08d0bba1bb | 490 | /* Close File */ |
Lucyjungz | 3:6e08d0bba1bb | 491 | fclose(fp); |
Lucyjungz | 3:6e08d0bba1bb | 492 | |
Lucyjungz | 3:6e08d0bba1bb | 493 | /* Populate amount */ |
nsrwsurasak | 0:a27e0d3581d1 | 494 | m_amountVarList = index; |
Lucyjungz | 3:6e08d0bba1bb | 495 | |
Lucyjungz | 3:6e08d0bba1bb | 496 | /* Return variable list */ |
nsrwsurasak | 0:a27e0d3581d1 | 497 | return m_varList; |
nsrwsurasak | 0:a27e0d3581d1 | 498 | } |
nsrwsurasak | 0:a27e0d3581d1 | 499 | } |
Lucyjungz | 3:6e08d0bba1bb | 500 | /** |
Lucyjungz | 3:6e08d0bba1bb | 501 | * @brief Function to amount of variable for data logging |
Lucyjungz | 3:6e08d0bba1bb | 502 | * @note Must be called after readVarFile |
Lucyjungz | 3:6e08d0bba1bb | 503 | * @param None |
Lucyjungz | 3:6e08d0bba1bb | 504 | * @retval amount of variable list |
Lucyjungz | 3:6e08d0bba1bb | 505 | */ |
Lucyjungz | 4:ec62bf823914 | 506 | int FileManager_GetAmountVarList() |
nsrwsurasak | 0:a27e0d3581d1 | 507 | { |
nsrwsurasak | 0:a27e0d3581d1 | 508 | return m_amountVarList; |
nsrwsurasak | 0:a27e0d3581d1 | 509 | } |
Lucyjungz | 3:6e08d0bba1bb | 510 | /** |
Lucyjungz | 3:6e08d0bba1bb | 511 | * @brief Function to get variable list |
Lucyjungz | 3:6e08d0bba1bb | 512 | * @note Must be called after readVarFile |
Lucyjungz | 3:6e08d0bba1bb | 513 | * @param None |
Lucyjungz | 3:6e08d0bba1bb | 514 | * @retval pointer to variable list |
Lucyjungz | 3:6e08d0bba1bb | 515 | */ |
Lucyjungz | 4:ec62bf823914 | 516 | Variable_Data_TypeDef * FileManager_GetVarList() |
nsrwsurasak | 0:a27e0d3581d1 | 517 | { |
nsrwsurasak | 0:a27e0d3581d1 | 518 | return m_varList; |
nsrwsurasak | 0:a27e0d3581d1 | 519 | } |
Lucyjungz | 11:e21d4c5bfd1b | 520 | /** |
Lucyjungz | 11:e21d4c5bfd1b | 521 | * @brief Utility to play with LED status |
Lucyjungz | 11:e21d4c5bfd1b | 522 | * @note Libary user need to assign proper PinName to LED_SDCARD |
Lucyjungz | 11:e21d4c5bfd1b | 523 | * @param on - True for turning LED ON, otherwise LED off |
Lucyjungz | 11:e21d4c5bfd1b | 524 | * @retval None |
Lucyjungz | 11:e21d4c5bfd1b | 525 | */ |
Lucyjungz | 11:e21d4c5bfd1b | 526 | static void FileManager_SetLedStatus(bool on) |
Lucyjungz | 11:e21d4c5bfd1b | 527 | { |
Lucyjungz | 12:0045fca3c160 | 528 | /* Check LED Connection */ |
Lucyjungz | 11:e21d4c5bfd1b | 529 | if (ledStatus.is_connected()) |
Lucyjungz | 11:e21d4c5bfd1b | 530 | { |
Lucyjungz | 12:0045fca3c160 | 531 | /* Set LED regarding to given argment */ |
Lucyjungz | 11:e21d4c5bfd1b | 532 | ledStatus = on; |
Lucyjungz | 12:0045fca3c160 | 533 | } |
Lucyjungz | 12:0045fca3c160 | 534 | #if DEBUG |
Lucyjungz | 12:0045fca3c160 | 535 | else |
Lucyjungz | 12:0045fca3c160 | 536 | { |
Lucyjungz | 12:0045fca3c160 | 537 | printf("\r\nSDCard LED is connected !!"); |
Lucyjungz | 12:0045fca3c160 | 538 | } |
Lucyjungz | 12:0045fca3c160 | 539 | #endif |
Lucyjungz | 11:e21d4c5bfd1b | 540 | } |
nsrwsurasak | 0:a27e0d3581d1 | 541 |