From 3ad2dc9d2a92e4b014970bc9276d4f8f015a98f8 Mon Sep 17 00:00:00 2001 From: Joshua Hill Date: Tue, 11 Jul 2017 19:07:38 -0400 Subject: [PATCH 1/2] fixed ports to allow users to pass port name on board --- host/hackrf-tools/src/hackrf_operacake.c | 31 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/host/hackrf-tools/src/hackrf_operacake.c b/host/hackrf-tools/src/hackrf_operacake.c index 1d28f288..93c686c9 100644 --- a/host/hackrf-tools/src/hackrf_operacake.c +++ b/host/hackrf-tools/src/hackrf_operacake.c @@ -92,9 +92,31 @@ int parse_u16_range(char* s, hackrf_oc_range* range) { result = parse_uint16(sep + 1, &range->freq_max); if (result != HACKRF_SUCCESS) return result; - result = parse_uint16(sep2 + 1, &port); - if (result != HACKRF_SUCCESS) - return result; + + sep2++; // Skip past the ':' + if(sep2[0] == 'A' || sep2[0] == 'B') { + // The port was specified as a side and number eg. A1 or B3 + if(sep2[1] > 0x30 && sep2[1] < 0x35) { + uint16_t tmp_port = sep2[1] - 0x30; + if(tmp_port >= 5 || tmp_port <= 0) + return HACKRF_ERROR_INVALID_PARAM; + + // Value was a valid port between 0-4 + if(sep2[0] == 'A') { + // A1=0, A2=1, A3=2, A4=3 + port = (uint16_t) tmp_port-1; + } else { + // If B was specfied just add 4-1 ports + // B1=4, B2=5, B3=6, B4=7 + port = (uint16_t) tmp_port+3; + } + //printf("Setting port %c%c to port %d\n", sep2[0], sep2[1], (uint16_t)port); + } + } else { + result = parse_uint16(sep2, &port); + if (result != HACKRF_SUCCESS) + return result; + } range->port = port; return HACKRF_SUCCESS; @@ -148,8 +170,7 @@ int main(int argc, char** argv) { usage(); return EXIT_FAILURE; } - range_idx++; - if(MAX_FREQ_RANGES <= range_idx) { + if(MAX_FREQ_RANGES <= range_idx++) { fprintf(stderr, "argument error: specify a maximum of %u frequency ranges.\n", MAX_FREQ_RANGES); From 42924698c569dc4129a83474a37e5e747744f2af Mon Sep 17 00:00:00 2001 From: Joshua Hill Date: Tue, 11 Jul 2017 19:54:44 -0400 Subject: [PATCH 2/2] OperaCake: fixes travis build errors --- host/hackrf-tools/src/hackrf_operacake.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/hackrf-tools/src/hackrf_operacake.c b/host/hackrf-tools/src/hackrf_operacake.c index 93c686c9..ad06d39c 100644 --- a/host/hackrf-tools/src/hackrf_operacake.c +++ b/host/hackrf-tools/src/hackrf_operacake.c @@ -73,8 +73,8 @@ int parse_uint16(char* const s, uint16_t* const value) { } int parse_u16_range(char* s, hackrf_oc_range* range) { - int result; - uint16_t port; + int result = 0; + uint16_t port = 0; char *sep = strchr(s, ':'); if (!sep)