Exemplo n.º 1
0
// Get USB device strings.
//
// int rtlsdr_get_usb_strings(rtlsdr_dev_t *dev, char *manufact, char *product, char *serial);
// rtlsdr_get_usb_strings returns 0 on success
func (c *Context) GetUsbStrings() (manufact, product, serial string, err int) {
	m := make([]byte, 257) // includes space for NULL byte
	p := make([]byte, 257)
	s := make([]byte, 257)
	err = int(C.rtlsdr_get_usb_strings((*C.rtlsdr_dev_t)(c.dev),
		(*C.char)(unsafe.Pointer(&m[0])),
		(*C.char)(unsafe.Pointer(&p[0])),
		(*C.char)(unsafe.Pointer(&s[0]))))
	return string(m), string(p), string(s), err
}
Exemplo n.º 2
0
// GetUsbStrings returns the device information. Note, strings may be empty.
func (dev *Context) GetUsbStrings() (manufact, product, serial string, err error) {
	m := make([]byte, 257) // includes space for NULL byte
	p := make([]byte, 257)
	s := make([]byte, 257)
	i := int(C.rtlsdr_get_usb_strings((*C.rtlsdr_dev_t)(dev),
		(*C.char)(unsafe.Pointer(&m[0])),
		(*C.char)(unsafe.Pointer(&p[0])),
		(*C.char)(unsafe.Pointer(&s[0]))))
	return string(bytes.Trim(m, "\x00")), string(bytes.Trim(p, "\x00")),
		string(bytes.Trim(s, "\x00")), libError(i)
}