diff --git a/OnPod/FlightComputer/.vscode/tasks.json b/OnPod/FlightComputer/.vscode/tasks.json new file mode 100644 index 0000000..d6ae241 --- /dev/null +++ b/OnPod/FlightComputer/.vscode/tasks.json @@ -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 + } + } + ] +} diff --git a/OnPod/FlightComputer/README.md b/OnPod/FlightComputer/README.md new file mode 100644 index 0000000..30f53c2 --- /dev/null +++ b/OnPod/FlightComputer/README.md @@ -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!!! ----` + diff --git a/OnPod/FlightComputer/SetupScriptPlusDockerfile/Dockerfile b/OnPod/FlightComputer/SetupScriptPlusDockerfile/Dockerfile index 2d1d0cb..6cdd7e3 100644 --- a/OnPod/FlightComputer/SetupScriptPlusDockerfile/Dockerfile +++ b/OnPod/FlightComputer/SetupScriptPlusDockerfile/Dockerfile @@ -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 diff --git a/OnPod/FlightComputer/SetupScriptPlusDockerfile/README.md b/OnPod/FlightComputer/SetupScriptPlusDockerfile/README.md index 1d64e7c..e6ea026 100644 --- a/OnPod/FlightComputer/SetupScriptPlusDockerfile/README.md +++ b/OnPod/FlightComputer/SetupScriptPlusDockerfile/README.md @@ -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 :/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 @@ -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 - diff --git a/OnPod/FlightComputer/SetupScriptPlusDockerfile/piSetup.sh b/OnPod/FlightComputer/SetupScriptPlusDockerfile/clangSetup.sh similarity index 64% rename from OnPod/FlightComputer/SetupScriptPlusDockerfile/piSetup.sh rename to OnPod/FlightComputer/SetupScriptPlusDockerfile/clangSetup.sh index 050f4c5..7f10ff4 100644 --- a/OnPod/FlightComputer/SetupScriptPlusDockerfile/piSetup.sh +++ b/OnPod/FlightComputer/SetupScriptPlusDockerfile/clangSetup.sh @@ -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 @@ -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' diff --git a/OnPod/FlightComputer/SetupScriptPlusDockerfile/helloTest.sh b/OnPod/FlightComputer/SetupScriptPlusDockerfile/helloTest.sh new file mode 100644 index 0000000..2912ec2 --- /dev/null +++ b/OnPod/FlightComputer/SetupScriptPlusDockerfile/helloTest.sh @@ -0,0 +1,7 @@ +#!/bin/bash +## custom aliases +# test c++ compilation +. ~/.bashrc +cd ~ +clang++ /home/data/SetupScriptPlusDockerfile/test_main.cpp +./a.out diff --git a/OnPod/FlightComputer/SetupScriptPlusDockerfile/test_main.cpp b/OnPod/FlightComputer/SetupScriptPlusDockerfile/test_main.cpp index 0ede7c3..841d811 100644 --- a/OnPod/FlightComputer/SetupScriptPlusDockerfile/test_main.cpp +++ b/OnPod/FlightComputer/SetupScriptPlusDockerfile/test_main.cpp @@ -2,7 +2,7 @@ int main() { - std::cout << "Hello Paradigm\n"; + std::cout << "\n---- Hello Paradigm!!! ----\n\n"; return 0; }