Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VsCode task runner with 1 click FC Docker image builder and compiling script. #7

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions OnPod/FlightComputer/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echoTest",
"type": "shell",
"command": "echo 'Hello taskrunner test good.'",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "build FC Image",
"type": "shell",
"command": "docker build -t pi_fc:v1 SetupScriptPlusDockerfile/.",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "compile and run FC HelloWorld",
"type": "shell",
"command": "docker run -it -v /c/hyperloop/comp5-software/OnPod/FlightComputer:/home/data --entrypoint helloTest.sh pi_fc:v1",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
11 changes: 11 additions & 0 deletions OnPod/FlightComputer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Flight Computer devlopment
- Ensure Docker is installed and running on your machine
## Taskrunner setup for VsCode
- install VsCode `Tasks' extension by actboy168
- open comp5-software\OnPod\FlightComputer folder with VsCode
- replace the folder bath in .vscode/tasks.json line 28 command:`compile and run RC HelloWorld`, with your path. replace this -> `/c/hyperloop/comp5-software/OnPod/FlightComputer`
- Try task buttons in blue taskbar at bottom of VsCode window:
`echoTest` // should print `Hello taskrunner test good.`
`build FC Image` // should build FC image `pi_fc:v1`
`compile and run RC HellowWorld` // should print `---- Hello Paradigm!!! ----`

26 changes: 24 additions & 2 deletions OnPod/FlightComputer/SetupScriptPlusDockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
FROM raspbian/stretch:latest

COPY piSetup.sh .
RUN sudo apt update -y && \
sudo apt upgrade -y

RUN ./piSetup.sh
RUN sudo apt-get install -y \
git \
make \
curl \
xz-utils \
libstdc++6-4.6-dev

COPY clangSetup.sh /home
RUN cd ~ && \
wget http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-armv7a-linux-gnueabihf.tar.xz && \
tar -xvf clang+llvm-9.0.0-armv7a-linux-gnueabihf.tar.xz && \
rm clang+llvm-9.0.0-armv7a-linux-gnueabihf.tar.xz && \
mv clang+llvm-9.0.0-armv7a-linux-gnueabihf clang_9.0.0 && \
sudo mv clang_9.0.0 /usr/local && \
echo 'export PATH=/usr/local/clang_9.0.0/bin:$PATH' >> ~/.bashrc && \
echo 'export LD_LIBRARY_PATH=/usr/local/clang_9.0.0/lib:$LD_LIBRARY_PATH' >> ~/.bashrc && \
. ~/.bashrc && \
clang++ --version

COPY helloTest.sh /usr/local/bin/
RUN sed -i.bak 's/\r$//' /usr/local/bin/helloTest.sh && \
chmod +x /usr/local/bin/helloTest.sh
16 changes: 8 additions & 8 deletions OnPod/FlightComputer/SetupScriptPlusDockerfile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ cd into folder with Dockerfile

`docker build -t pi_fc:v1 .`

`docker run -it -v path-to-FlightComputer-Dir:/home/data pi_fc:v1 /bin/bash`

// path-to-FlightComputer-Dir = /c/hyperloop/comp5-software/OnPod/FlightComputer on my windows machine
`docker run -it -v <path-to-flight-computer-dir>:/home/data --entrypoint helloTest.sh pi_fc:v1`

// my windows machine
// `docker run -it -v /c/hyperloop/comp5-software/OnPod/FlightComputer:/home/data --entrypoint helloTest.sh pi_fc:v1`
// to run with bash shell open
// `docker run -it -v /c/hyperloop/comp5-software/OnPod/FlightComputer:/home/data --entrypoint /bin/bash pi_fc:v1`

# General docker cmds
`docker images -a` // list images
Expand All @@ -17,14 +19,12 @@ cd into folder with Dockerfile

`docker run -it pi_fc:v1 bin/bash` // run container and open a bash terminal


# Fix for script interpreter error // doz2unix equivalent for pi
`sed -i.bak 's/\r$//' piSetup.sh`
`sed -i.bak 's/\r$//' fileToFix.sh`

# Remote SSH setup
turn on ssh via gui
`sudo systemctl enable ssh`
`sudo systemctl start ssh`

`ifconfig` // to get ip address

Default: user=pi password=raspberry

Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
#!/bin/bash
# PI setup script
echo 'Starting pi setup script'

sudo apt update -y
sudo apt upgrade -y

sudo apt-get install -y \
git \
make \
curl \
xz-utils

# clang++ setup
cd ~
wget http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-armv7a-linux-gnueabihf.tar.xz
Expand All @@ -22,9 +10,3 @@ echo 'export PATH=/usr/local/clang_9.0.0/bin:$PATH' >> .bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/clang_9.0.0/lib:$LD_LIBRARY_PATH' >> .bashrc
. .bashrc
clang++ --version
# end clang setup

sudo systemctl enable ssh
sudo systemctl start ssh

echo 'Done pi setup script'
7 changes: 7 additions & 0 deletions OnPod/FlightComputer/SetupScriptPlusDockerfile/helloTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
## custom aliases
# test c++ compilation
. ~/.bashrc
cd ~
clang++ /home/data/SetupScriptPlusDockerfile/test_main.cpp
./a.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

int main()
{
std::cout << "Hello Paradigm\n";
std::cout << "\n---- Hello Paradigm!!! ----\n\n";

return 0;
}