fix unit parsing (missin 'strcmp == 0')

This commit is contained in:
hallgato 2025-02-21 18:02:45 +01:00
parent 8010b7e24f
commit 00efdf84f1

View File

@ -92,17 +92,17 @@ PS2000_RANGE parse_range(char* range) {
} }
PS2000_TIME_UNITS parse_units(char* unit) { PS2000_TIME_UNITS parse_units(char* unit) {
if (strcmp(unit, "fs")) if (strcmp(unit, "fs") == 0)
return PS2000_FS; return PS2000_FS;
if (strcmp(unit, "ps")) if (strcmp(unit, "ps") == 0)
return PS2000_PS; return PS2000_PS;
if (strcmp(unit, "ns")) if (strcmp(unit, "ns") == 0)
return PS2000_US; return PS2000_US;
if (strcmp(unit, "us")) if (strcmp(unit, "us") == 0)
return PS2000_US; return PS2000_US;
if (strcmp(unit, "ms")) if (strcmp(unit, "ms") == 0)
return PS2000_MS; return PS2000_MS;
if (strcmp(unit, "s")) if (strcmp(unit, "s") == 0)
return PS2000_S; return PS2000_S;
return PS2000_MAX_TIME_UNITS; return PS2000_MAX_TIME_UNITS;
} }
@ -145,8 +145,8 @@ int main(int argc, char** argv) {
return -1; return -1;
} }
PS2000_TIME_UNITS selected_units = parse_units(*time_units); PS2000_TIME_UNITS selected_unit = parse_units(*time_units);
if (selected_units == PS2000_MAX_TIME_UNITS) { if (selected_unit == PS2000_MAX_TIME_UNITS) {
fprintf(stderr, "invalid time unit: %s\n", *time_units); fprintf(stderr, "invalid time unit: %s\n", *time_units);
return -1; return -1;
} }
@ -178,7 +178,7 @@ int main(int argc, char** argv) {
} }
// start data capture without aggregation // start data capture without aggregation
if (ps2000_run_streaming_ns(unit, *sample_interval, selected_units, *buffersize, false, 1, *max_buffersize) == 0) { if (ps2000_run_streaming_ns(unit, *sample_interval, selected_unit, *buffersize, false, 1, *max_buffersize) == 0) {
fprintf(stderr, "run_streaming_ns failed!\n"); fprintf(stderr, "run_streaming_ns failed!\n");
cleanup(unit); cleanup(unit);
return -1; return -1;
@ -194,4 +194,4 @@ int main(int argc, char** argv) {
cleanup(unit); cleanup(unit);
return 0; return 0;
} }