Hello

Le mercredi 2 octobre 2019 22:26:17 CEST, vous avez écrit :

> This is weird, I haven't seen this issue before. Which USB host
> controller are you using, which OS and which version of libusb?

This is with debian buster  (=stable)
with libusb 1.0 : 
libusb-1.0-0:amd64 version 2:1.0.22-2           

What do you mean by USB Host Controller ?
I attached a few files

When connected to 
rear USB 3.1gen1 : OK
rear USB 3.1gen2 : KO
front USB 2 : KO
front USB 3.1gen1 : KO

according to MB specs (asus PRIME b450M-a:
rear USB3.1 gen1 is controlled by CPU : Athlon200GE
the 3 other are controlled by chipset B450M

> How often does this problem occur?

Quite often. For ex when running welle.io 2.0 beta3 the ferquency gets set 
once and never changes again.
A way to get around it, is to call cancel_async before setting the frenquency.

But I have that error also without reading any data. with the sample test code 
attached.


Regards
[36076.696051] usb 1-8: new high-speed USB device number 7 using xhci_hcd
[36076.875854] usb 1-8: New USB device found, idVendor=0bda, idProduct=2838, 
bcdDevice= 1.00
[36076.875858] usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[36076.875860] usb 1-8: Product: RTL2838UHIDIR
[36076.875861] usb 1-8: Manufacturer: Realtek
[36076.875863] usb 1-8: SerialNumber: 00000001
[36076.893843] usb 1-8: dvb_usb_v2: found a 'Realtek RTL2832U reference design' 
in warm state
[36077.003944] usb 1-8: dvb_usb_v2: will pass the complete MPEG2 transport 
stream to the software demuxer
[36077.003954] dvbdev: DVB: registering new adapter (Realtek RTL2832U reference 
design)
[36077.097576] i2c i2c-8: Added multiplexed i2c bus 9
[36077.097579] rtl2832 8-0010: Realtek RTL2832 successfully attached
[36077.097592] usb 1-8: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 
(DVB-T))...
[36077.097674] r820t 9-001a: creating new instance
[36077.110893] r820t 9-001a: Rafael Micro r820t successfully identified
[36077.113479] rtl2832_sdr rtl2832_sdr.0.auto: Registered as swradio0
[36077.113481] rtl2832_sdr rtl2832_sdr.0.auto: Realtek RTL2832 SDR attached
[36077.113483] rtl2832_sdr rtl2832_sdr.0.auto: SDR API is still slightly 
experimental and functionality changes may follow
[36077.137899] Registered IR keymap rc-empty
[36077.137949] rc rc0: Realtek RTL2832U reference design as 
/devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-8/rc/rc0
[36077.137995] input: Realtek RTL2832U reference design as 
/devices/pci0000:00/0000:00:01.2/0000:01:00.0/usb1/1-8/rc/rc0/input18
[36077.138108] rc rc0: lirc_dev: driver dvb_usb_rtl28xxu registered at minor = 
0, raw IR receiver, no transmitter
[36077.138172] usb 1-8: dvb_usb_v2: schedule remote query interval to 200 msecs
[36077.157882] usb 1-8: dvb_usb_v2: 'Realtek RTL2832U reference design' 
successfully initialized and connected
Bus 001 Device 007: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x2838 RTL2838 DVB-T
  bcdDevice            1.00
  iManufacturer           1 Realtek
  iProduct                2 RTL2838UHIDIR
  iSerial                 3 00000001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0022
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          4 USB2.0-Bulk&Iso
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              5 Bulk-In, Interface
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              5 Bulk-In, Interface
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      2
Device Status:     0x0000
  (Bus Powered)
can't get debug descriptor: Resource temporarily unavailable
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 10000M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 480M
    |__ Port 8: Dev 7, If 0, Class=Vendor Specific Class, 
Driver=dvb_usb_rtl28xxu, 480M
    |__ Port 8: Dev 7, If 1, Class=Vendor Specific Class, Driver=, 480M
#include <unistd.h>
#include <iostream>
#include <SoapySDR/Errors.hpp>
#include <SoapySDR/Version.hpp>
#include <SoapySDR/Modules.hpp>
#include <SoapySDR/Registry.hpp>
#include <SoapySDR/Device.hpp>
#include <rtl-sdr.h>

#define BUFFER_DUMP	(1<<12)

int soapy()
{
    double ret;
    SoapySDR::Device *device = nullptr;
    std::string driver_args;
    
    driver_args="driver=rtlsdr";
    std::clog << "   Line: " << __LINE__ << " next: make " << std::endl;
    device = SoapySDR::Device::make(driver_args);
    
    std::vector<size_t> channels;
    channels.push_back(0);

    std::clog << "   Line: " << __LINE__ << " next: setupStream " << std::endl;
    //auto stream = device->setupStream(SOAPY_SDR_RX, "CF32", channels);
//    assert(stream != nullptr);

    //device->activateStream(stream);
    //device->deactivateStream(stream);

    std::clog << "   Line: " << __LINE__ << " next: pause 2sec " << std::endl;
    //sleep(2);
    
    std::clog << "   Line: " << __LINE__ << " next: closeStream " << std::endl;
    //device->closeStream(stream);
    
    std::clog << "   Line: " << __LINE__ << " next: pause 2sec " << std::endl;
    sleep(2);
    
    std::clog << "   Line: " << __LINE__ << " next: setFrequency " << std::endl;
    device->setFrequency(SOAPY_SDR_RX, 0, 175e6);
    std::clog << "   Line: " << __LINE__ << " next: getFrequency ";
    ret = device->getFrequency(0,0,"RF");
    std::cout << ret << std::endl;
    std::clog << "   Line: " << __LINE__ << " next: unmake" << std::endl;
    SoapySDR::Device::unmake(device);
    
    return 0; 
}


int rtlsdr() {
    int ret;
    
    struct rtlsdr_dev *device = nullptr;
    
    uint32_t deviceCount = rtlsdr_get_device_count();
    
    for(uint32_t i=0; i<deviceCount; i++) {
        ret = rtlsdr_open(&device, i);
        if (ret >= 0) {
            std::clog << "RTL_SDR:" << " Opening rtl-sdr device" << i << std::endl;
            break;
        }
    }
    //Automatic gain
    int g;
//g = rtlsdr_get_tuner_gain(device);
//    rtlsdr_set_tuner_gain_mode(device, 0);
    rtlsdr_reset_buffer(device);
    std::clog << "   Line: " << __LINE__ << " next: rtlsdr_set_center_freq " << std::endl;
    sleep(2);
    rtlsdr_set_center_freq(device, 175e6);
    
    usleep(5000);
    uint8_t dump[BUFFER_DUMP];
    int n_read;
    rtlsdr_read_sync(device, &dump, BUFFER_DUMP, &n_read);
    if (n_read != BUFFER_DUMP) { 
        fprintf(stderr, "Error: bad retune.\n");
    } else {
        fprintf(stderr, "Retune OK.\n");
    }
    
    
    std::clog << "   Line: " << __LINE__ << " next: rtlsdr_close" << std::endl;
    rtlsdr_close(device);
    device = nullptr;
    return 0;
}

int main(int argc, char** argv)
{
    int ret;
    //ret = soapy();
    ret = rtlsdr();
        return 0;
}

Reply via email to