예제 #1
0
파일: rtlsdr.go 프로젝트: cyoung/gortlsdr
// 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)
}
예제 #2
0
파일: hackrf.go 프로젝트: bemasher/hackrf
// hackrf_start_tx(hackrf_device* device, hackrf_sample_block_cb_fn callback, void* tx_ctx);
func (h *HackRF) StartTX(callback CallbackFunc) error {
	localCallback = callback

	return Error(C.hackrf_start_tx(
		(*C.hackrf_device)(h.ptr),
		(C.hackrf_sample_block_cb_fn)(C.get_go_cb()),
		nil,
	))
}
예제 #3
0
파일: rtlsdr.go 프로젝트: nlefler/gortlsdr
// 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
}