Permalink
Browse files

fx3_firmware: Fixed string index error introduced in 58c13c6

  • Loading branch information...
jynik committed Oct 5, 2013
1 parent 5cb9e61 commit cf552e30e53e51d85bd45c7159011267a58d3c07
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.3)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../host/cmake/modules)
set(VERSION_INFO_MAJOR 1)
set(VERSION_INFO_MINOR 5)
set(VERSION_INFO_PATCH 2)
set(VERSION_INFO_PATCH 3)
set(VERSION_INFO_EXTRA "git")
include(Version)
@@ -857,7 +857,7 @@ void bladeRFInit(void)
/* Configure the serial number string descriptor */
apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR,
BLADE_USB_STR_INDEX_PRODUCT,
BLADE_USB_STR_INDEX_SERIAL,
(uint8_t *)CyFxUSBSerial);
if (apiRetStatus != CY_U3P_SUCCESS) {
@@ -11,8 +11,8 @@ project(bladeRF-cli C)
################################################################################
set(VERSION_INFO_MAJOR 0)
set(VERSION_INFO_MINOR 4)
set(VERSION_INFO_PATCH 2)
set(VERSION_INFO_MINOR 5)
set(VERSION_INFO_PATCH 0)
set(VERSION_INFO_EXTRA "git")
include(Version)
@@ -85,6 +85,7 @@ set(BLADERF_CLI_SOURCE
src/cmd/calibrate.c
src/cmd/cmd.c
src/cmd/erase.c
src/cmd/info.c
src/cmd/load.c
src/cmd/open.c
src/cmd/peek.c
@@ -8,6 +8,7 @@
DECLARE_CMD(calibrate);
DECLARE_CMD(clear);
DECLARE_CMD(help);
DECLARE_CMD(info);
DECLARE_CMD(load);
DECLARE_CMD(open);
DECLARE_CMD(peek);
@@ -33,6 +34,7 @@ struct cmd {
static const char *cmd_names_calibrate[] = { "calibrate", "cal", NULL };
static const char *cmd_names_clear[] = { "clear", "cls", NULL };
static const char *cmd_names_help[] = { "help", "h", "?", NULL };
static const char *cmd_names_info[] = { "info", "i", NULL };
static const char *cmd_names_load[] = { "load", "ld", NULL };
static const char *cmd_names_open[] = { "open", "op", "o", NULL };
static const char *cmd_names_peek[] = { "peek", "pe", NULL };
@@ -220,6 +222,21 @@ static const struct cmd cmd_table[] = {
"Provides extended help, like this, on any command.\n"
)
},
{
FIELD_INIT(.names, cmd_names_info),
FIELD_INIT(.exec, cmd_info),
FIELD_INIT(.desc, "Print information about the currently opened device"),
FIELD_INIT(.help,
"info\n"
"\n"
"Prints the following information about an opened device:\n"
" Serial number\n"
" VCTCXO DAC calibration value\n"
" FPGA size\n"
" Whether or not the FPGA is loaded\n"
" USB bus and address\n"
)
},
{
FIELD_INIT(.names, cmd_names_load),
FIELD_INIT(.exec, cmd_load),
@@ -5,9 +5,6 @@
int cmd_version(struct cli_state *state, int argc, char **argv)
{
int status;
char serial[BLADERF_SERIAL_LENGTH] = { 0 };
bladerf_fpga_size fpga_size;
uint16_t dac_trim;
struct bladerf_version fw_version, fpga_version, lib_version;
bool fpga_loaded = false;
@@ -19,41 +16,31 @@ int cmd_version(struct cli_state *state, int argc, char **argv)
printf(" libbladeRF version: %s\n", lib_version.describe);
printf("\n");
/* Exit cleanly if no device is attached */
if (state->dev == NULL) {
printf(" No device attached to retrive version information from.\n\n");
printf(" Device version information unavailable: No device attached.\n");
return 0;
}
status = bladerf_is_fpga_configured(state->dev);
if (status < 0) {
return status;
} else if (status) {
state->last_lib_error = status;
return CMD_RET_LIBBLADERF;
} else if (status != 0) {
fpga_loaded = true;
status = bladerf_fpga_version(state->dev, &fpga_version);
if (status < 0) {
return status;
state->last_lib_error = status;
return CMD_RET_LIBBLADERF;
}
}
status = bladerf_fw_version(state->dev, &fw_version);
if (status < 0) {
return status;
state->last_lib_error = status;
return CMD_RET_LIBBLADERF;
}
status = bladerf_get_serial(state->dev, serial);
if (status < 0) {
return status;
}
status = bladerf_get_fpga_size(state->dev, &fpga_size);
if (status < 0) {
return status;
}
status = bladerf_get_vctcxo_trim(state->dev, &dac_trim);
if (status < 0) {
return status;
}
printf(" Firmware version: %s\n", fw_version.describe);
@@ -63,17 +50,7 @@ int cmd_version(struct cli_state *state, int argc, char **argv)
printf(" FPGA version: Unknown (FPGA not loaded)\n");
}
/* TODO: Move these into an info command */
printf(" Serial #: %s\n", serial);
printf(" VCTCXO DAC calibration: 0x%.4x\n", dac_trim);
if (fpga_size != 0) {
printf(" FPGA size: %d KLE\n", fpga_size);
} else {
printf(" FPGA size: Unknown\n");
}
printf("\n");
return CMD_RET_OK;
}

0 comments on commit cf552e3

Please sign in to comment.