Пример #1
0
// ReadSync performs a synchronous read of samples and returns
// the number of samples read.
func (dev *Context) ReadSync(buf []uint8, leng int) (nRead int, err error) {
	i := int(C.rtlsdr_read_sync((*C.rtlsdr_dev_t)(dev),
		unsafe.Pointer(&buf[0]),
		C.int(leng),
		(*C.int)(unsafe.Pointer(&nRead))))
	return nRead, libError(i)
}
Пример #2
0
// int rtlsdr_read_sync(rtlsdr_dev_t *dev, void *buf, int len, int *n_read);
// rtlsdr_read_sync returns 0 on success
func (c *Context) ReadSync(buf []uint8, len int) (n_read int, err int) {
	err = int(C.rtlsdr_read_sync((*C.rtlsdr_dev_t)(c.dev),
		(unsafe.Pointer(&buf[0])),
		C.int(len),
		(*C.int)(unsafe.Pointer(&n_read))))
	return
}
Пример #3
0
func (dev *Radio) readSyncInternal(dataPipe chan *DataBuffer) {
	var data C.int

	for {
		buf := newDataBuffer(dev.DataBufferSize)

		retval := C.rtlsdr_read_sync(
			dev.devptr, unsafe.Pointer(&buf.Buffer[0]), C.int(buf.Size), &data,
		)

		if retval != 0 {
			fmt.Printf("rtlsdr_read_sync returned error value: %d", retval)
		} else {
			buf.Length = int(data)
			dataPipe <- buf
		}
	}
}