Page 1 of 1

USB buffer overflow in mir_sdr_SetDeviceIDx routine

Posted: Wed Jun 21, 2017 5:01 pm
by ERtpl
Hello,

I am receiving the following error/output after calling mir_sdr_SetDeviceIdx(device) where device is an int set to 0.

mir_sdr_usb_SetDeviceIdx idx=0 numDevices=1
Opened device with idVendor = 0x1df7 idProduct = 0x3010 fwVersion = 0x0207 busNum = 009 portNum = 003
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=60dB fs=2.000MHz rf=98.800MHz bw=1.536MHz if=0.000MHz
DownConvert: Enable=0 DecM=1 OutScale=0 (fs=2.000000 bw=1536 if=0)
mir_sdr_usb_USB DLL: Revision 0.1.1
mir_sdr_2500_Init: fnaddr = 1
mir_sdr_2500_Init: adjusting squelch trim 0x1, rx gating enable 1, tx_trim 0, reg2 = 0x4801
initHw: Register7 = 0x000014
initRfFreqDependentHw(1): Tuner Register0 = 0x04f420
mir_sdr_GpioExtWrite: Addr=0 Data=0x00
mir_sdr_GpioExtWrite: Addr=1 Data=0x00
mir_sdr_GpioExtWrite: Addr=18 Data=0x5d
mir_sdr_GpioExtWrite: Addr=19 Data=0xa5
initRfFreqDependentHw(1): ExtGpioA = 0x5d ExtGpioB = 0xa5
mir_sdr_SetFs: Sample Freq requested 2000000.000000
mir_sdr_SetFs: Fs->FsNomHz+dFsHz=2000000.0+0.0Hz=2000000.0Hz FsToggle->1
mir_sdr_SetRf: f->98800000.000Hz (int=20 frac=af0 afc=0) fSynth:3161600000.000
mir_sdr_SetRf: Rf->RfNomHz+dRfHz+LifHz+Lif1Hz=98800000.0+0.0+0.0Hz+0.0Hz=98800000.0Hz RfToggle->1
mir_sdr_SetGr: GR->60[36,24,0,0] gRset->0x224 DCCALmode=3 DCCALspd=0 GrToggle->1
setToggleStates: initialising sampNum=0x00017a02, gainSetting=0x224, FsToggle=1, RfToggle=1, GrToggle=0
setToggleStates: initialising Fs=2000000.000, Rf=98800000.000, Gr=60
Error: USB buffer overflow

At this point the code hangs, and I force it to exit.

I know this is occurring in the SetDeviceIdx call because I have outputs to the terminal immediately before and after, but the second output is never written to the terminal. This was occurring in code I had written, but I had the same issue running the example play_sdr.c file. I am running this on CentOS 7. Is there a particular USB library that I need to interface with the API?

Re: USB buffer overflow in mir_sdr_SetDeviceIDx routine

Posted: Thu Jun 22, 2017 5:30 pm
by ERtpl
Since I'm having issues with the SetDeviceIdx function, I worked on my own workaround to "lock" the USB devices that I did not want to use, since StreamInit was supposed to connect to the first available device. Instead, StreamInit apparently tries to connect to the first device, regardless of whether or not it's available, even though there's a second available device:

mir_sdr_usb_GetDevices Dev0:vid=1df7 pid=3010 rev=0207 serno=1605039500 bus=009 port=004 devAvail=0
mir_sdr_usb_GetDevices Dev1:vid=1df7 pid=3010 rev=0207 serno=1605037400 bus=009 port=003 devAvail=1
Initializing stream for device0
mir_sdr_StreamInit()
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=40dB fs=10.000MHz rf=500.000MHz bw=8.000MHz if=0.000MHz
DownConvert: Enable=0 DecM=1 OutScale=0 (fs=10.000000 bw=8000 if=0)
mir_sdr_usb_USB DLL: Revision 0.1.1
Opened device with idVendor = 0x1df7 idProduct = 0x3010 fwVersion = 0x0207 busNum = 009 portNum = 004
Warning: libusb_claim_interface() -6
Error: kernel driver not active - should have been able to claim interface!
Close this device and try next one if there is one!
Opened device with idVendor = 0x1df7 idProduct = 0x3010 fwVersion = 0x0207 busNum = 009 portNum = 004
Warning: libusb_claim_interface() -6
Error: kernel driver not active - should have been able to claim interface!
Close this device and try next one if there is one!
Opened device with idVendor = 0x1df7 idProduct = 0x3010 fwVersion = 0x0207 busNum = 009 portNum = 004
Warning: libusb_claim_interface() -6
Error: kernel driver not active - should have been able to claim interface!
Close this device and try next one if there is one!
Opened device with idVendor = 0x1df7 idProduct = 0x3010 fwVersion = 0x0207 busNum = 009 portNum = 004
Warning: libusb_claim_interface() -6
Error: kernel driver not active - should have been able to claim interface!
Close this device and try next one if there is one!
mir_sdr_usb_Init: Timeout expired/failed to establish connection with the device
mir_sdr_2500_Init: mir_sdr_usb_Init() failed
mir_sdr_Init: mir_sdr_2500_Init() Error 1
mir_sdr_StreamInit: mir_sdr_Init failed 7
mir_sdr_StreamUninit()
Failed to start SDRPlay RSP device.

I'm confused as to why StreamInit was not able to move onto the next device on portNum=003. Any help with this or my earlier problem would be much appreciated.

Re: USB buffer overflow in mir_sdr_SetDeviceIDx routine

Posted: Fri Jun 23, 2017 4:52 am
by sdrplay
Something I'm not understanding here. The sequence of events should be...

GetDevices
SetDeviceIdx
StreamInit (or are you using Init?)
...
StreamUninit (or are you using Uninit?)
ReleaseDeviceIdx

Is this what you are doing? I can't see any error in your output from SetDeviceIdx

Can you send the code to software@sdrplay.com or raise a support ticket (http://www.sdrplay.com/support)

Please also let me know what OS/processor you are using.

Best regards,

SDRplay Support

Re: USB buffer overflow in mir_sdr_SetDeviceIDx routine

Posted: Fri Jun 23, 2017 1:10 pm
by ERtpl
Thanks for getting back to me. I've raised a support ticket with code/terminal outputs and supporting information.

I'm running CentOS 7 which may be the source of some incompatibility.

I think I might have been confusing by posting the two separate questions on this thread. For the original post the sequence did follow
GetDevices
SetDeviceIdx
StreamInit

but I don't believe that StreamInit was actually called during execution. The code appeared to hang after the call to SetDeviceIdx.

For the ticket, I ran play_sdr.c from the examples page on the Github repo and was able to recreate the "USB buffer overflow" error which again prevented further outputs to the terminal.

Re: USB buffer overflow in mir_sdr_SetDeviceIDx routine

Posted: Fri Jun 23, 2017 6:02 pm
by sdrplay
I've been doing some tests today and the behaviour seems to be dependant on libusb version. I will be investigating further.

Best regards,

SDRplay Support