Ejemplo n.º 1
0
// ReadAsync reads samples asynchronously. Note, this function
// will block until canceled using CancelAsync. ReadAsyncCbT is
// a package global variable and therefore unsafe for use with
// multiple dongles.
//
// Note, please use ReadAsync2 as this method will be deprecated
// in the future.
//
// Optional bufNum buffer count, bufNum * bufLen = overall buffer size,
// set to 0 for default buffer count (32).
// Optional bufLen buffer length, must be multiple of 512, set to 0 for
// default buffer length (16 * 32 * 512).
func (dev *Context) ReadAsync(f ReadAsyncCbT, _ *UserCtx, bufNum, bufLen int) error {
	clientCb = f
	i := int(C.rtlsdr_read_async((*C.rtlsdr_dev_t)(dev),
		(C.rtlsdr_read_async_cb_t)(C.get_go_cb()),
		nil, // userctx *UserCtx
		C.uint32_t(bufNum),
		C.uint32_t(bufLen)))
	return libError(i)
}
Ejemplo n.º 2
0
// Read samples from the device asynchronously. This function will block until
// it is being canceled using rtlsdr_cancel_async()
//
// Optional buf_num buffer count, buf_num * buf_len = overall buffer size,
// set to 0 for default buffer count (32).
// Optional buf_len buffer length, must be multiple of 512, set to 0 for
// default buffer length (16 * 32 * 512).
//
// int rtlsdr_read_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx, uint32_t buf_num, uint32_t buf_len);
// rtlsdr_read_async returns 0 on success
func (c *Context) ReadAsync(f ReadAsyncCb_T, userctx *UserCtx, buf_num,
	buf_len int) (err int) {
	clientCb = f
	err = int(C.rtlsdr_read_async((*C.rtlsdr_dev_t)(c.dev),
		(C.rtlsdr_read_async_cb_t)(C.get_go_cb()),
		unsafe.Pointer(userctx),
		C.uint32_t(buf_num),
		C.uint32_t(buf_len)))
	return
}