From mueller at kit.edu Thu Jan 2 13:49:06 2020 From: mueller at kit.edu (=?utf-8?B?TcO8bGxlciwgTWFyY3VzIChDRUwp?=) Date: Thu, 2 Jan 2020 13:49:06 +0000 Subject: Request for Comment: Creating a binary format output for rtl_power In-Reply-To: References: Message-ID: <1ff1308f8237eada5e959558854e5156dd7e230a.camel@kit.edu> Hi Abhishek, On Fri, 2019-12-27 at 20:11 +0530, Abhishek Goyal wrote: > In practice you will find that [text format+ compression] will be > fairly close to [binary format + compression] in final size. Is that so? Color me surprised! While certainly any dictionary-based compressor could find the bytes that make up the individual digits and compress them to an average of a little less than 4b, that'd still be worse than the 8b you need to represent any number 0-255, for example. And if your dictionary allows for variable-length words, like an LZ(W) kind of algorithm, the compression ratio should saturate pretty early. Now, I haven't worked with the specific text data coming out of rtl_power, so I'd be very interested in the results! Bill, could you compress a few of your textual rtl_power output files (using gzip --best, and maybe xz) for us and tell us the how many numbers were in the original files and how many bytes are the resulting files in length? (zstd: would be very interesting to have a detached dictionary, because I presume the dictionary overhead to be non-negligible with large numbers of smaller observation files) (BTW, tar is the worst format under the sun to compress many small files; it pads every file to 512B; of course, zeros compress nicely, but suddenly your shortest codeword is a useless padding symbol and that has a measurable compressed file size effect) > Compression obviously will reduce random access to data, so if your > intended use involves seeking randomly around in the data, things get > tricky. Indeed, that's what I'd have to bring forward: A "compressor" based on simply converting the tabular text data to binary format would be not so far away, worst case, from an actual entropy encoder, but allow for random seeks, AND be faster. I honestly don't see the downsides of that! > If the format is intended to be shared with other people, and/or > manage large collections of such data, either use hdf5[1] or look > into it for inspiration. Yep; or other formats. GNU Radio, for example, simply uses raw binary numbers packed end-to-end; there's the SigMF project which strives to provide metadata (sample format, acquisition time, and other parameters) in a separate file. It's JSON lying next to your data file. Whether or not that's useful to you... > If that sounds too complicated, then protobufs[2] might be another > option. Both hdf5 and protobufs benefit from having readily available > code for access to the data for later analysis, and from having > hundreds of man-years of bugfixes and portability fixes behind them. Yeah, but a protobuf that's mostly a buffer of ints really is only binary numbers right after each other, plus a header that you define yourself. It's a good idea to let some library like protobuf handle that, I agree! > Again, depending on the use case, another option might be to store > the data in a sqlite[3] database file, its an underrated option for > large amounts of data: here the binary conversion to and fro can be > handled by the sqlite tools themselves, and you have access to the > data in a fully random-access fashion. There are ways for sqlite to > do online compression of data as well[4], incase you find the > standard size reduction from going to binary isn't enough. Not quite sure how well sqlite handles compression of BLOBs, or are you suggesting you insert samples as values individually? By the way, I think "so much data it becomes a burden to my server" is actually not covered by what sqlite is designed to do. There might be more optimized databases for that. > Greg brought up endianness, then theres framing(indicating the start if each "row" of data, in case a few bytes got corrupted on disk, thus allowing the rest to still be recovered) Which should be no problem, seeing that rows are fixed-length, > versioning (if you change the data format, how do you have the reading code still remain able to read the older format) Important point, imho, but this feels like a one-off format, so really, might be a bit of overengineering. Anyways, never hurts to simply have a header field that says "version". Do that! > debugging (its very hard to be 100% sure that a binary data you intended to write, typically there will be no error messages from the code and no crashes - just wrong and misleading results due to miswritten/misread data), etc. In my experience, writing textual data is way harder to keep consistent, due to the non-fixed amount of bytes required per word. Best regards, Marcus -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 6582 bytes Desc: not available URL: From h_ayguen at web.de Fri Jan 3 01:25:28 2020 From: h_ayguen at web.de (Hayati Ayguen) Date: Fri, 3 Jan 2020 02:25:28 +0100 Subject: Request for Comment: Creating a binary format output for rtl_power In-Reply-To: <1ff1308f8237eada5e959558854e5156dd7e230a.camel@kit.edu> References: <1ff1308f8237eada5e959558854e5156dd7e230a.camel@kit.edu> Message-ID: Hi, i'd agree that having text encoding + compression is far from ideal. However, another aspect/goad might be following: have the main data readable binary from gnuplot. see http://gnuplot.sourceforge.net/docs_4.2/node103.html kind regards, Hayati Am 02.01.2020 um 14:49 schrieb M?ller, Marcus (CEL): > Hi Abhishek, > > On Fri, 2019-12-27 at 20:11 +0530, Abhishek Goyal wrote: >> In practice you will find that [text format+ compression] will be >> fairly close to [binary format + compression] in final size. > > Is that so? Color me surprised! While certainly any dictionary-based > compressor could find the bytes that make up the individual digits and > compress them to an average of a little less than 4b, that'd still be > worse than the 8b you need to represent any number 0-255, for example. > And if your dictionary allows for variable-length words, like an LZ(W) > kind of algorithm, the compression ratio should saturate pretty early. > > Now, I haven't worked with the specific text data coming out of > rtl_power, so I'd be very interested in the results! > Bill, could you compress a few of your textual rtl_power output files > (using gzip --best, and maybe xz) for us and tell us the how many > numbers were in the original files and how many bytes are the resulting > files in length? > > (zstd: would be very interesting to have a detached dictionary, because > I presume the dictionary overhead to be non-negligible with large > numbers of smaller observation files) > (BTW, tar is the worst format under the sun to compress many small > files; it pads every file to 512B; of course, zeros compress nicely, > but suddenly your shortest codeword is a useless padding symbol and > that has a measurable compressed file size effect) > >> Compression obviously will reduce random access to data, so if your >> intended use involves seeking randomly around in the data, things get >> tricky. > > Indeed, that's what I'd have to bring forward: A "compressor" based on > simply converting the tabular text data to binary format would be not > so far away, worst case, from an actual entropy encoder, but allow for > random seeks, AND be faster. I honestly don't see the downsides of > that! > >> If the format is intended to be shared with other people, and/or >> manage large collections of such data, either use hdf5[1] or look >> into it for inspiration. > > Yep; or other formats. GNU Radio, for example, simply uses raw binary > numbers packed end-to-end; there's the SigMF project which strives to > provide metadata (sample format, acquisition time, and other > parameters) in a separate file. It's JSON lying next to your data file. > Whether or not that's useful to you... > >> If that sounds too complicated, then protobufs[2] might be another >> option. Both hdf5 and protobufs benefit from having readily available >> code for access to the data for later analysis, and from having >> hundreds of man-years of bugfixes and portability fixes behind them. > > Yeah, but a protobuf that's mostly a buffer of ints really is only > binary numbers right after each other, plus a header that you define > yourself. It's a good idea to let some library like protobuf handle > that, I agree! > >> Again, depending on the use case, another option might be to store >> the data in a sqlite[3] database file, its an underrated option for >> large amounts of data: here the binary conversion to and fro can be >> handled by the sqlite tools themselves, and you have access to the >> data in a fully random-access fashion. There are ways for sqlite to >> do online compression of data as well[4], incase you find the >> standard size reduction from going to binary isn't enough. > > Not quite sure how well sqlite handles compression of BLOBs, or are you > suggesting you insert samples as values individually? > > By the way, I think "so much data it becomes a burden to my server" is > actually not covered by what sqlite is designed to do. There might be > more optimized databases for that. > >> Greg brought up endianness, then theres framing(indicating the start > if each "row" of data, in case a few bytes got corrupted on disk, thus > allowing the rest to still be recovered) > > Which should be no problem, seeing that rows are fixed-length, > >> versioning (if you change the data format, how do you have the > reading code still remain able to read the older format) > > Important point, imho, but this feels like a one-off format, so really, > might be a bit of overengineering. Anyways, never hurts to simply have > a header field that says "version". Do that! > >> debugging (its very hard to be 100% sure that a binary data you > intended to write, typically there will be no error messages from the > code and no crashes - just wrong and misleading results due to > miswritten/misread data), etc. > > In my experience, writing textual data is way harder to keep > consistent, due to the non-fixed amount of bytes required per word. > > Best regards, > Marcus > From chibill110 at gmail.com Fri Jan 3 19:51:41 2020 From: chibill110 at gmail.com (Bill Gaylord) Date: Fri, 3 Jan 2020 13:51:41 -0600 Subject: Request for Comment: Creating a binary format output for rtl_power In-Reply-To: References: <1ff1308f8237eada5e959558854e5156dd7e230a.camel@kit.edu> Message-ID: I will be starting by defining by format then writing a converter to convert between text csv and the binary format. I will also try to write a stream based converter that you can pipe the output of rtl_power into the write the binary format directly. I figure this is more universal then trying to make a binary format in the application itself. On Thu, Jan 2, 2020 at 7:30 PM Hayati Ayguen wrote: > > Hi, > > i'd agree that having text encoding + compression is far from ideal. > > However, another aspect/goad might be following: > have the main data readable binary from gnuplot. > > see > http://gnuplot.sourceforge.net/docs_4.2/node103.html > > > kind regards, > Hayati > > > Am 02.01.2020 um 14:49 schrieb M?ller, Marcus (CEL): > > Hi Abhishek, > > > > On Fri, 2019-12-27 at 20:11 +0530, Abhishek Goyal wrote: > >> In practice you will find that [text format+ compression] will be > >> fairly close to [binary format + compression] in final size. > > > > Is that so? Color me surprised! While certainly any dictionary-based > > compressor could find the bytes that make up the individual digits and > > compress them to an average of a little less than 4b, that'd still be > > worse than the 8b you need to represent any number 0-255, for example. > > And if your dictionary allows for variable-length words, like an LZ(W) > > kind of algorithm, the compression ratio should saturate pretty early. > > > > Now, I haven't worked with the specific text data coming out of > > rtl_power, so I'd be very interested in the results! > > Bill, could you compress a few of your textual rtl_power output files > > (using gzip --best, and maybe xz) for us and tell us the how many > > numbers were in the original files and how many bytes are the resulting > > files in length? > > > > (zstd: would be very interesting to have a detached dictionary, because > > I presume the dictionary overhead to be non-negligible with large > > numbers of smaller observation files) > > (BTW, tar is the worst format under the sun to compress many small > > files; it pads every file to 512B; of course, zeros compress nicely, > > but suddenly your shortest codeword is a useless padding symbol and > > that has a measurable compressed file size effect) > > > >> Compression obviously will reduce random access to data, so if your > >> intended use involves seeking randomly around in the data, things get > >> tricky. > > > > Indeed, that's what I'd have to bring forward: A "compressor" based on > > simply converting the tabular text data to binary format would be not > > so far away, worst case, from an actual entropy encoder, but allow for > > random seeks, AND be faster. I honestly don't see the downsides of > > that! > > > >> If the format is intended to be shared with other people, and/or > >> manage large collections of such data, either use hdf5[1] or look > >> into it for inspiration. > > > > Yep; or other formats. GNU Radio, for example, simply uses raw binary > > numbers packed end-to-end; there's the SigMF project which strives to > > provide metadata (sample format, acquisition time, and other > > parameters) in a separate file. It's JSON lying next to your data file. > > Whether or not that's useful to you... > > > >> If that sounds too complicated, then protobufs[2] might be another > >> option. Both hdf5 and protobufs benefit from having readily available > >> code for access to the data for later analysis, and from having > >> hundreds of man-years of bugfixes and portability fixes behind them. > > > > Yeah, but a protobuf that's mostly a buffer of ints really is only > > binary numbers right after each other, plus a header that you define > > yourself. It's a good idea to let some library like protobuf handle > > that, I agree! > > > >> Again, depending on the use case, another option might be to store > >> the data in a sqlite[3] database file, its an underrated option for > >> large amounts of data: here the binary conversion to and fro can be > >> handled by the sqlite tools themselves, and you have access to the > >> data in a fully random-access fashion. There are ways for sqlite to > >> do online compression of data as well[4], incase you find the > >> standard size reduction from going to binary isn't enough. > > > > Not quite sure how well sqlite handles compression of BLOBs, or are you > > suggesting you insert samples as values individually? > > > > By the way, I think "so much data it becomes a burden to my server" is > > actually not covered by what sqlite is designed to do. There might be > > more optimized databases for that. > > > >> Greg brought up endianness, then theres framing(indicating the start > > if each "row" of data, in case a few bytes got corrupted on disk, thus > > allowing the rest to still be recovered) > > > > Which should be no problem, seeing that rows are fixed-length, > > > >> versioning (if you change the data format, how do you have the > > reading code still remain able to read the older format) > > > > Important point, imho, but this feels like a one-off format, so really, > > might be a bit of overengineering. Anyways, never hurts to simply have > > a header field that says "version". Do that! > > > >> debugging (its very hard to be 100% sure that a binary data you > > intended to write, typically there will be no error messages from the > > code and no crashes - just wrong and misleading results due to > > miswritten/misread data), etc. > > > > In my experience, writing textual data is way harder to keep > > consistent, due to the non-fixed amount of bytes required per word. > > > > Best regards, > > Marcus > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From l29ah at cock.li Sat Jan 18 03:57:12 2020 From: l29ah at cock.li (L29Ah) Date: Sat, 18 Jan 2020 06:57:12 +0300 Subject: fl2k tools: libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=2 Message-ID: <20200118035712.j3nbfjkt2arjkmtw@l29ah-x201> I've put my flk2 away for half a year, and now i can't make it working: ? fl2k_test -s 162e6 Allocating 6 zero-copy buffers libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=2 Failed to submit transfer 0 Please increase your allowed usbfs buffer size with the following command: echo 0 > /sys/module/usbcore/parameters/usbfs_memory_mb /sys/module/usbcore/parameters/usbfs_memory_mb is zero ofc. strace tells me: [pid 9711] openat(AT_FDCWD, "/dev/bus/usb/001/007", O_RDWR|O_CLOEXEC) = 9 ... [pid 9711] ioctl(9, USBDEVFS_SUBMITURB, 0x558af7769f80) = 0 ... [pid 9711] write(2, "Allocating 6 zero-copy buffers\n", 31Allocating 6 zero-copy buffers ) = 31 [pid 9711] mmap(NULL, 3932160, PROT_READ|PROT_WRITE, MAP_SHARED, 9, 0) = 0x7ff5f7faa000 [pid 9711] mmap(NULL, 3932160, PROT_READ|PROT_WRITE, MAP_SHARED, 9, 0) = 0x7ff5f7bea000 [pid 9711] mmap(NULL, 3932160, PROT_READ|PROT_WRITE, MAP_SHARED, 9, 0) = 0x7ff5f782a000 [pid 9711] mmap(NULL, 3932160, PROT_READ|PROT_WRITE, MAP_SHARED, 9, 0) = 0x7ff5f746a000 [pid 9711] mmap(NULL, 3932160, PROT_READ|PROT_WRITE, MAP_SHARED, 9, 0) = 0x7ff5f70aa000 [pid 9711] mmap(NULL, 3932160, PROT_READ|PROT_WRITE, MAP_SHARED, 9, 0) = 0x7ff5f6cea000 [pid 9711] ioctl(9, USBDEVFS_SUBMITURB, 0x558af776a5a0) = -1 ENOENT (No such file or directory) Linux 5.5.0-rc6 and osmo-fl2k master here. What am i doing wrong? -- () ascii ribbon campaign - against html mail /\ http://arc.pasp.de/ - against proprietary attachments From steve at steve-m.de Sat Jan 18 11:25:12 2020 From: steve at steve-m.de (steve at steve-m.de) Date: Sat, 18 Jan 2020 12:25:12 +0100 Subject: fl2k tools: libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=2 In-Reply-To: <20200118035712.j3nbfjkt2arjkmtw@l29ah-x201> References: <20200118035712.j3nbfjkt2arjkmtw@l29ah-x201> Message-ID: Hi, On 2020-01-18 4:57, L29Ah wrote: > libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=2 > Failed to submit transfer 0 > Linux 5.5.0-rc6 and osmo-fl2k master here. > What am i doing wrong? I had the same issue yesterday with Kernel 5.5.0-rc6, with 5.5.0-rc5 everything is working fine. I guess we need to hurry up if we want to have that fixed for 5.5, so any help is welcome. Will try to further investigate later today. Regards, Steve From steve at steve-m.de Sun Jan 19 00:06:37 2020 From: steve at steve-m.de (Steve Markgraf) Date: Sun, 19 Jan 2020 01:06:37 +0100 Subject: fl2k tools: libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=2 In-Reply-To: References: <20200118035712.j3nbfjkt2arjkmtw@l29ah-x201> Message-ID: <66da92ff-bcf1-53c7-9f66-25f2058074ff@steve-m.de> Hi, so after some further investigation I put wrote to the linux-usb mailing list: https://marc.info/?l=linux-usb&m=157939170104145 Let's hope for the best to get this fixed for 5.5. Regards, Steve From savitaristic at gmail.com Wed Jan 22 13:34:35 2020 From: savitaristic at gmail.com (barry allen) Date: Wed, 22 Jan 2020 19:04:35 +0530 Subject: I'm unable to add osmocom sink to my gnuradio Message-ID: *while building the gr-osmosdr i received a bulk of errors* *I'm using Ubuntu 18.4 and gnuradio v3.9.* *The following are the errors* -- The CXX compiler identification is GNU 7.4.0 -- The C compiler identification is GNU 7.4.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Build type not specified: defaulting to release. -- Found Git: /usr/bin/git (found version "2.17.1") -- Extracting version information from git describe... -- Configuring Boost C++ Libraries... -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Boost version: 1.65.1 -- Found the following Boost libraries: -- thread -- system -- chrono -- date_time -- atomic -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Checking for module 'gruel' -- No package 'gruel' found -- Could NOT find GRUEL (missing: GRUEL_LIBRARIES GRUEL_INCLUDE_DIRS) -- Checking for module 'gnuradio-core' -- No package 'gnuradio-core' found -- Could NOT find GNURADIO_CORE (missing: GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) -- Checking for module 'gnuradio-iqbalance' -- Found gnuradio-iqbalance, version 0 -- Could NOT find GNURADIO_IQBALANCE (missing: GNURADIO_IQBALANCE_INCLUDE_DIRS) -- Checking for module 'uhd' -- No package 'uhd' found -- Could NOT find UHD (missing: UHD_LIBRARIES UHD_INCLUDE_DIRS) -- Checking for module 'gnuradio-uhd' -- Found gnuradio-uhd, version 3.9.0 -- gnuradio-uhd not found. -- Could NOT find GNURADIO_UHD (missing: GNURADIO_UHD_INCLUDE_DIRS) -- Checking for module 'gnuradio-fcd' -- No package 'gnuradio-fcd' found -- gnuradio-fcd not found. -- Could NOT find GNURADIO_FCD (missing: GNURADIO_FCD_LIBRARIES GNURADIO_FCD_INCLUDE_DIRS) -- Checking for module 'gnuradio-fcdproplus' -- Found gnuradio-fcdproplus, version 3.7.11 -- Found gnuradio-fcdproplus: /usr/include, /usr/lib/x86_64-linux-gnu/libgnuradio-fcdproplus.so -- Found GNURADIO_FCDPP: /usr/lib/x86_64-linux-gnu/libgnuradio-fcdproplus.so -- Checking for module 'libosmosdr' -- No package 'libosmosdr' found -- libosmosdr not found. -- Checking for module 'librtlsdr' -- No package 'librtlsdr' found -- librtlsdr not found. -- Checking for module 'libmirisdr' -- No package 'libmirisdr' found -- libmirisdr not found. -- Checking for module 'libhackrf' -- Found libhackrf, version 0.5 -- Found LIBHACKRF: /usr/local/lib/libhackrf.so -- Checking for module 'libairspy' -- No package 'libairspy' found -- Could NOT find LIBAIRSPY (missing: LIBAIRSPY_LIBRARIES LIBAIRSPY_INCLUDE_DIRS) -- Checking for module 'libbladeRF' -- No package 'libbladeRF' found -- libbladeRF not found. -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) CMake Error at CMakeLists.txt:166 (message): Gruel required to build gr-osmosdr -- Configuring incomplete, errors occurred! See also "/home/shan/gr-osmosdr/build/CMakeFiles/CMakeOutput.log". See also "/home/shan/gr-osmosdr/build/CMakeFiles/CMakeError.log". *Thanks:)* -------------- next part -------------- An HTML attachment was scrubbed... URL: From axilirator at gmail.com Wed Jan 22 14:07:05 2020 From: axilirator at gmail.com (Vadim Yanitskiy) Date: Wed, 22 Jan 2020 21:07:05 +0700 Subject: I'm unable to add osmocom sink to my gnuradio In-Reply-To: References: Message-ID: Hi, > I'm using Ubuntu 18.4 and gnuradio v3.9. You're running ahead of time, the latest release is 3.8 :) Where did you get GNU Radio from? packages? > -- Could NOT find GNURADIO_CORE (missing: GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) > -- Could NOT find UHD (missing: UHD_LIBRARIES UHD_INCLUDE_DIRS) > ... Make sure that GNU Radio is installed correctly (you should see a list of libraries like libgnuradio-uhd.so): $ sudo ldconfig -v | grep gnuradio and pkg-config can locate the libraries: $ pkg-config --libs gnuradio-uhd -lgnuradio-uhd -lgnuradio-runtime -lgnuradio-pmt -lgmpxx -lgmp With best regards, Vadim Yanitskiy. From mueller at kit.edu Wed Jan 22 14:51:21 2020 From: mueller at kit.edu (=?utf-8?B?TcO8bGxlciwgTWFyY3VzIChDRUwp?=) Date: Wed, 22 Jan 2020 14:51:21 +0000 Subject: I'm unable to add osmocom sink to my gnuradio In-Reply-To: References: Message-ID: Hi Barry, are you using a version of gr-osmosdr that's compatible with GNU Radio 3.8 and later? I'm almost certain that "GNURADIO_CORE" is a thing of the past. Best regards, Marcus On Wed, 2020-01-22 at 21:07 +0700, Vadim Yanitskiy wrote: > Hi, > > > I'm using Ubuntu 18.4 and gnuradio v3.9. > > You're running ahead of time, the latest release is 3.8 :) > Where did you get GNU Radio from? packages? > > > -- Could NOT find GNURADIO_CORE (missing: GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) > > -- Could NOT find UHD (missing: UHD_LIBRARIES UHD_INCLUDE_DIRS) > > ... > > Make sure that GNU Radio is installed correctly (you should see a list > of libraries like libgnuradio-uhd.so): > > $ sudo ldconfig -v | grep gnuradio > > and pkg-config can locate the libraries: > > $ pkg-config --libs gnuradio-uhd > -lgnuradio-uhd -lgnuradio-runtime -lgnuradio-pmt -lgmpxx -lgmp > > With best regards, > Vadim Yanitskiy. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 6582 bytes Desc: not available URL: From mueller at kit.edu Thu Jan 23 20:17:45 2020 From: mueller at kit.edu (=?utf-8?B?TcO8bGxlciwgTWFyY3VzIChDRUwp?=) Date: Thu, 23 Jan 2020 20:17:45 +0000 Subject: I'm unable to add osmocom sink to my gnuradio In-Reply-To: References: Message-ID: <215812ffd63e37356386963707d8eab18048103f.camel@kit.edu> Hi Barry, sorry, I just saw your mail. Please always make sure to reply to the whole mailing list, not just individuals. Thanks! Marcus On Wed, 2020-01-22 at 20:29 +0530, barry allen wrote: > I installed GNU radio using apt-get install gnuradio and i git cloned the gr-osmosdr from > > https://github.com/igorauad/gr-osmosdr.git > > On Wed, Jan 22, 2020 at 8:21 PM M?ller, Marcus (CEL) wrote: > > Hi Barry, > > > > are you using a version of gr-osmosdr that's compatible with GNU Radio > > 3.8 and later? I'm almost certain that "GNURADIO_CORE" is a thing of > > the past. > > > > Best regards, > > Marcus > > > > On Wed, 2020-01-22 at 21:07 +0700, Vadim Yanitskiy wrote: > > > Hi, > > > > > > > I'm using Ubuntu 18.4 and gnuradio v3.9. > > > > > > You're running ahead of time, the latest release is 3.8 :) > > > Where did you get GNU Radio from? packages? > > > > > > > -- Could NOT find GNURADIO_CORE (missing: GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) > > > > -- Could NOT find UHD (missing: UHD_LIBRARIES UHD_INCLUDE_DIRS) > > > > ... > > > > > > Make sure that GNU Radio is installed correctly (you should see a list > > > of libraries like libgnuradio-uhd.so): > > > > > > $ sudo ldconfig -v | grep gnuradio > > > > > > and pkg-config can locate the libraries: > > > > > > $ pkg-config --libs gnuradio-uhd > > > -lgnuradio-uhd -lgnuradio-runtime -lgnuradio-pmt -lgmpxx -lgmp > > > > > > With best regards, > > > Vadim Yanitskiy. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 6582 bytes Desc: not available URL: From savitaristic at gmail.com Tue Jan 21 09:04:30 2020 From: savitaristic at gmail.com (barry allen) Date: Tue, 21 Jan 2020 14:34:30 +0530 Subject: i can't builld the gr-osmosdr Message-ID: I can not compile the block gr-osmosdr, obtained block of errors ,if you can help me solve the problem ,please.Sincerely thebugslayers The following are the errors -- The CXX compiler identification is GNU 7.4.0 -- The C compiler identification is GNU 7.4.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Build type not specified: defaulting to release. -- Found Git: /usr/bin/git (found version "2.17.1") -- Extracting version information from git describe... -- Configuring Boost C++ Libraries... -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Boost version: 1.65.1 -- Found the following Boost libraries: -- thread -- system -- chrono -- date_time -- atomic -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Checking for module 'gruel' -- No package 'gruel' found -- Could NOT find GRUEL (missing: GRUEL_LIBRARIES GRUEL_INCLUDE_DIRS) -- Checking for module 'gnuradio-core' -- No package 'gnuradio-core' found -- Could NOT find GNURADIO_CORE (missing: GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) -- Checking for module 'gnuradio-iqbalance' -- Found gnuradio-iqbalance, version 0 -- Could NOT find GNURADIO_IQBALANCE (missing: GNURADIO_IQBALANCE_INCLUDE_DIRS) -- Checking for module 'uhd' -- No package 'uhd' found -- Could NOT find UHD (missing: UHD_LIBRARIES UHD_INCLUDE_DIRS) -- Checking for module 'gnuradio-uhd' -- Found gnuradio-uhd, version 3.9.0 -- gnuradio-uhd not found. -- Could NOT find GNURADIO_UHD (missing: GNURADIO_UHD_INCLUDE_DIRS) -- Checking for module 'gnuradio-fcd' -- No package 'gnuradio-fcd' found -- gnuradio-fcd not found. -- Could NOT find GNURADIO_FCD (missing: GNURADIO_FCD_LIBRARIES GNURADIO_FCD_INCLUDE_DIRS) -- Checking for module 'gnuradio-fcdproplus' -- Found gnuradio-fcdproplus, version 3.7.11 -- Found gnuradio-fcdproplus: /usr/include, /usr/lib/x86_64-linux-gnu/libgnuradio-fcdproplus.so -- Found GNURADIO_FCDPP: /usr/lib/x86_64-linux-gnu/libgnuradio-fcdproplus.so -- Checking for module 'libosmosdr' -- No package 'libosmosdr' found -- libosmosdr not found. -- Checking for module 'librtlsdr' -- No package 'librtlsdr' found -- librtlsdr not found. -- Checking for module 'libmirisdr' -- No package 'libmirisdr' found -- libmirisdr not found. -- Checking for module 'libhackrf' -- Found libhackrf, version 0.5 -- Found LIBHACKRF: /usr/local/lib/libhackrf.so -- Checking for module 'libairspy' -- No package 'libairspy' found -- Could NOT find LIBAIRSPY (missing: LIBAIRSPY_LIBRARIES LIBAIRSPY_INCLUDE_DIRS) -- Checking for module 'libbladeRF' -- No package 'libbladeRF' found -- libbladeRF not found. -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) CMake Error at CMakeLists.txt:166 (message): Gruel required to build gr-osmosdr -- Configuring incomplete, errors occurred! See also "/home/shan/gr-osmosdr/build/CMakeFiles/CMakeOutput.log". See also "/home/shan/gr-osmosdr/build/CMakeFiles/CMakeError.log". Thanks:) -------------- next part -------------- An HTML attachment was scrubbed... URL: From l29ah at cock.li Thu Jan 23 21:26:50 2020 From: l29ah at cock.li (L29Ah) Date: Fri, 24 Jan 2020 00:26:50 +0300 Subject: FL2k error Buffer In-Reply-To: References: Message-ID: <20200123212650.cacvp2lpaniqk7iu@l29ah-x201> On Mon, Dec 02, 2019 at 12:15:47AM +0530, Abhishek sharma wrote: > It was stange that I was getting an error constantly i.e. "no free > transfer, skipping input buffer" even though I setup the sample rate to > minimum but still getting the same error. You can revert a9f3771eb6ad4f9afb98d346dc6c54a1812d6e73 for now. -- () ascii ribbon campaign - against html mail /\ http://arc.pasp.de/ - against proprietary attachments From savitaristic at gmail.com Fri Jan 24 03:15:40 2020 From: savitaristic at gmail.com (barry allen) Date: Fri, 24 Jan 2020 08:45:40 +0530 Subject: i can't builld the gr-osmosdr In-Reply-To: References: Message-ID: Thanks for your reply . This helped a lot and i solved the problem? On Fri 24 Jan, 2020, 8:42 AM Kyeong Su Shin, wrote: > Hello Barry: > > Your previous e-mails suggest that you installed GNU Radio by using the > apt command. Are you using the official Ubuntu respository (which is GNU > Radio 3.7)? Or, are you using some kind third-party packages (maybe 3.8)? > > If you are using the official Ubuntu packages (for GNU Radio), then you > can just install gr-osmosdr from there too (sudo apt install gr-osmosdr). > If you still want to build gr-osmosdr (if you need to install a modified or > an updated version of gr-osmosdr), then get gr-osmosdr for GNU Radio 3.7 (I > think you are using one for the GNU Radio 3.6, which is too old), and > install missing dependencies as mentioned in the error message (like > doxygen, libhackrf-dev, etc). > > If you absolutely need to run gr-osmosdr for GNU Radio 3.6 (don't do this > unless you need to run a heavily modified version of gr-osmosdr that only > supports gr3.6), then you will need to install GNU Radio 3.6, which would > be pretty annoying on modern Linux distros. > > If you did not use the official Ubuntu repo to install GNU Radio and used > a third-party repo instead, then check if they have their own versions of > gr-osmosdr. If they don't, install gnuradio-dev (from their repo) and try > building gr-osmosdr for that. If it's GNU Radio v3.8 or higher, then you > need to get a version of gr-osmosdr that supports gr 3.8. Again, you will > need to install some additional dependencies as mentioned in the message. > > Regards, > Kyeong Su Shin > ------------------------------ > *?? ??:* barry allen ?? osmocom-sdr < > osmocom-sdr-bounces at lists.osmocom.org> > *?? ??:* 2020? 1? 21? ??? ?? 6:04 > *?? ??:* osmocom-sdr at lists.osmocom.org > *??:* i can't builld the gr-osmosdr > > > I can not compile the block gr-osmosdr, obtained block of errors ,if you > can help me solve the problem ,please.Sincerely thebugslayers > > The following are the errors > > -- The CXX compiler identification is GNU 7.4.0 > -- The C compiler identification is GNU 7.4.0 > -- Check for working CXX compiler: /usr/bin/c++ > -- Check for working CXX compiler: /usr/bin/c++ -- works > -- Detecting CXX compiler ABI info > -- Detecting CXX compiler ABI info - done > -- Detecting CXX compile features > -- Detecting CXX compile features - done > -- Check for working C compiler: /usr/bin/cc > -- Check for working C compiler: /usr/bin/cc -- works > -- Detecting C compiler ABI info > -- Detecting C compiler ABI info - done > -- Detecting C compile features > -- Detecting C compile features - done > -- Build type not specified: defaulting to release. > -- Found Git: /usr/bin/git (found version "2.17.1") > -- Extracting version information from git describe... > -- Configuring Boost C++ Libraries... > -- Looking for pthread.h > -- Looking for pthread.h - found > -- Looking for pthread_create > -- Looking for pthread_create - not found > -- Looking for pthread_create in pthreads > -- Looking for pthread_create in pthreads - not found > -- Looking for pthread_create in pthread > -- Looking for pthread_create in pthread - found > -- Found Threads: TRUE > -- Boost version: 1.65.1 > -- Found the following Boost libraries: > -- thread > -- system > -- chrono > -- date_time > -- atomic > -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") > -- Checking for module 'gruel' > -- No package 'gruel' found > -- Could NOT find GRUEL (missing: GRUEL_LIBRARIES GRUEL_INCLUDE_DIRS) > -- Checking for module 'gnuradio-core' > -- No package 'gnuradio-core' found > -- Could NOT find GNURADIO_CORE (missing: GNURADIO_CORE_LIBRARIES > GNURADIO_CORE_INCLUDE_DIRS) > -- Checking for module 'gnuradio-iqbalance' > -- Found gnuradio-iqbalance, version 0 > -- Could NOT find GNURADIO_IQBALANCE (missing: > GNURADIO_IQBALANCE_INCLUDE_DIRS) > -- Checking for module 'uhd' > -- No package 'uhd' found > -- Could NOT find UHD (missing: UHD_LIBRARIES UHD_INCLUDE_DIRS) > -- Checking for module 'gnuradio-uhd' > -- Found gnuradio-uhd, version 3.9.0 > -- gnuradio-uhd not found. > -- Could NOT find GNURADIO_UHD (missing: GNURADIO_UHD_INCLUDE_DIRS) > -- Checking for module 'gnuradio-fcd' > -- No package 'gnuradio-fcd' found > -- gnuradio-fcd not found. > -- Could NOT find GNURADIO_FCD (missing: GNURADIO_FCD_LIBRARIES > GNURADIO_FCD_INCLUDE_DIRS) > -- Checking for module 'gnuradio-fcdproplus' > -- Found gnuradio-fcdproplus, version 3.7.11 > -- Found gnuradio-fcdproplus: /usr/include, > /usr/lib/x86_64-linux-gnu/libgnuradio-fcdproplus.so > -- Found GNURADIO_FCDPP: > /usr/lib/x86_64-linux-gnu/libgnuradio-fcdproplus.so > -- Checking for module 'libosmosdr' > -- No package 'libosmosdr' found > -- libosmosdr not found. > -- Checking for module 'librtlsdr' > -- No package 'librtlsdr' found > -- librtlsdr not found. > -- Checking for module 'libmirisdr' > -- No package 'libmirisdr' found > -- libmirisdr not found. > -- Checking for module 'libhackrf' > -- Found libhackrf, version 0.5 > -- Found LIBHACKRF: /usr/local/lib/libhackrf.so > -- Checking for module 'libairspy' > -- No package 'libairspy' found > -- Could NOT find LIBAIRSPY (missing: LIBAIRSPY_LIBRARIES > LIBAIRSPY_INCLUDE_DIRS) > -- Checking for module 'libbladeRF' > -- No package 'libbladeRF' found > -- libbladeRF not found. > -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) > CMake Error at CMakeLists.txt:166 (message): > Gruel required to build gr-osmosdr > > -- Configuring incomplete, errors occurred! > See also "/home/shan/gr-osmosdr/build/CMakeFiles/CMakeOutput.log". > See also "/home/shan/gr-osmosdr/build/CMakeFiles/CMakeError.log". > > Thanks:) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ksshin at postech.ac.kr Fri Jan 24 03:12:18 2020 From: ksshin at postech.ac.kr (Kyeong Su Shin) Date: Fri, 24 Jan 2020 03:12:18 +0000 Subject: i can't builld the gr-osmosdr In-Reply-To: References: Message-ID: Hello Barry: Your previous e-mails suggest that you installed GNU Radio by using the apt command. Are you using the official Ubuntu respository (which is GNU Radio 3.7)? Or, are you using some kind third-party packages (maybe 3.8)? If you are using the official Ubuntu packages (for GNU Radio), then you can just install gr-osmosdr from there too (sudo apt install gr-osmosdr). If you still want to build gr-osmosdr (if you need to install a modified or an updated version of gr-osmosdr), then get gr-osmosdr for GNU Radio 3.7 (I think you are using one for the GNU Radio 3.6, which is too old), and install missing dependencies as mentioned in the error message (like doxygen, libhackrf-dev, etc). If you absolutely need to run gr-osmosdr for GNU Radio 3.6 (don't do this unless you need to run a heavily modified version of gr-osmosdr that only supports gr3.6), then you will need to install GNU Radio 3.6, which would be pretty annoying on modern Linux distros. If you did not use the official Ubuntu repo to install GNU Radio and used a third-party repo instead, then check if they have their own versions of gr-osmosdr. If they don't, install gnuradio-dev (from their repo) and try building gr-osmosdr for that. If it's GNU Radio v3.8 or higher, then you need to get a version of gr-osmosdr that supports gr 3.8. Again, you will need to install some additional dependencies as mentioned in the message. Regards, Kyeong Su Shin ________________________________ ?? ??: barry allen ?? osmocom-sdr ?? ??: 2020? 1? 21? ??? ?? 6:04 ?? ??: osmocom-sdr at lists.osmocom.org ??: i can't builld the gr-osmosdr I can not compile the block gr-osmosdr, obtained block of errors ,if you can help me solve the problem ,please.Sincerely thebugslayers The following are the errors -- The CXX compiler identification is GNU 7.4.0 -- The C compiler identification is GNU 7.4.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Build type not specified: defaulting to release. -- Found Git: /usr/bin/git (found version "2.17.1") -- Extracting version information from git describe... -- Configuring Boost C++ Libraries... -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Boost version: 1.65.1 -- Found the following Boost libraries: -- thread -- system -- chrono -- date_time -- atomic -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Checking for module 'gruel' -- No package 'gruel' found -- Could NOT find GRUEL (missing: GRUEL_LIBRARIES GRUEL_INCLUDE_DIRS) -- Checking for module 'gnuradio-core' -- No package 'gnuradio-core' found -- Could NOT find GNURADIO_CORE (missing: GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) -- Checking for module 'gnuradio-iqbalance' -- Found gnuradio-iqbalance, version 0 -- Could NOT find GNURADIO_IQBALANCE (missing: GNURADIO_IQBALANCE_INCLUDE_DIRS) -- Checking for module 'uhd' -- No package 'uhd' found -- Could NOT find UHD (missing: UHD_LIBRARIES UHD_INCLUDE_DIRS) -- Checking for module 'gnuradio-uhd' -- Found gnuradio-uhd, version 3.9.0 -- gnuradio-uhd not found. -- Could NOT find GNURADIO_UHD (missing: GNURADIO_UHD_INCLUDE_DIRS) -- Checking for module 'gnuradio-fcd' -- No package 'gnuradio-fcd' found -- gnuradio-fcd not found. -- Could NOT find GNURADIO_FCD (missing: GNURADIO_FCD_LIBRARIES GNURADIO_FCD_INCLUDE_DIRS) -- Checking for module 'gnuradio-fcdproplus' -- Found gnuradio-fcdproplus, version 3.7.11 -- Found gnuradio-fcdproplus: /usr/include, /usr/lib/x86_64-linux-gnu/libgnuradio-fcdproplus.so -- Found GNURADIO_FCDPP: /usr/lib/x86_64-linux-gnu/libgnuradio-fcdproplus.so -- Checking for module 'libosmosdr' -- No package 'libosmosdr' found -- libosmosdr not found. -- Checking for module 'librtlsdr' -- No package 'librtlsdr' found -- librtlsdr not found. -- Checking for module 'libmirisdr' -- No package 'libmirisdr' found -- libmirisdr not found. -- Checking for module 'libhackrf' -- Found libhackrf, version 0.5 -- Found LIBHACKRF: /usr/local/lib/libhackrf.so -- Checking for module 'libairspy' -- No package 'libairspy' found -- Could NOT find LIBAIRSPY (missing: LIBAIRSPY_LIBRARIES LIBAIRSPY_INCLUDE_DIRS) -- Checking for module 'libbladeRF' -- No package 'libbladeRF' found -- libbladeRF not found. -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) CMake Error at CMakeLists.txt:166 (message): Gruel required to build gr-osmosdr -- Configuring incomplete, errors occurred! See also "/home/shan/gr-osmosdr/build/CMakeFiles/CMakeOutput.log". See also "/home/shan/gr-osmosdr/build/CMakeFiles/CMakeError.log". Thanks:) -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at kyla.kiruna.se Sun Jan 26 17:25:46 2020 From: fredrik at kyla.kiruna.se (Carl-Fredrik Enell) Date: Sun, 26 Jan 2020 18:25:46 +0100 Subject: libusb issue when opening device Message-ID: <24109.52122.504483.28635@fenix.lan> Dear all, I just subscribed to this list since I encountered an issue after pulling the latest git commits. > lib: use interface 0 altsetting 1 instead of interface 1 ... > This makes osmo-fl2k work again with Linux 5.5.0-rc6 or later, On my system (Debian stable, kernel 4.19) this change results in "Error enabling IF 0 altsetting 1". Reverting to the previous version (with Interface 1) solved the problem for me. I will investigate a bit more whether it is related to kernel or libusb versions. Or have I missed some other required configuration? Best regards, Carl-Fredrik SM2YHP -- ------------------ Carl-Fredrik Enell F?raregatan 26B SE-98139 Kiruna +46705508256 ----------------- From steve at steve-m.de Sun Jan 26 20:03:33 2020 From: steve at steve-m.de (Steve Markgraf) Date: Sun, 26 Jan 2020 21:03:33 +0100 Subject: libusb issue when opening device In-Reply-To: <24109.52122.504483.28635@fenix.lan> References: <24109.52122.504483.28635@fenix.lan> Message-ID: <36857b05-7f52-ba61-a13b-1573fac6e7c3@steve-m.de> Hi, On 26.01.20 18:25, Carl-Fredrik Enell wrote: > On my system (Debian stable, kernel 4.19) this change results in > "Error enabling IF 0 altsetting 1". Reverting to the > previous version (with Interface 1) solved the problem for me. Thanks for reporting this issue, you are not the first one to encounter it as it seems. > I will investigate a bit more whether it is related to kernel or > libusb versions. Or have I missed some other required configuration? Do you see any reason in the kernel log (like "not enough bandwidth")? Some googling showed that the FX3 of the bladeRF has the same issue when setting the altsetting. It seems to only happen for them if the device wasn't properly released, and they added a libusb_reset_device() as a workaround. But in our case this happens always on some machines as far as I understand. I've just pushed a workaround for now that falls back to the old behavior (claiming interface 1) in case switching interface 0 to altsetting 1. This will of course only work for Kernels < 5.5.0-rc6, but so far nobody with a Kernel >= 5.5.0-rc6 reported the altsetting issue. Thanks for further investigating, so far I cannot reproduce this issue here, maybe I should set up a machine with Kernel 4.19. What USB 3.0 host controller and version of libusb are you using? Regards, Steve From fredrik at kyla.kiruna.se Sun Jan 26 21:06:39 2020 From: fredrik at kyla.kiruna.se (Carl-Fredrik Enell) Date: Sun, 26 Jan 2020 22:06:39 +0100 Subject: libusb issue when opening device In-Reply-To: <36857b05-7f52-ba61-a13b-1573fac6e7c3@steve-m.de> References: <24109.52122.504483.28635@fenix.lan> <36857b05-7f52-ba61-a13b-1573fac6e7c3@steve-m.de> Message-ID: <24109.65375.868134.370946@fenix.lan> Hi, Thanks for your fast reply! Steve> Do you see any reason in the kernel log (like "not enough Steve> bandwidth")? /... /What USB 3.0 host controller and version of Steve> libusb are you using? The Debian machine is a Thinkpad X240, ie Intel Haswell architecture I tried libusb 1.0.22 and 1.0.23 with same result. For information, I compiled a fresh git clone on my Archlinux box (kernel 5.4.14) which worked without problem. Thus it could be either a hardware or version issue, I will look into the logs later. Best regards, -- ------------------ Carl-Fredrik Enell F?raregatan 26B SE-98139 Kiruna +46705508256 ----------------- From argilo at gmail.com Sun Jan 26 23:48:59 2020 From: argilo at gmail.com (argilo at gmail.com) Date: Sun, 26 Jan 2020 18:48:59 -0500 Subject: [PATCH] hackrf: allow transmit/receive switching Message-ID: <20200126234859.18821-1-argilo@gmail.com> From: Clayton Smith To allow switching between transmit and receive mode within a single flow graph, I've followed the model used by the BladeRF: I factored common code into hackrf_common.cc and hackrf_common.h, and created a "_devs" map there to keep track of which devices have been previously opened. Shared pointers are used to track how many source & sink blocks are using a particular device. Because some properties (center frequency, sample rate, bandwidth, RF amplifier state, bias tee) are shared between receive and transmit, the blocks defer setting these until receiving or transmitting is started. That way a source and sink can safely use different values for these properties, and the correct values are set during T/R switching. Because the HackRF driver and/or hardware does not seem to fully transmit all samples sent to it, the code adds some silence to the end of transmissions to ensure all samples are transmitted. I've also replaced boost with C++11 code where possible. --- lib/hackrf/CMakeLists.txt | 10 +- lib/hackrf/hackrf_common.cc | 432 ++++++++++++++++++++++++++++++++++ lib/hackrf/hackrf_common.h | 111 +++++++++ lib/hackrf/hackrf_sink_c.cc | 414 +++++++------------------------- lib/hackrf/hackrf_sink_c.h | 37 +-- lib/hackrf/hackrf_source_c.cc | 405 ++++--------------------------- lib/hackrf/hackrf_source_c.h | 36 +-- 7 files changed, 693 insertions(+), 752 deletions(-) create mode 100644 lib/hackrf/hackrf_common.cc create mode 100644 lib/hackrf/hackrf_common.h diff --git a/lib/hackrf/CMakeLists.txt b/lib/hackrf/CMakeLists.txt index b817518f4c..d099b41c39 100644 --- a/lib/hackrf/CMakeLists.txt +++ b/lib/hackrf/CMakeLists.txt @@ -31,16 +31,8 @@ target_link_libraries(gnuradio-osmosdr ) list(APPEND gr_osmosdr_srcs + ${CMAKE_CURRENT_SOURCE_DIR}/hackrf_common.cc ${CMAKE_CURRENT_SOURCE_DIR}/hackrf_source_c.cc ${CMAKE_CURRENT_SOURCE_DIR}/hackrf_sink_c.cc ) set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) - -include(CheckFunctionExists) -set(CMAKE_REQUIRED_LIBRARIES ${LIBHACKRF_LIBRARIES}) -CHECK_FUNCTION_EXISTS(hackrf_device_list LIBHACKRF_HAVE_DEVICE_LIST) - -if(LIBHACKRF_HAVE_DEVICE_LIST) - message(STATUS "HackRF multiple device support enabled") - target_compile_definitions(gnuradio-osmosdr PRIVATE -DLIBHACKRF_HAVE_DEVICE_LIST) -endif(LIBHACKRF_HAVE_DEVICE_LIST) diff --git a/lib/hackrf/hackrf_common.cc b/lib/hackrf/hackrf_common.cc new file mode 100644 index 0000000000..0a20f2ec9c --- /dev/null +++ b/lib/hackrf/hackrf_common.cc @@ -0,0 +1,432 @@ +/* -*- c++ -*- */ +/* + * Copyright 2020 Clayton Smith + * + * gr-osmosdr is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * gr-osmosdr is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gr-osmosdr; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "hackrf_common.h" + +#include "arg_helpers.h" + +using namespace boost::assign; + +int hackrf_common::_usage = 0; +std::mutex hackrf_common::_usage_mutex; + +std::map> hackrf_common::_devs; +std::mutex hackrf_common::_devs_mutex; + +hackrf_common::hackrf_common(const std::string &args) : + _dev(NULL), + _sample_rate(0), + _center_freq(0), + _freq_corr(0), + _auto_gain(false), + _bandwidth(0), + _bias(false), + _started(false) +{ + int ret; + hackrf_device *raw_dev; + hackrf_device_list_t *list; + int dev_index; + std::string target_serial = "0"; + std::string final_serial = ""; + + dict_t dict = params_to_dict(args); + if (dict.count("hackrf") > 0 && dict["hackrf"].length() > 0) { + target_serial = dict["hackrf"]; + } + + { + std::lock_guard guard(_usage_mutex); + + if (_usage == 0) { + hackrf_init(); /* call only once before the first open */ + } + + _usage++; + } + + list = hackrf_device_list(); + + if (target_serial.length() > 1) { + for (dev_index = 0; dev_index < list->devicecount; dev_index++) { + if (list->serial_numbers[dev_index]) { + std::string serial(list->serial_numbers[dev_index]); + if (serial.compare(serial.length() - target_serial.length(), + target_serial.length(), target_serial) == 0) { + break; + } + } + } + + if (dev_index >= list->devicecount) { + hackrf_device_list_free(list); + throw std::runtime_error( + "No device found with serial number '" + target_serial + "'"); + } + } else { + try { + dev_index = std::stoi(target_serial); + } catch (std::exception &ex) { + hackrf_device_list_free(list); + throw std::runtime_error( + "Failed to use '" + target_serial + "' as HackRF device index number"); + } + + if (dev_index >= list->devicecount) { + hackrf_device_list_free(list); + throw std::runtime_error( + "Failed to use '" + target_serial + "' as HackRF device index: not enough devices"); + } + } + + if (list->serial_numbers[dev_index]) { + final_serial = list->serial_numbers[dev_index]; + } + + { + std::lock_guard guard(_devs_mutex); + + if (_devs.count(final_serial) > 0 && !_devs[final_serial].expired()) { + _dev = hackrf_sptr(_devs[final_serial]); + } else { + ret = hackrf_device_list_open(list, dev_index, &raw_dev); + HACKRF_THROW_ON_ERROR(ret, "Failed to open HackRF device") + _dev = hackrf_sptr(raw_dev, hackrf_common::close); + _devs[final_serial] = static_cast>(_dev); + } + } + + hackrf_device_list_free(list); + + uint8_t board_id; + ret = hackrf_board_id_read(_dev.get(), &board_id); + HACKRF_THROW_ON_ERROR(ret, "Failed to get HackRF board id") + + char version[40]; + memset(version, 0, sizeof(version)); + ret = hackrf_version_string_read(_dev.get(), version, sizeof(version)); + HACKRF_THROW_ON_ERROR(ret, "Failed to read version string") + + std::cerr << "Using " << hackrf_board_id_name(hackrf_board_id(board_id)) << " " + << "with firmware " << version + << std::endl; +} + +void hackrf_common::close(void *dev) +{ + int ret = hackrf_close(static_cast(dev)); + if (ret != HACKRF_SUCCESS) + { + std::cerr << HACKRF_FORMAT_ERROR(ret, "Failed to close HackRF") << std::endl; + } + + { + std::lock_guard guard(_usage_mutex); + + _usage--; + + if (_usage == 0) { + hackrf_exit(); /* call only once after last close */ + } + } +} + +std::vector hackrf_common::get_devices() +{ + std::vector devices; + std::string label; + + { + std::lock_guard guard(_usage_mutex); + + if (_usage == 0) { + hackrf_init(); /* call only once before the first open */ + } + + _usage++; + } + + hackrf_device_list_t *list = hackrf_device_list(); + + for (int i = 0; i < list->devicecount; i++) { + label = "HackRF "; + label += hackrf_usb_board_id_name(list->usb_board_ids[i]); + + std::string args; + if (list->serial_numbers[i]) { + std::string serial(list->serial_numbers[i]); + if (serial.length() > 6) + serial = serial.substr(serial.length() - 6, 6); + args = "hackrf=" + serial; + if (serial.length() ) + label += " " + serial; + } else { + args = "hackrf"; /* will pick the first one, serial number is required for choosing a specific one */ + } + + args += ",label='" + label + "'"; + devices.push_back(args); + } + + hackrf_device_list_free(list); + + { + std::lock_guard guard(_usage_mutex); + + _usage--; + + if (_usage == 0) { + hackrf_exit(); /* call only once after last close */ + } + } + + return devices; +} + +osmosdr::meta_range_t hackrf_common::get_sample_rates() +{ + osmosdr::meta_range_t range; + + /* we only add integer rates here because of better phase noise performance. + * the user is allowed to request arbitrary (fractional) rates within these + * boundaries. */ + + range += osmosdr::range_t( 8e6 ); + range += osmosdr::range_t( 10e6 ); + range += osmosdr::range_t( 12.5e6 ); + range += osmosdr::range_t( 16e6 ); + range += osmosdr::range_t( 20e6 ); /* confirmed to work on fast machines */ + + return range; +} + +double hackrf_common::set_sample_rate( double rate ) +{ + int ret; + + if (_dev.get() && _started) { + ret = hackrf_set_sample_rate( _dev.get(), rate ); + if ( HACKRF_SUCCESS != ret ) { + HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_sample_rate", rate ) ) + } + } + + _sample_rate = rate; + return get_sample_rate(); +} + +double hackrf_common::get_sample_rate() +{ + return _sample_rate; +} + +osmosdr::freq_range_t hackrf_common::get_freq_range( size_t chan ) +{ + osmosdr::freq_range_t range; + + range += osmosdr::range_t( _sample_rate / 2, 7250e6 - _sample_rate / 2 ); + + return range; +} + +double hackrf_common::set_center_freq( double freq, size_t chan ) +{ + int ret; + + #define APPLY_PPM_CORR(val, ppm) ((val) * (1.0 + (ppm) * 0.000001)) + + if (_dev.get() && _started) { + double corr_freq = APPLY_PPM_CORR( freq, _freq_corr ); + ret = hackrf_set_freq( _dev.get(), uint64_t(corr_freq) ); + if ( HACKRF_SUCCESS != ret ) { + HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_freq", corr_freq ) ) + } + } + + _center_freq = freq; + return get_center_freq( chan ); +} + +double hackrf_common::get_center_freq( size_t chan ) +{ + return _center_freq; +} + +double hackrf_common::set_freq_corr( double ppm, size_t chan ) +{ + _freq_corr = ppm; + + set_center_freq( _center_freq ); + + return get_freq_corr( chan ); +} + +double hackrf_common::get_freq_corr( size_t chan ) +{ + return _freq_corr; +} + +bool hackrf_common::set_gain_mode( bool automatic, size_t chan ) +{ + _auto_gain = automatic; + + return get_gain_mode(chan); +} + +bool hackrf_common::get_gain_mode( size_t chan ) +{ + return _auto_gain; +} + +double hackrf_common::set_gain( double gain, size_t chan ) +{ + int ret; + double clip_gain = (gain >= 14.0) ? 14.0 : 0.0; + + if (_dev.get() && _started) { + uint8_t value = (clip_gain == 14.0) ? 1 : 0; + + ret = hackrf_set_amp_enable( _dev.get(), value ); + if ( HACKRF_SUCCESS != ret ) { + HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_amp_enable", value ) ) + } + } + + _amp_gain = clip_gain; + return hackrf_common::get_gain(chan); +} + +double hackrf_common::get_gain( size_t chan ) +{ + return _amp_gain; +} + +std::vector< std::string > hackrf_common::get_antennas( size_t chan ) +{ + std::vector< std::string > antennas; + + antennas += get_antenna( chan ); + + return antennas; +} + +std::string hackrf_common::set_antenna( const std::string & antenna, size_t chan ) +{ + return get_antenna( chan ); +} + +std::string hackrf_common::get_antenna( size_t chan ) +{ + return "TX/RX"; +} + +double hackrf_common::set_bandwidth( double bandwidth, size_t chan ) +{ + int ret; +// osmosdr::freq_range_t bandwidths = get_bandwidth_range( chan ); + + if ( bandwidth == 0.0 ) /* bandwidth of 0 means automatic filter selection */ + bandwidth = _sample_rate * 0.75; /* select narrower filters to prevent aliasing */ + + /* compute best default value depending on sample rate (auto filter) */ + uint32_t bw = hackrf_compute_baseband_filter_bw( uint32_t(bandwidth) ); + + if (_dev.get() && _started) { + ret = hackrf_set_baseband_filter_bandwidth( _dev.get(), bw ); + if (HACKRF_SUCCESS != ret) { + HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_baseband_filter_bandwidth", bw ) ) + } + } + + _bandwidth = bw; + return get_bandwidth(chan); +} + +double hackrf_common::get_bandwidth( size_t chan ) +{ + return _bandwidth; +} + +osmosdr::freq_range_t hackrf_common::get_bandwidth_range( size_t chan ) +{ + osmosdr::freq_range_t bandwidths; + + // TODO: read out from libhackrf when an API is available + + bandwidths += osmosdr::range_t( 1750000 ); + bandwidths += osmosdr::range_t( 2500000 ); + bandwidths += osmosdr::range_t( 3500000 ); + bandwidths += osmosdr::range_t( 5000000 ); + bandwidths += osmosdr::range_t( 5500000 ); + bandwidths += osmosdr::range_t( 6000000 ); + bandwidths += osmosdr::range_t( 7000000 ); + bandwidths += osmosdr::range_t( 8000000 ); + bandwidths += osmosdr::range_t( 9000000 ); + bandwidths += osmosdr::range_t( 10000000 ); + bandwidths += osmosdr::range_t( 12000000 ); + bandwidths += osmosdr::range_t( 14000000 ); + bandwidths += osmosdr::range_t( 15000000 ); + bandwidths += osmosdr::range_t( 20000000 ); + bandwidths += osmosdr::range_t( 24000000 ); + bandwidths += osmosdr::range_t( 28000000 ); + + return bandwidths; +} + +bool hackrf_common::set_bias( bool bias ) +{ + int ret; + + if (_dev.get() && _started) { + ret = hackrf_set_antenna_enable(_dev.get(), static_cast(bias)); + if (ret != HACKRF_SUCCESS) + { + std::cerr << "Failed to apply antenna bias voltage state: " << bias << HACKRF_FORMAT_ERROR(ret, "") << std::endl; + } + } + + _bias = bias; + return get_bias(); +} + +bool hackrf_common::get_bias() +{ + return _bias; +} + +void hackrf_common::start() +{ + _started = true; + set_bandwidth(get_bandwidth()); + set_center_freq(get_center_freq()); + set_sample_rate(get_sample_rate()); + set_gain(get_gain()); + set_bias(get_bias()); +} + +void hackrf_common::stop() +{ + _started = false; +} diff --git a/lib/hackrf/hackrf_common.h b/lib/hackrf/hackrf_common.h new file mode 100644 index 0000000000..02eabd2f0c --- /dev/null +++ b/lib/hackrf/hackrf_common.h @@ -0,0 +1,111 @@ +/* -*- c++ -*- */ +/* + * Copyright 2020 Clayton Smith + * + * gr-osmosdr is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * gr-osmosdr is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gr-osmosdr; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_HACKRF_COMMON_H +#define INCLUDED_HACKRF_COMMON_H + +#include +#include +#include +#include + +#include + +#include +#include + +#define BUF_LEN (16 * 32 * 512) /* must be multiple of 512 */ +#define BUF_NUM 15 + +#define BYTES_PER_SAMPLE 2 /* HackRF device produces/consumes 8 bit unsigned IQ data */ + +#define HACKRF_FORMAT_ERROR(ret, msg) \ + boost::str( boost::format(msg " (%1%) %2%") \ + % ret % hackrf_error_name((enum hackrf_error)ret) ) + +#define HACKRF_THROW_ON_ERROR(ret, msg) \ + if ( ret != HACKRF_SUCCESS ) \ + { \ + throw std::runtime_error( HACKRF_FORMAT_ERROR(ret, msg) ); \ + } + +#define HACKRF_FUNC_STR(func, arg) \ + boost::str(boost::format(func "(%1%)") % arg) + " has failed" + +typedef std::shared_ptr hackrf_sptr; + +class hackrf_common +{ +public: + hackrf_common(const std::string &args); + +protected: + static std::vector< std::string > get_devices(); + + osmosdr::meta_range_t get_sample_rates( void ); + double set_sample_rate( double rate ); + double get_sample_rate( void ); + + osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); + double set_center_freq( double freq, size_t chan = 0 ); + double get_center_freq( size_t chan = 0 ); + double set_freq_corr( double ppm, size_t chan = 0 ); + double get_freq_corr( size_t chan = 0 ); + + bool set_gain_mode( bool automatic, size_t chan = 0 ); + bool get_gain_mode( size_t chan = 0 ); + double set_gain( double gain, size_t chan = 0 ); + double get_gain( size_t chan = 0 ); + + std::vector< std::string > get_antennas( size_t chan = 0 ); + std::string set_antenna( const std::string & antenna, size_t chan = 0 ); + std::string get_antenna( size_t chan = 0 ); + + double set_bandwidth( double bandwidth, size_t chan = 0 ); + double get_bandwidth( size_t chan = 0 ); + osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); + + bool set_bias( bool bias ); + bool get_bias(); + + void start(); + void stop(); + + hackrf_sptr _dev; + +private: + static void close(void *dev); + + static int _usage; + static std::mutex _usage_mutex; + + static std::map> _devs; + static std::mutex _devs_mutex; + + double _sample_rate; + double _center_freq; + double _freq_corr; + bool _auto_gain; + double _amp_gain; + double _bandwidth; + bool _bias; + bool _started; +}; + +#endif /* INCLUDED_HACKRF_COMMON_H */ diff --git a/lib/hackrf/hackrf_sink_c.cc b/lib/hackrf/hackrf_sink_c.cc index ee089c642c..f003b89ce3 100644 --- a/lib/hackrf/hackrf_sink_c.cc +++ b/lib/hackrf/hackrf_sink_c.cc @@ -2,19 +2,20 @@ /* * Copyright 2013 Dimitri Stolnikov * Copyright 2014 Hoernchen + * Copyright 2020 Clayton Smith * - * GNU Radio is free software; you can redistribute it and/or modify + * gr-osmosdr is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * - * GNU Radio is distributed in the hope that it will be useful, + * gr-osmosdr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to + * along with gr-osmosdr; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ @@ -38,10 +39,6 @@ #endif #include -#include -#include -#include -#include #include @@ -51,24 +48,6 @@ using namespace boost::assign; -#define BUF_LEN (16 * 32 * 512) /* must be multiple of 512 */ -#define BUF_NUM 15 - -#define BYTES_PER_SAMPLE 2 /* HackRF device consumes 8 bit unsigned IQ data */ - -#define HACKRF_FORMAT_ERROR(ret, msg) \ - boost::str( boost::format(msg " (%1%) %2%") \ - % ret % hackrf_error_name((enum hackrf_error)ret) ) - -#define HACKRF_THROW_ON_ERROR(ret, msg) \ - if ( ret != HACKRF_SUCCESS ) \ - { \ - throw std::runtime_error( HACKRF_FORMAT_ERROR(ret, msg) ); \ - } - -#define HACKRF_FUNC_STR(func, arg) \ - boost::str(boost::format(func "(%1%)") % arg) + " has failed" - static inline bool cb_init(circular_buffer_t *cb, size_t capacity, size_t sz) { cb->buffer = malloc(capacity * sz); @@ -103,6 +82,11 @@ static inline bool cb_has_room(circular_buffer_t *cb) return true; } +static inline bool cb_is_empty(circular_buffer_t *cb) +{ + return cb->count == 0; +} + static inline bool cb_push_back(circular_buffer_t *cb, const void *item) { if(cb->count == cb->capacity) @@ -127,9 +111,6 @@ static inline bool cb_pop_front(circular_buffer_t *cb, void *item) return true; } -int hackrf_sink_c::_usage = 0; -boost::mutex hackrf_sink_c::_usage_mutex; - hackrf_sink_c_sptr make_hackrf_sink_c (const std::string & args) { return gnuradio::get_initial_sptr(new hackrf_sink_c (args)); @@ -156,66 +137,21 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args) : gr::sync_block ("hackrf_sink_c", gr::io_signature::make(MIN_IN, MAX_IN, sizeof (gr_complex)), gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof (gr_complex))), - _dev(NULL), + hackrf_common::hackrf_common(args), _buf(NULL), - _sample_rate(0), - _center_freq(0), - _freq_corr(0), - _auto_gain(false), - _amp_gain(0), - _vga_gain(0), - _bandwidth(0) + _vga_gain(0) { - int ret; - std::string *hackrf_serial = NULL; - dict_t dict = params_to_dict(args); - if (dict.count("hackrf") && dict["hackrf"].length() > 0) - hackrf_serial = &dict["hackrf"]; - _buf_num = 0; if (dict.count("buffers")) - _buf_num = boost::lexical_cast< unsigned int >( dict["buffers"] ); + _buf_num = std::stoi(dict["buffers"]); if (0 == _buf_num) _buf_num = BUF_NUM; - { - boost::mutex::scoped_lock lock( _usage_mutex ); - - if ( _usage == 0 ) - hackrf_init(); /* call only once before the first open */ - - _usage++; - } - - _dev = NULL; -#ifdef LIBHACKRF_HAVE_DEVICE_LIST - if ( hackrf_serial ) - ret = hackrf_open_by_serial( hackrf_serial->c_str(), &_dev ); - else -#endif - ret = hackrf_open( &_dev ); - HACKRF_THROW_ON_ERROR(ret, "Failed to open HackRF device") - - uint8_t board_id; - ret = hackrf_board_id_read( _dev, &board_id ); - HACKRF_THROW_ON_ERROR(ret, "Failed to get HackRF board id") - - char version[40]; - memset(version, 0, sizeof(version)); - ret = hackrf_version_string_read( _dev, version, sizeof(version)); - HACKRF_THROW_ON_ERROR(ret, "Failed to read version string") -#if 0 - read_partid_serialno_t serial_number; - ret = hackrf_board_partid_serialno_read( _dev, &serial_number ); - HACKRF_THROW_ON_ERROR(ret, "Failed to read serial number") -#endif - std::cerr << "Using " << hackrf_board_id_name(hackrf_board_id(board_id)) << " " - << "with firmware " << version << " " - << std::endl; + _stopping = false; if ( BUF_NUM != _buf_num ) { std::cerr << "Using " << _buf_num << " buffers of size " << BUF_LEN << "." @@ -232,26 +168,12 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args) // Check device args to find out if bias/phantom power is desired. if ( dict.count("bias_tx") ) { - bool bias = boost::lexical_cast( dict["bias_tx"] ); - ret = hackrf_set_antenna_enable(_dev, static_cast(bias)); - if ( ret != HACKRF_SUCCESS ) - { - std::cerr << "Failed to apply antenna bias voltage state: " << bias << HACKRF_FORMAT_ERROR(ret, "") << std::endl; - } - else - { - std::cerr << (bias ? "Enabled" : "Disabled") << " antenna bias voltage" << std::endl; - } + hackrf_common::set_bias(dict["bias_tx"] == "1"); } _buf = (int8_t *) malloc( BUF_LEN ); cb_init( &_cbuf, _buf_num, BUF_LEN ); - -// _thread = gr::thread::thread(_hackrf_wait, this); - - ret = hackrf_start_tx( _dev, _hackrf_tx_callback, (void *)this ); - HACKRF_THROW_ON_ERROR(ret, "Failed to start TX streaming") } /* @@ -259,30 +181,6 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args) */ hackrf_sink_c::~hackrf_sink_c () { - if (_dev) { -// _thread.join(); - int ret = hackrf_stop_tx( _dev ); - if ( ret != HACKRF_SUCCESS ) - { - std::cerr << HACKRF_FORMAT_ERROR(ret, "Failed to stop TX streaming") << std::endl; - } - ret = hackrf_close( _dev ); - if ( ret != HACKRF_SUCCESS ) - { - std::cerr << HACKRF_FORMAT_ERROR(ret, "Failed to close HackRF") << std::endl; - } - _dev = NULL; - - { - boost::mutex::scoped_lock lock( _usage_mutex ); - - _usage--; - - if ( _usage == 0 ) - hackrf_exit(); /* call only once after last close */ - } - } - free(_buf); _buf = NULL; @@ -302,11 +200,16 @@ int hackrf_sink_c::hackrf_tx_callback(unsigned char *buffer, uint32_t length) *buffer++ = rand() % 255; #else { - boost::mutex::scoped_lock lock( _buf_mutex ); + std::unique_lock lock(_buf_mutex); if ( ! cb_pop_front( &_cbuf, buffer ) ) { memset(buffer, 0, length); - std::cerr << "U" << std::flush; + if (_stopping) { + _buf_cond.notify_one(); + return -1; + } else { + std::cerr << "U" << std::flush; + } } else { // std::cerr << "-" << std::flush; _buf_cond.notify_one(); @@ -316,42 +219,61 @@ int hackrf_sink_c::hackrf_tx_callback(unsigned char *buffer, uint32_t length) return 0; // TODO: return -1 on error/stop } -void hackrf_sink_c::_hackrf_wait(hackrf_sink_c *obj) -{ - obj->hackrf_wait(); -} - -void hackrf_sink_c::hackrf_wait() -{ -} - bool hackrf_sink_c::start() { - if ( ! _dev ) + if ( ! _dev.get() ) return false; + _stopping = false; _buf_used = 0; -#if 0 - int ret = hackrf_start_tx( _dev, _hackrf_tx_callback, (void *)this ); + hackrf_common::start(); + int ret = hackrf_start_tx( _dev.get(), _hackrf_tx_callback, (void *)this ); if ( ret != HACKRF_SUCCESS ) { std::cerr << "Failed to start TX streaming (" << ret << ")" << std::endl; return false; } -#endif return true; } bool hackrf_sink_c::stop() { - if ( ! _dev ) + int i; + + if ( ! _dev.get() ) return false; -#if 0 - int ret = hackrf_stop_tx( _dev ); + + { + std::unique_lock lock(_buf_mutex); + + while ( ! cb_has_room(&_cbuf) ) + _buf_cond.wait( lock ); + + // Fill the rest of the current buffer with silence. + memset(_buf + _buf_used, 0, BUF_LEN - _buf_used); + cb_push_back( &_cbuf, _buf ); + _buf_used = 0; + + // Add some more silence so the end doesn't get cut off. + memset(_buf, 0, BUF_LEN); + for (i = 0; i < 5; i++) { + while ( ! cb_has_room(&_cbuf) ) + _buf_cond.wait( lock ); + + cb_push_back( &_cbuf, _buf ); + } + + _stopping = true; + + while (hackrf_is_streaming(_dev.get()) == HACKRF_TRUE) + _buf_cond.wait( lock ); + } + + hackrf_common::stop(); + int ret = hackrf_stop_tx( _dev.get() ); if ( ret != HACKRF_SUCCESS ) { std::cerr << "Failed to stop TX streaming (" << ret << ")" << std::endl; return false; } -#endif return true; } @@ -424,7 +346,7 @@ int hackrf_sink_c::work( int noutput_items, const gr_complex *in = (const gr_complex *) input_items[0]; { - boost::mutex::scoped_lock lock( _buf_mutex ); + std::unique_lock lock(_buf_mutex); while ( ! cb_has_room(&_cbuf) ) _buf_cond.wait( lock ); @@ -454,7 +376,7 @@ int hackrf_sink_c::work( int noutput_items, if((unsigned int)noutput_items >= remaining) { { - boost::mutex::scoped_lock lock( _buf_mutex ); + std::unique_lock lock(_buf_mutex); if ( ! cb_push_back( &_cbuf, _buf ) ) { _buf_used = prev_buf_used; @@ -477,78 +399,7 @@ int hackrf_sink_c::work( int noutput_items, std::vector hackrf_sink_c::get_devices() { - std::vector devices; - std::string label; - - { - boost::mutex::scoped_lock lock( _usage_mutex ); - - if ( _usage == 0 ) - hackrf_init(); /* call only once before the first open */ - - _usage++; - } - -#ifdef LIBHACKRF_HAVE_DEVICE_LIST - hackrf_device_list_t *list = hackrf_device_list(); - - for (int i = 0; i < list->devicecount; i++) { - label = "HackRF "; - label += hackrf_usb_board_id_name( list->usb_board_ids[i] ); - - std::string args; - if (list->serial_numbers[i]) { - std::string serial = boost::lexical_cast< std::string >( list->serial_numbers[i] ); - if (serial.length() > 6) - serial = serial.substr(serial.length() - 6, 6); - args = "hackrf=" + serial; - label += " " + serial; - } else - args = "hackrf"; /* will pick the first one, serial number is required for choosing a specific one */ - - boost::algorithm::trim(label); - - args += ",label='" + label + "'"; - devices.push_back( args ); - } - - hackrf_device_list_free(list); -#else - - int ret; - hackrf_device *dev = NULL; - ret = hackrf_open(&dev); - if ( HACKRF_SUCCESS == ret ) - { - std::string args = "hackrf=0"; - - label = "HackRF"; - - uint8_t board_id; - ret = hackrf_board_id_read( dev, &board_id ); - if ( HACKRF_SUCCESS == ret ) - { - label += std::string(" ") + hackrf_board_id_name(hackrf_board_id(board_id)); - } - - args += ",label='" + label + "'"; - devices.push_back( args ); - - ret = hackrf_close(dev); - } - -#endif - - { - boost::mutex::scoped_lock lock( _usage_mutex ); - - _usage--; - - if ( _usage == 0 ) - hackrf_exit(); /* call only once after last close */ - } - - return devices; + return hackrf_common::get_devices(); } size_t hackrf_sink_c::get_num_channels() @@ -558,88 +409,42 @@ size_t hackrf_sink_c::get_num_channels() osmosdr::meta_range_t hackrf_sink_c::get_sample_rates() { - osmosdr::meta_range_t range; - - /* we only add integer rates here because of better phase noise performance. - * the user is allowed to request arbitrary (fractional) rates within these - * boundaries. */ - - range += osmosdr::range_t( 8e6 ); - range += osmosdr::range_t( 10e6 ); - range += osmosdr::range_t( 12.5e6 ); - range += osmosdr::range_t( 16e6 ); - range += osmosdr::range_t( 20e6 ); /* confirmed to work on fast machines */ - - return range; + return hackrf_common::get_sample_rates(); } double hackrf_sink_c::set_sample_rate( double rate ) { - int ret; - - if (_dev) { - ret = hackrf_set_sample_rate( _dev, rate ); - if ( HACKRF_SUCCESS == ret ) { - _sample_rate = rate; - //set_bandwidth( 0.0 ); /* bandwidth of 0 means automatic filter selection */ - } else { - HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_sample_rate", rate ) ) - } - } - - return get_sample_rate(); + return hackrf_common::set_sample_rate(rate); } double hackrf_sink_c::get_sample_rate() { - return _sample_rate; + return hackrf_common::get_sample_rate(); } osmosdr::freq_range_t hackrf_sink_c::get_freq_range( size_t chan ) { - osmosdr::freq_range_t range; - - range += osmosdr::range_t( _sample_rate / 2, 7250e6 - _sample_rate / 2 ); - - return range; + return hackrf_common::get_freq_range(chan); } double hackrf_sink_c::set_center_freq( double freq, size_t chan ) { - int ret; - - #define APPLY_PPM_CORR(val, ppm) ((val) * (1.0 + (ppm) * 0.000001)) - - if (_dev) { - double corr_freq = APPLY_PPM_CORR( freq, _freq_corr ); - ret = hackrf_set_freq( _dev, uint64_t(corr_freq) ); - if ( HACKRF_SUCCESS == ret ) { - _center_freq = freq; - } else { - HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_freq", corr_freq ) ) - } - } - - return get_center_freq( chan ); + return hackrf_common::set_center_freq(freq, chan); } double hackrf_sink_c::get_center_freq( size_t chan ) { - return _center_freq; + return hackrf_common::get_center_freq(chan); } double hackrf_sink_c::set_freq_corr( double ppm, size_t chan ) { - _freq_corr = ppm; - - set_center_freq( _center_freq ); - - return get_freq_corr( chan ); + return hackrf_common::set_freq_corr(ppm, chan); } double hackrf_sink_c::get_freq_corr( size_t chan ) { - return _freq_corr; + return hackrf_common::get_freq_corr(chan); } std::vector hackrf_sink_c::get_gain_names( size_t chan ) @@ -672,34 +477,17 @@ osmosdr::gain_range_t hackrf_sink_c::get_gain_range( const std::string & name, s bool hackrf_sink_c::set_gain_mode( bool automatic, size_t chan ) { - _auto_gain = automatic; - - return get_gain_mode(chan); + return hackrf_common::set_gain_mode(automatic, chan); } bool hackrf_sink_c::get_gain_mode( size_t chan ) { - return _auto_gain; + return hackrf_common::get_gain_mode(chan); } double hackrf_sink_c::set_gain( double gain, size_t chan ) { - int ret; - osmosdr::gain_range_t rf_gains = get_gain_range( "RF", chan ); - - if (_dev) { - double clip_gain = rf_gains.clip( gain, true ); - uint8_t value = clip_gain == 14.0f ? 1 : 0; - - ret = hackrf_set_amp_enable( _dev, value ); - if ( HACKRF_SUCCESS == ret ) { - _amp_gain = clip_gain; - } else { - HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_amp_enable", value ) ) - } - } - - return _amp_gain; + return hackrf_common::set_gain(gain, chan); } double hackrf_sink_c::set_gain( double gain, const std::string & name, size_t chan) @@ -717,7 +505,7 @@ double hackrf_sink_c::set_gain( double gain, const std::string & name, size_t ch double hackrf_sink_c::get_gain( size_t chan ) { - return _amp_gain; + return hackrf_common::get_gain(chan); } double hackrf_sink_c::get_gain( const std::string & name, size_t chan ) @@ -738,10 +526,10 @@ double hackrf_sink_c::set_if_gain( double gain, size_t chan ) int ret; osmosdr::gain_range_t if_gains = get_gain_range( "IF", chan ); - if (_dev) { + if (_dev.get()) { double clip_gain = if_gains.clip( gain, true ); - ret = hackrf_set_txvga_gain( _dev, uint32_t(clip_gain) ); + ret = hackrf_set_txvga_gain( _dev.get(), uint32_t(clip_gain) ); if ( HACKRF_SUCCESS == ret ) { _vga_gain = clip_gain; } else { @@ -759,72 +547,30 @@ double hackrf_sink_c::set_bb_gain( double gain, size_t chan ) std::vector< std::string > hackrf_sink_c::get_antennas( size_t chan ) { - std::vector< std::string > antennas; - - antennas += get_antenna( chan ); - - return antennas; + return hackrf_common::get_antennas(chan); } std::string hackrf_sink_c::set_antenna( const std::string & antenna, size_t chan ) { - return get_antenna( chan ); + return hackrf_common::set_antenna(antenna, chan); } std::string hackrf_sink_c::get_antenna( size_t chan ) { - return "TX/RX"; + return hackrf_common::get_antenna(chan); } double hackrf_sink_c::set_bandwidth( double bandwidth, size_t chan ) { - int ret; -// osmosdr::freq_range_t bandwidths = get_bandwidth_range( chan ); - - if ( bandwidth == 0.0 ) /* bandwidth of 0 means automatic filter selection */ - bandwidth = _sample_rate * 0.75; /* select narrower filters to prevent aliasing */ - - if ( _dev ) { - /* compute best default value depending on sample rate (auto filter) */ - uint32_t bw = hackrf_compute_baseband_filter_bw( uint32_t(bandwidth) ); - ret = hackrf_set_baseband_filter_bandwidth( _dev, bw ); - if ( HACKRF_SUCCESS == ret ) { - _bandwidth = bw; - } else { - HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_baseband_filter_bandwidth", bw ) ) - } - } - - return _bandwidth; + return hackrf_common::set_bandwidth(bandwidth, chan); } double hackrf_sink_c::get_bandwidth( size_t chan ) { - return _bandwidth; + return hackrf_common::get_bandwidth(chan); } osmosdr::freq_range_t hackrf_sink_c::get_bandwidth_range( size_t chan ) { - osmosdr::freq_range_t bandwidths; - - // TODO: read out from libhackrf when an API is available - - bandwidths += osmosdr::range_t( 1750000 ); - bandwidths += osmosdr::range_t( 2500000 ); - bandwidths += osmosdr::range_t( 3500000 ); - bandwidths += osmosdr::range_t( 5000000 ); - bandwidths += osmosdr::range_t( 5500000 ); - bandwidths += osmosdr::range_t( 6000000 ); - bandwidths += osmosdr::range_t( 7000000 ); - bandwidths += osmosdr::range_t( 8000000 ); - bandwidths += osmosdr::range_t( 9000000 ); - bandwidths += osmosdr::range_t( 10000000 ); - bandwidths += osmosdr::range_t( 12000000 ); - bandwidths += osmosdr::range_t( 14000000 ); - bandwidths += osmosdr::range_t( 15000000 ); - bandwidths += osmosdr::range_t( 20000000 ); - bandwidths += osmosdr::range_t( 24000000 ); - bandwidths += osmosdr::range_t( 28000000 ); - - return bandwidths; + return hackrf_common::get_bandwidth_range(chan); } diff --git a/lib/hackrf/hackrf_sink_c.h b/lib/hackrf/hackrf_sink_c.h index a7e7ab86f5..08ff2ca8b3 100644 --- a/lib/hackrf/hackrf_sink_c.h +++ b/lib/hackrf/hackrf_sink_c.h @@ -1,34 +1,35 @@ /* -*- c++ -*- */ /* * Copyright 2013 Dimitri Stolnikov + * Copyright 2020 Clayton Smith * - * GNU Radio is free software; you can redistribute it and/or modify + * gr-osmosdr is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * - * GNU Radio is distributed in the hope that it will be useful, + * gr-osmosdr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to + * along with gr-osmosdr; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_HACKRF_SINK_C_H #define INCLUDED_HACKRF_SINK_C_H -#include #include -#include -#include +#include +#include #include #include "sink_iface.h" +#include "hackrf_common.h" class hackrf_sink_c; @@ -67,7 +68,8 @@ hackrf_sink_c_sptr make_hackrf_sink_c (const std::string & args = ""); class hackrf_sink_c : public gr::sync_block, - public sink_iface + public sink_iface, + protected hackrf_common { private: // The friend declaration allows hackrf_make_sink_c to @@ -124,29 +126,16 @@ public: private: static int _hackrf_tx_callback(hackrf_transfer* transfer); int hackrf_tx_callback(unsigned char *buffer, uint32_t length); - static void _hackrf_wait(hackrf_sink_c *obj); - void hackrf_wait(); - - static int _usage; - static boost::mutex _usage_mutex; - - hackrf_device *_dev; -// gr::thread::thread _thread; circular_buffer_t _cbuf; int8_t *_buf; unsigned int _buf_num; unsigned int _buf_used; - boost::mutex _buf_mutex; - boost::condition_variable _buf_cond; - - double _sample_rate; - double _center_freq; - double _freq_corr; - bool _auto_gain; - double _amp_gain; + bool _stopping; + std::mutex _buf_mutex; + std::condition_variable _buf_cond; + double _vga_gain; - double _bandwidth; }; #endif /* INCLUDED_HACKRF_SINK_C_H */ diff --git a/lib/hackrf/hackrf_source_c.cc b/lib/hackrf/hackrf_source_c.cc index 30b63c780b..51a6580eca 100644 --- a/lib/hackrf/hackrf_source_c.cc +++ b/lib/hackrf/hackrf_source_c.cc @@ -1,19 +1,20 @@ /* -*- c++ -*- */ /* * Copyright 2013 Dimitri Stolnikov + * Copyright 2020 Clayton Smith * - * GNU Radio is free software; you can redistribute it and/or modify + * gr-osmosdr is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * - * GNU Radio is distributed in the hope that it will be useful, + * gr-osmosdr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to + * along with gr-osmosdr; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ @@ -31,10 +32,7 @@ #include #include -#include #include -#include -#include #include @@ -44,27 +42,6 @@ using namespace boost::assign; -#define BUF_LEN (16 * 32 * 512) /* must be multiple of 512 */ -#define BUF_NUM 15 - -#define BYTES_PER_SAMPLE 2 /* HackRF device produces 8 bit unsigned IQ data */ - -#define HACKRF_FORMAT_ERROR(ret, msg) \ - boost::str( boost::format(msg " (%1%) %2%") \ - % ret % hackrf_error_name((enum hackrf_error)ret) ) - -#define HACKRF_THROW_ON_ERROR(ret, msg) \ - if ( ret != HACKRF_SUCCESS ) \ - { \ - throw std::runtime_error( HACKRF_FORMAT_ERROR(ret, msg) ); \ - } - -#define HACKRF_FUNC_STR(func, arg) \ - boost::str(boost::format(func "(%1%)") % arg) + " has failed" - -int hackrf_source_c::_usage = 0; -boost::mutex hackrf_source_c::_usage_mutex; - hackrf_source_c_sptr make_hackrf_source_c (const std::string & args) { return gnuradio::get_initial_sptr(new hackrf_source_c (args)); @@ -91,29 +68,20 @@ hackrf_source_c::hackrf_source_c (const std::string &args) : gr::sync_block ("hackrf_source_c", gr::io_signature::make(MIN_IN, MAX_IN, sizeof (gr_complex)), gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof (gr_complex))), - _dev(NULL), + hackrf_common::hackrf_common(args), _buf(NULL), - _sample_rate(0), - _center_freq(0), - _freq_corr(0), - _auto_gain(false), - _amp_gain(0), _lna_gain(0), - _vga_gain(0), - _bandwidth(0) + _vga_gain(0) { - int ret; - std::string hackrf_serial; - dict_t dict = params_to_dict(args); _buf_num = _buf_len = _buf_head = _buf_used = _buf_offset = 0; if (dict.count("buffers")) - _buf_num = boost::lexical_cast< unsigned int >( dict["buffers"] ); + _buf_num = std::stoi(dict["buffers"]); // if (dict.count("buflen")) -// _buf_len = boost::lexical_cast< unsigned int >( dict["buflen"] ); +// _buf_len = std::stoi(dict["buflen"]); if (0 == _buf_num) _buf_num = BUF_NUM; @@ -134,66 +102,6 @@ hackrf_source_c::hackrf_source_c (const std::string &args) #endif } - { - boost::mutex::scoped_lock lock( _usage_mutex ); - - if ( _usage == 0 ) - hackrf_init(); /* call only once before the first open */ - - _usage++; - } - - _dev = NULL; - -#ifdef LIBHACKRF_HAVE_DEVICE_LIST - if (dict.count("hackrf") && dict["hackrf"].length() > 0) { - hackrf_serial = dict["hackrf"]; - - if (hackrf_serial.length() > 1) { - ret = hackrf_open_by_serial( hackrf_serial.c_str(), &_dev ); - } else { - int dev_index = 0; - try { - dev_index = boost::lexical_cast< int >( hackrf_serial ); - } catch ( std::exception &ex ) { - throw std::runtime_error( - "Failed to use '" + hackrf_serial + "' as HackRF device index number: " + ex.what()); - } - - hackrf_device_list_t *list = hackrf_device_list(); - if (dev_index < list->devicecount) { - ret = hackrf_device_list_open(list, dev_index, &_dev); - } else { - hackrf_device_list_free(list); - throw std::runtime_error( - "Failed to use '" + hackrf_serial + "' as HackRF device index: not enough devices"); - } - hackrf_device_list_free(list); - } - } else -#endif - ret = hackrf_open( &_dev ); - - HACKRF_THROW_ON_ERROR(ret, "Failed to open HackRF device") - - uint8_t board_id; - ret = hackrf_board_id_read( _dev, &board_id ); - HACKRF_THROW_ON_ERROR(ret, "Failed to get HackRF board id") - - char version[40]; - memset(version, 0, sizeof(version)); - ret = hackrf_version_string_read( _dev, version, sizeof(version)); - HACKRF_THROW_ON_ERROR(ret, "Failed to read version string") - -#if 0 - read_partid_serialno_t serial_number; - ret = hackrf_board_partid_serialno_read( _dev, &serial_number ); - HACKRF_THROW_ON_ERROR(ret, "Failed to read serial number") -#endif - std::cerr << "Using " << hackrf_board_id_name(hackrf_board_id(board_id)) << " " - << "with firmware " << version << " " - << std::endl; - if ( BUF_NUM != _buf_num || BUF_LEN != _buf_len ) { std::cerr << "Using " << _buf_num << " buffers of size " << _buf_len << "." << std::endl; @@ -211,16 +119,7 @@ hackrf_source_c::hackrf_source_c (const std::string &args) // Check device args to find out if bias/phantom power is desired. if ( dict.count("bias") ) { - bool bias = boost::lexical_cast( dict["bias"] ); - ret = hackrf_set_antenna_enable(_dev, static_cast(bias)); - if ( ret != HACKRF_SUCCESS ) - { - std::cerr << "Failed to apply antenna bias voltage state: " << bias << HACKRF_FORMAT_ERROR(ret, "") << std::endl; - } - else - { - std::cerr << (bias ? "Enabled" : "Disabled") << " antenna bias voltage" << std::endl; - } + hackrf_common::set_bias(dict["bias"] == "1"); } _buf = (unsigned short **) malloc(_buf_num * sizeof(unsigned short *)); @@ -229,11 +128,6 @@ hackrf_source_c::hackrf_source_c (const std::string &args) for(unsigned int i = 0; i < _buf_num; ++i) _buf[i] = (unsigned short *) malloc(_buf_len); } - -// _thread = gr::thread::thread(_hackrf_wait, this); - - ret = hackrf_start_rx( _dev, _hackrf_rx_callback, (void *)this ); - HACKRF_THROW_ON_ERROR(ret, "Failed to start RX streaming") } /* @@ -241,30 +135,6 @@ hackrf_source_c::hackrf_source_c (const std::string &args) */ hackrf_source_c::~hackrf_source_c () { - if (_dev) { -// _thread.join(); - int ret = hackrf_stop_rx( _dev ); - if ( ret != HACKRF_SUCCESS ) - { - std::cerr << HACKRF_FORMAT_ERROR(ret, "Failed to stop RX streaming") << std::endl; - } - ret = hackrf_close( _dev ); - if ( ret != HACKRF_SUCCESS ) - { - std::cerr << HACKRF_FORMAT_ERROR(ret, "Failed to close HackRF") << std::endl; - } - _dev = NULL; - - { - boost::mutex::scoped_lock lock( _usage_mutex ); - - _usage--; - - if ( _usage == 0 ) - hackrf_exit(); /* call only once after last close */ - } - } - if (_buf) { for(unsigned int i = 0; i < _buf_num; ++i) { free(_buf[i]); @@ -284,7 +154,7 @@ int hackrf_source_c::_hackrf_rx_callback(hackrf_transfer *transfer) int hackrf_source_c::hackrf_rx_callback(unsigned char *buf, uint32_t len) { { - boost::mutex::scoped_lock lock( _buf_mutex ); + std::unique_lock lock(_buf_mutex); int buf_tail = (_buf_head + _buf_used) % _buf_num; memcpy(_buf[buf_tail], buf, len); @@ -302,40 +172,31 @@ int hackrf_source_c::hackrf_rx_callback(unsigned char *buf, uint32_t len) return 0; // TODO: return -1 on error/stop } -void hackrf_source_c::_hackrf_wait(hackrf_source_c *obj) -{ - obj->hackrf_wait(); -} - -void hackrf_source_c::hackrf_wait() -{ -} - bool hackrf_source_c::start() { - if ( ! _dev ) + if ( ! _dev.get() ) return false; -#if 0 - int ret = hackrf_start_rx( _dev, _hackrf_rx_callback, (void *)this ); + + hackrf_common::start(); + int ret = hackrf_start_rx( _dev.get(), _hackrf_rx_callback, (void *)this ); if ( ret != HACKRF_SUCCESS ) { std::cerr << "Failed to start RX streaming (" << ret << ")" << std::endl; return false; } -#endif return true; } bool hackrf_source_c::stop() { - if ( ! _dev ) + if ( ! _dev.get() ) return false; -#if 0 - int ret = hackrf_stop_rx( _dev ); + + hackrf_common::stop(); + int ret = hackrf_stop_rx( _dev.get() ); if ( ret != HACKRF_SUCCESS ) { std::cerr << "Failed to stop RX streaming (" << ret << ")" << std::endl; return false; } -#endif return true; } @@ -347,11 +208,11 @@ int hackrf_source_c::work( int noutput_items, bool running = false; - if ( _dev ) - running = (hackrf_is_streaming( _dev ) == HACKRF_TRUE); + if ( _dev.get() ) + running = (hackrf_is_streaming( _dev.get() ) == HACKRF_TRUE); { - boost::mutex::scoped_lock lock( _buf_mutex ); + std::unique_lock lock(_buf_mutex); while (_buf_used < 3 && running) // collect at least 3 buffers _buf_cond.wait( lock ); @@ -373,7 +234,7 @@ int hackrf_source_c::work( int noutput_items, *out++ = _lut[ *(buf + i) ]; { - boost::mutex::scoped_lock lock( _buf_mutex ); + std::unique_lock lock(_buf_mutex); _buf_head = (_buf_head + 1) % _buf_num; _buf_used--; @@ -395,78 +256,7 @@ int hackrf_source_c::work( int noutput_items, std::vector hackrf_source_c::get_devices() { - std::vector devices; - std::string label; - - { - boost::mutex::scoped_lock lock( _usage_mutex ); - - if ( _usage == 0 ) - hackrf_init(); /* call only once before the first open */ - - _usage++; - } - -#ifdef LIBHACKRF_HAVE_DEVICE_LIST - hackrf_device_list_t *list = hackrf_device_list(); - - for (int i = 0; i < list->devicecount; i++) { - label = "HackRF "; - label += hackrf_usb_board_id_name( list->usb_board_ids[i] ); - - std::string args; - if (list->serial_numbers[i]) { - std::string serial = boost::lexical_cast< std::string >( list->serial_numbers[i] ); - if (serial.length() > 6) - serial = serial.substr(serial.length() - 6, 6); - args = "hackrf=" + serial; - label += " " + serial; - } else - args = "hackrf"; /* will pick the first one, serial number is required for choosing a specific one */ - - boost::algorithm::trim(label); - - args += ",label='" + label + "'"; - devices.push_back( args ); - } - - hackrf_device_list_free(list); -#else - - int ret; - hackrf_device *dev = NULL; - ret = hackrf_open(&dev); - if ( HACKRF_SUCCESS == ret ) - { - std::string args = "hackrf=0"; - - label = "HackRF"; - - uint8_t board_id; - ret = hackrf_board_id_read( dev, &board_id ); - if ( HACKRF_SUCCESS == ret ) - { - label += std::string(" ") + hackrf_board_id_name(hackrf_board_id(board_id)); - } - - args += ",label='" + label + "'"; - devices.push_back( args ); - - ret = hackrf_close(dev); - } - -#endif - - { - boost::mutex::scoped_lock lock( _usage_mutex ); - - _usage--; - - if ( _usage == 0 ) - hackrf_exit(); /* call only once after last close */ - } - - return devices; + return hackrf_common::get_devices(); } size_t hackrf_source_c::get_num_channels() @@ -476,88 +266,42 @@ size_t hackrf_source_c::get_num_channels() osmosdr::meta_range_t hackrf_source_c::get_sample_rates() { - osmosdr::meta_range_t range; - - /* we only add integer rates here because of better phase noise performance. - * the user is allowed to request arbitrary (fractional) rates within these - * boundaries. */ - - range += osmosdr::range_t( 8e6 ); - range += osmosdr::range_t( 10e6 ); - range += osmosdr::range_t( 12.5e6 ); - range += osmosdr::range_t( 16e6 ); - range += osmosdr::range_t( 20e6 ); /* confirmed to work on fast machines */ - - return range; + return hackrf_common::get_sample_rates(); } double hackrf_source_c::set_sample_rate( double rate ) { - int ret; - - if (_dev) { - ret = hackrf_set_sample_rate( _dev, rate ); - if ( HACKRF_SUCCESS == ret ) { - _sample_rate = rate; - //set_bandwidth( 0.0 ); /* bandwidth of 0 means automatic filter selection */ - } else { - HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_sample_rate", rate ) ) - } - } - - return get_sample_rate(); + return hackrf_common::set_sample_rate(rate); } double hackrf_source_c::get_sample_rate() { - return _sample_rate; + return hackrf_common::get_sample_rate(); } osmosdr::freq_range_t hackrf_source_c::get_freq_range( size_t chan ) { - osmosdr::freq_range_t range; - - range += osmosdr::range_t( _sample_rate / 2, 7250e6 - _sample_rate / 2 ); - - return range; + return hackrf_common::get_freq_range(chan); } double hackrf_source_c::set_center_freq( double freq, size_t chan ) { - int ret; - - #define APPLY_PPM_CORR(val, ppm) ((val) * (1.0 + (ppm) * 0.000001)) - - if (_dev) { - double corr_freq = APPLY_PPM_CORR( freq, _freq_corr ); - ret = hackrf_set_freq( _dev, uint64_t(corr_freq) ); - if ( HACKRF_SUCCESS == ret ) { - _center_freq = freq; - } else { - HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_freq", corr_freq ) ) - } - } - - return get_center_freq( chan ); + return hackrf_common::set_center_freq(freq, chan); } double hackrf_source_c::get_center_freq( size_t chan ) { - return _center_freq; + return hackrf_common::get_center_freq(chan); } double hackrf_source_c::set_freq_corr( double ppm, size_t chan ) { - _freq_corr = ppm; - - set_center_freq( _center_freq ); - - return get_freq_corr( chan ); + return hackrf_common::set_freq_corr(ppm, chan); } double hackrf_source_c::get_freq_corr( size_t chan ) { - return _freq_corr; + return hackrf_common::get_freq_corr(chan); } std::vector hackrf_source_c::get_gain_names( size_t chan ) @@ -595,34 +339,17 @@ osmosdr::gain_range_t hackrf_source_c::get_gain_range( const std::string & name, bool hackrf_source_c::set_gain_mode( bool automatic, size_t chan ) { - _auto_gain = automatic; - - return get_gain_mode(chan); + return hackrf_common::set_gain_mode(automatic, chan); } bool hackrf_source_c::get_gain_mode( size_t chan ) { - return _auto_gain; + return hackrf_common::get_gain_mode(chan); } double hackrf_source_c::set_gain( double gain, size_t chan ) { - int ret; - osmosdr::gain_range_t rf_gains = get_gain_range( "RF", chan ); - - if (_dev) { - double clip_gain = rf_gains.clip( gain, true ); - uint8_t value = clip_gain == 14.0f ? 1 : 0; - - ret = hackrf_set_amp_enable( _dev, value ); - if ( HACKRF_SUCCESS == ret ) { - _amp_gain = clip_gain; - } else { - HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_amp_enable", value ) ) - } - } - - return _amp_gain; + return hackrf_common::set_gain(gain, chan); } double hackrf_source_c::set_gain( double gain, const std::string & name, size_t chan) @@ -644,7 +371,7 @@ double hackrf_source_c::set_gain( double gain, const std::string & name, size_t double hackrf_source_c::get_gain( size_t chan ) { - return _amp_gain; + return hackrf_common::get_gain(chan); } double hackrf_source_c::get_gain( const std::string & name, size_t chan ) @@ -669,10 +396,10 @@ double hackrf_source_c::set_if_gain(double gain, size_t chan) int ret; osmosdr::gain_range_t rf_gains = get_gain_range( "IF", chan ); - if (_dev) { + if (_dev.get()) { double clip_gain = rf_gains.clip( gain, true ); - ret = hackrf_set_lna_gain( _dev, uint32_t(clip_gain) ); + ret = hackrf_set_lna_gain( _dev.get(), uint32_t(clip_gain) ); if ( HACKRF_SUCCESS == ret ) { _lna_gain = clip_gain; } else { @@ -688,10 +415,10 @@ double hackrf_source_c::set_bb_gain( double gain, size_t chan ) int ret; osmosdr::gain_range_t if_gains = get_gain_range( "BB", chan ); - if (_dev) { + if (_dev.get()) { double clip_gain = if_gains.clip( gain, true ); - ret = hackrf_set_vga_gain( _dev, uint32_t(clip_gain) ); + ret = hackrf_set_vga_gain( _dev.get(), uint32_t(clip_gain) ); if ( HACKRF_SUCCESS == ret ) { _vga_gain = clip_gain; } else { @@ -704,72 +431,30 @@ double hackrf_source_c::set_bb_gain( double gain, size_t chan ) std::vector< std::string > hackrf_source_c::get_antennas( size_t chan ) { - std::vector< std::string > antennas; - - antennas += get_antenna( chan ); - - return antennas; + return hackrf_common::get_antennas(chan); } std::string hackrf_source_c::set_antenna( const std::string & antenna, size_t chan ) { - return get_antenna( chan ); + return hackrf_common::set_antenna(antenna, chan); } std::string hackrf_source_c::get_antenna( size_t chan ) { - return "TX/RX"; + return hackrf_common::get_antenna(chan); } double hackrf_source_c::set_bandwidth( double bandwidth, size_t chan ) { - int ret; -// osmosdr::freq_range_t bandwidths = get_bandwidth_range( chan ); - - if ( bandwidth == 0.0 ) /* bandwidth of 0 means automatic filter selection */ - bandwidth = _sample_rate * 0.75; /* select narrower filters to prevent aliasing */ - - if ( _dev ) { - /* compute best default value depending on sample rate (auto filter) */ - uint32_t bw = hackrf_compute_baseband_filter_bw( uint32_t(bandwidth) ); - ret = hackrf_set_baseband_filter_bandwidth( _dev, bw ); - if ( HACKRF_SUCCESS == ret ) { - _bandwidth = bw; - } else { - HACKRF_THROW_ON_ERROR( ret, HACKRF_FUNC_STR( "hackrf_set_baseband_filter_bandwidth", bw ) ) - } - } - - return _bandwidth; + return hackrf_common::set_bandwidth(bandwidth, chan); } double hackrf_source_c::get_bandwidth( size_t chan ) { - return _bandwidth; + return hackrf_common::get_bandwidth(chan); } osmosdr::freq_range_t hackrf_source_c::get_bandwidth_range( size_t chan ) { - osmosdr::freq_range_t bandwidths; - - // TODO: read out from libhackrf when an API is available - - bandwidths += osmosdr::range_t( 1750000 ); - bandwidths += osmosdr::range_t( 2500000 ); - bandwidths += osmosdr::range_t( 3500000 ); - bandwidths += osmosdr::range_t( 5000000 ); - bandwidths += osmosdr::range_t( 5500000 ); - bandwidths += osmosdr::range_t( 6000000 ); - bandwidths += osmosdr::range_t( 7000000 ); - bandwidths += osmosdr::range_t( 8000000 ); - bandwidths += osmosdr::range_t( 9000000 ); - bandwidths += osmosdr::range_t( 10000000 ); - bandwidths += osmosdr::range_t( 12000000 ); - bandwidths += osmosdr::range_t( 14000000 ); - bandwidths += osmosdr::range_t( 15000000 ); - bandwidths += osmosdr::range_t( 20000000 ); - bandwidths += osmosdr::range_t( 24000000 ); - bandwidths += osmosdr::range_t( 28000000 ); - - return bandwidths; + return hackrf_common::get_bandwidth_range(chan); } diff --git a/lib/hackrf/hackrf_source_c.h b/lib/hackrf/hackrf_source_c.h index 6ae81d2511..e9aacb95b3 100644 --- a/lib/hackrf/hackrf_source_c.h +++ b/lib/hackrf/hackrf_source_c.h @@ -1,36 +1,35 @@ /* -*- c++ -*- */ /* * Copyright 2013 Dimitri Stolnikov + * Copyright 2020 Clayton Smith * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify + * gr-osmosdr is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * - * GNU Radio is distributed in the hope that it will be useful, + * gr-osmosdr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to + * along with gr-osmosdr; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_HACKRF_SOURCE_C_H #define INCLUDED_HACKRF_SOURCE_C_H -#include #include -#include -#include +#include +#include #include #include "source_iface.h" +#include "hackrf_common.h" class hackrf_source_c; @@ -62,12 +61,12 @@ hackrf_source_c_sptr make_hackrf_source_c (const std::string & args = ""); */ class hackrf_source_c : public gr::sync_block, - public source_iface + public source_iface, + protected hackrf_common { private: // The friend declaration allows make_hackrf_source_c to // access the private constructor. - friend hackrf_source_c_sptr make_hackrf_source_c (const std::string & args); /*! @@ -123,35 +122,22 @@ public: private: static int _hackrf_rx_callback(hackrf_transfer* transfer); int hackrf_rx_callback(unsigned char *buf, uint32_t len); - static void _hackrf_wait(hackrf_source_c *obj); - void hackrf_wait(); - - static int _usage; - static boost::mutex _usage_mutex; std::vector _lut; - hackrf_device *_dev; - gr::thread::thread _thread; unsigned short **_buf; unsigned int _buf_num; unsigned int _buf_len; unsigned int _buf_head; unsigned int _buf_used; - boost::mutex _buf_mutex; - boost::condition_variable _buf_cond; + std::mutex _buf_mutex; + std::condition_variable _buf_cond; unsigned int _buf_offset; int _samp_avail; - double _sample_rate; - double _center_freq; - double _freq_corr; - bool _auto_gain; - double _amp_gain; double _lna_gain; double _vga_gain; - double _bandwidth; }; #endif /* INCLUDED_HACKRF_SOURCE_C_H */ -- 2.17.1 From argilo at gmail.com Mon Jan 27 02:34:39 2020 From: argilo at gmail.com (argilo at gmail.com) Date: Sun, 26 Jan 2020 21:34:39 -0500 Subject: [PATCH] airspy: fix cmake target_link_libraries Message-ID: <20200127023439.22526-1-argilo@gmail.com> From: Clayton Smith --- lib/airspy/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/airspy/CMakeLists.txt b/lib/airspy/CMakeLists.txt index 75770866db..4a601382c9 100644 --- a/lib/airspy/CMakeLists.txt +++ b/lib/airspy/CMakeLists.txt @@ -27,7 +27,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE ) target_link_libraries(gnuradio-osmosdr - gnuradio::filter + gnuradio::gnuradio-filter ${Gnuradio-blocks_LIBRARIES} ${LIBAIRSPY_LIBRARIES} ) -- 2.17.1 From tom at tswartz.net Mon Jan 27 02:35:37 2020 From: tom at tswartz.net (tom at tswartz.net) Date: Sun, 26 Jan 2020 21:35:37 -0500 Subject: GR 3.8 Build issues Message-ID: <20200127023537.GA1795@gmail.com> Hi all: I'm trying to build the latest gr-osmosdr package from the gr3.8 branch, but I'm seeing some unusual errors, and I'm not quite sure what the deal is. I'll note the following: - I had errors related to existing python2 packages, so I tried building with Python3. I'd be less than surprised if someone says that this is the cause of the issues, but personally, I'd like to roll with the Py3 products from now on, what with Py2 being EOL? - OS is Arch. My cmake command was: ``` cmake \ -DCMAKE_BUILD_TYPE=Release \ -DPYTHON_EXECUTABLE=$(which python3) \ -DPYTHON_INCLUDE_DIR=$(echo /usr/include/python3*) \ -DPYTHON_LIBRARY=$(echo /usr/lib/libpython3.*.so) \ -DENABLE_DOXYGEN=1 \ -DCMAKE_INSTALL_PREFIX=/usr ../ ``` Output from cmake: ``` -- ###################################################### -- # Gnuradio enabled components -- ###################################################### -- * Python support -- * sysmocom OsmoSDR -- * IQ File Source & Sink -- * Osmocom RTLSDR -- * RTLSDR TCP Client -- * Ettus USRP Devices -- * Osmocom MiriSDR -- * HackRF & rad1o Badge -- * nuand bladeRF -- * RFSPACE Receivers -- * AIRSPY Receiver -- * SoapySDR support -- * Red Pitaya SDR -- -- ###################################################### -- # Gnuradio disabled components -- ###################################################### -- * Osmocom IQ Imbalance Correction -- * AIRSPY HF+ Receiver -- * FreeSRP support -- -- Building for version: 0.2.0.0 / 0.2.0 -- Using install prefix: /usr -- Configuring done CMake Error at lib/CMakeLists.txt:43 (add_library): Target "gnuradio-osmosdr" links to target "gnuradio::filter" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? CMake Error at /usr/lib64/cmake/gnuradio/UseSWIG.cmake:573 (add_library): Target "osmosdr_swig" links to target "gnuradio::filter" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? Call Stack (most recent call first): /usr/lib64/cmake/gnuradio/GrSwig.cmake:133 (swig_add_library) swig/CMakeLists.txt:42 (GR_SWIG_MAKE) CMake Error at lib/CMakeLists.txt:43 (add_library): Target "gnuradio-osmosdr" links to target "gnuradio::filter" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? -- Generating done CMake Generate step failed. Build files cannot be regenerated correctly. ``` Any feedback would be appreciated. Thanks, -- Tom Swartz -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From argilo at gmail.com Mon Jan 27 02:38:56 2020 From: argilo at gmail.com (Clayton Smith) Date: Sun, 26 Jan 2020 21:38:56 -0500 Subject: GR 3.8 Build issues In-Reply-To: <20200127023537.GA1795@gmail.com> References: <20200127023537.GA1795@gmail.com> Message-ID: Coincidentally, I sent a patch for this issue just a moment ago after hitting the same issue. Regards, Clayton On Sun, Jan 26, 2020 at 9:36 PM wrote: > Hi all: > > I'm trying to build the latest gr-osmosdr package from the gr3.8 branch, > but I'm > seeing some unusual errors, and I'm not quite sure what the deal is. > > I'll note the following: > - I had errors related to existing python2 packages, so I tried building > with Python3. > I'd be less than surprised if someone says that this is the cause of the > issues, but > personally, I'd like to roll with the Py3 products from now on, what > with Py2 being EOL? > - OS is Arch. > > My cmake command was: > ``` > cmake \ > -DCMAKE_BUILD_TYPE=Release \ > -DPYTHON_EXECUTABLE=$(which python3) \ > -DPYTHON_INCLUDE_DIR=$(echo /usr/include/python3*) \ > -DPYTHON_LIBRARY=$(echo /usr/lib/libpython3.*.so) \ > -DENABLE_DOXYGEN=1 \ > -DCMAKE_INSTALL_PREFIX=/usr ../ > ``` > > > Output from cmake: > > ``` > -- ###################################################### > -- # Gnuradio enabled components > -- ###################################################### > -- * Python support > -- * sysmocom OsmoSDR > -- * IQ File Source & Sink > -- * Osmocom RTLSDR > -- * RTLSDR TCP Client > -- * Ettus USRP Devices > -- * Osmocom MiriSDR > -- * HackRF & rad1o Badge > -- * nuand bladeRF > -- * RFSPACE Receivers > -- * AIRSPY Receiver > -- * SoapySDR support > -- * Red Pitaya SDR > -- > -- ###################################################### > -- # Gnuradio disabled components > -- ###################################################### > -- * Osmocom IQ Imbalance Correction > -- * AIRSPY HF+ Receiver > -- * FreeSRP support > -- > -- Building for version: 0.2.0.0 / 0.2.0 > -- Using install prefix: /usr > -- Configuring done > CMake Error at lib/CMakeLists.txt:43 (add_library): > Target "gnuradio-osmosdr" links to target "gnuradio::filter" but the > target > was not found. Perhaps a find_package() call is missing for an IMPORTED > target, or an ALIAS target is missing? > > > CMake Error at /usr/lib64/cmake/gnuradio/UseSWIG.cmake:573 (add_library): > Target "osmosdr_swig" links to target "gnuradio::filter" but the target > was > not found. Perhaps a find_package() call is missing for an IMPORTED > target, or an ALIAS target is missing? > Call Stack (most recent call first): > /usr/lib64/cmake/gnuradio/GrSwig.cmake:133 (swig_add_library) > swig/CMakeLists.txt:42 (GR_SWIG_MAKE) > > > CMake Error at lib/CMakeLists.txt:43 (add_library): > Target "gnuradio-osmosdr" links to target "gnuradio::filter" but the > target > was not found. Perhaps a find_package() call is missing for an IMPORTED > target, or an ALIAS target is missing? > > > -- Generating done > CMake Generate step failed. Build files cannot be regenerated correctly. > ``` > > Any feedback would be appreciated. > Thanks, > > -- > Tom Swartz > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom at tswartz.net Mon Jan 27 02:41:09 2020 From: tom at tswartz.net (tom at tswartz.net) Date: Sun, 26 Jan 2020 21:41:09 -0500 Subject: GR 3.8 Build issues In-Reply-To: References: <20200127023537.GA1795@gmail.com> Message-ID: <20200127024109.GB1795@gmail.com> I just saw that come across. The messages probably crossed electrons as they were going to the server. Trying your patch now, will report. Thanks Clayton. -- Tom Swartz On Sun, Jan 26, 2020 at 09:38:56PM -0500, Clayton Smith wrote: > Coincidentally, I sent a patch for this issue just a moment ago after > hitting the same issue. > > Regards, > Clayton > > On Sun, Jan 26, 2020 at 9:36 PM wrote: > > Hi all: > > I'm trying to build the latest gr-osmosdr package from the gr3.8 > branch, but I'm > seeing some unusual errors, and I'm not quite sure what the deal is. > > I'll note the following: > - I had errors related to existing python2 packages, so I tried > building with Python3. > ? I'd be less than surprised if someone says that this is the cause of > the issues, but > ? personally, I'd like to roll with the Py3 products from now on, what > with Py2 being EOL? > - OS is Arch. > > My cmake command was: > ``` > ? cmake \ > ? ? -DCMAKE_BUILD_TYPE=Release \ > ? ? -DPYTHON_EXECUTABLE=$(which python3) \ > ? ? -DPYTHON_INCLUDE_DIR=$(echo /usr/include/python3*) \ > ? ? -DPYTHON_LIBRARY=$(echo /usr/lib/libpython3.*.so) \ > ? ? -DENABLE_DOXYGEN=1 \ > ? ? -DCMAKE_INSTALL_PREFIX=/usr ../ > ``` > > > Output from cmake: > > ``` > -- ###################################################### > -- # Gnuradio enabled components? ? ? ? ? ? ? ? ? ? ? ? ? > -- ###################################################### > --? ?* Python support > --? ?* sysmocom OsmoSDR > --? ?* IQ File Source & Sink > --? ?* Osmocom RTLSDR > --? ?* RTLSDR TCP Client > --? ?* Ettus USRP Devices > --? ?* Osmocom MiriSDR > --? ?* HackRF & rad1o Badge > --? ?* nuand bladeRF > --? ?* RFSPACE Receivers > --? ?* AIRSPY Receiver > --? ?* SoapySDR support > --? ?* Red Pitaya SDR > -- > -- ###################################################### > -- # Gnuradio disabled components? ? ? ? ? ? ? ? ? ? ? ? > -- ###################################################### > --? ?* Osmocom IQ Imbalance Correction > --? ?* AIRSPY HF+ Receiver > --? ?* FreeSRP support > -- > -- Building for version: 0.2.0.0 / 0.2.0 > -- Using install prefix: /usr > -- Configuring done > CMake Error at lib/CMakeLists.txt:43 (add_library): > ? Target "gnuradio-osmosdr" links to target "gnuradio::filter" but the > target > ? was not found.? Perhaps a find_package() call is missing for an > IMPORTED > ? target, or an ALIAS target is missing? > > > CMake Error at /usr/lib64/cmake/gnuradio/UseSWIG.cmake:573 > (add_library): > ? Target "osmosdr_swig" links to target "gnuradio::filter" but the > target was > ? not found.? Perhaps a find_package() call is missing for an IMPORTED > ? target, or an ALIAS target is missing? > Call Stack (most recent call first): > ? /usr/lib64/cmake/gnuradio/GrSwig.cmake:133 (swig_add_library) > ? swig/CMakeLists.txt:42 (GR_SWIG_MAKE) > > > CMake Error at lib/CMakeLists.txt:43 (add_library): > ? Target "gnuradio-osmosdr" links to target "gnuradio::filter" but the > target > ? was not found.? Perhaps a find_package() call is missing for an > IMPORTED > ? target, or an ALIAS target is missing? > > > -- Generating done > CMake Generate step failed.? Build files cannot be regenerated > correctly. > ``` > > Any feedback would be appreciated. > Thanks, > > -- > Tom Swartz > > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From tom at tswartz.net Mon Jan 27 02:59:09 2020 From: tom at tswartz.net (tom at tswartz.net) Date: Sun, 26 Jan 2020 21:59:09 -0500 Subject: GR 3.8 Build issues In-Reply-To: References: <20200127023537.GA1795@gmail.com> Message-ID: <20200127025909.GC1795@gmail.com> Looks like the patch did the trick. Builds are successful now. I haven't given it a live test with RX, but after several clean builds and installs, I can say that the package build issue is resolved. -- Tom Swartz On Sun, Jan 26, 2020 at 09:38:56PM -0500, Clayton Smith wrote: > Coincidentally, I sent a patch for this issue just a moment ago after > hitting the same issue. > > Regards, > Clayton > > On Sun, Jan 26, 2020 at 9:36 PM wrote: > > Hi all: > > I'm trying to build the latest gr-osmosdr package from the gr3.8 > branch, but I'm > seeing some unusual errors, and I'm not quite sure what the deal is. > > I'll note the following: > - I had errors related to existing python2 packages, so I tried > building with Python3. > ? I'd be less than surprised if someone says that this is the cause of > the issues, but > ? personally, I'd like to roll with the Py3 products from now on, what > with Py2 being EOL? > - OS is Arch. > > My cmake command was: > ``` > ? cmake \ > ? ? -DCMAKE_BUILD_TYPE=Release \ > ? ? -DPYTHON_EXECUTABLE=$(which python3) \ > ? ? -DPYTHON_INCLUDE_DIR=$(echo /usr/include/python3*) \ > ? ? -DPYTHON_LIBRARY=$(echo /usr/lib/libpython3.*.so) \ > ? ? -DENABLE_DOXYGEN=1 \ > ? ? -DCMAKE_INSTALL_PREFIX=/usr ../ > ``` > > > Output from cmake: > > ``` > -- ###################################################### > -- # Gnuradio enabled components? ? ? ? ? ? ? ? ? ? ? ? ? > -- ###################################################### > --? ?* Python support > --? ?* sysmocom OsmoSDR > --? ?* IQ File Source & Sink > --? ?* Osmocom RTLSDR > --? ?* RTLSDR TCP Client > --? ?* Ettus USRP Devices > --? ?* Osmocom MiriSDR > --? ?* HackRF & rad1o Badge > --? ?* nuand bladeRF > --? ?* RFSPACE Receivers > --? ?* AIRSPY Receiver > --? ?* SoapySDR support > --? ?* Red Pitaya SDR > -- > -- ###################################################### > -- # Gnuradio disabled components? ? ? ? ? ? ? ? ? ? ? ? > -- ###################################################### > --? ?* Osmocom IQ Imbalance Correction > --? ?* AIRSPY HF+ Receiver > --? ?* FreeSRP support > -- > -- Building for version: 0.2.0.0 / 0.2.0 > -- Using install prefix: /usr > -- Configuring done > CMake Error at lib/CMakeLists.txt:43 (add_library): > ? Target "gnuradio-osmosdr" links to target "gnuradio::filter" but the > target > ? was not found.? Perhaps a find_package() call is missing for an > IMPORTED > ? target, or an ALIAS target is missing? > > > CMake Error at /usr/lib64/cmake/gnuradio/UseSWIG.cmake:573 > (add_library): > ? Target "osmosdr_swig" links to target "gnuradio::filter" but the > target was > ? not found.? Perhaps a find_package() call is missing for an IMPORTED > ? target, or an ALIAS target is missing? > Call Stack (most recent call first): > ? /usr/lib64/cmake/gnuradio/GrSwig.cmake:133 (swig_add_library) > ? swig/CMakeLists.txt:42 (GR_SWIG_MAKE) > > > CMake Error at lib/CMakeLists.txt:43 (add_library): > ? Target "gnuradio-osmosdr" links to target "gnuradio::filter" but the > target > ? was not found.? Perhaps a find_package() call is missing for an > IMPORTED > ? target, or an ALIAS target is missing? > > > -- Generating done > CMake Generate step failed.? Build files cannot be regenerated > correctly. > ``` > > Any feedback would be appreciated. > Thanks, > > -- > Tom Swartz > > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From fredrik at kyla.kiruna.se Mon Jan 27 21:51:51 2020 From: fredrik at kyla.kiruna.se (Carl-Fredrik Enell) Date: Mon, 27 Jan 2020 22:51:51 +0100 Subject: libusb issue when opening device In-Reply-To: <36857b05-7f52-ba61-a13b-1573fac6e7c3@steve-m.de> References: <24109.52122.504483.28635@fenix.lan> <36857b05-7f52-ba61-a13b-1573fac6e7c3@steve-m.de> Message-ID: <24111.23415.315126.926902@fenix.lan> Hi, I have posted some notes from my tests on two different systems at https://kyla.kiruna.se/nextcloud/index.php/s/SBc8jH4nS3FnoAZ A short summary: libusb is the same version, kernel and hardware are different. Only the Arch Linux system with kernel 5.4.15 on AMD hardware detects altsettings. I have also listed lsmod output in case conflicting modules would be loaded. >>>>> "Steve" == Steve Markgraf writes Steve> I've just pushed a workaround for now that falls back to Steve> the old behavior (claiming interface 1) in case switching Steve> interface 0 to altsetting 1. As you can see in the notes this works on the laptop, thanks! Best regards SM2YHP -- ------------------ Carl-Fredrik Enell F?raregatan 26B SE-98139 Kiruna +46705508256 ----------------- From tnt at 246tnt.com Tue Jan 28 14:53:21 2020 From: tnt at 246tnt.com (Sylvain Munaut) Date: Tue, 28 Jan 2020 15:53:21 +0100 Subject: [PATCH] hackrf: allow transmit/receive switching In-Reply-To: <20200126234859.18821-1-argilo@gmail.com> References: <20200126234859.18821-1-argilo@gmail.com> Message-ID: Thanks, I applied both patches to the gr3.8 branch. Cheers, Sylvain From argilo at gmail.com Fri Jan 31 04:22:03 2020 From: argilo at gmail.com (argilo at gmail.com) Date: Thu, 30 Jan 2020 23:22:03 -0500 Subject: [PATCH] hackrf: replace boost::assign with C++11 Message-ID: <20200131042203.13491-1-argilo@gmail.com> From: Clayton Smith Since GNU Radio is gradually replacing Boost with C++11, it seemed worth doing that for the HackRF blocks I was working on. This change removes all usage of boost::assign. --- lib/hackrf/hackrf_common.cc | 54 +++++++++++++++-------------------- lib/hackrf/hackrf_common.h | 1 + lib/hackrf/hackrf_sink_c.cc | 11 +------ lib/hackrf/hackrf_source_c.cc | 11 +------ 4 files changed, 26 insertions(+), 51 deletions(-) diff --git a/lib/hackrf/hackrf_common.cc b/lib/hackrf/hackrf_common.cc index 0a20f2ec9c..a6de22aab6 100644 --- a/lib/hackrf/hackrf_common.cc +++ b/lib/hackrf/hackrf_common.cc @@ -21,14 +21,10 @@ #include "config.h" #endif -#include - #include "hackrf_common.h" #include "arg_helpers.h" -using namespace boost::assign; - int hackrf_common::_usage = 0; std::mutex hackrf_common::_usage_mutex; @@ -213,11 +209,11 @@ osmosdr::meta_range_t hackrf_common::get_sample_rates() * the user is allowed to request arbitrary (fractional) rates within these * boundaries. */ - range += osmosdr::range_t( 8e6 ); - range += osmosdr::range_t( 10e6 ); - range += osmosdr::range_t( 12.5e6 ); - range += osmosdr::range_t( 16e6 ); - range += osmosdr::range_t( 20e6 ); /* confirmed to work on fast machines */ + range.push_back(osmosdr::range_t( 8e6 )); + range.push_back(osmosdr::range_t( 10e6 )); + range.push_back(osmosdr::range_t( 12.5e6 )); + range.push_back(osmosdr::range_t( 16e6 )); + range.push_back(osmosdr::range_t( 20e6 )); /* confirmed to work on fast machines */ return range; } @@ -246,7 +242,7 @@ osmosdr::freq_range_t hackrf_common::get_freq_range( size_t chan ) { osmosdr::freq_range_t range; - range += osmosdr::range_t( _sample_rate / 2, 7250e6 - _sample_rate / 2 ); + range.push_back(osmosdr::range_t( _sample_rate / 2, 7250e6 - _sample_rate / 2 )); return range; } @@ -325,11 +321,7 @@ double hackrf_common::get_gain( size_t chan ) std::vector< std::string > hackrf_common::get_antennas( size_t chan ) { - std::vector< std::string > antennas; - - antennas += get_antenna( chan ); - - return antennas; + return { get_antenna( chan ) }; } std::string hackrf_common::set_antenna( const std::string & antenna, size_t chan ) @@ -375,22 +367,22 @@ osmosdr::freq_range_t hackrf_common::get_bandwidth_range( size_t chan ) // TODO: read out from libhackrf when an API is available - bandwidths += osmosdr::range_t( 1750000 ); - bandwidths += osmosdr::range_t( 2500000 ); - bandwidths += osmosdr::range_t( 3500000 ); - bandwidths += osmosdr::range_t( 5000000 ); - bandwidths += osmosdr::range_t( 5500000 ); - bandwidths += osmosdr::range_t( 6000000 ); - bandwidths += osmosdr::range_t( 7000000 ); - bandwidths += osmosdr::range_t( 8000000 ); - bandwidths += osmosdr::range_t( 9000000 ); - bandwidths += osmosdr::range_t( 10000000 ); - bandwidths += osmosdr::range_t( 12000000 ); - bandwidths += osmosdr::range_t( 14000000 ); - bandwidths += osmosdr::range_t( 15000000 ); - bandwidths += osmosdr::range_t( 20000000 ); - bandwidths += osmosdr::range_t( 24000000 ); - bandwidths += osmosdr::range_t( 28000000 ); + bandwidths.push_back(osmosdr::range_t( 1750000 )); + bandwidths.push_back(osmosdr::range_t( 2500000 )); + bandwidths.push_back(osmosdr::range_t( 3500000 )); + bandwidths.push_back(osmosdr::range_t( 5000000 )); + bandwidths.push_back(osmosdr::range_t( 5500000 )); + bandwidths.push_back(osmosdr::range_t( 6000000 )); + bandwidths.push_back(osmosdr::range_t( 7000000 )); + bandwidths.push_back(osmosdr::range_t( 8000000 )); + bandwidths.push_back(osmosdr::range_t( 9000000 )); + bandwidths.push_back(osmosdr::range_t( 10000000 )); + bandwidths.push_back(osmosdr::range_t( 12000000 )); + bandwidths.push_back(osmosdr::range_t( 14000000 )); + bandwidths.push_back(osmosdr::range_t( 15000000 )); + bandwidths.push_back(osmosdr::range_t( 20000000 )); + bandwidths.push_back(osmosdr::range_t( 24000000 )); + bandwidths.push_back(osmosdr::range_t( 28000000 )); return bandwidths; } diff --git a/lib/hackrf/hackrf_common.h b/lib/hackrf/hackrf_common.h index 02eabd2f0c..ea093b9680 100644 --- a/lib/hackrf/hackrf_common.h +++ b/lib/hackrf/hackrf_common.h @@ -20,6 +20,7 @@ #ifndef INCLUDED_HACKRF_COMMON_H #define INCLUDED_HACKRF_COMMON_H +#include #include #include #include diff --git a/lib/hackrf/hackrf_sink_c.cc b/lib/hackrf/hackrf_sink_c.cc index f003b89ce3..7271109b15 100644 --- a/lib/hackrf/hackrf_sink_c.cc +++ b/lib/hackrf/hackrf_sink_c.cc @@ -38,16 +38,12 @@ #include #endif -#include - #include #include "hackrf_sink_c.h" #include "arg_helpers.h" -using namespace boost::assign; - static inline bool cb_init(circular_buffer_t *cb, size_t capacity, size_t sz) { cb->buffer = malloc(capacity * sz); @@ -449,12 +445,7 @@ double hackrf_sink_c::get_freq_corr( size_t chan ) std::vector hackrf_sink_c::get_gain_names( size_t chan ) { - std::vector< std::string > names; - - names += "RF"; - names += "IF"; - - return names; + return { "RF", "IF" }; } osmosdr::gain_range_t hackrf_sink_c::get_gain_range( size_t chan ) diff --git a/lib/hackrf/hackrf_source_c.cc b/lib/hackrf/hackrf_source_c.cc index 51a6580eca..eea5caafda 100644 --- a/lib/hackrf/hackrf_source_c.cc +++ b/lib/hackrf/hackrf_source_c.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include @@ -40,8 +39,6 @@ #include "arg_helpers.h" -using namespace boost::assign; - hackrf_source_c_sptr make_hackrf_source_c (const std::string & args) { return gnuradio::get_initial_sptr(new hackrf_source_c (args)); @@ -306,13 +303,7 @@ double hackrf_source_c::get_freq_corr( size_t chan ) std::vector hackrf_source_c::get_gain_names( size_t chan ) { - std::vector< std::string > names; - - names += "RF"; - names += "IF"; - names += "BB"; - - return names; + return { "RF", "IF", "BB" }; } osmosdr::gain_range_t hackrf_source_c::get_gain_range( size_t chan ) -- 2.17.1 From tnt at 246tnt.com Fri Jan 31 09:24:33 2020 From: tnt at 246tnt.com (Sylvain Munaut) Date: Fri, 31 Jan 2020 10:24:33 +0100 Subject: [PATCH] hackrf: replace boost::assign with C++11 In-Reply-To: <20200131042203.13491-1-argilo@gmail.com> References: <20200131042203.13491-1-argilo@gmail.com> Message-ID: On Fri, Jan 31, 2020 at 5:22 AM wrote: > > From: Clayton Smith > > Since GNU Radio is gradually replacing Boost with C++11, it seemed worth > doing that for the HackRF blocks I was working on. This change removes > all usage of boost::assign. > --- > lib/hackrf/hackrf_common.cc | 54 +++++++++++++++-------------------- > lib/hackrf/hackrf_common.h | 1 + > lib/hackrf/hackrf_sink_c.cc | 11 +------ > lib/hackrf/hackrf_source_c.cc | 11 +------ > 4 files changed, 26 insertions(+), 51 deletions(-) Tx, merged. Cheers, Sylvain From murat_1.2 at hotmail.com Wed Jan 29 21:36:35 2020 From: murat_1.2 at hotmail.com (=?iso-8859-9?Q?Murat_=D6zen?=) Date: Wed, 29 Jan 2020 21:36:35 -0000 Subject: Please Help Osmo-Fl2k Message-ID: I started application but dont transmit any signal ? Why ? I dont understand ? I am listening in rtl sdr but dont transmit any signal . What is my error ? I dont contact any antenna to the device . murat at murat-VivoBook-14-ASUS-Laptop-X407MA-X407MA:~$ pacat -r -d alsa_output.pci-0000_00_0e.0.analog-stereo.monitor | \ > pv -B 256k | \ > sox -t raw -r 44100 -e signed-integer -L -b 16 -c 2 - -c 1 -e signed-integer -b 16 -t raw - \ > biquad 4.76963 -2.98129 0 1 0.78833 0 sinc -15k loudness 5 | \ > fl2k_fm - -s 130e6 -c 30e6 -i 44100 Samplerate: 130.00 MHz Carrier: 30.00 MHz Frequencies: 100.00 MHz, 160.00 MHz Failed to switch interface 0 to altsetting 1, trying to use interface 1 Allocating 6 zero-copy buffers ^C24,2MiB 0:18:45 [0,00 B/s] [ <=> ] Signal caught, exiting! ^CSignal caught, exiting! -------------- next part -------------- An HTML attachment was scrubbed... URL: From murat_1.2 at hotmail.com Wed Jan 29 23:39:40 2020 From: murat_1.2 at hotmail.com (=?iso-8859-9?Q?Murat_=D6zen?=) Date: Wed, 29 Jan 2020 23:39:40 -0000 Subject: Osmo-fl2k Please Help ? Message-ID: I can not transmit signal please help ? I am taking a low signal 165MHz after device is stopping to send signal. Why ? Please Help? ?n this picture I take a very low signal after device stopped to send signal . Why I dont understand ? -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 2020-01-30 02-35-36 ekran g?r?nt?s?.png Type: image/png Size: 601746 bytes Desc: 2020-01-30 02-35-36 ekran g?r?nt?s?.png URL: