Skip to content
Snippets Groups Projects
Commit b8d277cb authored by bbartels's avatar bbartels
Browse files

quad: enable virtual quad to take a quiet flag to silence output

this resolves #3
parent 192d5c4e
No related branches found
No related tags found
No related merge requests found
...@@ -11,10 +11,12 @@ require script_dir + "/testing_library" ...@@ -11,10 +11,12 @@ require script_dir + "/testing_library"
bin_dir = script_dir + "/../../bin/" bin_dir = script_dir + "/../../bin/"
Dir.chdir(bin_dir) Dir.chdir(bin_dir)
puts("Firing up the quad...")
# Start virtual quad # Start virtual quad
quad = Process.spawn("./virt-quad") quad = Process.spawn("./virt-quad -q")
sleep 1 delay_spin_cursor(3)
################## ##################
# Begin Flight! # Begin Flight!
...@@ -37,7 +39,7 @@ begin ...@@ -37,7 +39,7 @@ begin
end end
puts("Hovering for 10 seconds") puts("Hovering for 10 seconds")
sleep 10 delay_spin_cursor(10)
puts("Relaxing thrust to zero") puts("Relaxing thrust to zero")
i = THROTTLE_MID i = THROTTLE_MID
......
...@@ -20,11 +20,11 @@ Timeout::timeout(30) { ...@@ -20,11 +20,11 @@ Timeout::timeout(30) {
sleep 1 sleep 1
# Start virtual quad # Start virtual quad
quad_pid = Process.spawn("./virt-quad", quad_pid = Process.spawn("./virt-quad -q",
{ :rlimit_as => 536870912, # 512 MiB total RAM { :rlimit_as => 536870912, # 512 MiB total RAM
:rlimit_stack => 1048576}) # 1 MiB stack :rlimit_stack => 1048576}) # 1 MiB stack
sleep 5 delay_spin_cursor(5)
################# #################
# Begin Tests # Begin Tests
...@@ -83,7 +83,7 @@ Timeout::timeout(30) { ...@@ -83,7 +83,7 @@ Timeout::timeout(30) {
puts averages, "(#{average})" puts averages, "(#{average})"
assert average.between?(THROTTLE_EIGHTH, MOTOR_MAX) assert average.between?(THROTTLE_EIGHTH, MOTOR_MAX)
# Check that gear switch kills the motors puts("Check that gear switch kills the motors")
# (and that light goes off) # (and that light goes off)
File.write(GEAR, GEAR_OFF) File.write(GEAR, GEAR_OFF)
sleep 0.1 sleep 0.1
......
...@@ -19,11 +19,11 @@ Timeout::timeout(30) { ...@@ -19,11 +19,11 @@ Timeout::timeout(30) {
sleep 1 sleep 1
# Start virtual quad # Start virtual quad
quad_pid = Process.spawn("./virt-quad", quad_pid = Process.spawn("./virt-quad -q",
{ :rlimit_as => 536870912, # 512 MiB total RAM { :rlimit_as => 536870912, # 512 MiB total RAM
:rlimit_stack => 1048576}) # 1 MiB stack :rlimit_stack => 1048576}) # 1 MiB stack
sleep 5 delay_spin_cursor(5)
################# #################
# Begin Tests # Begin Tests
......
...@@ -75,3 +75,15 @@ def check_led(is_on) ...@@ -75,3 +75,15 @@ def check_led(is_on)
led = read_fifo_num(LED) led = read_fifo_num(LED)
assert_equal(led, is_on) assert_equal(led, is_on)
end end
def delay_spin_cursor(delay)
fps = 10
chars = %w[| / - \\]
iteations = delay * fps
iter = 0
iteations.times() do
print chars[(iter+=1) % chars.length]
sleep (1.0/fps)
print "\b"
end
end
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include "hw_impl_unix.h" #include "hw_impl_unix.h"
#include "quad_app.h" #include "quad_app.h"
#include <fcntl.h>
int setup_hardware(hardware_t *hardware) { int setup_hardware(hardware_t *hardware) {
hardware->i2c = create_unix_i2c(); hardware->i2c = create_unix_i2c();
...@@ -14,8 +16,21 @@ int setup_hardware(hardware_t *hardware) { ...@@ -14,8 +16,21 @@ int setup_hardware(hardware_t *hardware) {
return 0; return 0;
} }
int main() int main(int argc, char *argv[]) {
{ int fd, opt;
while ((opt = getopt(argc, argv, "q")) != -1) {
switch (opt) {
case 'q':
fd = open("/dev/null", O_WRONLY);
close(STDOUT_FILENO);
dup2(STDOUT_FILENO, fd);
break;
default: /* '?' */
fprintf(stderr, "Usage: %s [-q]\n", argv[0]);
exit(EXIT_FAILURE);
}
}
quad_main(setup_hardware); quad_main(setup_hardware);
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment