cosmetic fixes/cleanup

Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
Steve Markgraf 2012-03-31 14:32:18 +02:00
parent 542533c229
commit ffea5061f0
2 changed files with 150 additions and 161 deletions

View File

@ -100,15 +100,13 @@ int main(int argc, char **argv)
/* Set the sample rate */
r = rtlsdr_set_sample_rate(dev, samp_rate);
if (r < 0) {
if (r < 0)
fprintf(stderr, "WARNING: Failed to set sample rate.\n");
}
/* Set the frequency */
r = rtlsdr_set_center_freq(dev, frequency);
if (r < 0) {
if (r < 0)
fprintf(stderr, "WARNING: Failed to set center freq.\n");
}
file = fopen(filename, "wb");
@ -119,16 +117,15 @@ int main(int argc, char **argv)
/* Reset endpoint before we start reading from it */
r = rtlsdr_reset_buffer(dev);
if (r < 0) {
if (r < 0)
fprintf(stderr, "WARNING: Failed to reset buffers.\n");
}
printf("Reading samples...\n");
while (!do_exit) {
r = rtlsdr_read_sync(dev, buffer, READLEN, &n_read);
if (r < 0) {
if (r < 0)
fprintf(stderr, "WARNING: sync read failed.\n");
}
fwrite(buffer, n_read, 1, file);

View File

@ -48,6 +48,7 @@ int fc0013_tune(void *dev, int freq) {
//fc0013_GetBandwidthMode(dev, &bw); // FIXME: missing
return FC0013_SetFrequency(dev, freq/1000, bw & 0xff);
}
int fc0013_set_bw(void *dev, int bw) {
/* read frequency to reapply it */
unsigned long freq = 0;
@ -82,11 +83,11 @@ struct rtlsdr_device {
uint16_t vid;
uint16_t pid;
} devices[] = {
{ 0x0bda, 0x2832, /*RTLSDR_TUNER_E4000,*/ }, /* default RTL2832U vid/pid (eg. hama nano) */
{ 0x0bda, 0x2838, /*RTLSDR_TUNER_E4000,*/ }, /* ezcap USB 2.0 DVB-T/DAB/FM stick */
{ 0x0ccd, 0x00b3, /*RTLSDR_TUNER_FC0013,*/ }, /* Terratec NOXON DAB/DAB+ USB-Stick */
{ 0x1f4d, 0xb803, /*RTLSDR_TUNER_FC0012,*/ }, /* GTek T803 */
{ 0x1b80, 0xd3a4, /*RTLSDR_TUNER_FC0013,*/ }, /* Twintech UT-40 */
{ 0x0bda, 0x2832 }, /* default RTL2832U vid/pid (eg. hama nano) */
{ 0x0bda, 0x2838 }, /* ezcap USB 2.0 DVB-T/DAB/FM stick */
{ 0x0ccd, 0x00b3 }, /* Terratec NOXON DAB/DAB+ USB-Stick */
{ 0x1f4d, 0xb803 }, /* GTek T803 */
{ 0x1b80, 0xd3a4 }, /* Twintech UT-40 */
};
typedef struct {
@ -311,15 +312,10 @@ int rtlsdr_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq)
if (dev->tuner) {
dev->tuner->freq = freq;
double f = (double) freq;
f *= 1.0 + dev->tuner->corr / 1e6;
dev->tuner->tune((void *)dev, (int) f);
printf("Tuned to %i Hz\n", freq);
}
rtlsdr_set_i2c_repeater(dev, 0);
@ -408,11 +404,10 @@ uint32_t rtlsdr_get_device_count(void)
libusb_get_device_descriptor(list[i], &dd);
for (j = 0; j < sizeof(devices)/sizeof(struct rtlsdr_device); j++ ) {
if ( devices[j].vid == dd.idVendor && devices[j].pid == dd.idProduct ) {
if (devices[j].vid == dd.idVendor && devices[j].pid == dd.idProduct)
device_count++;
}
}
}
libusb_free_device_list(list, 0);
@ -460,7 +455,6 @@ rtlsdr_dev_t *rtlsdr_open(int index)
for (j = 0; j < sizeof(devices)/sizeof(struct rtlsdr_device); j++ ) {
if ( devices[j].vid == dd.idVendor && devices[j].pid == dd.idProduct ) {
device_count++;
if (index == device_count - 1)
break;
}
@ -486,13 +480,13 @@ rtlsdr_dev_t *rtlsdr_open(int index)
unsigned char buffer[256];
libusb_get_string_descriptor_ascii(dev->devh, 0, buffer, sizeof(buffer) );
libusb_get_string_descriptor_ascii(dev->devh, 0, buffer, sizeof(buffer));
printf("sn#: %s\n", buffer);
libusb_get_string_descriptor_ascii(dev->devh, 1, buffer, sizeof(buffer) );
libusb_get_string_descriptor_ascii(dev->devh, 1, buffer, sizeof(buffer));
printf("manufacturer: %s\n", buffer);
libusb_get_string_descriptor_ascii(dev->devh, 2, buffer, sizeof(buffer) );
libusb_get_string_descriptor_ascii(dev->devh, 2, buffer, sizeof(buffer));
printf("product: %s\n", buffer);
r = libusb_claim_interface(dev->devh, 0);
@ -514,9 +508,7 @@ err:
int rtlsdr_close(rtlsdr_dev_t *dev)
{
libusb_release_interface(dev->devh, 0);
libusb_close(dev->devh);
free(dev);
return 0;