-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "ignitor.h" | ||
|
||
Ignitor::Ignitor(){ | ||
wiringPiSetupGpio(); | ||
pinMode(IG_0, OUTPUT); | ||
pinMode(IG_1, OUTPUT); | ||
|
||
// write low initially | ||
digitalWrite(IG_0, LOW); | ||
digitalWrite(IG_1, LOW); | ||
} | ||
|
||
Ignitor::~Ignitor(){} | ||
|
||
bool Ignitor::Actuate(){ | ||
digitalWrite(IG_0, HIGH); | ||
digitalWrite(IG_1, HIGH); | ||
delay(1000); | ||
digitalWrite(IG_0, LOW); | ||
digitalWrite(IG_1, LOW); | ||
} | ||
|
||
bool Ignitor::isActuating(){} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef IGNITOR_H | ||
#define IGNITOR_H | ||
|
||
#include "actuator.h" | ||
#include "wiringPi.h" | ||
|
||
#define IG_0 17 | ||
#define IG_1 27 | ||
|
||
class Ignitor : public Actuator{ | ||
public: | ||
Ignitor(); | ||
~Ignitor(); | ||
bool Actuate(); | ||
bool isActuating(); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
# Check if grpcurl is already installed | ||
if ! command -v grpcurl &> /dev/null; then | ||
echo "Installing grpcurl..." | ||
wget https://github.com/fullstorydev/grpcurl/releases/download/v1.9.1/grpcurl_1.9.1_linux_amd64.deb | ||
sudo apt install ./grpcurl_1.9.1_linux_amd64.deb | ||
rm ./grpcurl_1.9.1_linux_amd64.deb # Clean up the downloaded deb file | ||
echo "grpcurl installed." | ||
fi | ||
|
||
# Capture output and check against expected value | ||
# Run fill_station in the background and capture its PID | ||
stdbuf -oL ./bazel-bin/fill/fill_station > fill_station_output.txt 2>&1 & | ||
fill_station_pid=$! | ||
|
||
# Wait for fill_station to start listening | ||
while [[ ! $(grep "Server listening on" fill_station_output.txt) ]]; do | ||
sleep 0.1 # Check every 0.1 seconds | ||
if [[ $(ps -p $fill_station_pid) == "" ]]; then | ||
echo "fill_station died unexpectedly" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Send grpcurl command | ||
grpcurl -plaintext -d '{"ignite": true}' localhost:50051 command.Commander/SendCommand | ||
grpcurl -plaintext -d '{"ignite": false}' localhost:50051 command.Commander/SendCommand | ||
|
||
# Kill fill_station after a timeout (adjust timeout as needed) | ||
sleep 2 | ||
pkill -9 -f fill_station | ||
|
||
actual_output=$(cat fill_station_output.txt) | ||
expected_output=$(cat ./fill/test/ignitor_test_expected_output.txt) | ||
if [[ "$actual_output" != "$expected_output" ]]; then | ||
echo "Output mismatch:" | ||
echo "Expected:" | ||
echo "$expected_output" | ||
echo "Actual:" | ||
echo "$actual_output" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[MOCK] wiringPiSetupGpio called | ||
[MOCK] pinMode called, pin: 5, mode: 1 | ||
[MOCK] pinMode called, pin: 6, mode: 1 | ||
[MOCK] pinMode called, pin: 22, mode: 1 | ||
[MOCK] pinMode called, pin: 26, mode: 1 | ||
[MOCK] wiringPiSetupGpio called | ||
[MOCK] pinMode called, pin: 24, mode: 1 | ||
[MOCK] pinMode called, pin: 23, mode: 1 | ||
[MOCK] digitalWrite called, pin: 24, value: 0 | ||
[MOCK] digitalWrite called, pin: 23, value: 0 | ||
[MOCK] wiringPiSetupGpio called | ||
[MOCK] pinMode called, pin: 13, mode: 1 | ||
[MOCK] digitalWrite called, pin: 13, value: 0 | ||
[MOCK] wiringPiSetupGpio called | ||
[MOCK] pinMode called, pin: 17, mode: 1 | ||
[MOCK] pinMode called, pin: 27, mode: 1 | ||
[MOCK] digitalWrite called, pin: 17, value: 0 | ||
[MOCK] digitalWrite called, pin: 27, value: 0 | ||
setting up ADS with m_i2cAddress = 72 | ||
[MOCK] wiringPiI2CSetup called with devId: 72 | ||
m_i2cFd = 72 | ||
setting up ADS with m_i2cAddress = 72 | ||
[MOCK] wiringPiI2CSetup called with devId: 72 | ||
m_i2cFd = 72 | ||
Error opening /dev/rocket. | ||
Error getting termios attributes. | ||
Error setting termios attributes. | ||
Server listening on 0.0.0.0:50051 | ||
[MOCK] digitalWrite called, pin: 17, value: 1 | ||
[MOCK] digitalWrite called, pin: 27, value: 1 | ||
[MOCK] delay called, howLong: 1000 (usleep used in mock) | ||
[MOCK] digitalWrite called, pin: 17, value: 0 | ||
[MOCK] digitalWrite called, pin: 27, value: 0 |