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

quad: re-enable communciation functional test

- and improve output of functional tests overall
parent 4e99f95b
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ test: all
$(MAKE) -C src/quad_app test
ruby scripts/tests/test_safety_checks.rb
ruby scripts/tests/test_memory_integrity.rb
# ruby scripts/tests/test_unix_uart.rb
ruby scripts/tests/test_communication.rb
clean:
rm -rf $(INCDIR) $(LIBDIR) $(OUTDIR) $(EXEDIR)
......
......@@ -11,7 +11,6 @@ require script_dir + "/testing_library"
bin_dir = script_dir + "/../../bin/"
Dir.chdir(bin_dir)
Timeout::timeout(30) {
puts("Setting up...")
......@@ -23,7 +22,20 @@ Timeout::timeout(30) {
{ :rlimit_as => 536870912, # 512 MiB total RAM
:rlimit_stack => 1048576}) # 1 MiB stack
delay_spin_cursor(5)
delay_spin_cursor(1)
# Set RC switches
set_gear GEAR_OFF
set_flap FLAP_OFF
# Set initial quad orientation (flat on the ground, facing forward)
`./virt-quad set i2c_imu_x 0`
`./virt-quad set i2c_imu_y 0`
`./virt-quad set i2c_imu_z -1`
`./virt-quad set rc_roll 0.498`
`./virt-quad set rc_pitch 0.497`
`./virt-quad set rc_yaw 0.498`
#################
# Begin Tests
......@@ -31,39 +43,25 @@ Timeout::timeout(30) {
begin
puts("Beginning tests...")
# Flip gear on
File.write(GEAR, GEAR_ON)
sleep 0.015
puts "------------------------------------------"
puts "-- Beginning basic communication test..."
puts "------------------------------------------"
for j in 1..10
# Send a debug command
File.write(UART_RX, [0xBE, 1, 0, 0, 0, 0, 0, 0xBF].pack("CCCCCCCC"))
fifo = File.open(UART_TX)
# Receive the header
msg = []
for i in 1..7
sleep 0.010
msg.push(fifo.read(1))
end
# Receive the remaining data, according to the header specified length
length = msg[5..7].join().unpack("S")[0]
msg = []
for i in 1..length
sleep 0.010
msg.push(fifo.read(1))
end
fifo.close
puts msg.join()
assert_equal(msg.join().force_encoding("UTF-8"), "Packets received: #{j}")
Thread.new {
sleep 0.1
send_packet [0xBE, 1, 0, 0, 0, 0, 0, 0xBF]
}
msg = recv_packet
puts msg
assert_equal(msg.force_encoding("UTF-8"), "Packets received: #{j}")
end
puts "Basic UART test passed."
puts "Basic communication test passed."
puts "------------------------------------------"
ensure
......
......@@ -26,7 +26,9 @@ set_flap FLAP_ON
##################
begin
puts("Starting flight...")
puts "------------------------------------------"
puts "-- Beginning memory integrity test..."
puts "------------------------------------------"
# Set initial quad orientation (flat on ground, facing forward)
`./virt-quad set i2c_imu_x 0`
......@@ -94,12 +96,14 @@ ensure
everything = file.readlines
last_line = everything.last
errors = last_line.scanf("%s ERROR SUMMARY: %d errors %s")
puts everything
if errors[1] > 0
puts everything
puts "Memory Integrity Check Failed."
puts "------------------------------------------"
Kernel.exit(1)
end
puts "Memory Integrity Check Passed."
puts "------------------------------------------"
end
......@@ -40,7 +40,9 @@ Timeout::timeout(60) {
#################
begin
puts("Beginning tests...")
puts "------------------------------------------"
puts "-- Beginning safety checks test..."
puts "------------------------------------------"
puts("Check that motors are off at startup")
check_motors_are_off "Motors weren't off at startup! How dangerous!"
......@@ -141,6 +143,7 @@ Timeout::timeout(60) {
set_throttle THROTTLE_MIN
puts "All safety checks passed."
puts "------------------------------------------"
ensure
......
......@@ -13,20 +13,6 @@ FLAP_ON = 0.9
FLAP_OFF = 0.1
GRAVITY = 4096
MOTOR1 = "virt-quad-fifos/motor1"
MOTOR2 = "virt-quad-fifos/motor2"
MOTOR3 = "virt-quad-fifos/motor3"
MOTOR4 = "virt-quad-fifos/motor4"
GEAR = "virt-quad-fifos/rc-gear"
THROTTLE = "virt-quad-fifos/rc-throttle"
LED = "virt-quad-fifos/mio7-led"
I2C_MPU_ACCEL_X = "virt-quad-fifos/i2c-mpu-accel-x"
I2C_MPU_ACCEL_Y = "virt-quad-fifos/i2c-mpu-accel-y"
I2C_MPU_ACCEL_Z = "virt-quad-fifos/i2c-mpu-accel-z"
UART_RX = "virt-quad-fifos/uart-rx"
UART_TX = "virt-quad-fifos/uart-tx"
......@@ -92,3 +78,30 @@ def delay_spin_cursor(delay)
print "\b"
end
end
def send_packet(bytes)
File.write(UART_RX, bytes.pack("C" * bytes.length))
end
def recv_packet
fifo = File.open(UART_TX)
# Receive the header
msg = []
for i in 1..7
sleep 0.010
c = fifo.read(1)
msg.push(c)
end
# Receive the remaining data, according to the header specified length
length = msg[5..7].join().unpack("S")[0]
msg = []
for i in 1..length
sleep 0.010
msg.push(fifo.read(1))
end
fifo.close
msg.join()
end
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