hackrf_debug: allow parse_int() to handle 32-bit parameters.

This commit is contained in:
Martin Ling
2021-12-24 09:53:28 +00:00
parent f0bc6eda30
commit 2f79c03b2c

View File

@ -36,7 +36,7 @@ typedef int bool;
#define REGISTER_INVALID 32767
int parse_int(char* s, uint16_t* const value) {
int parse_int(char* s, uint32_t* const value) {
uint_fast8_t base = 10;
char* s_end;
long long_value;
@ -56,7 +56,7 @@ int parse_int(char* s, uint16_t* const value) {
s_end = s;
long_value = strtol(s, &s_end, base);
if( (s != s_end) && (*s_end == 0) ) {
*value = (uint16_t)long_value;
*value = (uint32_t)long_value;
return HACKRF_SUCCESS;
} else {
return HACKRF_ERROR_INVALID_PARAM;
@ -431,8 +431,8 @@ static struct option long_options[] = {
int main(int argc, char** argv) {
int opt;
uint16_t register_number = REGISTER_INVALID;
uint16_t register_value;
uint32_t register_number = REGISTER_INVALID;
uint32_t register_value;
hackrf_device* device = NULL;
int option_index = 0;
bool read = false;
@ -442,7 +442,7 @@ int main(int argc, char** argv) {
uint8_t part = PART_NONE;
const char* serial_number = NULL;
bool set_ui = false;
uint16_t ui_enable;
uint32_t ui_enable;
int result = hackrf_init();
if(result) {