Rename test exec
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 22 Feb 2018 06:21:27 +0000 (22:21 -0800)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 22 Feb 2018 06:21:27 +0000 (22:21 -0800)
scripts/reset-video [new file with mode: 0755]
src/avr/test/Makefile
src/avr/test/firmware-test.c [new file with mode: 0644]
src/avr/test/planner-test.c [deleted file]

diff --git a/scripts/reset-video b/scripts/reset-video
new file mode 100755 (executable)
index 0000000..94b46cd
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+import sys
+import subprocess
+import os.path
+import time
+
+if not os.path.exists('/dev/video0'):
+    print('/dev/video0 not found')
+    sys.exit(1)
+
+p = subprocess.Popen('udevadm info -q path /dev/video0'.split(),
+                     stdout = subprocess.PIPE)
+s = p.communicate()[0].decode('utf-8')
+dev = s.split('/')[7]
+
+with open('/sys/bus/usb/drivers/usb/unbind', 'w') as f:
+    f.write(dev)
+
+time.sleep(1)
+
+with open('/sys/bus/usb/drivers/usb/bind', 'w') as f:
+    f.write(dev)
index 06ece7a576df1231759e7a16f0cf91ef862f33d6..350416005af8d7f65ed708c72540e8e58f69c090 100644 (file)
@@ -1,28 +1,28 @@
-TESTS=planner-test
+TARGET=firmware-test
 
-PLANNER_TEST_SRC = status.c util.c axis.c report.c type.c exec.c base64.c \
+FIRMWARE_TEST_SRC = status.c util.c axis.c report.c type.c exec.c base64.c \
   command.c commands.c vars.c state.c line.c scurve.c seek.c
-PLANNER_TEST_SRC := $(patsubst %,../src/%,$(PLANNER_TEST_SRC))
-PLANNER_TEST_SRC += $(wildcard ../src/plan/*.c) planner-test.c hal.c
+FIRMWARE_TEST_SRC := $(patsubst %,../src/%,$(FIRMWARE_TEST_SRC))
+FIRMWARE_TEST_SRC += $(wildcard ../src/plan/*.c) firmware-test.c hal.c
 
 CFLAGS = -I../src -Wall -Werror -DDEBUG -g -std=gnu99
 CFLAGS += -MD -MP -MT $@ -MF .dep/$(@F).d
 CFLAGS += -DF_CPU=320000000
 LDFLAGS = -lm
 
-all: $(TESTS)
+all: $(TARGET)
 
-planner-test: $(PLANNER_TEST_SRC)
-       gcc -o $@ $(PLANNER_TEST_SRC) $(CFLAGS) $(LDFLAGS)
+$(TARGET): $(FIRMWARE_TEST_SRC)
+       gcc -o $@ $(FIRMWARE_TEST_SRC) $(CFLAGS) $(LDFLAGS)
 
-%.csv: %.gc planner-test
-       ./planner-test < $< | grep -E '^-?[0-9.]+,'
+%.csv: %.gc firmware-test
+       ./firmware-test < $< | grep -E '^-?[0-9.]+,'
 
-%-test: %.gc planner-test
-       ./planner-test < $<
+%-test: %.gc firmware-test
+       ./firmware-test < $<
 
-%-plot: %.gc planner-test
-       ./planner-test < $< | grep -E '^-?[0-9.]+,' | ./plot.py
+%-plot: %.gc firmware-test
+       ./firmware-test < $< | grep -E '^-?[0-9.]+,' | ./plot.py
 
 # Clean
 tidy:
diff --git a/src/avr/test/firmware-test.c b/src/avr/test/firmware-test.c
new file mode 100644 (file)
index 0000000..ae51a31
--- /dev/null
@@ -0,0 +1,75 @@
+/******************************************************************************\
+
+                 This file is part of the Buildbotics firmware.
+
+                   Copyright (c) 2015 - 2018, Buildbotics LLC
+                              All rights reserved.
+
+      This file ("the software") is free software: you can redistribute it
+      and/or modify it under the terms of the GNU General Public License,
+       version 2 as published by the Free Software Foundation. You should
+       have received a copy of the GNU General Public License, version 2
+      along with the software. If not, see <http://www.gnu.org/licenses/>.
+
+      The software is distributed in the hope that it will be useful, but
+           WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+                Lesser General Public License for more details.
+
+        You should have received a copy of the GNU Lesser General Public
+                 License along with the software.  If not, see
+                        <http://www.gnu.org/licenses/>.
+
+                 For information regarding this software email:
+                   "Joseph Coffland" <joseph@buildbotics.com>
+
+\******************************************************************************/
+
+#include "axis.h"
+#include "command.h"
+#include "exec.h"
+#include "state.h"
+#include "vars.h"
+#include "report.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int main(int argc, char *argv[]) {
+  axis_map_motors();
+  exec_init();                    // motion exec
+  vars_init();                    // configuration variables
+  command_init();
+
+  stat_t status = STAT_OK;
+
+  while (true) {
+    bool reading = !feof(stdin);
+
+    report_callback();
+
+    if (reading) {
+      state_callback();
+      if (command_callback()) continue;
+    }
+
+    status = exec_next();
+    printf("EXEC: %s\n", status_to_pgmstr(status));
+
+    switch (status) {
+    case STAT_NOP: break;       // No command executed
+    case STAT_AGAIN: continue;  // No command executed, try again
+    case STAT_OK: continue;     // Move executed
+
+    default:
+      printf("ERROR: %s\n", status_to_pgmstr(status));
+    }
+
+    if (!reading) break;
+  }
+
+  printf("STATE: %s\n", state_get_pgmstr(state_get()));
+
+  return 0;
+}
diff --git a/src/avr/test/planner-test.c b/src/avr/test/planner-test.c
deleted file mode 100644 (file)
index ae51a31..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/******************************************************************************\
-
-                 This file is part of the Buildbotics firmware.
-
-                   Copyright (c) 2015 - 2018, Buildbotics LLC
-                              All rights reserved.
-
-      This file ("the software") is free software: you can redistribute it
-      and/or modify it under the terms of the GNU General Public License,
-       version 2 as published by the Free Software Foundation. You should
-       have received a copy of the GNU General Public License, version 2
-      along with the software. If not, see <http://www.gnu.org/licenses/>.
-
-      The software is distributed in the hope that it will be useful, but
-           WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-                Lesser General Public License for more details.
-
-        You should have received a copy of the GNU Lesser General Public
-                 License along with the software.  If not, see
-                        <http://www.gnu.org/licenses/>.
-
-                 For information regarding this software email:
-                   "Joseph Coffland" <joseph@buildbotics.com>
-
-\******************************************************************************/
-
-#include "axis.h"
-#include "command.h"
-#include "exec.h"
-#include "state.h"
-#include "vars.h"
-#include "report.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-
-int main(int argc, char *argv[]) {
-  axis_map_motors();
-  exec_init();                    // motion exec
-  vars_init();                    // configuration variables
-  command_init();
-
-  stat_t status = STAT_OK;
-
-  while (true) {
-    bool reading = !feof(stdin);
-
-    report_callback();
-
-    if (reading) {
-      state_callback();
-      if (command_callback()) continue;
-    }
-
-    status = exec_next();
-    printf("EXEC: %s\n", status_to_pgmstr(status));
-
-    switch (status) {
-    case STAT_NOP: break;       // No command executed
-    case STAT_AGAIN: continue;  // No command executed, try again
-    case STAT_OK: continue;     // Move executed
-
-    default:
-      printf("ERROR: %s\n", status_to_pgmstr(status));
-    }
-
-    if (!reading) break;
-  }
-
-  printf("STATE: %s\n", state_get_pgmstr(state_get()));
-
-  return 0;
-}