Merge pull request #177 from ckuethe/master

Explain which gain setting was unacceptable
This commit is contained in:
Michael Ossmann
2015-07-08 16:11:51 -06:00
2 changed files with 8 additions and 0 deletions

View File

@ -581,6 +581,12 @@ int main(int argc, char** argv) {
} }
} }
if (lna_gain % 8)
printf("warning: lna_gain (-l) must be a multiple of 8\n");
if (vga_gain % 2)
printf("warning: vga_gain (-g) must be a multiple of 2\n");
if (samples_to_xfer >= SAMPLES_TO_XFER_MAX) { if (samples_to_xfer >= SAMPLES_TO_XFER_MAX) {
printf("argument error: num_samples must be less than %s/%sMio\n", printf("argument error: num_samples must be less than %s/%sMio\n",
u64toa(SAMPLES_TO_XFER_MAX,&ascii_u64_data1), u64toa(SAMPLES_TO_XFER_MAX,&ascii_u64_data1),

View File

@ -1211,6 +1211,7 @@ int ADDCALL hackrf_set_lna_gain(hackrf_device* device, uint32_t value)
return HACKRF_ERROR_INVALID_PARAM; return HACKRF_ERROR_INVALID_PARAM;
} }
value &= ~0x07;
result = libusb_control_transfer( result = libusb_control_transfer(
device->usb_device, device->usb_device,
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
@ -1240,6 +1241,7 @@ int ADDCALL hackrf_set_vga_gain(hackrf_device* device, uint32_t value)
return HACKRF_ERROR_INVALID_PARAM; return HACKRF_ERROR_INVALID_PARAM;
} }
value &= ~0x01;
result = libusb_control_transfer( result = libusb_control_transfer(
device->usb_device, device->usb_device,
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,