changeset 283:64bb50fc470f

librftab reader: implemented reading of Tx ramps tables
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 18 Nov 2017 00:01:31 +0000
parents 90c475877d34
children 556bb8c860fa
files librftab/rftablerd.c
diffstat 1 files changed, 54 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/librftab/rftablerd.c	Fri Nov 17 23:48:49 2017 +0000
+++ b/librftab/rftablerd.c	Sat Nov 18 00:01:31 2017 +0000
@@ -112,6 +112,29 @@
 }
 
 static
+expect_keyword(kw)
+	char *kw;
+{
+	char *field;
+	int rc;
+
+	rc = get_field(&field);
+	if (rc < 0)
+		return(ERROR_USAGE);
+	if (!rc) {
+		printf("error: %s is too short for table format %s\n",
+			filename, format);
+		return(ERROR_USAGE);
+	}
+	if (strcmp(field, kw)) {
+		printf("%s line %d: expected %s keyword\n", filename, lineno,
+			kw);
+		return(ERROR_USAGE);
+	}
+	return(0);
+}
+
+static
 ensure_eof()
 {
 	char *field;
@@ -186,6 +209,36 @@
 }
 
 static
+read_tx_ramps()
+{
+	int i, j, rc;
+
+	if (maxsize < 512) {
+		printf("error: tx-ramps table not allowed in this context\n");
+		return(ERROR_USAGE);
+	}
+	for (i = 0; i < 16; i++) {
+		rc = expect_keyword("ramp-up");
+		if (rc)
+			return(rc);
+		for (j = 0; j < 16; j++) {
+			rc = process_number(1);
+			if (rc)
+				return(rc);
+		}
+		rc = expect_keyword("ramp-down");
+		if (rc)
+			return(rc);
+		for (j = 0; j < 16; j++) {
+			rc = process_number(1);
+			if (rc)
+				return(rc);
+		}
+	}
+	return ensure_eof();
+}
+
+static
 read_tx_levels()
 {
 	int i, rc;
@@ -306,6 +359,7 @@
 	{"afcparams", read_afcparams},
 	{"agc-global-params", read_agc_global_params},
 	{"il2agc", read_il2agc},
+	{"tx-ramps", read_tx_ramps},
 	{"tx-levels", read_tx_levels},
 	{"tx-calchan", read_tx_calchan},
 	{"tx-caltemp", read_tx_caltemp},