test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: utility.cpp
- Revision:
- 151:3047ebb3c9a8
- Parent:
- 150:ef46ce63345c
- Child:
- 152:a4d66901785d
--- a/utility.cpp Fri Sep 27 04:43:41 2013 +0000 +++ b/utility.cpp Mon Sep 30 15:31:01 2013 +0000 @@ -593,7 +593,7 @@ void readConfig(){ FILE *cfile; - int ff; + int ff,readhex; char sTemp[16]; cfile = fopen("/local/config.txt", "r"); @@ -659,7 +659,8 @@ if(ff>7){ for(char i=0;i<8;i++){ fscanf(cfile, "usrMsgId %s\r\n", &sTemp ); - sscanf(sTemp,"%4x", &uMsgId[i]); + sscanf(sTemp,"%x", &readhex); + uMsgId[i]=readhex; } } fclose(cfile); @@ -901,6 +902,10 @@ char buffer[bufSize]; FILE *lfile; + tt.background(Blue); + tt.foreground(Yellow); + tt.locate(0,10); + tt.cls(); // Check for config file on USB drive sfr = f_open(&efile,"CONFIG.TXT",FA_READ|FA_OPEN_EXISTING); if(sfr == FR_OK) @@ -942,7 +947,6 @@ wait(2); } - sfr = f_open(&efile,"firmware.bin",FA_READ|FA_OPEN_EXISTING); if(sfr != FR_OK) { @@ -952,12 +956,13 @@ return; } fwCount ++; + printf("Saving config.\n"); saveConfig(); //delete all bin files in /local DIR *dir; struct dirent *ent; - printf("Starting update\n"); - printf("deleting old firmware files\n"); + printf("Starting update.\n"); + printf("Deleting old firmware files.\n"); if ((dir = opendir ("/local/")) != NULL) { // print all the files and directories within directory while ((ent = readdir (dir)) != NULL) { @@ -971,28 +976,27 @@ { sprintf(sTemp,"/local/%s",ent->d_name); int result = remove(sTemp); - printf("REMOVED: %s",ent->d_name); + printf("deleted: %s\n",ent->d_name); } } closedir (dir); } else { //could not open directory - printf("Couldnt open folder"); - wait(3); + printf("Couldn't open folder.\n"); + wait(2); return; } - printf("copying new firmware\n"); - tt.cls(); + printf("Copying new firmware.\n"); //Copy the new firmware from usb->local //The newest bin file is the one that is used by the mbed sprintf(sTemp,"/local/fw%d.bin",fwCount); - printf("Writing %s\n",sTemp); + printf("Writing %s.\n",sTemp); wait(2); lfile = fopen(sTemp, "wb"); if(lfile == NULL) { - printf("Couldn't Open Destination\n"); - wait(3); + printf("Couldn't open destination.\n"); + wait(2); return; } @@ -1005,9 +1009,8 @@ fflush(lfile); fclose(lfile); f_close(&efile); - tt.cls(); - printf("Succesful\n\n"); - printf("Rebooting in 3 seconds\n"); + printf("Succesful.\n\n"); + printf("Rebooting in 3 seconds.\n"); wait(3); //Now run new firmware mbed_reset();