From 6fa5a595f3eeaa3c1b51c67c3030941ed9d099cc Mon Sep 17 00:00:00 2001 From: Joseph Poirier Date: Sun, 30 Aug 2015 14:57:18 -0500 Subject: [PATCH 1/3] rename the dump978 export file, add some example build instructions --- dump978.go | 14 +++++++++++++- exports.go | 41 ----------------------------------------- 2 files changed, 13 insertions(+), 42 deletions(-) delete mode 100644 exports.go diff --git a/dump978.go b/dump978.go index 898e3319..1479d000 100644 --- a/dump978.go +++ b/dump978.go @@ -3,6 +3,18 @@ // that can be found in the LICENSE file. // Package dump978 wraps libdump978, a 978MHz UAT demodulator. +// +// Build example +// +// dump978.so: +// $ gcc -c -O2 -g -Wall -Werror -Ifec -fpic -DBUILD_LIB=1 dump978.c fec.c fec/decode_rs_char.c fec/init_rs_char.c +// $ gcc -shared -lm -o ../libdump978.so dump978.o fec.o decode_rs_char.o init_rs_char.o +// +// dump978 go wrapper: +// $ go build -o dump978.a dump978.go dump978_exports.go +// +// uat_read executable: +// $ go build uat_read.go package dump978 @@ -47,4 +59,4 @@ func ProcessDataFromChannel() { inData := <-InChan ProcessData(inData) } -} \ No newline at end of file +} diff --git a/exports.go b/exports.go deleted file mode 100644 index 6020f4a0..00000000 --- a/exports.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2015 Joseph D Poirier -// Distributable under the terms of The New BSD License -// that can be found in the LICENSE file. - -// Package dump978 wraps libdump978, a 978MHz UAT demodulator. - -package dump978 - -import ( - "fmt" - "reflect" - "unsafe" -) - -/* -#include -#include "dump978/dump978.h" -*/ -import "C" - -// OutChan is a buffered output channel for demodulated data. -var OutChan = make(chan string, 100) - -//export dump978Cb -func dump978Cb(updown C.char, data *C.uint8_t, length C.int) { - // c buffer to go slice without copying - var buf []byte - - b := (*reflect.SliceHeader)((unsafe.Pointer(&buf))) - b.Cap = int(length) - b.Len = int(length) - b.Data = uintptr(unsafe.Pointer(data)) - - // copy incoming to outgoing - outData := string(updown) - for i := 0; i < int(length); i++ { - outData += fmt.Sprintf("%02x", buf[i]) - } - - OutChan <- outData -} From 2071d145102dcc24d8c5ecfad987e14e266726c8 Mon Sep 17 00:00:00 2001 From: Joseph Poirier Date: Sun, 30 Aug 2015 15:01:41 -0500 Subject: [PATCH 2/3] actually add the new export file --- dump978_exports.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 dump978_exports.go diff --git a/dump978_exports.go b/dump978_exports.go new file mode 100644 index 00000000..6020f4a0 --- /dev/null +++ b/dump978_exports.go @@ -0,0 +1,41 @@ +// Copyright (c) 2015 Joseph D Poirier +// Distributable under the terms of The New BSD License +// that can be found in the LICENSE file. + +// Package dump978 wraps libdump978, a 978MHz UAT demodulator. + +package dump978 + +import ( + "fmt" + "reflect" + "unsafe" +) + +/* +#include +#include "dump978/dump978.h" +*/ +import "C" + +// OutChan is a buffered output channel for demodulated data. +var OutChan = make(chan string, 100) + +//export dump978Cb +func dump978Cb(updown C.char, data *C.uint8_t, length C.int) { + // c buffer to go slice without copying + var buf []byte + + b := (*reflect.SliceHeader)((unsafe.Pointer(&buf))) + b.Cap = int(length) + b.Len = int(length) + b.Data = uintptr(unsafe.Pointer(data)) + + // copy incoming to outgoing + outData := string(updown) + for i := 0; i < int(length); i++ { + outData += fmt.Sprintf("%02x", buf[i]) + } + + OutChan <- outData +} From d1c23f81ec681452cdd10f74ef5192798c9518c0 Mon Sep 17 00:00:00 2001 From: Joseph Poirier Date: Sun, 30 Aug 2015 15:14:59 -0500 Subject: [PATCH 3/3] added dump1090 submodule --- .gitmodules | 3 +++ dump1090 | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 dump1090 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..d12a87a8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dump1090"] + path = dump1090 + url = https://github.com/antirez/dump1090 diff --git a/dump1090 b/dump1090 new file mode 160000 index 00000000..82363197 --- /dev/null +++ b/dump1090 @@ -0,0 +1 @@ +Subproject commit 823631979b74f83caa48da69c86f8967e4c17c47