Browse Source

sync rx/tx timeout supported

master
Eray Arslan 11 months ago
parent
commit
abb267d2fe
  1. 8
      README.md
  2. 8
      bladerf.go
  3. 4
      bladerf_test.go
  4. 4
      go.mod

8
README.md

@ -1,11 +1,9 @@ @@ -1,11 +1,9 @@
# Go-BladeRF
# go-bladerf
`under development "draft"`
## Examples
## examples
[go-bladerf-examples](https://github.com/erayarslan/go-bladerf-examples)
## Tested On
## tested on
`libbladeRF 2.2.1-MacPorts-20191220-45521019`

8
bladerf.go

@ -811,7 +811,7 @@ func (trigger *Trigger) SetRole(role TriggerRole) { @@ -811,7 +811,7 @@ func (trigger *Trigger) SetRole(role TriggerRole) {
(*trigger.ref).role = C.bladerf_trigger_role(role)
}
func (bladeRF *BladeRF) SyncTX(input []int16, metadata Metadata) (Metadata, error) {
func (bladeRF *BladeRF) SyncTX(input []int16, metadata Metadata, timeout uint) (Metadata, error) {
if metadata.ref == nil {
var ref C.struct_bladerf_metadata
metadata.ref = &ref
@ -826,7 +826,7 @@ func (bladeRF *BladeRF) SyncTX(input []int16, metadata Metadata) (Metadata, erro @@ -826,7 +826,7 @@ func (bladeRF *BladeRF) SyncTX(input []int16, metadata Metadata) (Metadata, erro
*addr = (C.uint16_t)(input[i])
}
err := GetError(C.bladerf_sync_tx(bladeRF.ref, unsafe.Pointer(buf), C.uint(numberOfSample/2), metadata.ref, 5000))
err := GetError(C.bladerf_sync_tx(bladeRF.ref, unsafe.Pointer(buf), C.uint(numberOfSample/2), metadata.ref, C.uint(timeout)))
if err != nil {
return metadata, err
@ -835,7 +835,7 @@ func (bladeRF *BladeRF) SyncTX(input []int16, metadata Metadata) (Metadata, erro @@ -835,7 +835,7 @@ func (bladeRF *BladeRF) SyncTX(input []int16, metadata Metadata) (Metadata, erro
return LoadMetadata(metadata.ref), nil
}
func (bladeRF *BladeRF) SyncRX(bufferSize uintptr, metadata Metadata) ([]int16, Metadata, error) {
func (bladeRF *BladeRF) SyncRX(bufferSize uintptr, metadata Metadata, timeout uint) ([]int16, Metadata, error) {
if metadata.ref == nil {
var ref C.struct_bladerf_metadata
metadata.ref = &ref
@ -843,7 +843,7 @@ func (bladeRF *BladeRF) SyncRX(bufferSize uintptr, metadata Metadata) ([]int16, @@ -843,7 +843,7 @@ func (bladeRF *BladeRF) SyncRX(bufferSize uintptr, metadata Metadata) ([]int16,
start := C.malloc(C.size_t(C.sizeof_int16_t * bufferSize * 2 * 1))
defer C.free(unsafe.Pointer(start))
err := GetError(C.bladerf_sync_rx(bladeRF.ref, start, C.uint(bufferSize), metadata.ref, 5000))
err := GetError(C.bladerf_sync_rx(bladeRF.ref, start, C.uint(bufferSize), metadata.ref, C.uint(timeout)))
if err != nil {
return nil, metadata, err

4
bladerf_test.go

@ -1219,7 +1219,7 @@ func TestSyncTX(t *testing.T) { @@ -1219,7 +1219,7 @@ func TestSyncTX(t *testing.T) {
data[i] = complex(0.5, 0.5)
}
_, err = rf.SyncTX(Complex64ToInt16(data), Metadata{})
_, err = rf.SyncTX(Complex64ToInt16(data), Metadata{}, 3500)
if err == nil {
t.Log("PASSED")
@ -1240,7 +1240,7 @@ func TestSyncRX(t *testing.T) { @@ -1240,7 +1240,7 @@ func TestSyncRX(t *testing.T) {
err = rf.SyncConfig(RxX1, FormatSc16Q11, 2, 1024, 1, 3500)
err = rf.EnableModule(ChannelRx(0))
data, _, err := rf.SyncRX(1024, Metadata{})
data, _, err := rf.SyncRX(1024, Metadata{}, 3500)
complexData := Int16ToComplex64(data)

4
go.mod

@ -2,6 +2,4 @@ module github.com/erayarslan/go-bladerf @@ -2,6 +2,4 @@ module github.com/erayarslan/go-bladerf
go 1.13
require (
github.com/mattn/go-pointer v0.0.1
)
require github.com/mattn/go-pointer v0.0.1

Loading…
Cancel
Save