bladeRF-cli: Fixed bladeRF-cli exit on FW/FPGA version mismatch

A status check needed an override for the situation where a user
was loading and incompatible FW or FPGA version.

Fixes #466.
This commit is contained in:
Jon Szymaniak 2016-04-14 12:44:51 -04:00
commit 538e2d7987
2 changed files with 18 additions and 2 deletions

View file

@ -35,6 +35,7 @@ int cmd_open(struct cli_state *state, int argc, char **argv)
int i;
int status;
int ret;
bool update_required;
if (state->dev) {
bladerf_close(state->dev);
@ -68,9 +69,18 @@ int cmd_open(struct cli_state *state, int argc, char **argv)
}
status = bladerf_open(&state->dev, dev_ident);
update_required = (status == BLADERF_ERR_UPDATE_FPGA) ||
(status == BLADERF_ERR_UPDATE_FW);
if (status) {
state->last_lib_error = status;
ret = CLI_RET_LIBBLADERF;
if (update_required) {
/* LibbladeRF will print a warning. No need to show an error. */
status = 0;
} else {
state->last_lib_error = status;
ret = CLI_RET_LIBBLADERF;
}
} else {
ret = 0;
putchar('\n');

View file

@ -301,6 +301,8 @@ static int open_device(struct rc_config *rc, struct cli_state *state, int status
if (!status) {
status = bladerf_open(&state->dev, rc->device);
if (status) {
bool update_required = (status == BLADERF_ERR_UPDATE_FPGA) ||
(status == BLADERF_ERR_UPDATE_FW);
/* Just warn if no device is attached; don't error out */
if (!rc->device && status == BLADERF_ERR_NODEV) {
@ -311,6 +313,10 @@ static int open_device(struct rc_config *rc, struct cli_state *state, int status
fprintf(stderr, "and that the current user has permission to access it.\n");
fprintf(stderr, "\n");
status = 0;
} else if (update_required) {
/* Allow users to enter the console so they can perform
* an update. */
status = 0;
} else {
fprintf(stderr, "Failed to open device (%s): %s\n",
rc->device ? rc->device : "first available",