Skip to content

Commit 8e61565

Browse files
committed
Fix hydrasdr_set_samplerate() to support Firmware alt conf and fix few minor warnings
1 parent cb0ea52 commit 8e61565

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

hydrasdr-tools/src/hydrasdr_r82x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ uint8_t conf_r82x[] =
172172

173173
int configure_registers(struct hydrasdr_device* device)
174174
{
175-
int i, j;
175+
size_t i, j;
176176
uint8_t register_number;
177177
uint8_t register_value;
178178
int result = HYDRASDR_SUCCESS;

libhydrasdr/src/hydrasdr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static const hydrasdr_device_entry_t hydrasdr_device_registry[] = {
8585
*/
8686
static const hydrasdr_device_entry_t* find_device_by_vid_pid(uint16_t vid, uint16_t pid)
8787
{
88-
for (int i = 0; i < HYDRASDR_DEVICE_REGISTRY_COUNT; i++) {
88+
for (size_t i = 0; i < HYDRASDR_DEVICE_REGISTRY_COUNT; i++) {
8989
if (hydrasdr_device_registry[i].vid == vid &&
9090
hydrasdr_device_registry[i].pid == pid) {
9191
return &hydrasdr_device_registry[i];
@@ -100,7 +100,7 @@ static const hydrasdr_device_entry_t* find_device_by_vid_pid(uint16_t vid, uint1
100100
*/
101101
static const hydrasdr_device_entry_t* find_device_by_board_id(enum hydrasdr_board_id board_id)
102102
{
103-
for (int i = 0; i < HYDRASDR_DEVICE_REGISTRY_COUNT; i++) {
103+
for (size_t i = 0; i < HYDRASDR_DEVICE_REGISTRY_COUNT; i++) {
104104
if (hydrasdr_device_registry[i].board_id == board_id) {
105105
return &hydrasdr_device_registry[i];
106106
}

libhydrasdr/src/hydrasdr_shared.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ static int hydrasdr_create_io_threads(hydrasdr_streaming_t* stream, hydrasdr_sam
990990
{
991991
int result;
992992
pthread_attr_t attr;
993+
(void)callback;
993994

994995
/* Note: streaming flag is already set by hydrasdr_start_streaming()
995996
* before USB transfers are submitted (to avoid race condition).
@@ -1505,15 +1506,19 @@ static int rate_compare_desc(const void *a, const void *b)
15051506
*/
15061507
int hydrasdr_generic_build_virtual_samplerates(struct hydrasdr_device* dev)
15071508
{
1508-
hydrasdr_streaming_t* stream = (hydrasdr_streaming_t*)dev->private_data;
1509+
hydrasdr_streaming_t* stream;
15091510
uint32_t *temp_rates;
15101511
uint32_t temp_count = 0;
15111512
uint32_t max_rates;
15121513
uint32_t i, d, j;
15131514
uint32_t unique_count;
15141515
static const uint32_t dec_factors[] = {1, 2, 4, 8, 16, 32, 64};
15151516

1516-
if (!dev || !stream) {
1517+
if (!dev) {
1518+
return HYDRASDR_ERROR_INVALID_PARAM;
1519+
}
1520+
stream = (hydrasdr_streaming_t*)dev->private_data;
1521+
if (!stream) {
15171522
return HYDRASDR_ERROR_INVALID_PARAM;
15181523
}
15191524

@@ -1896,7 +1901,9 @@ int hydrasdr_generic_set_samplerate(struct hydrasdr_device* dev, uint32_t sample
18961901
}
18971902

18981903
if (!found) {
1899-
return HYDRASDR_ERROR_INVALID_PARAM;
1904+
/* Let firmware decide (alt config rates) */
1905+
hw_rate = samplerate;
1906+
decimation = 1;
19001907
}
19011908
}
19021909

0 commit comments

Comments
 (0)