dfu: don't check filename -> let configBitstreamParser to do check
This commit is contained in:
parent
f404199e25
commit
e182a53659
55
src/dfu.cpp
55
src/dfu.cpp
|
|
@ -57,37 +57,36 @@ DFU::DFU(const string &filename, uint16_t vid, uint16_t pid,
|
||||||
struct dfu_status status;
|
struct dfu_status status;
|
||||||
int dfu_vid = 0, dfu_pid = 0;
|
int dfu_vid = 0, dfu_pid = 0;
|
||||||
|
|
||||||
if (!filename.empty()) {
|
printInfo("Open file ", false);
|
||||||
printInfo("Open file " + filename + " ", false);
|
|
||||||
try {
|
|
||||||
_bit = new DFUFileParser(filename, _verbose > 0);
|
|
||||||
printSuccess("DONE");
|
|
||||||
} catch (std::exception &e) {
|
|
||||||
printError("FAIL");
|
|
||||||
throw runtime_error("Error: Fail to open file");
|
|
||||||
}
|
|
||||||
|
|
||||||
printInfo("Parse file ", false);
|
try {
|
||||||
try {
|
_bit = new DFUFileParser(filename, _verbose > 0);
|
||||||
_bit->parse();
|
printSuccess("DONE");
|
||||||
printSuccess("DONE");
|
} catch (std::exception &e) {
|
||||||
} catch (std::exception &e) {
|
printError("FAIL");
|
||||||
printError("FAIL");
|
throw runtime_error("Error: Fail to open file");
|
||||||
delete _bit;
|
}
|
||||||
throw runtime_error("Error: Fail to parse file");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_verbose > 0)
|
printInfo("Parse file ", false);
|
||||||
_bit->displayHeader();
|
try {
|
||||||
|
_bit->parse();
|
||||||
|
printSuccess("DONE");
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
printError("FAIL");
|
||||||
|
delete _bit;
|
||||||
|
throw runtime_error("Error: Fail to parse file");
|
||||||
|
}
|
||||||
|
|
||||||
/* get VID and PID from dfu file */
|
if (_verbose > 0)
|
||||||
try {
|
_bit->displayHeader();
|
||||||
dfu_vid = std::stoi(_bit->getHeaderVal("idVendor"), 0, 16);
|
|
||||||
dfu_pid = std::stoi(_bit->getHeaderVal("idProduct"), 0, 16);
|
/* get VID and PID from dfu file */
|
||||||
} catch (std::exception &e) {
|
try {
|
||||||
if (_verbose)
|
dfu_vid = std::stoi(_bit->getHeaderVal("idVendor"), 0, 16);
|
||||||
printWarn(e.what());
|
dfu_pid = std::stoi(_bit->getHeaderVal("idProduct"), 0, 16);
|
||||||
}
|
} catch (std::exception &e) {
|
||||||
|
if (_verbose)
|
||||||
|
printWarn(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libusb_init(&usb_ctx) < 0) {
|
if (libusb_init(&usb_ctx) < 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue