Beispiel #1
0
// Open a handle to the RTLSDR device
func Open(index int) (*Radio, error) {
	dev := NewRadio()

	// Possible return values:
	//  * 0 on success
	//  * -ENOMEM
	// RTLSDR_API int rtlsdr_open(rtlsdr_dev_t **dev, uint32_t index);
	retval := C.rtlsdr_open(&dev.devptr, C.uint32_t(index))

	if retval != 0 {
		defer dev.Cleanup()
		return nil, fmt.Errorf("rtlsdr_open returned error value: %d", retval)
	}

	return dev, nil
}
Beispiel #2
0
// Open returns a valid device's context.
//
// int rtlsdr_open(rtlsdr_dev_t **dev, uint32_t index);
// rtlsdr_open returns 0 on success
func Open(index int) (c *Context, err int) {
	c = &Context{}
	err = int(C.rtlsdr_open((**C.rtlsdr_dev_t)(&c.dev),
		C.uint32_t(index)))
	return
}
Beispiel #3
0
// Open returns an opened device by index.
func Open(index int) (*Context, error) {
	var dev *C.rtlsdr_dev_t
	i := int(C.rtlsdr_open((**C.rtlsdr_dev_t)(&dev),
		C.uint32_t(index)))
	return (*Context)(dev), libError(i)
}