Skip to content

Commit

Permalink
Added version.h file, and -v option.
Browse files Browse the repository at this point in the history
  • Loading branch information
nethomas1968 authored Jun 11, 2023
1 parent 93c45e9 commit 3342bf7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions HanshowFlasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using namespace std;
#include "MCUTools.h"
#include "FileUtils.h"
#include "TelinkFile.h"
#include "version.h"

#define SHOW_DATE_TIME true
#define NOSHOW_DATE_TIME false
Expand All @@ -38,7 +39,8 @@ static void usage(const char *progname)
cout << " -r (optional) Reset MCU." << endl;
cout << " -u (optional) Unlock flash" << endl;
cout << " -d1 (optional) Set debug level to 1" << endl;
cout << " -h (optional) Show this help and exit." << endl << endl;
cout << " -v (optional) Show version information." << endl;
cout << " -h (optional) Show this help and exit." << endl;
}

/***********************************************************************
Expand All @@ -56,9 +58,10 @@ int main(int argc, char** argv)
bool bSoftResetMCU;
bool bShowHelp = false;
bool bUnlockFlash = false;
bool bShowVersion = false;
Logger log("./log.txt");

while ((option = getopt(argc, argv,"d:b:t:f:c:ruh")) != -1)
while ((option = getopt(argc, argv,"d:b:t:f:c:ruvh")) != -1)
{
switch (option) {
case 'd' : debugLevel = (uint8_t)atoi(optarg); break;
Expand All @@ -68,6 +71,7 @@ int main(int argc, char** argv)
case 'c' : comPort = optarg; break;
case 'r' : bSoftResetMCU = true; break; // optional
case 'u' : bUnlockFlash = true; break; // optional
case 'v' : bShowVersion = true; break; // optional
case 'h' : bShowHelp = true; break;
default: usage(argv[0]);
return -1;
Expand All @@ -79,6 +83,11 @@ int main(int argc, char** argv)
usage(argv[0]);
return 0;
}
else if (bShowVersion) {
cout << argv[0] << " Version " << HANSHOW_FLASHER_VERSION << endl << endl;
usage(argv[0]);
return 0;
}

log.setLogLevel(debugLevel);
log.enable(NOSHOW_DATE_TIME); // Logger must be enabled before use. Use "true" to see date/time in the log file.
Expand Down
6 changes: 6 additions & 0 deletions version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _VERSION_H_
#define _VERSION_H_

#define HANSHOW_FLASHER_VERSION "1.2"

#endif

0 comments on commit 3342bf7

Please sign in to comment.