Skip to content

Commit

Permalink
make it easier to run stratux on x86/amd64 development machine, make …
Browse files Browse the repository at this point in the history
…it possible to run without /root/stratux clone
  • Loading branch information
b3nn0 committed Jul 18, 2019
1 parent fb77f9b commit 92b4afd
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ install:
cp -f dump1090/dump1090 /usr/bin/
cp -f image/hostapd_manager.sh /usr/sbin/
cp -f image/stratux-wifi.sh /usr/sbin/
mkdir -p /var/lib/stratux/
cp -f ogn/rtlsdr-ogn/stratux.conf.template /etc/stratux-ogn.conf.template
rm -f /var/run/ogn-rf.fifo
mkfifo /var/run/ogn-rf.fifo
cp -f ogn/rtlsdr-ogn/ogn-rf /usr/bin/
chmod a+s /usr/bin/ogn-rf
cp -f ogn/rtlsdr-ogn/ogn-decode /usr/bin/

# make sure we have a user-writabel stratux.conf
touch /etc/stratux.conf
chmod a+rw /etc/stratux.conf

clean:
rm -f gen_gdl90 libdump978.so fancontrol ahrs_approx
cd dump1090 && make clean
Expand Down
63 changes: 63 additions & 0 deletions Makefile.x86
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

ifeq "$(CIRCLECI)" "true"
BUILDINFO=
PLATFORMDEPENDENT=
else
LDFLAGS_VERSION=-X main.stratuxVersion=`git describe --tags --abbrev=0` -X main.stratuxBuild=`git log -n 1 --pretty=%H`
BUILDINFO=-ldflags "$(LDFLAGS_VERSION)"
BUILDINFO_STATIC=-ldflags "-extldflags -static $(LDFLAGS_VERSION)"
$(if $(GOROOT),,$(error GOROOT is not set!))
PLATFORMDEPENDENT=
endif

all: xdump978 xdump1090 xgen_gdl90 $(PLATFORMDEPENDENT)

xgen_gdl90:
go get -t -d -v ./main ./godump978 ./uatparse ./sensors
export CGO_CFLAGS_ALLOW="-L$(CURDIR)" && go build $(BUILDINFO) -p 4 main/gen_gdl90.go main/traffic.go main/gps.go main/network.go main/managementinterface.go main/sdr.go main/ping.go main/uibroadcast.go main/monotonic.go main/datalog.go main/equations.go main/sensors.go main/cputemp.go main/lowpower_uat.go main/flarm.go main/flarm-nmea.go main/networksettings.go

fancontrol:
go get -t -d -v ./main
go build $(BUILDINFO) -p 4 main/fancontrol.go main/equations.go main/cputemp.go

xdump1090:
git submodule update --init
cd dump1090 && make

xdump978:
cd dump978 && make lib
sudo cp -f ./libdump978.so /usr/lib/libdump978.so

.PHONY: test
test:
make -C test

www:
cd web && make

install:
cp -f gen_gdl90 /usr/bin/gen_gdl90
chmod 755 /usr/bin/gen_gdl90
cp image/10-stratux.rules /etc/udev/rules.d/10-stratux.rules
cp image/99-uavionix.rules /etc/udev/rules.d/99-uavionix.rules
make www
cp -f libdump978.so /usr/lib/libdump978.so
cp -f dump1090/dump1090 /usr/bin/

# Do this last!
cd /tmp && \
rm -f rtlsdr-ogn-bin-x64-0.2.6.tgz && \
wget http://download.glidernet.org/x64/rtlsdr-ogn-bin-x64-0.2.6.tgz && tar xzf rtlsdr-ogn-bin-x64-0.2.6.tgz && \
cp rtlsdr-ogn-0.2.6/ogn-rf /usr/bin && \
cp rtlsdr-ogn-0.2.6/ogn-decode /usr/bin
mkdir -p /var/lib/stratux/ogn
cp -f ogn/rtlsdr-ogn/stratux.conf.template /etc/stratux-ogn.conf.template

rm -f /var/run/ogn-rf.fifo
mkfifo /var/run/ogn-rf.fifo
chmod a+s /usr/bin/ogn-rf

clean:
rm -f gen_gdl90 libdump978.so fancontrol ahrs_approx
cd dump1090 && make clean
cd dump978 && make clean
4 changes: 2 additions & 2 deletions main/flarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ func flarmListen() {
go aprsServer()

// set OGN configuration file path
configTemplateFileName := "/root/stratux/ogn/rtlsdr-ogn/stratux.conf.template"
configFileName := "/root/stratux/ogn/rtlsdr-ogn/stratux.conf"
configTemplateFileName := "/etc/stratux-ogn.conf.template"
configFileName := "/tmp/stratux-ogn.conf"

// initialize decoding infrastructure
var decodingProcess *os.Process
Expand Down
4 changes: 3 additions & 1 deletion main/gen_gdl90.go
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,9 @@ func main() {
initDataLog()

// Start the AHRS sensor monitoring.
initI2CSensors()
if runtime.GOARCH != "i386" && runtime.GOARCH != "amd64" {
initI2CSensors()
}

// Start the GPS external sensor monitoring.
initGPS()
Expand Down
8 changes: 7 additions & 1 deletion main/managementinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/http"
"os"
"os/exec"
"os/user"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -889,7 +890,12 @@ func managementInterface() {
http.HandleFunc("/downloadahrslogs", handleDownloadAHRSLogsRequest)
http.HandleFunc("/downloaddb", handleDownloadDBRequest)

err := http.ListenAndServe(managementAddr, nil)
usr, _ := user.Current()
addr := managementAddr
if usr.Username != "root" {
addr = ":8080" // Make sure we can run without root priviledges on different port
}
err := http.ListenAndServe(addr, nil)

if err != nil {
log.Printf("managementInterface ListenAndServe: %s\n", err.Error())
Expand Down
4 changes: 2 additions & 2 deletions main/sdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ func (f *FLARM) read() {
log.Println("Entered FLARM read() ...")

// generate OGN configuration file
configTemplateFileName := "/root/stratux/ogn/rtlsdr-ogn/stratux.conf.template"
configFileName := "/root/stratux/ogn/rtlsdr-ogn/stratux.conf"
configTemplateFileName := "/etc/stratux-ogn.conf.template"
configFileName := "/tmp/stratux-ogn.conf"
OGNConfigDataCache.DeviceIndex = strconv.Itoa(f.indexID)
OGNConfigDataCache.Ppm = strconv.Itoa(f.ppm)
OGNConfigDataCache.Longitude = "0.0"
Expand Down

0 comments on commit 92b4afd

Please sign in to comment.