Skip to content

feature/PI/raspbian-dockerfile-taskrunner #5

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

Merged
merged 11 commits into from
Mar 8, 2020
Merged
2 changes: 2 additions & 0 deletions Node/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.vscode/settings.json
.vscode/extensions.json
1 change: 1 addition & 0 deletions Pidaq/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!important vscode/tasks.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be .vscode/tasks.json? I think that directory is still getting gitignored, just noticed this when following the instructions on the README

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct, fixed

20 changes: 16 additions & 4 deletions Pidaq/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# Pidaq (Rasp Pi Data Aquisitor)

This directory contains all of the code that will run on the raspberry pi. The pi will receive and parse CAN messages containing raw telemetry, apply calculations, and create a packet(s) containing either a JSON or protobuf message to send to the control laptop via ethernet (UDP)
***
## Examples

# Development
We will be using docker to cross compile c++ for the raspberry pi

Includes relevant examples
***
Ensure docker is installed and running on your machine. Windows 10 Home does not have proper support for docker, however MUN offers a free upgrade to windows 10 education which is fully featured. The update is easy, unintrusive, and takes less than 1 hour.

## Taskrunner Setup Code for VsCode
* Install vscode extension "Tasks" by actboy 168

* Open testing-software/Pidaq folder with vscode

* Replace the folder path in .vscode/tasks.json line 28 command: `compile and run Pidaq HelloWorld`, with your path. replace this -> `/c/Hyperloop/testing-software/Pidaq `

* Try the task buttons in blue taskbar at bottom of vscode window:
* `echoTest` should print Hello taskrunner good.
* `buildPiImage` should build docker image `pidaq:v1`
* `compileRunPiHelloWorld` should print "---Hello Paradigm!!!---"
32 changes: 32 additions & 0 deletions Pidaq/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM raspbian/stretch:latest

LABEL build-date="2020-03-01" \
name="Raspi + Clang for xcompiling"

RUN sudo apt update -y && \
sudo apt upgrade -y

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

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

CMD /bin/bash
33 changes: 33 additions & 0 deletions Pidaq/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Raspbian Docker Setup
**Developed by Mark Duffett for CompV Software**

Building and running the raspbian docker container:

* Docker build
```
docker build -t pidaq:v1 .
```

* Docker Run (open to bash prompt)
```
docker run -it -v path-to-PIDAQ-dir:/home/data pidaq:v1 /bin/bash
```

* Docker Run (launch script)
```
docker run -it -v path-to-PIDAQ-dir:/home/data --entrypoint helloTest.sh pidaq:v1
```

*Where path-to-PIDAQ-dir = `/c/Hyperloop/testing-software/Pidaq on my machine*

## General Docker Commands
* `docker --version` // Check docker version/ ensure docker is installed
* `docker image ls` // list docker images

## Remote Pi SSH Setup
* `sudo systemctl enable ssh`
* `sudo systemctl start ssh`
* `ifconfig` // to get IP address of raspi

Default: user=pi, password=raspberry

8 changes: 8 additions & 0 deletions Pidaq/docker/helloTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Custom aliases
# Test C++ Compilation
. ~/.bashrc
cd ~
clang++ /home/data/docker/test_main.cpp
./a.out

9 changes: 9 additions & 0 deletions Pidaq/docker/test_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Raspi cross compiling test program
#include<iostream>

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

return 0;
}