diff --git a/client/experimental_lib/example_c/02run_test.sh b/client/experimental_lib/example_c/02run_test.sh index a3e4ec057..7da0e3700 100755 --- a/client/experimental_lib/example_c/02run_test.sh +++ b/client/experimental_lib/example_c/02run_test.sh @@ -1,3 +1,3 @@ #!/bin/bash -LD_LIBRARY_PATH=../build ./test +LD_LIBRARY_PATH=../build ./test /dev/ttyACM0 diff --git a/client/experimental_lib/example_c/02run_test_grab.sh b/client/experimental_lib/example_c/02run_test_grab.sh index 2dd6f892b..93545c422 100755 --- a/client/experimental_lib/example_c/02run_test_grab.sh +++ b/client/experimental_lib/example_c/02run_test_grab.sh @@ -1,3 +1,3 @@ #!/bin/bash -LD_LIBRARY_PATH=../build ./test_grab +LD_LIBRARY_PATH=../build ./test_grab /dev/ttyACM0 diff --git a/client/experimental_lib/example_c/test.c b/client/experimental_lib/example_c/test.c index a3cf212dc..319b6b08e 100644 --- a/client/experimental_lib/example_c/test.c +++ b/client/experimental_lib/example_c/test.c @@ -1,8 +1,14 @@ +#include +#include #include "pm3.h" int main(int argc, char *argv[]) { + if (argc < 2) { + printf("Usage: %s \n", argv[0]); + exit(-1); + } pm3 *p; - p = pm3_open("/dev/ttyACM0"); + p = pm3_open(argv[1]); pm3_console(p, "hw status"); pm3_close(p); } diff --git a/client/experimental_lib/example_c/test_grab.c b/client/experimental_lib/example_c/test_grab.c index f4a6c64bf..c785361ba 100644 --- a/client/experimental_lib/example_c/test_grab.c +++ b/client/experimental_lib/example_c/test_grab.c @@ -10,6 +10,11 @@ int main(int argc, char *argv[]) { char buf[8196 + 1]; size_t n; + if (argc < 2) { + printf("Usage: %s \n", argv[0]); + exit(-1); + } + if (pipe(pipefd) == -1) { exit(-1); } @@ -31,8 +36,7 @@ int main(int argc, char *argv[]) { close(pipefd[1]); // Close original write end pm3 *p; - p = pm3_open("/dev/ttyS9"); - //printf("Device: %s\n", pm3_name_get(p)); + p = pm3_open(argv[1]); // Execute the command pm3_console(p, "hw status"); @@ -55,6 +59,9 @@ int main(int argc, char *argv[]) { } else { // null termination buf[n] = 0; + if (strstr(buf, "ERROR") != NULL) { + printf("%s", buf); + } if (strstr(buf, "Unique ID") != NULL) { printf("%s", buf); }