add verbose-level args: -1 quiet, 0 normal mode, 1 verbose, 2 debug lowlevel
This commit is contained in:
parent
28cbd1faad
commit
abef1f4968
|
|
@ -71,6 +71,8 @@ openFPGALoader -- a program to flash FPGA
|
|||
-r, --reset reset FPGA after operations
|
||||
--spi SPI mode (only for FTDI in serial mode)
|
||||
-v, --verbose Produce verbose output
|
||||
--verbose-level arg verbose level -1: quiet, 0: normal, 1:verbose,
|
||||
2:debug
|
||||
-h, --help Give this help list
|
||||
--verify Verify write operation (SPI Flash only)
|
||||
-V, --Version Print program version
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ using namespace std;
|
|||
|
||||
#define DEBUG 0
|
||||
|
||||
#ifdef DEBUG
|
||||
#if DEBUG
|
||||
#define display(...) \
|
||||
do { if (_verbose) fprintf(stdout, __VA_ARGS__);}while(0)
|
||||
#else
|
||||
|
|
@ -59,9 +59,9 @@ using namespace std;
|
|||
*/
|
||||
|
||||
Jtag::Jtag(cable_t &cable, const jtag_pins_conf_t *pin_conf, string dev,
|
||||
const string &serial, uint32_t clkHZ, bool verbose,
|
||||
const string &serial, uint32_t clkHZ, int8_t verbose,
|
||||
const string &firmware_path):
|
||||
_verbose(verbose),
|
||||
_verbose(verbose > 1),
|
||||
_state(RUN_TEST_IDLE),
|
||||
_tms_buffer_size(128), _num_tms(0),
|
||||
_board_name("nope"), device_index(0)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
class Jtag {
|
||||
public:
|
||||
Jtag(cable_t &cable, const jtag_pins_conf_t *pin_conf, std::string dev,
|
||||
const std::string &serial, uint32_t clkHZ, bool verbose = false,
|
||||
const std::string &serial, uint32_t clkHZ, int8_t verbose = 0,
|
||||
const std::string &firmware_path="");
|
||||
~Jtag();
|
||||
|
||||
|
|
@ -90,13 +90,13 @@ class Jtag {
|
|||
const char *getStateName(tapState_t s);
|
||||
|
||||
/* utilities */
|
||||
void setVerbose(bool verbose){_verbose = verbose;}
|
||||
void setVerbose(int8_t verbose){_verbose = verbose;}
|
||||
|
||||
private:
|
||||
void init_internal(cable_t &cable, const std::string &dev, const std::string &serial,
|
||||
const jtag_pins_conf_t *pin_conf, uint32_t clkHZ,
|
||||
const std::string &firmware_path);
|
||||
bool _verbose;
|
||||
int8_t _verbose;
|
||||
int _state;
|
||||
int _tms_buffer_size;
|
||||
int _num_tms;
|
||||
|
|
|
|||
14
src/main.cpp
14
src/main.cpp
|
|
@ -299,7 +299,7 @@ int main(int argc, char **argv)
|
|||
Jtag *jtag;
|
||||
try {
|
||||
jtag = new Jtag(cable, &pins_config, args.device, args.ftdi_serial,
|
||||
args.freq, false, args.probe_firmware);
|
||||
args.freq, args.verbose, args.probe_firmware);
|
||||
} catch (std::exception &e) {
|
||||
printError("JTAG init failed with: " + string(e.what()));
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -476,6 +476,7 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
|
|||
string freqo;
|
||||
vector<string> pins;
|
||||
bool verbose, quiet;
|
||||
int8_t verbose_level = -2;
|
||||
try {
|
||||
cxxopts::Options options(argv[0], "openFPGALoader -- a program to flash FPGA",
|
||||
"<gwenhael.goavec-merou@trabucayre.com>");
|
||||
|
|
@ -534,6 +535,8 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
|
|||
("spi", "SPI mode (only for FTDI in serial mode)",
|
||||
cxxopts::value<bool>(args->spi))
|
||||
("v,verbose", "Produce verbose output", cxxopts::value<bool>(verbose))
|
||||
("verbose-level", "verbose level -1: quiet, 0: normal, 1:verbose, 2:debug",
|
||||
cxxopts::value<int8_t>(verbose_level))
|
||||
("h,help", "Give this help list")
|
||||
("verify", "Verify write operation (SPI Flash only)",
|
||||
cxxopts::value<bool>(args->verify))
|
||||
|
|
@ -555,6 +558,15 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
|
|||
args->verbose = 1;
|
||||
if (quiet)
|
||||
args->verbose = -1;
|
||||
if (verbose_level != -2) {
|
||||
if ((verbose && verbose_level != 1) ||
|
||||
(quiet && verbose_level != -1)) {
|
||||
printError("Error: mismatch quiet/verbose and verbose-level\n");
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
args->verbose = verbose_level;
|
||||
}
|
||||
|
||||
if (result.count("Version")) {
|
||||
cout << "openFPGALoader " << VERSION << endl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue