rename the dump978 export file, add some example build instructions

pull/23/head
Joseph Poirier 2015-08-30 14:57:18 -05:00
rodzic d6529f25b8
commit 6fa5a595f3
2 zmienionych plików z 13 dodań i 42 usunięć

Wyświetl plik

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

Wyświetl plik

@ -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 <stdint.h>
#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
}