Skip to content

Commit

Permalink
Merge pull request #5 from ParadigmHyperloop/feature/PI/raspbian-dock…
Browse files Browse the repository at this point in the history
…erfile-taskrunner

feature/PI/raspbian-dockerfile-taskrunner
  • Loading branch information
colton-smith authored Mar 8, 2020
2 parents c5f4f4c + 38d9a53 commit 6217a79
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.vscode
.vscode/*
!important .vscode/tasks.json

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 @@

34 changes: 34 additions & 0 deletions Pidaq/.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": "buildPiImage",
"type": "shell",
"command": "docker build -t pidaq:v1 docker/.",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "compileRunPiHelloWorld",
"type": "shell",
"command": "docker run -it -v /c/Hyperloop/testing-software/Pidaq:/home/data --entrypoint helloTest.sh pidaq:v1",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
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;
}

0 comments on commit 6217a79

Please sign in to comment.