Exemple #1
0
// GetIndexBySerial returns a device index by serial id.
func GetIndexBySerial(serial string) (index int, err error) {
	cstring := C.CString(serial)
	defer C.free(unsafe.Pointer(cstring))
	index = int(C.rtlsdr_get_index_by_serial(cstring))
	switch {
	case index >= 0:
		return
	case index == -1:
		err = errors.New("serial blank")
	case index == -2:
		err = errors.New("no devices were found")
	case index == -3:
		err = errors.New("no device found with matching name")
	default:
		err = errors.New("unknown error")
	}
	return
}
Exemple #2
0
// returns device index of first device where the name matched
// -1 if name is NULL
// -2 if no devices were found at all
// -3 if devices were found, but none with matching name
//
// int rtlsdr_get_index_by_serial(const char *serial);
func GetIndexBySerial(serial string) (index int) {
	cstring := C.CString(serial)
	defer C.free(unsafe.Pointer(cstring))
	return int(C.rtlsdr_get_index_by_serial(cstring))
}