make style

This commit is contained in:
Ray Lee 2021-08-14 10:59:50 +08:00
commit 5768ae9395

View file

@ -45,15 +45,15 @@
static char cur_dump_file[22] = {0}; static char cur_dump_file[22] = {0};
static bool fill_eml_from_file(char *dumpfile){ static bool fill_eml_from_file(char *dumpfile) {
// check file exist // check file exist
if (!exists_in_spiffs(dumpfile)){ if (!exists_in_spiffs(dumpfile)) {
Dbprintf(_RED_("Dump file %s not found!"), dumpfile); Dbprintf(_RED_("Dump file %s not found!"), dumpfile);
return false; return false;
} }
//check dumpfile size //check dumpfile size
uint32_t size = size_in_spiffs(dumpfile); uint32_t size = size_in_spiffs(dumpfile);
if (size != DUMP_SIZE){ if (size != DUMP_SIZE) {
Dbprintf(_RED_("File Size: %dB The dump file size is incorrect! Only support Mifare Classic 1K! Please check it.")); Dbprintf(_RED_("File Size: %dB The dump file size is incorrect! Only support Mifare Classic 1K! Please check it."));
BigBuf_free(); BigBuf_free();
return false; return false;
@ -67,8 +67,8 @@ static bool fill_eml_from_file(char *dumpfile){
return true; return true;
} }
static bool write_file_from_eml(char *dumpfile){ static bool write_file_from_eml(char *dumpfile) {
if (!exists_in_spiffs(dumpfile)){ if (!exists_in_spiffs(dumpfile)) {
Dbprintf(_RED_("Dump file %s not found!"), dumpfile); Dbprintf(_RED_("Dump file %s not found!"), dumpfile);
return false; return false;
} }
@ -77,12 +77,11 @@ static bool write_file_from_eml(char *dumpfile){
return true; return true;
} }
void ModInfo(void){ void ModInfo(void) {
DbpString(_YELLOW_(" HF Mifare Classic simulation mode") " - a.k.a MFCSIM"); DbpString(_YELLOW_(" HF Mifare Classic simulation mode") " - a.k.a MFCSIM");
} }
void RunMod(void) void RunMod(void) {
{
//initializing //initializing
StandAloneMode(); StandAloneMode();
FpgaDownloadAndGo(FPGA_BITSTREAM_HF); FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
@ -90,13 +89,12 @@ void RunMod(void)
Dbprintf(_YELLOW_("Standalone mode MFCSIM started!")); Dbprintf(_YELLOW_("Standalone mode MFCSIM started!"));
bool flag_has_dumpfile = false; bool flag_has_dumpfile = false;
for (int i = 1;; i++) for (int i = 1;; i++) {
{
//Exit! usbcommand break //Exit! usbcommand break
if (data_available()) break; if (data_available()) break;
//Infinite loop //Infinite loop
if (i > 15){ if (i > 15) {
if (!flag_has_dumpfile) if (!flag_has_dumpfile)
break; //still no dump file found break; //still no dump file found
i = 1; //next loop i = 1; //next loop
@ -108,7 +106,7 @@ void RunMod(void)
//Try to load dump form flash //Try to load dump form flash
sprintf(cur_dump_file, HF_MFCSIM_DUMPFILE_SIM, i); sprintf(cur_dump_file, HF_MFCSIM_DUMPFILE_SIM, i);
Dbprintf(_YELLOW_("[Slot: %d] Try to load dump file: %s"), i, cur_dump_file); Dbprintf(_YELLOW_("[Slot: %d] Try to load dump file: %s"), i, cur_dump_file);
if (!fill_eml_from_file(cur_dump_file)){ if (!fill_eml_from_file(cur_dump_file)) {
Dbprintf(_YELLOW_("[Slot: %d] Dump load Failed, Next one!"), i); Dbprintf(_YELLOW_("[Slot: %d] Dump load Failed, Next one!"), i);
LEDsoff(); LEDsoff();
continue; continue;
@ -117,7 +115,7 @@ void RunMod(void)
//Exit! Button hold break //Exit! Button hold break
int button_pressed = BUTTON_HELD(500); int button_pressed = BUTTON_HELD(500);
if (button_pressed == BUTTON_HOLD){ if (button_pressed == BUTTON_HOLD) {
Dbprintf("Button hold, Break!"); Dbprintf("Button hold, Break!");
break; break;
} }
@ -132,7 +130,7 @@ void RunMod(void)
Dbprintf(_YELLOW_("[Slot: %d] Simulation end, Write Back to dump file!"), i); Dbprintf(_YELLOW_("[Slot: %d] Simulation end, Write Back to dump file!"), i);
//Simulation end, Write Back //Simulation end, Write Back
if (!write_file_from_eml(cur_dump_file)){ if (!write_file_from_eml(cur_dump_file)) {
Dbprintf(_RED_("[Slot: %d] Write Failed! Anyway, Change to next one!"), i); Dbprintf(_RED_("[Slot: %d] Write Failed! Anyway, Change to next one!"), i);
continue; continue;
} }