Skip to content

Commit

Permalink
fx3_firmware: Fixed string index error introduced in 58c13c6
Browse files Browse the repository at this point in the history
  • Loading branch information
jynik committed Oct 5, 2013
1 parent 5cb9e61 commit cf552e3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 36 deletions.
2 changes: 1 addition & 1 deletion fx3_firmware/CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.3)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../host/cmake/modules) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../host/cmake/modules)
set(VERSION_INFO_MAJOR 1) set(VERSION_INFO_MAJOR 1)
set(VERSION_INFO_MINOR 5) set(VERSION_INFO_MINOR 5)
set(VERSION_INFO_PATCH 2) set(VERSION_INFO_PATCH 3)
set(VERSION_INFO_EXTRA "git") set(VERSION_INFO_EXTRA "git")
include(Version) include(Version)


Expand Down
2 changes: 1 addition & 1 deletion fx3_firmware/bladeRF.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ void bladeRFInit(void)


/* Configure the serial number string descriptor */ /* Configure the serial number string descriptor */
apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR,
BLADE_USB_STR_INDEX_PRODUCT, BLADE_USB_STR_INDEX_SERIAL,
(uint8_t *)CyFxUSBSerial); (uint8_t *)CyFxUSBSerial);


if (apiRetStatus != CY_U3P_SUCCESS) { if (apiRetStatus != CY_U3P_SUCCESS) {
Expand Down
5 changes: 3 additions & 2 deletions host/utilities/bladeRF-cli/CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ project(bladeRF-cli C)
################################################################################ ################################################################################


set(VERSION_INFO_MAJOR 0) set(VERSION_INFO_MAJOR 0)
set(VERSION_INFO_MINOR 4) set(VERSION_INFO_MINOR 5)
set(VERSION_INFO_PATCH 2) set(VERSION_INFO_PATCH 0)
set(VERSION_INFO_EXTRA "git") set(VERSION_INFO_EXTRA "git")
include(Version) include(Version)


Expand Down Expand Up @@ -85,6 +85,7 @@ set(BLADERF_CLI_SOURCE
src/cmd/calibrate.c src/cmd/calibrate.c
src/cmd/cmd.c src/cmd/cmd.c
src/cmd/erase.c src/cmd/erase.c
src/cmd/info.c
src/cmd/load.c src/cmd/load.c
src/cmd/open.c src/cmd/open.c
src/cmd/peek.c src/cmd/peek.c
Expand Down
17 changes: 17 additions & 0 deletions host/utilities/bladeRF-cli/src/cmd/cmd.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
DECLARE_CMD(calibrate); DECLARE_CMD(calibrate);
DECLARE_CMD(clear); DECLARE_CMD(clear);
DECLARE_CMD(help); DECLARE_CMD(help);
DECLARE_CMD(info);
DECLARE_CMD(load); DECLARE_CMD(load);
DECLARE_CMD(open); DECLARE_CMD(open);
DECLARE_CMD(peek); DECLARE_CMD(peek);
Expand All @@ -33,6 +34,7 @@ struct cmd {
static const char *cmd_names_calibrate[] = { "calibrate", "cal", NULL }; static const char *cmd_names_calibrate[] = { "calibrate", "cal", NULL };
static const char *cmd_names_clear[] = { "clear", "cls", NULL }; static const char *cmd_names_clear[] = { "clear", "cls", NULL };
static const char *cmd_names_help[] = { "help", "h", "?", 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_load[] = { "load", "ld", NULL };
static const char *cmd_names_open[] = { "open", "op", "o", NULL }; static const char *cmd_names_open[] = { "open", "op", "o", NULL };
static const char *cmd_names_peek[] = { "peek", "pe", NULL }; static const char *cmd_names_peek[] = { "peek", "pe", NULL };
Expand Down Expand Up @@ -220,6 +222,21 @@ static const struct cmd cmd_table[] = {
"Provides extended help, like this, on any command.\n" "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(.names, cmd_names_load),
FIELD_INIT(.exec, cmd_load), FIELD_INIT(.exec, cmd_load),
Expand Down
41 changes: 9 additions & 32 deletions host/utilities/bladeRF-cli/src/cmd/version.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
int cmd_version(struct cli_state *state, int argc, char **argv) int cmd_version(struct cli_state *state, int argc, char **argv)
{ {
int status; 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; struct bladerf_version fw_version, fpga_version, lib_version;
bool fpga_loaded = false; bool fpga_loaded = false;
Expand All @@ -19,41 +16,31 @@ int cmd_version(struct cli_state *state, int argc, char **argv)
printf(" libbladeRF version: %s\n", lib_version.describe); printf(" libbladeRF version: %s\n", lib_version.describe);
printf("\n"); printf("\n");


/* Exit cleanly if no device is attached */
if (state->dev == NULL) { 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; return 0;
} }


status = bladerf_is_fpga_configured(state->dev); status = bladerf_is_fpga_configured(state->dev);
if (status < 0) { if (status < 0) {
return status; state->last_lib_error = status;
} else if (status) { return CMD_RET_LIBBLADERF;
} else if (status != 0) {
fpga_loaded = true; fpga_loaded = true;
status = bladerf_fpga_version(state->dev, &fpga_version); status = bladerf_fpga_version(state->dev, &fpga_version);
if (status < 0) { if (status < 0) {
return status; state->last_lib_error = status;
return CMD_RET_LIBBLADERF;
} }
} }


status = bladerf_fw_version(state->dev, &fw_version); status = bladerf_fw_version(state->dev, &fw_version);
if (status < 0) { 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); printf(" Firmware version: %s\n", fw_version.describe);


Expand All @@ -63,17 +50,7 @@ int cmd_version(struct cli_state *state, int argc, char **argv)
printf(" FPGA version: Unknown (FPGA not loaded)\n"); 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"); printf("\n");


return CMD_RET_OK; return CMD_RET_OK;
} }


0 comments on commit cf552e3

Please sign in to comment.