summaryrefslogtreecommitdiff
path: root/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
diff options
context:
space:
mode:
authorandrew-elder <andrew_elder@pobox.com>2021-06-22 11:02:29 -0400
committerGitHub <noreply@github.com>2021-06-22 11:02:29 -0400
commit90065dc56717761008c357b57407ee591faad9e8 (patch)
tree301179b5769d300a2a5bbee17d58a2da78d3f358 /lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
parentb4b986082f06f5b9882e18710c8638246eb98cf5 (diff)
parent12d5c8317c398f7fc7fccf85f35b5673a99f77cb (diff)
downloadOpen-AVB-90065dc56717761008c357b57407ee591faad9e8.tar.gz
Merge pull request #915 from MarcinMiklas/configuration_options_can_be_changed_at_runtimeopen-avb-next
Configuration options can be changed at runtime
Diffstat (limited to 'lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c')
-rw-r--r--lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c b/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
index 6802c447..98535ab4 100644
--- a/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
+++ b/lib/avtp_pipeline/platform/Linux/avb_host/openavb_harness.c
@@ -150,6 +150,7 @@ void openavbTlHarnessMenu()
" t Stop all streams\n"
" l List streams\n"
" 0-99 Toggle the state of the numbered stream\n"
+ " c N NAME VAL Change config option for stream N\n"
" m Display this menu\n"
" z Stats\n"
" x Exit\n"
@@ -157,6 +158,39 @@ void openavbTlHarnessMenu()
);
}
+// manually matches following regular expression:
+//
+// /(\d+)\s+([^\s]+)\s+(.*)\s*/
+//
+// where:
+// $1 - idx
+// $2 - name
+// $3 - value
+int parse_idx_name_value(char* line, int* pIdx, char** pName, char** pValue)
+{
+ char *token = NULL;
+
+ int tmp = strtol(line, &token, 10);
+ if (token == line) return 0;
+ *pIdx = tmp;
+
+ while (isspace(*token)) ++token;
+ if (*token == '\0') return 1;
+
+ *pName = token;
+ while (!isspace(*++token) && *token != '\0') ;
+ if (*token == '\0') return 2;
+ *token = '\0';
+
+ while (isspace(*++token)) ;
+ if (*token == '\0') return 2;
+ *pValue = token;
+
+ token += strlen(token);
+ while (isspace(*--token) && *token != '\0') *token = '\0';
+
+ return 3;
+}
/**********************************************
* main
@@ -403,7 +437,7 @@ int main(int argc, char *argv[])
openavbTlHarnessMenu();
while (bRunning) {
- char buf[16];
+ char buf[512];
printf("> ");
if (fgets(buf, sizeof(buf), stdin) == NULL) {
openavbTlHarnessMenu();
@@ -449,10 +483,26 @@ int main(int argc, char *argv[])
}
}
break;
+ case 'c':
+ {
+ int i1 = -1;
+ char *name = NULL;
+ char *value = NULL;
+
+ if (parse_idx_name_value(&buf[1], &i1, &name, &value) == 3 && i1 < tlCount) {
+ openavb_tl_cfg_name_value_t NVCfg = {{name}, {value}, 1};
+ openavbTlChangeConfig(tlHandleList[i1], &NVCfg);
+ } else {
+ openavbTlHarnessMenu();
+ }
+
+ }
+ break;
case 'm':
// Display menu
openavbTlHarnessMenu();
break;
+
case 'z':
// Stats
{