Commit 51093919 authored by Martin Cífka's avatar Martin Cífka
Browse files

added automated build & run into sdk/run.sh, README update

parent 0e66b6d7
Loading
Loading
Loading
Loading
+2 −16
Original line number Diff line number Diff line
@@ -30,23 +30,9 @@ Copy autorun.ash to the micro SD card root. Then connect over telnet (user: root

	cd sdk

Build a Docker container with the development environment and compile a "hello world" executable by running

	./run.sh

Then copy the resulting binary to the camera:

 - run on the computer:


	nc -l 1234 < hello


 - then run on the camera:


	nc 192.168.42.5 1234 > /tmp/hello && chmod +x /tmp/hello && /tmp/hello
By running script run.sh, build a Docker container with the development environment and compile a "hello world" executable (-b option), then copy and run it directly on the camera (-r option):

	./run.sh -br


# Running the script on Android (5.0+)
+39 −3
Original line number Diff line number Diff line
#!/bin/sh -euxo pipefail
#!/bin/bash
set -euo pipefail

sources="hello.cpp"
headers=""
outfile="hello"


build=false
run=false
usage=$(echo -e "Usage: run.sh [OPTIONS] \n\t-b build \n\t-r copy to camera and run")

if [ $# -eq 0 ]; then
    echo "$usage"
    exit 1
fi

while getopts "br" opt; do
  case ${opt} in
    b ) build=true
      ;;
    r ) run=true
      ;;
    \? ) echo "$usage"
      ;;
  esac
done


if [ "$build" = true ] ; then
    sudo docker build -t mi_camera_sdk .
    sudo docker run -it --rm -v "$PWD":/workdir mi_camera_sdk bash -c "cp $sources $headers /tmp && arm-linux-gnueabihf-c++ -o /workdir/$outfile $sources"
    echo -e "\n"
fi

if [ "$run" = true ] ; then
    sleep 1 && nc 192.168.42.1 1234 -w2 <"$outfile" &
    ./telnet.exp /tmp/"$outfile"
fi
docker build -t mi_camera_sdk .
docker run -it --rm -v "$PWD":/workdir mi_camera_sdk bash -c 'cp hello.cpp /tmp && arm-linux-gnueabihf-c++ -o /workdir/hello /tmp/hello.cpp'

sdk/telnet.exp

0 → 100755
+39 −0
Original line number Diff line number Diff line
#!/usr/bin/expect



set timeout 5
set filepath [lindex $argv 0]

spawn telnet 192.168.42.1
match_max 10000

expect "Trying 192.168.42.1...\r"
expect {
    "Connected to 192.168.42.1.\r" {}
    timeout {puts "timed out during connecting" ; exit 1}
    }
expect "Escape character is '^\]'.\r"
expect "\r\r"
expect "a12 login: "

send -- "root\r"
expect -exact "root\r
~ # "

send -- "nc -w3 -l -p 1234 >$filepath\r"
expect -exact "nc -w3 -l -p 1234 >$filepath\r
~ # "

send -- "chmod +x $filepath\r"
expect -exact "chmod +x $filepath\r
~ # "


send -- "$filepath\r"
expect -exact "$filepath\r"


#send -- "exit\r"
#expect eof
interact