Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature request: support libmirisdr-4 (modern fork of libmirisdr-2 / libmirisdr-3 with SDRplay support) #9

Open
xmikos opened this issue Mar 26, 2017 · 2 comments

Comments

@xmikos
Copy link

xmikos commented Mar 26, 2017

Hello,

would it be possible to support libmirisdr-4 library? It is actively developed fork of libmirisdr-2 / libmirisdr-3-bsz with direct support of SDRplay through a "flavour" option in the open function (this is also reason why build of SoapyOsmo fails with libmirisdr-4).

libmirisdr-4 is used by SDRangel app (similar to GQRX or CubicSDR) for SDRplay support. On my laptop (Lenovo ThinkPad 13, Intel Core i5 Skylake platform) SoapySDRplay (and generally everything which uses proprietary libsdrplay library) fails to read samples and according to SDRplay support it is known issue with some USB 3 drivers (my laptop doesn't have USB 2-only ports). But SDRangel with libmirisdr-4 works really great.

Maybe the best option would be separate SoapyMiriSDR driver, same as like SoapyRTLSDR and SoapyAirspy has been separated. It would be great because 1.) it is not so fragile as libsdrplay (works on more hardware configurations) and 2.) it is open source and therefore can be distributed without any problems.

Btw. just for the reference there is build error when using libmirisdr-4:

/home/mikos/temp/soapyosmo-git/gr-osmosdr/lib/miri/miri_source_c.cc: In constructor 'miri_source_c::miri_source_c(const string&)':
/home/mikos/temp/soapyosmo-git/gr-osmosdr/lib/miri/miri_source_c.cc:119:40: error: invalid conversion from 'unsigned int' to 'mirisdr_hw_flavour_t' [-fpermissive]
   ret = mirisdr_open( &_dev, dev_index );
                                        ^
/home/mikos/temp/soapyosmo-git/gr-osmosdr/lib/miri/miri_source_c.cc:119:40: error: too few arguments to function 'int mirisdr_open(mirisdr_dev_t**, mirisdr_hw_flavour_t, uint32_t)'
In file included from /home/mikos/temp/soapyosmo-git/gr-osmosdr/lib/miri/miri_source_c.cc:41:0:
/usr/include/mirisdr.h:59:17: note: declared here
 MIRISDR_API int mirisdr_open (mirisdr_dev_t **p, mirisdr_hw_flavour_t hw_flavour, uint32_t index);
                 ^~~~~~~~~~~~
make[2]: *** [CMakeFiles/miriSupport.dir/build.make:63: CMakeFiles/miriSupport.dir/gr-osmosdr/lib/miri/miri_source_c.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/miriSupport.dir/all] Error 2
make: *** [Makefile:139: all] Error 2
@guruofquality
Copy link
Contributor

would it be possible to support libmirisdr-4 library?

Keep in mind SoapyOsmo is just a copy of gr-osmosdr. If its become out of date for some reason I'm happy to resync it. If I recall, most of the recent osmosdr developments have been for components that are supported now by other Soapy* modules. But I don't want to do independent development in this repo aside from just making the wrapper work.

Maybe the best option would be separate SoapyMiriSDR

I agree. I'm happy to host this, and provide builds/packages much like the other support modules. So long as someone is willing to do the initial development.

@ericek111
Copy link

ericek111 commented Nov 29, 2021

That hw_flavour parameter was the only thing breaking backwards compatibility. BUT, there is one more bug in the mirisdr receiver.

https://github.com/pothosware/SoapyOsmo/blob/master/gr-osmosdr/lib/miri/miri_source_c.cc#L136

Here, it should be calloc(_buf_num, sizeof(unsigned int)). I don't really understand what's exactly going on. I think it's trying to put the next buffer's length into _samp_avail, but only unitialized garbage is copied, resulting in a crash (as if the receive buffer was many megabytes long -- it overflows the output buffer on line 249):
https://github.com/pothosware/SoapyOsmo/blob/master/gr-osmosdr/lib/miri/miri_source_c.cc#L268

But, I'm not sure if we should continue to support this. I don't want to submit patches here, because the gr-osmosdr repo is pulled into this one. Sadly, the MiriSDR implementation has been dropped from gr-osmosdr: https://osmocom.org/projects/gr-osmosdr/repository/gr-osmosdr/revisions/fe03d837038884bfde2efe63cbf8ead4b846a3c8

Making a new SoapySDR module would be better, I think. I'll try to put something together.

EDIT: Here's a fix for the aforementioned issues: https://gist.github.com/ericek111/4e59b94ecfc20a182c2bb1c3fab5fa42
And here is my Soapy driver for libmirisdr-4 (and my fork, libmirisdr-5): https://github.com/ericek111/SoapyMiri

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants