Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP2:Update
gr-fcdproplus
gr-fcdproplus-3.8~git.20190817.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gr-fcdproplus-3.8~git.20190817.obscpio of Package gr-fcdproplus
07070100000000000081A4000003E800000064000000015D58261300001F3E000000000000000000000000000000000000002E00000000gr-fcdproplus-3.8~git.20190817/CMakeLists.txt# Copyright 2011-2014 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. ######################################################################## # Project setup ######################################################################## ######################################################################## # # First look in the install directory for package config of gnuradio # ######################################################################## set( ENV{PKG_CONFIG_PATH} "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") cmake_minimum_required(VERSION 3.8) project(gr-fcdproplus CXX C) #install to PyBOMBS target prefix if defined if(DEFINED ENV{PYBOMBS_PREFIX}) set(CMAKE_INSTALL_PREFIX $ENV{PYBOMBS_PREFIX}) message(STATUS "PyBOMBS installed GNU Radio. Setting CMAKE_INSTALL_PREFIX to $ENV{PYBOMBS_PREFIX}") endif() #select the release build type by default to get optimization flags if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message(STATUS "Build type not specified: defaulting to release.") endif(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") ######################################################################## # # setup version info # ######################################################################## set(VERSION_MAJOR 3) set(VERSION_API 8) SET(VERSION_ABI 0) SET(VERSION_PATCH 0) cmake_policy(SET CMP0011 NEW) ######################################################################## # Compiler specific setup ######################################################################## #if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) # #http://gcc.gnu.org/wiki/Visibility # add_definitions(-fvisibility=hidden) # endif() if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) #http://gcc.gnu.org/wiki/Visibility add_definitions(-fvisibility=hidden) endif() ######################################################################## # Find gnuradio build dependencies ######################################################################## find_package(Gnuradio "3.8" REQUIRED audio blocks PATHS ${CMAKE_INSTALL_PREFIX} ) list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/Modules") FIND_LIBRARY(HIDAPI_LIBRARY hidapi-libusb) include(GrVersion) ######################################################################## # Find fcd(proplus) dependencies ######################################################################## if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux") find_package(USB) if(NOT LIBUSB_FOUND) message(FATAL_ERROR "libusb required to compile fcdproplus") endif() endif() ######################################################################## # Install directories ######################################################################## include(GrPlatform) #define LIB_SUFFIX if(NOT CMAKE_MODULES_DIR) SET(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) endif(NOT CMAKE_MODULES_DIR) set(GR_RUNTIME_DIR bin) set(GR_LIBRARY_DIR lib${LIB_SUFFIX}) set(GR_INCLUDE_DIR include/fcdproplus) set(GR_DATA_DIR share) set(GR_PKG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/${GR_DATA_DIR}/${CMAKE_PROJECT_NAME}) set(GR_DOC_DIR ${GR_DATA_DIR}/doc) set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME}) set(GR_CONF_DIR etc) set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d) set(GR_LIBEXEC_DIR libexec) set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME}) set(GRC_BLOCKS_DIR ${CMAKE_INSTALL_PREFIX}/${GR_DATA_DIR}/gnuradio/grc/blocks) SET(GR_CMAKE_DIR ${CMAKE_MODULES_DIR}/gr-fcdproplus) ######################################################################## # On Apple only, set install name and use rpath correctly, if not already set ######################################################################## if(APPLE) if(NOT CMAKE_INSTALL_NAME_DIR) set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE PATH "Library Install Name Destination Directory" FORCE) endif(NOT CMAKE_INSTALL_NAME_DIR) if(NOT CMAKE_INSTALL_RPATH) set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE PATH "Library Install RPath" FORCE) endif(NOT CMAKE_INSTALL_RPATH) if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "Do Build Using Library Install RPath" FORCE) endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) endif(APPLE) ######################################################################## # Setup doxygen option ######################################################################## find_package(Doxygen) if(DOXYGEN_FOUND) option(ENABLE_DOXYGEN "Build docs using Doxygen" ON) else(DOXYGEN_FOUND) option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF) endif(DOXYGEN_FOUND) ######################################################################## # Create uninstall target ######################################################################## configure_file( ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake @ONLY) add_custom_target(uninstall ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake ) ######################################################################## # Add subdirectories ######################################################################## add_subdirectory(include/fcdproplus) add_subdirectory(lib) add_subdirectory(swig) add_subdirectory(python) add_subdirectory(grc) add_subdirectory(docs) ######################################################################## # Create Pkg Config File ######################################################################## # fake gnuradio cpack behavior as long as we don't use it directly set(CPACK_PACKAGE_NAME "gnuradio-fcdproplus") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GNU Radio block for Funcube Dongle Pro+") set(CPACK_PACKAGE_VERSION ${VERSION}) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-fcdproplus.pc.in ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fcdproplus.pc @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fcdproplus.pc DESTINATION ${GR_LIBRARY_DIR}/pkgconfig COMPONENT "fcdproplus_devel" ) ######################################################################## # Print Summary ######################################################################## MESSAGE(STATUS "================ Build Summary =========================") MESSAGE(STATUS "Building gr-fcdproplus : ${LIBVER} for ${CMAKE_SYSTEM_NAME} ") MESSAGE(STATUS "Building for gnuradio : ${Gnuradio_VERSION}") MESSAGE(STATUS "Using CMAKE Module path : ${CMAKE_MODULE_PATH}" ) MESSAGE(STATUS "CMake Modules Dir : ${CMAKE_MODULES_DIR}" ) MESSAGE(STATUS "fcdproplus INCLUDES : ${GR_INCLUDE_DIR}") MESSAGE(STATUS "Using install prefix : ${CMAKE_INSTALL_PREFIX}") MESSAGE(STATUS "Installing grc files to : ${GRC_BLOCKS_DIR}") if(HIDAPI_LIBRARY) MESSAGE(STATUS "System Hidapi Lib ${HIDAPI_LIBRARY} is used") else() MESSAGE(STATUS "Bundled hidapi is used") endif() MESSAGE(STATUS "========================================================") 07070100000001000081A4000003E800000064000000015D5826130000894B000000000000000000000000000000000000002700000000gr-fcdproplus-3.8~git.20190817/COPYING GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program 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 of the License, or (at your option) any later version. This program 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 this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: <program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>. 07070100000002000081A4000003E800000064000000015D58261300000445000000000000000000000000000000000000002B00000000gr-fcdproplus-3.8~git.20190817/MANIFEST.mdtitle: gr-fcdproplus brief: A GNU Radio funcube dongle and funcube dongle pro+ source tags: - funcube author: - Volker Schroer copyright_owner: - Volker Schroer dependencies: - gnuradio (>= 3.8.0 ) - alsa usb drivers activated - hidapi-libusb repo: https://github.com/dl1ksv/gr-fcdproplus.git --- gr-fcdproplus is an linux and OSX addon for gnuradio to implement a funcube dongle pro+ source. On linux it autodetects the correct soundcard from /proc/asound/cards. This idea was taken from the osmosdr drivers. To control the device the hidapi usb version is used. It contains four components: Funcube Dongle - The complete V1.0 source block Funcube Dongle control - The control block, to set frequency, gain, etc. Funcube dongle Pro+ - The complete V2.0 source block Funcube dongle Pro+ control - The control block, to set frequency, gain, etc. The control block are used inside the source block but can be used standalone, too. All blocks contain a message port to set the frequency by messages. You find these blocks in Custom - Fcd in grc 07070100000003000081A4000003E800000064000000015D58261300000956000000000000000000000000000000000000002900000000gr-fcdproplus-3.8~git.20190817/README.mdgr-fcdproplus is an linux and OSX addon for gnuradio to implement a funcube dongle and a funcube dongle pro+ source. On linux it autodetects the correct soundcard from /proc/asound/cards. This idea was taken from the osmosdr drivers. To control the device the hidapi usb version is used. 1. Dependencies: - gnuradio (>= 3.8 ) - alsa usb drivers activated - hidapi-libusb If the hidapi lib of your distro is installed then this hidapi version is used. Otherwise bundled code will be used. In case of MAC OSX this is hidmac.c otherwise hid.c ( This new MAC Version is untested, due to a lack of access to MAC OSX. So reports of success or bugs are welcome. ) 2. Installation: get the latest code from https://github.com/dl1ksv/gr-fcdproplus The build process is cmake based. So change to code directory. There $mkdir build $cd build $cmake -DCMAKE_INSTALL_PREFIX=<where gnuradio is installed> ../ $make $su $make install After that you'll find in grc in Custom - Fcd Funcube Dongle Funcube Dongle control Funcube Dongle Pro+ Funcube Dongle Pro+ control 3. Important Don't forget the udev rules: For instance: # Udev rules for the Funcube Dongle Pro (0xfb56) and Pro+ (0xfb31) # HIDAPI/libusb: SUBSYSTEMS=="usb" ATTRS{idVendor}=="04d8" ATTRS{idProduct}=="fb56" MODE:="0666" SUBSYSTEMS=="usb" ATTRS{idVendor}=="04d8" ATTRS{idProduct}=="fb31" MODE:="0666" # HIDAPI/hidraw: KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="fb56", MODE="0666" KERNEL=="hidraw*", ATTRS{busnum}=="1", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="fb31", MODE="0666" 4. Usage Four modules are available: - fcd control - fcd - fcdpp_control - fcdproplus The control modules only controls the dongles, while the other modules control the dongles and provide the IQ samples. All modules accept messages to control the frequency. That was the reason to introduce the control modules. The fcd modules where introduced, as gnuradio 3.8 does not contain gr-fcd at the moment. See the examples of a simple fm receiver in the examples directory or see a more complex example in in gr-display 5. Credits Some code is taken from qthid-4.1 by Alexandru Csete, OZ9AEC. The hid part is taken from http://github.com/signal11/hidapi Thanks to Michael Dickens, who gave valuable hints for implementing message in hier2_blocks. 07070100000004000041ED000003E800000064000000035D58261300000000000000000000000000000000000000000000002500000000gr-fcdproplus-3.8~git.20190817/cmake07070100000005000041ED000003E800000064000000025D58261300000000000000000000000000000000000000000000002D00000000gr-fcdproplus-3.8~git.20190817/cmake/Modules07070100000006000081A4000003E800000064000000015D58261300000345000000000000000000000000000000000000003B00000000gr-fcdproplus-3.8~git.20190817/cmake/Modules/FindUSB.cmakeif(NOT LIBUSB_FOUND) include(FindPkgConfig) pkg_check_modules (LIBUSB_PKG libusb-1.0) find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h PATHS ${LIBUSB_PKG_INCLUDE_DIRS} /usr/include/libusb-1.0 /usr/include /usr/local/include ) find_library(LIBUSB_LIBRARIES NAMES usb-1.0 usb PATHS ${LIBUSB_PKG_LIBRARY_DIRS} /usr/lib /usr/local/lib ) if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found") message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}") else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found") message(STATUS "libusb-1.0 not found.") endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES) endif(NOT LIBUSB_FOUND) 07070100000007000081A4000003E800000064000000015D58261300001BA7000000000000000000000000000000000000003A00000000gr-fcdproplus-3.8~git.20190817/cmake/Modules/GrSwig.cmake# Copyright 2010-2011,2019 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. if(DEFINED __INCLUDED_GR_SWIG_CMAKE) return() endif() set(__INCLUDED_GR_SWIG_CMAKE TRUE) include(GrPython) ######################################################################## # Builds a swig documentation file to be generated into python docstrings # Usage: GR_SWIG_MAKE_DOCS(output_file input_path input_path....) # # Set the following variable to specify extra dependent targets: # - GR_SWIG_DOCS_SOURCE_DEPS # - GR_SWIG_DOCS_TARGET_DEPS ######################################################################## function(GR_SWIG_MAKE_DOCS output_file) if(ENABLE_DOXYGEN) #setup the input files variable list, quote formatted set(input_files) unset(INPUT_PATHS) foreach(input_path ${ARGN}) if(IS_DIRECTORY ${input_path}) #when input path is a directory file(GLOB input_path_h_files ${input_path}/*.h) else() #otherwise its just a file, no glob set(input_path_h_files ${input_path}) endif() list(APPEND input_files ${input_path_h_files}) set(INPUT_PATHS "${INPUT_PATHS} \"${input_path}\"") endforeach(input_path) #determine the output directory get_filename_component(name ${output_file} NAME_WE) get_filename_component(OUTPUT_DIRECTORY ${output_file} PATH) set(OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}/${name}_swig_docs) make_directory(${OUTPUT_DIRECTORY}) #generate the Doxyfile used by doxygen #Find Doxyfile.swig_doc.in either in oot-modules directory or in gnuradio directory find_path(DOXY_FILE_PATH names Doxyfile.swig_doc.in PATHS ${CMAKE_SOURCE_DIR}/docs/doxygen ${CMAKE_INSTALL_PREFIX}/share/gnuradio/modtool/templates/gr-newmod/docs/doxygen ) message(STATUS "Doxxyfile found in ${DOXY_FILE_PATH}") configure_file( # ${CMAKE_SOURCE_DIR}/docs/doxygen/Doxyfile.swig_doc.in ${DOXY_FILE_PATH}/Doxyfile.swig_doc.in ${OUTPUT_DIRECTORY}/Doxyfile @ONLY) #Create a dummy custom command that depends on other targets include(GrMiscUtils) GR_GEN_TARGET_DEPS(_${name}_tag tag_deps ${GR_SWIG_DOCS_TARGET_DEPS}) #call doxygen on the Doxyfile + input headers add_custom_command( OUTPUT ${OUTPUT_DIRECTORY}/xml/index.xml DEPENDS ${input_files} ${GR_SWIG_DOCS_SOURCE_DEPS} ${tag_deps} COMMAND ${DOXYGEN_EXECUTABLE} ${OUTPUT_DIRECTORY}/Doxyfile COMMENT "Generating doxygen xml for ${name} docs" ) #call the swig_doc script on the xml files add_custom_command( OUTPUT ${output_file} DEPENDS ${input_files} ${stamp-file} ${OUTPUT_DIRECTORY}/xml/index.xml COMMAND ${PYTHON_EXECUTABLE} -B # ${CMAKE_SOURCE_DIR}/docs/doxygen/swig_doc.py ${DOXY_FILE_PATH}/swig_doc.py ${OUTPUT_DIRECTORY}/xml ${output_file} COMMENT "Generating python docstrings for ${name}" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs/doxygen ) else(ENABLE_DOXYGEN) file(WRITE ${output_file} "\n") #no doxygen -> empty file endif(ENABLE_DOXYGEN) endfunction(GR_SWIG_MAKE_DOCS) ######################################################################## # Build a swig target for the common gnuradio use case. Usage: # GR_SWIG_MAKE(target ifile ifile ifile...) # # Set the following variables before calling: # - GR_SWIG_FLAGS # - GR_SWIG_INCLUDE_DIRS # - GR_SWIG_LIBRARIES # - GR_SWIG_SOURCE_DEPS # - GR_SWIG_TARGET_DEPS # - GR_SWIG_DOC_FILE # - GR_SWIG_DOC_DIRS ######################################################################## macro(GR_SWIG_MAKE name) set(ifiles ${ARGN}) #do swig doc generation if specified if(GR_SWIG_DOC_FILE) set(GR_SWIG_DOCS_SOURCE_DEPS ${GR_SWIG_SOURCE_DEPS}) list(APPEND GR_SWIG_DOCS_TARGET_DEPS ${GR_SWIG_TARGET_DEPS}) GR_SWIG_MAKE_DOCS(${GR_SWIG_DOC_FILE} ${GR_SWIG_DOC_DIRS}) add_custom_target(${name}_swig_doc DEPENDS ${GR_SWIG_DOC_FILE}) list(APPEND GR_SWIG_TARGET_DEPS ${name}_swig_doc) endif() #prepend local swig directories list(INSERT GR_SWIG_INCLUDE_DIRS 0 "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") list(INSERT GR_SWIG_INCLUDE_DIRS 0 "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>") if (PYTHON3) set(py3 "-py3") endif (PYTHON3) #setup the swig flags with flags and include directories set(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -w314 -relativeimport ${py3} -module ${name} ${GR_SWIG_FLAGS}) #set the C++ property on the swig .i file so it builds set_source_files_properties(${ifiles} PROPERTIES CPLUSPLUS ON) #setup the actual swig library target to be built include(UseSWIG) swig_add_library(${name} LANGUAGE python SOURCES ${ifiles}) if(${name} STREQUAL "runtime_swig") set_target_properties(runtime_swig PROPERTIES DEFINE_SYMBOL "gnuradio_runtime_EXPORTS") endif(${name} STREQUAL "runtime_swig") set_target_properties(${name} PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE ) target_include_directories(${name} PUBLIC ${GR_SWIG_INCLUDE_DIRS}) set_property(TARGET ${name} PROPERTY SWIG_DEPENDS ${GR_SWIG_TARGET_DEPS}) target_link_libraries(${name} Python::Python ${GR_SWIG_LIBRARIES}) endmacro(GR_SWIG_MAKE) ######################################################################## # Install swig targets generated by GR_SWIG_MAKE. Usage: # GR_SWIG_INSTALL( # TARGETS target target target... # [DESTINATION destination] # ) ######################################################################## macro(GR_SWIG_INSTALL) include(CMakeParseArgumentsCopy) CMAKE_PARSE_ARGUMENTS(GR_SWIG_INSTALL "" "DESTINATION" "TARGETS" ${ARGN}) foreach(name ${GR_SWIG_INSTALL_TARGETS}) install(TARGETS ${name} DESTINATION ${GR_SWIG_INSTALL_DESTINATION} ) include(GrPython) GR_PYTHON_INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.py DESTINATION ${GR_SWIG_INSTALL_DESTINATION} DEPENDS ${name} ) endforeach(name) endmacro(GR_SWIG_INSTALL) 07070100000008000081A4000003E800000064000000015D582613000003DD000000000000000000000000000000000000004300000000gr-fcdproplus-3.8~git.20190817/cmake/Modules/targetConfig.cmake.in# Copyright 2018 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. include(CMakeFindDependencyMacro) set(target_deps "@TARGET_DEPENDENCIES@") foreach(dep IN LISTS target_deps) find_dependency(${dep}) endforeach() include("${CMAKE_CURRENT_LIST_DIR}/@TARGET@Targets.cmake") 07070100000009000081A4000003E800000064000000015D582613000005A5000000000000000000000000000000000000003E00000000gr-fcdproplus-3.8~git.20190817/cmake/cmake_uninstall.cmake.in# http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F list(APPEND CMAKE_MODULE_PATH "@CMAKE_INSTALL_PREFIX@/lib/cmake/gnuradio") IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) STRING(REGEX REPLACE "\n" ";" files "${files}") FOREACH(file ${files}) MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") IF(EXISTS "$ENV{DESTDIR}${file}") EXEC_PROGRAM( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) IF(NOT "${rm_retval}" STREQUAL 0) MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") ENDIF(NOT "${rm_retval}" STREQUAL 0) ELSEIF(IS_SYMLINK "$ENV{DESTDIR}${file}") EXEC_PROGRAM( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) IF(NOT "${rm_retval}" STREQUAL 0) MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") ENDIF(NOT "${rm_retval}" STREQUAL 0) ELSE(EXISTS "$ENV{DESTDIR}${file}") MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") ENDIF(EXISTS "$ENV{DESTDIR}${file}") ENDFOREACH(file) 0707010000000A000041ED000003E800000064000000035D58261300000000000000000000000000000000000000000000002400000000gr-fcdproplus-3.8~git.20190817/docs0707010000000B000081A4000003E800000064000000015D58261300000569000000000000000000000000000000000000003300000000gr-fcdproplus-3.8~git.20190817/docs/CMakeLists.txt# Copyright 2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. ######################################################################## # Setup dependencies ######################################################################## find_package(Doxygen) ######################################################################## # Begin conditional configuration ######################################################################## if(ENABLE_DOXYGEN) ######################################################################## # Add subdirectories ######################################################################## add_subdirectory(doxygen) endif(ENABLE_DOXYGEN) 0707010000000C000081A4000003E800000064000000015D58261300000193000000000000000000000000000000000000003600000000gr-fcdproplus-3.8~git.20190817/docs/README.fcdproplusThis is the fcdproplus-write-a-block package meant as a guide to building out-of-tree packages. To use the fcdproplus blocks, the Python namespaces is in 'fcdproplus', which is imported as: import fcdproplus See the Doxygen documentation for details about the blocks available in this package. A quick listing of the details can be found in Python after importing by using: help(fcdproplus) 0707010000000D000041ED000003E800000064000000025D58261300000000000000000000000000000000000000000000002C00000000gr-fcdproplus-3.8~git.20190817/docs/doxygen0707010000000E000081A4000003E800000064000000015D582613000007D4000000000000000000000000000000000000003B00000000gr-fcdproplus-3.8~git.20190817/docs/doxygen/CMakeLists.txt# Copyright 2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. ######################################################################## # Create the doxygen configuration file ######################################################################## file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} top_srcdir) file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} top_builddir) file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} abs_top_srcdir) file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} abs_top_builddir) set(HAVE_DOT ${DOXYGEN_DOT_FOUND}) set(enable_html_docs YES) set(enable_latex_docs NO) set(enable_xml_docs YES) configure_file( ${DOXY_FILE_PATH}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) set(BUILT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/xml ${CMAKE_CURRENT_BINARY_DIR}/html) ######################################################################## # Make and install doxygen docs ######################################################################## add_custom_command( OUTPUT ${BUILT_DIRS} COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating documentation with doxygen" ) add_custom_target(doxygen_target ALL DEPENDS ${BUILT_DIRS}) install(DIRECTORY ${BUILT_DIRS} DESTINATION ${GR_PKG_DOC_DIR}) 0707010000000F000041ED000003E800000064000000025D58261300000000000000000000000000000000000000000000002700000000gr-fcdproplus-3.8~git.20190817/example07070100000010000081A4000003E800000064000000015D58261300000E63000000000000000000000000000000000000003B00000000gr-fcdproplus-3.8~git.20190817/example/FCDPPControl_FM.grcoptions: parameters: author: dl1ksv category: '[GRC Hier Blocks]' description: Example of an FM receiver,using the Fcdproplus Control Block generate_options: qt_gui hier_block_src_path: '.:' id: fcdControl max_nouts: '0' placement: (0,0) run: 'True' run_command: '{python} -u {filename}' run_options: prompt sizing_mode: fixed title: FM Receiver, states: coordinate: [8, 8] rotation: 0 state: enabled blocks: - name: RxFrequency id: variable_qtgui_range parameters: gui_hint: 0,0,1,1 label: 'Set Frequency ' min_len: '200' orient: Qt.Horizontal rangeType: float start: '80000' step: '100' stop: '146000' value: '94300' widget: counter states: coordinate: [304, 20.0] rotation: 0 state: enabled - name: samp_rate id: variable parameters: value: '192000' states: coordinate: [184, 12] rotation: 0 state: enabled - name: analog_fm_demod_cf_1 id: analog_fm_demod_cf parameters: audio_decim: '4' audio_pass: '15000' audio_stop: '16000' chan_rate: samp_rate deviation: '75000' gain: '1' maxoutbuf: '0' minoutbuf: '0' tau: 75e-6 states: coordinate: [680, 336.0] rotation: 0 state: enabled - name: audio_sink_1 id: audio_sink parameters: device_name: default num_inputs: '2' ok_to_block: 'True' samp_rate: '48000' states: coordinate: [1392, 400.0] rotation: 0 state: enabled - name: audio_source_0 id: audio_source parameters: device_name: hw:2,0 num_outputs: '2' ok_to_block: 'True' samp_rate: samp_rate states: coordinate: [320, 240.0] rotation: 0 state: true - name: blocks_float_to_complex_0 id: blocks_float_to_complex parameters: vlen: '1' states: coordinate: [584, 176.0] rotation: 0 state: true - name: blocks_message_debug_0 id: blocks_message_debug parameters: {} states: coordinate: [1184, 176.0] rotation: 0 state: true - name: fcdproplus_control_0 id: fcdproplus_control parameters: freq: RxFrequency*1000 if_gain: '8' lnaswitch: '1' mixergainswitch: '1' states: coordinate: [56, 156.0] rotation: 0 state: true - name: low_pass_filter_1 id: low_pass_filter parameters: beta: '6.76' cutoff_freq: '40000' decim: '1' gain: '5' interp: '1' maxoutbuf: '0' minoutbuf: '0' samp_rate: samp_rate type: interp_fir_filter_ccf width: '300' win: firdes.WIN_HAMMING states: coordinate: [392, 344.0] rotation: 0 state: enabled - name: qtgui_sink_x_1 id: qtgui_sink_x parameters: bw: samp_rate fc: RxFrequency*1000 fftsize: '1024' gui_hint: 1,0,1,7 maxoutbuf: '0' minoutbuf: '0' name: QT GUI Plot plotconst: 'False' plotfreq: 'True' plottime: 'False' plotwaterfall: 'True' rate: '10' showports: 'False' showrf: 'True' type: complex wintype: firdes.WIN_BLACKMAN_hARRIS states: coordinate: [896, 176.0] rotation: 0 state: enabled connections: - [analog_fm_demod_cf_1, '0', audio_sink_1, '0'] - [analog_fm_demod_cf_1, '0', audio_sink_1, '1'] - [audio_source_0, '0', blocks_float_to_complex_0, '0'] - [audio_source_0, '1', blocks_float_to_complex_0, '1'] - [blocks_float_to_complex_0, '0', low_pass_filter_1, '0'] - [blocks_float_to_complex_0, '0', qtgui_sink_x_1, '0'] - [low_pass_filter_1, '0', analog_fm_demod_cf_1, '0'] - [qtgui_sink_x_1, freq, blocks_message_debug_0, print] - [qtgui_sink_x_1, freq, fcdproplus_control_0, freq] - [qtgui_sink_x_1, freq, qtgui_sink_x_1, freq] metadata: file_format: 1 07070100000011000081A4000003E800000064000000015D58261300001075000000000000000000000000000000000000003100000000gr-fcdproplus-3.8~git.20190817/example/fmfcd.grcoptions: parameters: author: dl1ksv category: Custom generate_options: qt_gui hier_block_src_path: '.:' id: FMRadio max_nouts: '0' placement: (0,0) run: 'True' run_command: '{python} -u {filename}' run_options: prompt sizing_mode: fixed title: FM radio to test FCD window_size: 1280, 1024 states: coordinate: [10, 10] rotation: 0 state: enabled blocks: - name: Ifgain id: variable_qtgui_range parameters: gui_hint: 0,3,1,1 label: IFGain min_len: '45' orient: Qt.Horizontal rangeType: int start: '0' step: '1' stop: '59' value: '10' widget: counter states: coordinate: [770, 10] rotation: 0 state: enabled - name: Lna id: variable_qtgui_chooser parameters: gui_hint: 0,1,1,1 label0: 'On' label1: 'Off' labels: '[]' num_opts: '2' option1: '0' option2: '2' option3: '3' option4: '4' options: '[0, 1, 2]' orient: Qt.QVBoxLayout type: int value: '1' widget: combo_box states: coordinate: [499, 15] rotation: 0 state: enabled - name: Mixergain id: variable_qtgui_chooser parameters: gui_hint: 0,2,1,1 label0: 'On' label1: 'Off' labels: '[]' num_opts: '2' option1: '0' option2: '2' option3: '3' option4: '4' options: '[0, 1, 2]' orient: Qt.QVBoxLayout type: int value: '1' widget: combo_box states: coordinate: [641, 9] rotation: 0 state: enabled - name: PPM id: variable_qtgui_range parameters: gui_hint: 0,6,1,1 label: set PPM min_len: '40' orient: Qt.Horizontal rangeType: int start: '-100' step: '1' stop: '100' value: '0' widget: counter states: coordinate: [1029, 3] rotation: 0 state: enabled - name: RxFrequency id: variable_qtgui_range parameters: gui_hint: 0,0,1,1 label: 'Set Frequency ' min_len: '200' orient: Qt.Horizontal rangeType: float start: '80000' step: '1' stop: '146000' value: '94300' widget: counter states: coordinate: [345, 19] rotation: 0 state: enabled - name: samp_rate id: variable parameters: value: '96000' states: coordinate: [227, 23] rotation: 0 state: enabled - name: analog_fm_demod_cf_0 id: analog_fm_demod_cf parameters: audio_decim: '2' audio_pass: '15000' audio_stop: '16000' chan_rate: samp_rate deviation: '75000' gain: '1.0' tau: 75e-6 states: coordinate: [736, 348.0] rotation: 0 state: enabled - name: audio_sink_0 id: audio_sink parameters: device_name: default num_inputs: '2' ok_to_block: 'True' samp_rate: '48000' states: coordinate: [1110, 406] rotation: 0 state: enabled - name: fcd_0 id: fcd parameters: dci: '0.0' dcq: '0.0' freq: RxFrequency*1000 iq_gain: '1.0' iq_phase: '0.0' lna: '20.0' mixer: '+12' ppm: '0' states: coordinate: [88, 300.0] rotation: 0 state: true - name: low_pass_filter_0 id: low_pass_filter parameters: beta: '6.76' cutoff_freq: '40000' decim: '1' gain: '5' interp: '1' maxoutbuf: '0' minoutbuf: '0' samp_rate: samp_rate type: fir_filter_ccf width: '500' win: firdes.WIN_HAMMING states: coordinate: [400, 324.0] rotation: 0 state: enabled - name: qtgui_sink_x_0 id: qtgui_sink_x parameters: bw: samp_rate fc: RxFrequency*1000 fftsize: '1024' gui_hint: 1,0,1,7 maxoutbuf: '0' minoutbuf: '0' name: QT GUI Plot plotconst: 'False' plotfreq: 'True' plottime: 'False' plotwaterfall: 'True' rate: '10' showports: 'False' showrf: 'True' type: complex wintype: firdes.WIN_BLACKMAN_hARRIS states: coordinate: [648, 140.0] rotation: 0 state: enabled connections: - [analog_fm_demod_cf_0, '0', audio_sink_0, '0'] - [analog_fm_demod_cf_0, '0', audio_sink_0, '1'] - [fcd_0, '0', low_pass_filter_0, '0'] - [fcd_0, '0', qtgui_sink_x_0, '0'] - [low_pass_filter_0, '0', analog_fm_demod_cf_0, '0'] - [qtgui_sink_x_0, freq, qtgui_sink_x_0, freq] metadata: file_format: 1 07070100000012000081A4000003E800000064000000015D58261300000F7E000000000000000000000000000000000000003300000000gr-fcdproplus-3.8~git.20190817/example/fmfcdpp.grcoptions: parameters: author: dl1ksv category: Custom generate_options: qt_gui hier_block_src_path: '.:' id: FMRadio max_nouts: '0' placement: (0,0) run: 'True' run_command: '{python} -u {filename}' run_options: prompt sizing_mode: fixed title: FM radio to test FCDPROplus window_size: 1280, 1024 states: coordinate: [10, 10] rotation: 0 state: enabled blocks: - name: Ifgain id: variable_qtgui_range parameters: gui_hint: 0,3,1,1 label: IFGain min_len: '45' orient: Qt.Horizontal rangeType: int start: '0' step: '1' stop: '59' value: '10' widget: counter states: coordinate: [880, 12.0] rotation: 0 state: enabled - name: Lna id: variable_qtgui_chooser parameters: gui_hint: 0,1,1,1 label0: 'On' label1: 'Off' labels: '[]' num_opts: '2' option1: '0' option2: '2' option3: '3' option4: '4' options: '[0, 1, 2]' orient: Qt.QVBoxLayout type: int value: '1' widget: combo_box states: coordinate: [499, 15] rotation: 0 state: enabled - name: Mixergain id: variable_qtgui_chooser parameters: gui_hint: 0,2,1,1 label0: 'On' label1: 'Off' labels: '[]' num_opts: '2' option1: '0' option2: '2' option3: '3' option4: '4' options: '[0, 1, 2]' orient: Qt.QVBoxLayout type: int value: '1' widget: combo_box states: coordinate: [688, 12.0] rotation: 0 state: enabled - name: RxFrequency id: variable_qtgui_range parameters: gui_hint: 0,0,1,1 label: 'Set Frequency ' min_len: '200' orient: Qt.Horizontal rangeType: float start: '80000' step: '1' stop: '146000' value: '94300' widget: counter states: coordinate: [345, 19] rotation: 0 state: enabled - name: samp_rate id: variable parameters: value: '192000' states: coordinate: [227, 23] rotation: 0 state: enabled - name: analog_wfm_rcv_pll_0 id: analog_wfm_rcv_pll parameters: audio_decimation: '4' quad_rate: samp_rate states: coordinate: [648, 432.0] rotation: 0 state: true - name: audio_sink_0 id: audio_sink parameters: device_name: default num_inputs: '2' ok_to_block: 'True' samp_rate: '48000' states: coordinate: [1110, 406] rotation: 0 state: enabled - name: fcdproplus_fcdproplus_0 id: fcdproplus_fcdproplus parameters: freq: RxFrequency if_gain: Ifgain lnaswitch: Lna maxoutbuf: '0' minoutbuf: '0' mixergainswitch: Mixergain ppm: ' 0' unit: '1000' states: coordinate: [112, 212.0] rotation: 0 state: enabled - name: low_pass_filter_0 id: low_pass_filter parameters: beta: '6.76' cutoff_freq: '60000' decim: '1' gain: '5' interp: '1' maxoutbuf: '0' minoutbuf: '0' samp_rate: samp_rate type: fir_filter_ccf width: '500' win: firdes.WIN_HAMMING states: coordinate: [400, 324.0] rotation: 0 state: enabled - name: qtgui_sink_x_0 id: qtgui_sink_x parameters: bw: samp_rate fc: RxFrequency*1000 fftsize: '1024' gui_hint: 1,0,1,7 maxoutbuf: '0' minoutbuf: '0' name: QT GUI Plot plotconst: 'False' plotfreq: 'True' plottime: 'False' plotwaterfall: 'True' rate: '10' showports: 'False' showrf: 'True' type: complex wintype: firdes.WIN_BLACKMAN_hARRIS states: coordinate: [648, 140.0] rotation: 0 state: enabled connections: - [analog_wfm_rcv_pll_0, '0', audio_sink_0, '0'] - [analog_wfm_rcv_pll_0, '1', audio_sink_0, '1'] - [fcdproplus_fcdproplus_0, '0', low_pass_filter_0, '0'] - [fcdproplus_fcdproplus_0, '0', qtgui_sink_x_0, '0'] - [low_pass_filter_0, '0', analog_wfm_rcv_pll_0, '0'] - [qtgui_sink_x_0, freq, fcdproplus_fcdproplus_0, freq] - [qtgui_sink_x_0, freq, qtgui_sink_x_0, freq] metadata: file_format: 1 07070100000013000081A4000003E800000064000000015D58261300000185000000000000000000000000000000000000003900000000gr-fcdproplus-3.8~git.20190817/gnuradio-fcdproplus.pc.inprefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@GR_LIBRARY_DIR@ includedir=${prefix}/@GR_INCLUDE_DIR@/fcdproplus Name: @CPACK_PACKAGE_NAME@ Description: @CPACK_PACKAGE_DESCRIPTION_SUMMARY@ URL: http://github.com/dl1ksv/ Version: @CPACK_PACKAGE_VERSION@ Requires: gnuradio-runtime gnuradio-audio Libs: -L${libdir} -lgnuradio-fcdproplus Cflags: -I${includedir} 07070100000014000041ED000003E800000064000000025D58261300000000000000000000000000000000000000000000002300000000gr-fcdproplus-3.8~git.20190817/grc07070100000015000081A4000003E800000064000000015D58261300000488000000000000000000000000000000000000003200000000gr-fcdproplus-3.8~git.20190817/grc/CMakeLists.txt# Copyright 2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(DEVICE_STRING "FUNcube Dongle V2.0") else() set(DEVICE_STRING "''") endif() configure_file ( fcdproplus.block.yml.in fcdproplus.block.yml ESCAPE_QUOTES @ONLY ) install(FILES ${CMAKE_BINARY_DIR}/grc/fcdproplus.block.yml fcdproplus_control.block.yml fcd_control.block.yml fcd.block.yml DESTINATION "${GRC_BLOCKS_DIR}" ) 07070100000016000081A4000003E800000064000000015D58261300000A4F000000000000000000000000000000000000003100000000gr-fcdproplus-3.8~git.20190817/grc/fcd.block.ymlid: fcd label: Funcube Dongle category: '[Custom]/Fcd' flags: throttle parameters: - id: devicename label: Device Name dtype: string default: '' - id: freq label: Frequency (Hz) dtype: real default: '145500000' - id: lna label: LNA Gain (dB) dtype: real default: '20.0' - id: mixer label: Mixer Gain (dB) dtype: real default: '+12' - id: ppm label: Frequency corr. (ppm) dtype: int default: '-120' - id: dci label: DC I offset dtype: real default: '0.0' - id: dcq label: DC Q offset dtype: real default: '0.0' - id: iq_phase label: IQ phase balance dtype: real default: '0.0' - id: iq_gain label: IQ gain balance dtype: real default: '1.0' inputs: - domain: message id: freq optional: true outputs: - label: out dtype: complex asserts: - ${ (freq >= 50e6) and (freq <= 2e9) } - ${ (dci >= -1.0) and (dci <= 1.0) } - ${ (dcq >= -1.0) and (dcq <= 1.0) } - ${ (iq_phase >= -1.0) and (iq_phase <= 1.0) } - ${ (iq_gain >= -1.0) and (iq_gain <= 1.0) } templates: imports: import fcdproplus make: |- fcdproplus.fcd(${devicename}) % if lna != '20.0' : self.${id}.set_lna_gain(${lna}) % endif % if mixer != '+12' : self.${id}.set_mixer_gain(${mixer}) %endif % if ppm != '-120' : self.${id}.set_freq_corr(${ppm}) % endif % if (dci != '0.0') or (dcq != '0.0'): self.${id}.set_dc_corr(${dci},${dcq}) % endif % if (iq_phase != '0.0') or (iq_gain != '1.0'): self.${id}.set_iq_corr(${iq_gain},${iq_phase}) % endif self.${id}.set_freq(${freq}) callbacks: - set_freq(${freq}) - set_lna_gain(${lna}) - set_mixer_gain(${mixer}) - set_freq_corr(${ppm}) - set_dc_corr(${dci},${dcq}) - set_iq_corr(${iq_gain},${iq_phase}) documentation: |- This block wraps the Funcube Dongle USB HID control interface into one convenient GNU Radio source block. The LNA gain is a set of discrete values between -5 to 30 dB with 2.5 dB step, but you can use any float value and it will be rounded to the nearest valid value. The Mixer gain can be set either to +4 or +12 dB, but you can use any float value and it will be rounded to the nearest valid value. The FCD block can autmatically apply frequency correction: - For FCD v1.0 you can leave at -120 ppm - For FCD v1.1 with serial number 810 or greater use -12 ppm The DC offset and IQ balance parameters can have range -1.0 to 1.0. file_format: 1 07070100000017000081A4000003E800000064000000015D582613000009D2000000000000000000000000000000000000003900000000gr-fcdproplus-3.8~git.20190817/grc/fcd_control.block.ymlid: fcd_control label: Funcube Dongle Control category: '[Custom]/Fcd' parameters: - id: freq label: Frequency (Hz) dtype: real default: '145500000' - id: lna label: LNA Gain (dB) dtype: real default: '20.0' - id: mixer label: Mixer Gain (dB) dtype: real default: '+12' - id: ppm label: Frequency corr. (ppm) dtype: int default: '-120' - id: dci label: DC I offset dtype: real default: '0.0' - id: dcq label: DC Q offset dtype: real default: '0.0' - id: iq_phase label: IQ phase balance dtype: real default: '0.0' - id: iq_gain label: IQ gain balance dtype: real default: '1.0' inputs: - domain: message id: freq optional: true asserts: - ${ (freq >= 50e6) and (freq <= 2e9) } - ${ (dci >= -1.0) and (dci <= 1.0) } - ${ (dcq >= -1.0) and (dcq <= 1.0) } - ${ (iq_phase >= -1.0) and (iq_phase <= 1.0) } - ${ (iq_gain >= -1.0) and (iq_gain <= 1.0) } templates: imports: import fcdproplus make: |- fcdproplus.fcd_control() % if lna != '20.0' : self.${id}.set_lna_gain(${lna}) % endif % if mixer != '+12' : self.${id}.set_mixer_gain(${mixer}) %endif % if ppm != '-120' : self.${id}.set_freq_corr(${ppm}) % endif % if (dci != '0.0') or (dcq != '0.0'): self.${id}.set_dc_corr(${dci},${dcq}) % endif % if (iq_phase != '0.0') or (iq_gain != '1.0'): self.${id}.set_iq_corr(${iq_gain},${iq_phase}) % endif self.${id}.set_freq(${freq}) callbacks: - set_freq(${freq}) - set_lna_gain(${lna}) - set_mixer_gain(${mixer}) - set_freq_corr(${ppm}) - set_dc_corr(${dci},${dcq}) - set_iq_corr(${iq_gain},${iq_phase}) documentation: |- This block wraps the Funcube Dongle USB HID control interface into one convenient GNU Radio source block. The LNA gain is a set of discrete values between -5 to 30 dB with 2.5 dB step, but you can use any float value and it will be rounded to the nearest valid value. The Mixer gain can be set either to +4 or +12 dB, but you can use any float value and it will be rounded to the nearest valid value. The FCD block can autmatically apply frequency correction: - For FCD v1.0 you can leave at -120 ppm - For FCD v1.1 with serial number 810 or greater use -12 ppm The DC offset and IQ balance parameters can have range -1.0 to 1.0. file_format: 1 07070100000018000081A4000003E800000064000000015D582613000007B3000000000000000000000000000000000000003B00000000gr-fcdproplus-3.8~git.20190817/grc/fcdproplus.block.yml.inid: fcdproplus_fcdproplus label: Funcube dongle Pro+ category: '[Custom]/Fcd' flags: throttle parameters: - id: devicename label: Device Name dtype: string default: @DEVICE_STRING@ - id: unit label: Unit dtype: int default: '1' - id: lnaswitch label: Lna enable,disable dtype: int default: '1' - id: mixergainswitch label: Mixergain enable/disable dtype: int default: '1' - id: freq label: Frequency (Unit Hz) dtype: real default: '137500000' - id: ppm label: Frequency corr. (ppm) dtype: int default: '0' - id: if_gain label: If gain dtype: int default: '1' inputs: - domain: message id: freq optional: true outputs: - label: out dtype: complex templates: imports: import fcdproplus make: |- fcdproplus.fcdproplus(${devicename},${unit}) self.${id}.set_lna(${lnaswitch}) self.${id}.set_mixer_gain(${mixergainswitch}) self.${id}.set_if_gain(${if_gain}) self.${id}.set_freq_corr(${ppm}) self.${id}.set_freq(${freq}) callbacks: - set_freq(${freq}) - set_lna(${lnaswitch}) - set_mixer_gain(${mixergainswitch}) - set_freq_corr(${ppm}) - set_if_gain(${if_gain}) documentation: This block wraps the Funcube Dongle Pro+ USB alsa audio input and the USB control interface \ into one convenient GNU Radio source block. The sample rate is fixed at 192 ksps. The sound device is taken from the device_name. This should be the alsa device name, like \ hw:1 or plughw:1,0. If the device name is empty or invalid the device will beautodetected\ by looking into /proc/asound/cards . The frequency is expressed in Unit Hz, that means\ Unit = 1 Hz, Unit = 1000 Khz The LNA can be switched on and off. The mixer gain can be switched on and off. The if gain can be set between 0 and 59 ( integer values) . file_format: 1 07070100000019000081A4000003E800000064000000015D582613000004E4000000000000000000000000000000000000004000000000gr-fcdproplus-3.8~git.20190817/grc/fcdproplus_control.block.ymlid: fcdproplus_control label: Funcube dongle Pro+ Control category: '[Custom]/Fcd' parameters: - id: lnaswitch label: Lna enable,disable dtype: int default: '1' - id: mixergainswitch label: Mixergain enable/disable dtype: int default: '1' - id: freq label: Frequency (Unit Hz) dtype: real default: '137500000' - id: if_gain label: If gain dtype: int default: '1' inputs: - domain: message id: freq optional: true templates: imports: import fcdproplus make: |- fcdproplus.fcdpp_control() self.${id}.set_lna(${lnaswitch}) self.${id}.set_mixer_gain(${mixergainswitch}) self.${id}.set_if_gain(${if_gain}) self.${id}.set_freq(${freq}) callbacks: - set_freq(${freq}) - set_lna(${lnaswitch}) - set_mixer_gain(${mixergainswitch}) - set_if_gain(${if_gain}) documentation: This block wraps the Funcube Dongle Pro+ USB USB control interface \ into one convenient GNU Radio source block. The frequency is expressed in Unit Hz The LNA can be switched on and off. The mixer gain can be switched on and off. The if gain can be set between 0 and 59 ( integer values) . file_format: 1 0707010000001A000041ED000003E800000064000000035D58261300000000000000000000000000000000000000000000002700000000gr-fcdproplus-3.8~git.20190817/include0707010000001B000041ED000003E800000064000000025D58261300000000000000000000000000000000000000000000003200000000gr-fcdproplus-3.8~git.20190817/include/fcdproplus0707010000001C000081A4000003E800000064000000015D5826130000043E000000000000000000000000000000000000004100000000gr-fcdproplus-3.8~git.20190817/include/fcdproplus/CMakeLists.txt# Copyright 2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. ######################################################################## # Install public header files ######################################################################## install(FILES api.h fcdproplus.h fcdpp_control.h fcd_control.h fcd.h DESTINATION include/fcdproplus ) 0707010000001D000081A4000003E800000064000000015D58261300000437000000000000000000000000000000000000003800000000gr-fcdproplus-3.8~git.20190817/include/fcdproplus/api.h/* * Copyright 2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCDPROPLUS_API_H #define INCLUDED_FCDPROPLUS_API_H #include <gnuradio/attributes.h> #ifdef gnuradio_fcdproplus_EXPORTS # define FCDPROPLUS_API __GR_ATTR_EXPORT #else # define FCDPROPLUS_API __GR_ATTR_IMPORT #endif #endif /* INCLUDED_FCDPROPLUS_API_H */ 0707010000001E000081A4000003E800000064000000015D582613000011AD000000000000000000000000000000000000003800000000gr-fcdproplus-3.8~git.20190817/include/fcdproplus/fcd.h/* -*- c++ -*- */ /* * Copyright 2011-2013 Free Software Foundation, Inc. * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCDPROPLUS_FCD_H #define INCLUDED_FCDPROPLUS_FCD_H #include <fcdproplus/api.h> #include <gnuradio/hier_block2.h> #include <string> namespace gr { namespace fcdproplus { /*! * \brief Funcube Dongle source block. * \ingroup fcdproplus * * \details * This class provides a Funcube Dongle source block by wrapping * the USB audio interface and the USB HID control interface of * the Funcube Dongle into one convenient source block. * * The Funcube Dongle needs to have firmware 18f or later for the * control interface to work properly. As of early 2011, FCDs * still come with firmware 18b. You can use qthid 2.2 (not 3) to * upgrade the firmware: http://qthid.sf.net */ class FCDPROPLUS_API fcd : virtual public gr::hier_block2 { public: typedef boost::shared_ptr<fcd> sptr; /*! * \brief Return a shared_ptr to a new instance of fcd_source_c. * * \details * This is effectively the public constructor. To avoid accidental * use of raw pointers, fcd_source_c's constructor is private. * fcd_make_source_c is the public interface for creating new * instances. */ static sptr make(const std::string device_name = ""); /*! \brief Set frequency with Hz resolution. * \param freq The frequency in Hz * * This is a convenience function that uses float parameter in * order to allow using engineering notation in GRC. * */ virtual void set_freq(float freq) = 0; /*! \brief Set LNA gain. * \param gain The new gain in dB. * * Set the LNA gain in the FCD. Valid range is -5 to * 30. Although the LNA gain in the FCD takes enumerated values * corresponding to 2.5 dB steps, you can can call this method * with any float value and it will be rounded to the nearest * valid value. * * By default the LNA gain is set to 20 dB and this is a good value for * most cases. In noisy areas you may try to reduce the gain. */ virtual void set_lna_gain(float gain) = 0; /*! \brief Set mixer gain. * \param gain The new gain in dB. * * Set the mixer gain in the FCD. Valid values are +4 and +12 dB. * * By default the mixer gain is set to +12 dB and this is a good * value for most cases. In noisy areas you may try to reduce * the gain. */ virtual void set_mixer_gain(float gain) = 0; /*! \brief Set new frequency correction. * \param ppm The new frequency correction in parts per million * * Version 1.1 FCDs (S/N 810 or later) need a correction of -12 * ppm. Earlier FCDs need roughly -120 ppm (default for * gr-fcd). * * Ref: http://www.funcubedongle.com/?p=617 */ virtual void set_freq_corr(int ppm) = 0; /*! \brief Set DC offset correction. * \param _dci DC correction for I component (-1.0 to 1.0) * \param _dcq DC correction for Q component (-1.0 to 1.0) * * Set DC offset correction in the device. Default is 0.0. */ virtual void set_dc_corr(double _dci, double _dcq) = 0; /*! \brief Set IQ phase and gain balance. * \param _gain The gain correction (-1.0 to 1.0) * \param _phase The phase correction (-1.0 to 1.0) * * Set IQ phase and gain balance in the device. The default values * are 0.0 for phase and 1.0 for gain. */ virtual void set_iq_corr(double _gain, double _phase) = 0; }; } /* namespace fcd */ } /* namespace gr */ #endif /* INCLUDED_FCDPROPLUS_FCD_H */ 0707010000001F000081A4000003E800000064000000015D5826130000115B000000000000000000000000000000000000004000000000gr-fcdproplus-3.8~git.20190817/include/fcdproplus/fcd_control.h/* -*- c++ -*- */ /* * Copyright 2011-2013 Free Software Foundation, Inc. * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCD_CONTROL_H #define INCLUDED_FCD_CONTROL_H #include <fcdproplus/api.h> #include <gnuradio/block.h> namespace gr { namespace fcdproplus { /*! * \brief Funcube Dongle control block. * \ingroup fcd_blk * * \details * This class provides a Funcube Dongle control block by wrapping * th USB HID control interface of * the Funcube Dongle into one convenient source block. * * The Funcube Dongle needs to have firmware 18f or later for the * control interface to work properly. As of early 2011, FCDs * still come with firmware 18b. You can use qthid 2.2 (not 3) to * upgrade the firmware: http://qthid.sf.net */ class FCDPROPLUS_API fcd_control : virtual public gr::block { public: typedef boost::shared_ptr<fcd_control> sptr; static sptr make(); /*! * \brief Return a shared_ptr to a new instance of fcd_source_c. * * \details * This is effectively the public constructor. To avoid accidental * use of raw pointers, fcd_source_c's constructor is private. * fcd_make_source_c is the public interface for creating new * instances. */ /*! \brief Set frequency with Hz resolution. * \param freq The frequency in Hz * * This is a convenience function that uses float parameter in * order to allow using engineering notation in GRC. * */ virtual void set_freq(float freq) = 0; /*! \brief Set LNA gain. * \param gain The new gain in dB. * * Set the LNA gain in the FCD. Valid range is -5 to * 30. Although the LNA gain in the FCD takes enumerated values * corresponding to 2.5 dB steps, you can can call this method * with any float value and it will be rounded to the nearest * valid value. * * By default the LNA gain is set to 20 dB and this is a good value for * most cases. In noisy areas you may try to reduce the gain. */ virtual void set_lna_gain(float gain) = 0; /*! \brief Set mixer gain. * \param gain The new gain in dB. * * Set the mixer gain in the FCD. Valid values are +4 and +12 dB. * * By default the mixer gain is set to +12 dB and this is a good * value for most cases. In noisy areas you may try to reduce * the gain. */ virtual void set_mixer_gain(float gain) = 0; /*! \brief Set new frequency correction. * \param ppm The new frequency correction in parts per million * * Version 1.1 FCDs (S/N 810 or later) need a correction of -12 * ppm. Earlier FCDs need roughly -120 ppm (default for * gr-fcd). * * Ref: http://www.funcubedongle.com/?p=617 */ virtual void set_freq_corr(int ppm) = 0; /*! \brief Set DC offset correction. * \param _dci DC correction for I component (-1.0 to 1.0) * \param _dcq DC correction for Q component (-1.0 to 1.0) * * Set DC offset correction in the device. Default is 0.0. */ virtual void set_dc_corr(double _dci, double _dcq) = 0; /*! \brief Set IQ phase and gain balance. * \param _gain The gain correction (-1.0 to 1.0) * \param _phase The phase correction (-1.0 to 1.0) * * Set IQ phase and gain balance in the device. The default values * are 0.0 for phase and 1.0 for gain. */ virtual void set_iq_corr(double _gain, double _phase) = 0; }; } /* namespace fcd */ } /* namespace gr */ #endif /* INCLUDED_FCD_CONTROL_H */ 07070100000020000081A4000003E800000064000000015D5826130000077A000000000000000000000000000000000000004200000000gr-fcdproplus-3.8~git.20190817/include/fcdproplus/fcdpp_control.h/* -*- c++ -*- */ /* * Copyright 2018 Volker Schroer, DL1KSV * * This 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. * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCDPROPLUS_CONTROL_H #define INCLUDED_FCDPROPLUS_CONTROL_H #include <fcdproplus/api.h> #include <gnuradio/block.h> namespace gr { namespace fcdproplus { class FCDPROPLUS_API fcdpp_control : virtual public block { public: typedef boost::shared_ptr<fcdpp_control> sptr; static sptr make(); /*! \brief Sets the frequency . * \param freq The frequency in unit Hz * * Sets the frequency of the Funcube Dongle with Hz resolution * */ virtual void set_freq(float freq) = 0; /*! \brief Switches the LNA on/off. * \param gain lna on/off. * */ virtual void set_lna(int gain) = 0; /*! \brief Switches mixer gain onf/off. * \param gain true means on. * */ virtual void set_mixer_gain(int gain) = 0; /*! \brief Set If gain. * \param gain The If gain value between 0 and 59 db * */ virtual void set_if_gain(int gain)=0; }; } // namespace fcdproplus } // namespace gr #endif /* INCLUDED_FCDPROPLUS_CONTROL_H */ 07070100000021000081A4000003E800000064000000015D58261300000CEE000000000000000000000000000000000000003F00000000gr-fcdproplus-3.8~git.20190817/include/fcdproplus/fcdproplus.h/* -*- c++ -*- */ /* * Copyright 2013 Volker Schroer, DL1KSV * * This 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. * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCDPROPLUS_FCDPROPLUS_H #define INCLUDED_FCDPROPLUS_FCDPROPLUS_H #include <fcdproplus/api.h> #include <gnuradio/hier_block2.h> #include <string> namespace gr { namespace fcdproplus { /*! * \brief Funcube Pro+ Dongle source block. * * This class provides a soure block for the Funcube Pro+ Dongle by wrapping the * alsa audio interface and the USB control interface of the Funcube Dongle * into one convenient source block. * The hadware audio device is autodetected by the card name. If more than one Pro+ are * connected it takes the first card. * The block was tested with firmware version 20.3 * * \ingroup fcdproplus * */ class FCDPROPLUS_API fcdproplus : virtual public hier_block2 { public: typedef boost::shared_ptr<fcdproplus> sptr; /*! * \brief Return a shared_ptr to a new instance of fcdproplus::fcdproplus. * * To avoid accidental use of raw pointers, fcdproplus::fcdproplus's * constructor is in a private implementation * class. fcdproplus::fcdproplus::make is the public interface for * creating new instances. */ static sptr make(const std::string device_name = "",int unit =1 ); /*! \brief Set frequency with resolution defined by unit. * \param freq The frequency in unit Hz * * Sets the frequency of the Funcube Dongle with Hz or Khz resolution * depending on the unit paramater ( 1: Hz , 1000 Khz ) * applying the frequency correction set by set_freq_corr(). * */ virtual void set_freq(float freq) = 0; /*! \brief Switches the LNA on/off. * \param gain lna on/off. * */ virtual void set_lna(int gain) = 0; /*! \brief Switches mixer gain onf/off. * \param gain true means on. * */ virtual void set_mixer_gain(int gain) = 0; /*! \brief Set new frequency correction. * \param ppm The new frequency correction in parts per million * * Funcube recommends 0 for the Pro+. * * Ref: http://www.funcubedongle.com/MyImages/FCD2ManualV4.pdf */ virtual void set_freq_corr(int ppm) = 0; /*! \brief Set If gain. * \param gain The If gain value between 0 and 59 db * */ virtual void set_if_gain(int gain)=0; }; } // namespace fcdproplus } // namespace gr #endif /* INCLUDED_FCDPROPLUS_FCDPROPLUS_H */ 07070100000022000041ED000003E800000064000000035D58261300000000000000000000000000000000000000000000002300000000gr-fcdproplus-3.8~git.20190817/lib07070100000023000081A4000003E800000064000000015D582613000008D8000000000000000000000000000000000000003200000000gr-fcdproplus-3.8~git.20190817/lib/CMakeLists.txt# Copyright 2011-2014 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. ######################################################################## # Setup library ######################################################################## include(GrPlatform) #define LIB_SUFFIX include(GrMiscUtils) list(APPEND fcdproplus_sources fcdproplus_impl.cc fcdpp_control_impl.cc fcd_control_impl.cc fcd_impl.cc ) add_library(gnuradio-fcdproplus SHARED ${fcdproplus_sources}) list(APPEND fcdproplus_libs ${LIBUSB_LIBRARIES} ) if(HIDAPI_LIBRARY) MESSAGE(STATUS "System Hidapi will be used") list(APPEND fcdproplus_libs ${HIDAPI_LIBRARY} ) find_path(HIDAPI_INCLUDES NAMES "hidapi.h" HINTS /usr/include/hidapi PATHS /usr/include /usr/local/include ) else () list(APPEND fcdproplus_sources ${CMAKE_CURRENT_SOURCE_DIR}/hid/hid.c) set(HIDAPI_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/hid") endif() target_link_libraries(gnuradio-fcdproplus gnuradio::gnuradio-audio gnuradio::gnuradio-blocks ${fcdproplus_libs}) target_include_directories(gnuradio-fcdproplus PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> PUBLIC $<BUILD_INTERFACE:${HIDAPI_INCLUDES}> PUBLIC $<INSTALL_INTERFACE:include> ) if(APPLE) SET_TARGET_PROPERTIES(gnuradio-fcdproplus PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR}") endif(APPLE) set_target_properties(gnuradio-fcdproplus PROPERTIES DEFINE_SYMBOL "gnuradio_fcdproplus_EXPORTS") GR_LIBRARY_FOO(gnuradio-fcdproplus) 07070100000024000081A4000003E800000064000000015D582613000026B8000000000000000000000000000000000000003700000000gr-fcdproplus-3.8~git.20190817/lib/fcd_control_impl.cc/* -*- c++ -*- */ /* * Copyright 2011-2013 Free Software Foundation, Inc. * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "fcdcmd.h" #include "fcd_control_impl.h" #include <gnuradio/logger.h> #define FCD_VENDOR_ID 0x04D8 /*!< USB vendor ID. */ #define FCD_PRODUCT_ID 0xFB56 /*!< USB product ID. */ namespace gr { namespace fcdproplus { /* * Create a new instance of gr::fcd::fcd_control_impl and return an * upcasted boost shared_ptr. This is effectively the public * constructor. */ fcd_control::sptr fcd_control::make() { return gnuradio::get_initial_sptr (new fcd_control_impl()); } /* * The private constructor */ fcd_control_impl::fcd_control_impl() : gr::block("fcd_control", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), d_freq_corr(-120) { /* setup the control part */ d_control_handle =NULL; hid_init(); d_control_handle = hid_open ( FCD_VENDOR_ID ,FCD_PRODUCT_ID,NULL ); if(d_control_handle == NULL ) { GR_LOG_ERROR(d_logger,"FunCube Dongle V1.0 not found."); throw std::runtime_error("FunCube Dongle V1.0 not found."); } else { GR_LOG_INFO(d_logger,"FunCube Dongle V1.0 initialized."); } /* * Check mode, so * Send a BL Query Command */ aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_HID_CMD_QUERY; hid_write(d_control_handle,aucBuf,65); hid_read(d_control_handle,aucBuf,65); aucBuf[15]=0; GR_LOG_INFO(d_logger,boost::format("Dongle: %S ") % &aucBuf[2]); /* * Initialize message handling */ message_port_register_in(pmt::mp("freq")); set_msg_handler(pmt::mp("freq"), boost::bind(&fcd_control_impl::set_frequency_msg, this, _1)); } fcd_control_impl::~fcd_control_impl() { if(d_control_handle !=0) { hid_close(d_control_handle); } hid_exit(); } // Set frequency with Hz resolution (type float) void fcd_control_impl::set_freq(float freq) { /* valid range 50 MHz - 2.0 GHz */ if((freq < 50.0e6) || (freq > 2.0e9)) return; unsigned int nfreq = (double)freq*(1.0 + d_freq_corr/1000000.0); aucBuf[0]=0; aucBuf[1]=FCD_HID_CMD_SET_FREQUENCY_HZ; aucBuf[2] = (unsigned char)nfreq; aucBuf[3] = (unsigned char)(nfreq>>8); aucBuf[4] = (unsigned char)(nfreq>>16); aucBuf[5] = (unsigned char)(nfreq>>24); hid_write(d_control_handle, aucBuf, 65); aucBuf[1]=0; hid_read(d_control_handle, aucBuf, 65); if (aucBuf[0]==FCD_HID_CMD_SET_FREQUENCY_HZ && aucBuf[1]==1) { nfreq = 0; nfreq = (unsigned int) aucBuf[2]; nfreq += (unsigned int) (aucBuf[3] << 8); nfreq += (unsigned int) (aucBuf[4] << 16); nfreq += (unsigned int) (aucBuf[5] << 24); GR_LOG_INFO(d_logger,boost::format("Set Frequency to: %1% Hz") % nfreq); } else { GR_LOG_INFO(d_logger,boost::format("Set Frequency to %1% Hz failed") % nfreq ); } } // Set LNA gain void fcd_control_impl::set_lna_gain(float gain) { unsigned char g; /* convert to nearest discrete value */ if(gain > 27.5) { g = 14; // 30.0 dB } else if(gain > 22.5) { g = 13; // 25.0 dB } else if(gain > 18.75) { g = 12; // 20.0 dB } else if(gain > 16.25) { g = 11; // 17.5 dB } else if(gain > 13.75) { g = 10; // 15.0 dB } else if(gain > 11.25) { g = 9; // 12.5 dB } else if(gain > 8.75) { g = 8; // 10.0 dB } else if(gain > 6.25) { g = 7; // 7.5 dB } else if(gain > 3.75) { g = 6; // 5.0 dB } else if(gain > 1.25) { g = 5; // 2.5 dB } else if(gain > -1.25) { g = 4; // 0.0 dB } else if(gain > -3.75) { g = 1; // -2.5 dB } else { g = 0; // -5.0 dB } aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_HID_CMD_SET_LNA_GAIN; aucBuf[2] = g; hid_write(d_control_handle, aucBuf, 65); hid_read(d_control_handle, aucBuf, 65); if(aucBuf[0] == FCD_HID_CMD_SET_LNA_GAIN) { GR_LOG_INFO(d_logger,boost::format("LNA gain set to: %1$7d")% gain); } else { GR_LOG_ERROR(d_logger,boost::format("Failed to modify LNA gain. Result of transaction: %1%,%2%") % aucBuf[0] %aucBuf[1]); } } // Set mixer gain void fcd_control_impl::set_mixer_gain(float gain) { unsigned char g; if( gain > 4.0 ) { g = TMGE_P12_0DB; } else { g = TMGE_P4_0DB; } aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_HID_CMD_SET_MIXER_GAIN; aucBuf[2] = g; hid_write(d_control_handle, aucBuf, 65); hid_read(d_control_handle, aucBuf, 65); if(aucBuf[0] == FCD_HID_CMD_SET_MIXER_GAIN) { GR_LOG_INFO(d_logger,boost::format("Mixer gain set to: ") % gain); } else { GR_LOG_ERROR(d_logger,boost::format("Failed to modify Mixer gain. Result of transaction: %1%,%2%") % aucBuf[0] %aucBuf[1]); } } // Set new frequency correction void fcd_control_impl::set_freq_corr(int ppm) { d_freq_corr = ppm; // re-tune with new correction value //set_freq(d_freq_req); } // Set DC offset correction. void fcd_control_impl::set_dc_corr(double _dci, double _dcq) { union { unsigned char auc[4]; struct { signed short dci; // equivalent of qint16 which should be 16 bit everywhere signed short dcq; }; } dcinfo; if((_dci < -1.0) || (_dci > 1.0) || (_dcq < -1.0) || (_dcq > 1.0)) return; dcinfo.dci = static_cast<signed short>(_dci*32768.0); dcinfo.dcq = static_cast<signed short>(_dcq*32768.0); aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_CMD_APP_SET_DC_CORR; for(int i= 0;i < 4; i++ ) aucBuf[2+i] = dcinfo.auc[i]; hid_write(d_control_handle, aucBuf, 65); hid_read(d_control_handle, aucBuf, 65); if(aucBuf[0] == FCD_CMD_APP_SET_DC_CORR) { GR_LOG_INFO(d_logger,"DC offset correction set "); } else { GR_LOG_ERROR(d_logger,boost::format("Failed to set DC offset correction. Result of transaction: %1%,%2%") % aucBuf[0] %aucBuf[1]); } } // Set IQ phase and gain balance. void fcd_control_impl::set_iq_corr(double _gain, double _phase) { union { unsigned char auc[4]; struct { signed short phase; signed short gain; }; } iqinfo; if ((_gain < -1.0) || (_gain > 1.0) || (_phase < -1.0) || (_phase > 1.0)) return; iqinfo.phase = static_cast<signed short>(_phase*32768.0); iqinfo.gain = static_cast<signed short>(_gain*32768.0); aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_CMD_APP_SET_IQ_CORR; for(int i= 0;i < 4; i++ ) aucBuf[2+i] = iqinfo.auc[i]; hid_write(d_control_handle, aucBuf, 65); hid_read(d_control_handle, aucBuf, 65); if(aucBuf[0] == FCD_CMD_APP_SET_IQ_CORR) { GR_LOG_INFO(d_logger,"IQ phase and gain balance set"); } else { GR_LOG_ERROR(d_logger,boost::format("Failed to set IQ phase and gain balance. Result of transaction: %1%,%2%") % aucBuf[0] %aucBuf[1]); } } void fcd_control_impl::set_frequency_msg(pmt::pmt_t msg) { // Accepts either a number that is assumed to be the new // frequency or a key:value pair message where the key must be // "freq" and the value is the new frequency. GR_LOG_DEBUG(d_logger,"Funcube Control frequency message arrived"); if(pmt::is_number(msg)) { set_freq(pmt::to_float(msg)); } else if(pmt::is_pair(msg)) { pmt::pmt_t key = pmt::car(msg); pmt::pmt_t val = pmt::cdr(msg); if(pmt::eq(key, pmt::intern("freq"))) { if(pmt::is_number(val)) { set_freq(pmt::to_float(val)); } } else { GR_LOG_WARN(d_logger, boost::format("Set Frequency Message must have the key = 'freq'; got '%1%'.")% pmt::write_string(key)); } } else { GR_LOG_WARN(d_logger, "Set Frequency Message must be either a number or a key:value pair where the key is 'freq'."); } } } /* namespace fcd */ } /* namespace gr */ 07070100000025000081A4000003E800000064000000015D5826130000077A000000000000000000000000000000000000003600000000gr-fcdproplus-3.8~git.20190817/lib/fcd_control_impl.h/* -*- c++ -*- */ /* * Copyright 2011-2013 Free Software Foundation, Inc. * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCD_CONTROL_IMPL_H #define INCLUDED_FCD_CONTROL_IMPL_H #include <fcdproplus/fcd_control.h> #ifdef SYSTEM_HIDAPI #include <hidapi/hidapi.h> #else #include "hidapi.h" #endif namespace gr { namespace fcdproplus { class fcd_control_impl : public fcd_control { public: fcd_control_impl(); ~fcd_control_impl(); /* Public API functions documented in include/fcdprplus/fcd_control.h */ void set_freq(float freq); void set_lna_gain(float gain); void set_mixer_gain(float gain); void set_freq_corr(int ppm); void set_dc_corr(double _dci, double _dcq); void set_iq_corr(double _gain, double _phase); void set_frequency_msg(pmt::pmt_t msg); private: int d_freq_corr; /*!< The frequency correction in ppm */ hid_device *d_control_handle; /*!< handle to control the device, set frequency, etc */ unsigned char aucBuf[65]; /*!< Buffers to read/write control messages to the dongle */ }; } /* namespace fcd */ } /* namespace gr */ #endif /* INCLUDED_FCD_CONTROL_IMPL_H */ 07070100000026000081A4000003E800000064000000015D58261300001870000000000000000000000000000000000000002F00000000gr-fcdproplus-3.8~git.20190817/lib/fcd_impl.cc/* -*- c++ -*- */ /* * Copyright 2011-2013 Free Software Foundation, Inc. * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <gnuradio/io_signature.h> #include <gnuradio/blocks/float_to_complex.h> #include "fcd_impl.h" #include <iostream> #include <fstream> #include <exception> //using namespace std; namespace gr { namespace fcdproplus { /* * Create a new instance of gr::fcd::fcd_impl and return an * upcasted boost shared_ptr. This is effectively the public * constructor. */ fcd::sptr fcd::make(const std::string device_name) { return gnuradio::get_initial_sptr (new fcd_impl(device_name)); } fcd_impl::fcd_impl(const std::string user_device_name) : gr::hier_block2("fcd", gr::io_signature::make( 0 , 0 , 0 ), gr::io_signature::make( 1 , 1 , sizeof(gr_complex))), d_freq_corr(-120) { prefs *p = prefs::singleton(); std::string config_file = p->get_string("LOG", "log_config", ""); std::string log_level = p->get_string("LOG", "log_level", "off"); std::string log_file = p->get_string("LOG", "log_file", ""); GR_CONFIG_LOGGER(config_file); GR_LOG_GETLOGGER(LOG, "gr_log." + alias()); GR_LOG_SET_LEVEL(LOG, log_level); if(log_file.size() > 0) { if(log_file == "stdout") { GR_LOG_SET_CONSOLE_APPENDER(LOG, "cout","gr::log :%p: %c{1} - %m%n"); } else if(log_file == "stderr") { GR_LOG_SET_CONSOLE_APPENDER(LOG, "cerr","gr::log :%p: %c{1} - %m%n"); } else { GR_LOG_SET_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n"); } } d_logger = LOG; std::string device_name; bool success; gr::blocks::float_to_complex::sptr f2c; success = false; d_freq_req=0; d_freq_corr=0; if(!user_device_name.empty()) { try { /* Audio source; sample rate fixed at 192kHz */ fcd_audio = gr::audio::source::make(96000, user_device_name, true); success=true; } catch (std::exception ) { std::cerr << "Could not open device: " <<user_device_name << std::endl; GR_LOG_INFO(d_logger,boost::format("Could not open device: %1%") % user_device_name); success=false; } } if(success) { device_name=user_device_name; } else { device_name.clear(); std::string line; std::ifstream cards( "/proc/asound/cards" ); if ( cards.is_open() ) { while ( cards.good() ) { getline (cards, line); if ( line.find( "USB-Audio - FUNcube Dongle V1.0" ) != std::string::npos ) { int id; std::istringstream( line ) >> id; std::ostringstream hw_id; hw_id << "hw:" << id<<",0"; // build alsa identifier device_name= hw_id.str(); } } cards.close(); if(device_name.empty()) { throw std::runtime_error("No FunCube Dongle V1.0 found."); } } else { throw std::runtime_error("Alsa not found."); } /* Audio source; sample rate fixed at 96kHz */ fcd_audio = gr::audio::source::make(96000, device_name, true); } if(success) { GR_LOG_INFO(d_logger,boost::format("Audio device %1% opened") % device_name); } else { GR_LOG_INFO(d_logger,boost::format("Funcube Dongle found as: %1%") % device_name); } /* block to convert stereo audio to a complex stream */ f2c = gr::blocks::float_to_complex::make(1); connect(fcd_audio, 0, f2c, 0); connect(fcd_audio, 1, f2c, 1); connect(f2c, 0, self(), 0); fcd_control_block = fcd_control::make(); message_port_register_hier_in(pmt::mp("freq")); msg_connect(self(),pmt::mp("freq"),fcd_control_block,pmt::mp("freq")); } fcd_impl::~fcd_impl() { } // Set frequency with Hz resolution (type float) void fcd_impl::set_freq(float freq) { float setfreq; if(d_freq_req == (int) freq) return; // Frequency did not change d_freq_req=(int) freq; if(d_freq_corr != 0) { setfreq=(1.+((float) d_freq_corr)/1000000.)*freq; } else setfreq=freq; fcd_control_block->set_freq(setfreq); } // Set LNA gain void fcd_impl::set_lna_gain(float gain) { fcd_control_block->set_lna_gain(gain); } // Set mixer gain void fcd_impl::set_mixer_gain(float gain) { fcd_control_block->set_mixer_gain(gain); } // Set new frequency correction void fcd_impl::set_freq_corr(int ppm) { d_freq_corr = ppm; // re-tune with new correction value // set_freq(d_freq_req); } // Set DC offset correction. void fcd_impl::set_dc_corr(double _dci, double _dcq) { fcd_control_block->set_dc_corr(_dci,_dcq); } // Set IQ phase and gain balance. void fcd_impl::set_iq_corr(double _gain, double _phase) { fcd_control_block->set_iq_corr(_gain,_phase) ; } } /* namespace fcd */ } /* namespace gr */ 07070100000027000081A4000003E800000064000000015D582613000007AD000000000000000000000000000000000000002E00000000gr-fcdproplus-3.8~git.20190817/lib/fcd_impl.h/* -*- c++ -*- */ /* * Copyright 2011-2013 Free Software Foundation, Inc. * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCDPROPLUS_FCD_IMPL_H #define INCLUDED_FCDPROPLUS_FCD_IMPL_H #include <fcdproplus/fcd.h> #include <fcdproplus/fcd_control.h> #include <gnuradio/audio/source.h> #include <gnuradio/logger.h> #include <gnuradio/prefs.h> namespace gr { namespace fcdproplus { class fcd_impl : public fcd { public: fcd_impl(const std::string device_name = ""); ~fcd_impl(); /* Public API functions documented in include/fcdproplus/fcd.h */ void set_freq(float freq); void set_lna_gain(float gain); void set_mixer_gain(float gain); void set_freq_corr(int ppm); void set_dc_corr(double _dci, double _dcq); void set_iq_corr(double _gain, double _phase); private: gr::audio::source::sptr fcd_audio; /*!< The audio input source */ int d_freq_corr; /*!< The frequency correction in ppm */ int d_freq_req; /*!< The latest requested frequency in Hz */ fcd_control::sptr fcd_control_block;/*!< The fcd control block */ gr::logger_ptr d_logger; }; } /* namespace fcd */ } /* namespace gr */ #endif /* INCLUDED_FCDPROPLUS_FCD_IMPL_H */ 07070100000028000081A4000003E800000064000000015D58261300000974000000000000000000000000000000000000002C00000000gr-fcdproplus-3.8~git.20190817/lib/fcdcmd.h//#ifndef FCDCMD_INCLUDED__H #define FCDCMD_INCLUDED__H #define FCD_HID_CMD_H 1 #define FCD_HID_CMD_QUERY 1 // Returns string with "FCDAPP version" #define FCD_HID_CMD_SET_FREQUENCY_KHZ 100 // Send with 3 byte unsigned little endian frequency in kHz. #define FCD_HID_CMD_SET_FREQUENCY_HZ 101 // Send with 4 byte unsigned little endian frequency in Hz, returns with actual frequency set in Hz #define FCD_HID_CMD_GET_FREQUENCY_HZ 102 // Returns 4 byte unsigned little endian frequency in Hz. #define FCD_CMD_APP_SET_DC_CORR 106 /*!< Send with 2 byte unsigned I DC correction followed by 2 byte unsigned Q DC correction. 32768 is the default centre value. */ #define FCD_CMD_APP_SET_IQ_CORR 108 /*!< Send with 2 byte signed phase correction followed by 2 byte unsigned gain correction. 0 is the default centre value for phase correction, * 32768 is the default centre value for gain. */ #define FCD_HID_CMD_SET_LNA_GAIN 110 // Send one byte, 1 on, 0 off #define FCD_HID_CMD_SET_RF_FILTER 113 // Send one byte enum, see TUNERRFFILTERENUM #define FCD_HID_CMD_SET_MIXER_GAIN 114 // Send one byte, 1 on, 0 off #define FCD_HID_CMD_SET_IF_GAIN 117 // Send one byte value, valid value 0 to 59 (dB) #define FCD_HID_CMD_SET_IF_FILTER 122 // Send one byte enum, see TUNERIFFILTERENUM #define FCD_HID_CMD_SET_BIAS_TEE 126 // Send one byte, 1 on, 0 off #define FCD_HID_CMD_GET_LNA_GAIN 150 // Returns one byte, 1 on, 0 off #define FCD_HID_CMD_GET_RF_FILTER 153 // Returns one byte enum, see TUNERRFFILTERENUM #define FCD_HID_CMD_GET_MIXER_GAIN 154 // Returns one byte, 1 on, 0 off #define FCD_HID_CMD_GET_IF_GAIN 157 // Returns one byte value, valid value 0 to 59 (dB) #define FCD_HID_CMD_GET_IF_FILTER 162 // Returns one byte enum, see TUNERIFFILTERENUM #define FCD_HID_CMD_GET_BIAS_TEE 166 // Returns one byte, 1 on, 0 off #define FCD_RESET 255 // Reset to bootloader typedef enum { TRFE_0_4, TRFE_4_8, TRFE_8_16, TRFE_16_32, TRFE_32_75, TRFE_75_125, TRFE_125_250, TRFE_145, TRFE_410_875, TRFE_435, TRFE_875_2000 } TUNERRFFILTERENUM; typedef enum { TIFE_200KHZ=0, TIFE_300KHZ=1, TIFE_600KHZ=2, TIFE_1536KHZ=3, TIFE_5MHZ=4, TIFE_6MHZ=5, TIFE_7MHZ=6, TIFE_8MHZ=7 } TUNERIFFILTERENUM; typedef enum { TMGE_P4_0DB=0, TMGE_P12_0DB=1 } TUNER_MIXER_GAIN_ENUM; //#endif 07070100000029000081A4000003E800000064000000015D58261300001BCD000000000000000000000000000000000000003900000000gr-fcdproplus-3.8~git.20190817/lib/fcdpp_control_impl.cc/* -*- c++ -*- */ /* * Copyright 2018 Volker Schroer, DL1KSV * * This 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. * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #include "fcdcmd.h" #include "fcdpp_control_impl.h" #include <gnuradio/logger.h> #define FCDPROPLUS_VENDOR_ID 0x04d8 #define FCDPROPLUS_PRODUCT_ID 0xfb31 #define TIMEOUT 5000 //using namespace std; namespace gr { namespace fcdproplus { fcdpp_control::sptr fcdpp_control::make() { return gnuradio::get_initial_sptr (new fcdpp_control_impl()); } /* * The private constructor */ fcdpp_control_impl::fcdpp_control_impl() : gr::block("fcdpp_control", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) { /* setup the control part */ d_control_handle =NULL; hid_init(); d_control_handle = hid_open ( FCDPROPLUS_VENDOR_ID ,FCDPROPLUS_PRODUCT_ID,NULL ); if(d_control_handle == NULL ) { GR_LOG_ERROR(d_logger,"FunCube Dongle V2.0 not found."); throw std::runtime_error("FunCube Dongle V2.0 not found."); } else { GR_LOG_INFO(d_logger,"FunCube Dongle V2.0 initialized."); } /* * Check mode, so * Send a BL Query Command */ aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_HID_CMD_QUERY; hid_write(d_control_handle,aucBuf,65); hid_read(d_control_handle,aucBuf,65); aucBuf[15]=0; GR_LOG_INFO(d_logger,boost::format("Dongle: %S ") % &aucBuf[2]); /* * Initialize message handling */ message_port_register_in(pmt::mp("freq")); set_msg_handler(pmt::mp("freq"), boost::bind(&fcdpp_control_impl::set_frequency_msg, this, _1)); } fcdpp_control_impl::~fcdpp_control_impl() { if(d_control_handle !=0) { hid_close(d_control_handle); } hid_exit(); } void fcdpp_control_impl::set_freq(float freq) { unsigned int nfreq = freq; aucBuf[0]=0; aucBuf[1]=FCD_HID_CMD_SET_FREQUENCY_HZ; aucBuf[2] = (unsigned char)nfreq; aucBuf[3] = (unsigned char)(nfreq>>8); aucBuf[4] = (unsigned char)(nfreq>>16); aucBuf[5] = (unsigned char)(nfreq>>24); hid_write(d_control_handle, aucBuf, 65); aucBuf[1]=0; hid_read(d_control_handle, aucBuf, 65); if (aucBuf[0]==FCD_HID_CMD_SET_FREQUENCY_HZ && aucBuf[1]==1) { nfreq = 0; nfreq = (unsigned int) aucBuf[2]; nfreq += (unsigned int) (aucBuf[3] << 8); nfreq += (unsigned int) (aucBuf[4] << 16); nfreq += (unsigned int) (aucBuf[5] << 24); GR_LOG_INFO(d_logger,boost::format("Set Frequency to: %1% Hz") % nfreq); } else { GR_LOG_INFO(d_logger,boost::format("Set Frequency to %1% Hz failed") % nfreq ); } } void fcdpp_control_impl::set_frequency_msg(pmt::pmt_t msg) { // Accepts either a number that is assumed to be the new // frequency or a key:value pair message where the key must be // "freq" and the value is the new frequency. GR_LOG_DEBUG(d_logger,"Funcube Control frequency message arrived"); if(pmt::is_number(msg)) { set_freq(pmt::to_float(msg)); } else if(pmt::is_pair(msg)) { pmt::pmt_t key = pmt::car(msg); pmt::pmt_t val = pmt::cdr(msg); if(pmt::eq(key, pmt::intern("freq"))) { if(pmt::is_number(val)) { set_freq(pmt::to_float(val)); } } else { GR_LOG_WARN(d_logger, boost::format("Set Frequency Message must have the key = 'freq'; got '%1%'.")% pmt::write_string(key)); } } else { GR_LOG_WARN(d_logger, "Set Frequency Message must be either a number or a key:value pair where the key is 'freq'."); } } void fcdpp_control_impl::set_lna(int gain) { aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_HID_CMD_SET_LNA_GAIN; if(gain !=0 ) { aucBuf[2] = 1; } else { aucBuf[2]=0; } hid_write(d_control_handle, aucBuf, 65); hid_read(d_control_handle, aucBuf, 65); if(aucBuf[0] == FCD_HID_CMD_SET_LNA_GAIN) { if (gain != 0) { GR_LOG_INFO(d_logger,"LNA gain enabled"); } else { GR_LOG_INFO(d_logger,"LNA gain disabled"); } } else { GR_LOG_ERROR(d_logger,boost::format("Failed to modify LNA gain. Result of transaction: %1%,%2%") % aucBuf[0] %aucBuf[1]); } } void fcdpp_control_impl::set_mixer_gain(int gain) { aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_HID_CMD_SET_MIXER_GAIN; if(gain !=0 ) { aucBuf[2] = 1; } else { aucBuf[2]=0; } hid_write(d_control_handle, aucBuf, 65); hid_read(d_control_handle, aucBuf, 65); if(aucBuf[0] == FCD_HID_CMD_SET_MIXER_GAIN) { if (gain != 0) { GR_LOG_INFO(d_logger,"Mixer gain enabled"); } else { GR_LOG_INFO(d_logger,"Mixer gain disabled"); } } else { GR_LOG_ERROR(d_logger,boost::format("Failed to modify Mixer gain. Result of transaction: %1%,%2%") % aucBuf[0] %aucBuf[1]); } } void fcdpp_control_impl::set_if_gain(int gain) { if( (gain < 0) || gain > 59) { GR_LOG_ERROR(d_logger,boost::format("Invalid IF gain value: %1%") % gain); return; } aucBuf[0] = 0; // Report ID. Ignored by HID Class firmware as only config'd for one report aucBuf[1] = FCD_HID_CMD_SET_IF_GAIN; aucBuf[2] = (unsigned char) gain; hid_write(d_control_handle, aucBuf, 65); hid_read(d_control_handle, aucBuf, 65); if(aucBuf[0] == FCD_HID_CMD_SET_IF_GAIN) { GR_LOG_INFO(d_logger,boost::format("IF gain set to: %1%") % gain ); } else { GR_LOG_ERROR(d_logger,"Could not set IF gain"); } } } /* namespace fcdproplus */ } /* namespace gr */ 0707010000002A000081A4000003E800000064000000015D582613000006C7000000000000000000000000000000000000003800000000gr-fcdproplus-3.8~git.20190817/lib/fcdpp_control_impl.h/* -*- c++ -*- */ /* * Copyright 2018 Volker Schroer, DL1KSV * * This 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. * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCDPROPLUS_CONTROL_IMPL_H #define INCLUDED_FCDPROPLUS_CONTROL_IMPL_H #include <fcdproplus/fcdpp_control.h> #ifdef SYSTEM_HIDAPI #include <hidapi/hidapi.h> #else #include "hidapi.h" #endif namespace gr { namespace fcdproplus { class fcdpp_control_impl : public fcdpp_control { private: hid_device *d_control_handle; /*!< handle to control the device, set frequency, etc */ unsigned char aucBuf[65]; /*!< Buffers to read/write control messages to the dongle */ public: fcdpp_control_impl(); ~fcdpp_control_impl(); /* Public API functions documented in include/control.h */ void set_freq(float freq); void set_lna(int gain); void set_mixer_gain(int gain); void set_if_gain(int gain); void set_frequency_msg(pmt::pmt_t msg); }; } // namespace fcdproplus } // namespace gr #endif /* INCLUDED_FCDPROPLUS_CONTROL_H */ 0707010000002B000081A4000003E800000064000000015D58261300001879000000000000000000000000000000000000003600000000gr-fcdproplus-3.8~git.20190817/lib/fcdproplus_impl.cc/* -*- c++ -*- */ /* * Copyright 2013, 2018 Volker Schroer, DL1KSV * * This 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. * * This software 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 this software; 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 <gnuradio/io_signature.h> #include <gnuradio/blocks/float_to_complex.h> #include "fcdproplus_impl.h" #include <iostream> #include <fstream> #include <exception> using namespace std; namespace gr { namespace fcdproplus { fcdproplus::sptr fcdproplus::make(const std::string device_name,int unit) { return gnuradio::get_initial_sptr (new fcdproplus_impl(device_name,unit)); } /* * The private constructor */ fcdproplus_impl::fcdproplus_impl(const std::string user_device_name,int unit) : gr::hier_block2("fcdproplus", gr::io_signature::make(0, 0, 0), gr::io_signature::make(1, 1, sizeof (gr_complex))) { prefs *p = prefs::singleton(); std::string config_file = p->get_string("LOG", "log_config", ""); std::string log_level = p->get_string("LOG", "log_level", "off"); std::string log_file = p->get_string("LOG", "log_file", ""); GR_CONFIG_LOGGER(config_file); GR_LOG_GETLOGGER(LOG, "gr_log." + alias()); GR_LOG_SET_LEVEL(LOG, log_level); if(log_file.size() > 0) { if(log_file == "stdout") { GR_LOG_SET_CONSOLE_APPENDER(LOG, "cout","gr::log :%p: %c{1} - %m%n"); } else if(log_file == "stderr") { GR_LOG_SET_CONSOLE_APPENDER(LOG, "cerr","gr::log :%p: %c{1} - %m%n"); } else { GR_LOG_SET_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n"); } } d_logger = LOG; std::string device_name; bool success; gr::blocks::float_to_complex::sptr f2c; success = false; d_freq_req=0; d_corr=0; d_unit=unit; if(!user_device_name.empty()) { try { /* Audio source; sample rate fixed at 192kHz */ fcd = gr::audio::source::make(192000, user_device_name, true); success=true; } catch (std::exception ) { std::cerr << "Could not open device: " <<user_device_name << std::endl; GR_LOG_INFO(d_logger,boost::format("Could not open device: %1%") % user_device_name); success=false; } } if(success) { device_name=user_device_name; } else { device_name.clear(); std::string line; std::ifstream cards( "/proc/asound/cards" ); if ( cards.is_open() ) { while ( cards.good() ) { getline (cards, line); if ( line.find( "USB-Audio - FUNcube Dongle V2.0" ) != std::string::npos ) { int id; std::istringstream( line ) >> id; std::ostringstream hw_id; hw_id << "hw:" << id<<",0"; // build alsa identifier device_name= hw_id.str(); } } cards.close(); if(device_name.empty()) { throw std::runtime_error("No FunCube Dongle V2.0 found."); } } else { throw std::runtime_error("Alsa not found."); } /* Audio source; sample rate fixed at 192kHz */ fcd = gr::audio::source::make(192000, device_name, true); } if(success) { GR_LOG_INFO(d_logger,boost::format("Audio device %1% opened") % device_name); } else { GR_LOG_INFO(d_logger,boost::format("Funcube Dongle Pro+ found as: %1%") % device_name); } /* block to convert stereo audio to a complex stream */ f2c = gr::blocks::float_to_complex::make(1); connect(fcd, 0, f2c, 0); connect(fcd, 1, f2c, 1); connect(f2c, 0, self(), 0); fcd_control_block = fcdpp_control::make(); message_port_register_hier_in(pmt::mp("freq")); msg_connect(self(),pmt::mp("freq"),fcd_control_block,pmt::mp("freq")); } /* * Our virtual destructor. */ fcdproplus_impl::~fcdproplus_impl() { } void fcdproplus_impl::set_freq(float freq) { float setfreq; if(d_freq_req == (int) freq) return; // Frequency did not change d_freq_req=(int) freq; if(d_corr == 0) { setfreq= freq*d_unit; } else { setfreq=((float)d_unit+((float) d_corr)/(1000000./d_unit))*freq; } fcd_control_block->set_freq(setfreq); } void fcdproplus_impl::set_lna(int gain) { fcd_control_block->set_lna(gain); } void fcdproplus_impl::set_mixer_gain(int gain) { fcd_control_block->set_mixer_gain(gain); } void fcdproplus_impl::set_freq_corr(int ppm) { float freq; if(d_corr == ppm) return; d_corr=ppm; GR_LOG_INFO(d_logger,boost::format("Set frequency correction to: %1% ppm ") % ppm ); freq=d_freq_req; d_freq_req=0; set_freq(freq); } void fcdproplus_impl::set_if_gain(int gain) { if( (gain < 0) || gain > 59) { GR_LOG_WARN(d_logger,boost::format("Invalid If gain value: %1%") % gain ); return; } fcd_control_block->set_if_gain(gain); } } /* namespace fcdproplus */ } /* namespace gr */ 0707010000002C000081A4000003E800000064000000015D58261300000797000000000000000000000000000000000000003500000000gr-fcdproplus-3.8~git.20190817/lib/fcdproplus_impl.h/* -*- c++ -*- */ /* * Copyright 2013 Volker Schroer, DL1KSV. * * This 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. * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_FCDPROPLUS_FCDPROPLUS_IMPL_H #define INCLUDED_FCDPROPLUS_FCDPROPLUS_IMPL_H #include <fcdproplus/fcdproplus.h> #include <fcdproplus/fcdpp_control.h> #include <gnuradio/audio/source.h> #include <gnuradio/logger.h> #include <gnuradio/prefs.h> namespace gr { namespace fcdproplus { class fcdproplus_impl : public fcdproplus { private: gr::audio::source::sptr fcd; /*!< The audio input source */ fcdpp_control::sptr fcd_control_block; /*!< The fcd control block */ unsigned int d_freq_req; /*!< The latest requested frequency in Khz */ int d_corr; int d_unit; gr::logger_ptr d_logger; public: fcdproplus_impl(const std::string user_device_name,int unit); ~fcdproplus_impl(); /* Public API functions documented in include/fcdproplus/fcdproplus.h */ void set_freq(float freq); void set_lna(int gain); void set_mixer_gain(int gain); void set_freq_corr(int ppm); void set_if_gain(int gain); }; } // namespace fcdproplus } // namespace gr #endif /* INCLUDED_FCDPROPLUS_FCDPROPLUS_IMPL_H */ 0707010000002D000041ED000003E800000064000000025D58261300000000000000000000000000000000000000000000002700000000gr-fcdproplus-3.8~git.20190817/lib/hid0707010000002E000081A4000003E800000064000000015D58261300004D6D000000000000000000000000000000000000002D00000000gr-fcdproplus-3.8~git.20190817/lib/hid/hid.c/******************************************************* HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software 8/22/2009 Linux Version - 6/2/2009 Copyright 2009, All Rights Reserved. At the discretion of the user of this library, this software may be licensed under the terms of the GNU General Public License v3, a BSD-Style license, or the original HIDAPI license as outlined in the LICENSE.txt, LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt files located at the root of the source distribution. These files may also be found in the public source code repository located at: http://github.com/signal11/hidapi . ********************************************************/ /* C */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <locale.h> #include <errno.h> /* Unix */ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/utsname.h> #include <fcntl.h> #include <poll.h> /* Linux */ #include <linux/hidraw.h> #include <linux/version.h> #include <linux/input.h> #include <libudev.h> #include "hidapi.h" /* Definitions from linux/hidraw.h. Since these are new, some distros may not have header files which contain them. */ #ifndef HIDIOCSFEATURE #define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len) #endif #ifndef HIDIOCGFEATURE #define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len) #endif /* USB HID device property names */ const char *device_string_names[] = { "manufacturer", "product", "serial", }; /* Symbolic names for the properties above */ enum device_string_id { DEVICE_STRING_MANUFACTURER, DEVICE_STRING_PRODUCT, DEVICE_STRING_SERIAL, DEVICE_STRING_COUNT, }; struct hid_device_ { int device_handle; int blocking; int uses_numbered_reports; }; static __u32 kernel_version = 0; static __u32 detect_kernel_version(void) { struct utsname name; int major, minor, release; int ret; uname(&name); ret = sscanf(name.release, "%d.%d.%d", &major, &minor, &release); if (ret == 3) { return KERNEL_VERSION(major, minor, release); } ret = sscanf(name.release, "%d.%d", &major, &minor); if (ret == 2) { return KERNEL_VERSION(major, minor, 0); } printf("Couldn't determine kernel version from version string \"%s\"\n", name.release); return 0; } static hid_device *new_hid_device(void) { hid_device *dev = calloc(1, sizeof(hid_device)); dev->device_handle = -1; dev->blocking = 1; dev->uses_numbered_reports = 0; return dev; } /* The caller must free the returned string with free(). */ static wchar_t *utf8_to_wchar_t(const char *utf8) { wchar_t *ret = NULL; if (utf8) { size_t wlen = mbstowcs(NULL, utf8, 0); if ((size_t) -1 == wlen) { return wcsdup(L""); } ret = calloc(wlen+1, sizeof(wchar_t)); mbstowcs(ret, utf8, wlen+1); ret[wlen] = 0x0000; } return ret; } /* Get an attribute value from a udev_device and return it as a whar_t string. The returned string must be freed with free() when done.*/ static wchar_t *copy_udev_string(struct udev_device *dev, const char *udev_name) { return utf8_to_wchar_t(udev_device_get_sysattr_value(dev, udev_name)); } /* uses_numbered_reports() returns 1 if report_descriptor describes a device which contains numbered reports. */ static int uses_numbered_reports(__u8 *report_descriptor, __u32 size) { unsigned int i = 0; int size_code; int data_len, key_size; while (i < size) { int key = report_descriptor[i]; /* Check for the Report ID key */ if (key == 0x85/*Report ID*/) { /* This device has a Report ID, which means it uses numbered reports. */ return 1; } //printf("key: %02hhx\n", key); if ((key & 0xf0) == 0xf0) { /* This is a Long Item. The next byte contains the length of the data section (value) for this key. See the HID specification, version 1.11, section 6.2.2.3, titled "Long Items." */ if (i+1 < size) data_len = report_descriptor[i+1]; else data_len = 0; /* malformed report */ key_size = 3; } else { /* This is a Short Item. The bottom two bits of the key contain the size code for the data section (value) for this key. Refer to the HID specification, version 1.11, section 6.2.2.2, titled "Short Items." */ size_code = key & 0x3; switch (size_code) { case 0: case 1: case 2: data_len = size_code; break; case 3: data_len = 4; break; default: /* Can't ever happen since size_code is & 0x3 */ data_len = 0; break; }; key_size = 1; } /* Skip over this key and it's associated data */ i += data_len + key_size; } /* Didn't find a Report ID key. Device doesn't use numbered reports. */ return 0; } /* * The caller is responsible for free()ing the (newly-allocated) character * strings pointed to by serial_number_utf8 and product_name_utf8 after use. */ static int parse_uevent_info(const char *uevent, int *bus_type, unsigned short *vendor_id, unsigned short *product_id, char **serial_number_utf8, char **product_name_utf8) { char *tmp = strdup(uevent); char *saveptr = NULL; char *line; char *key; char *value; int found_id = 0; int found_serial = 0; int found_name = 0; line = strtok_r(tmp, "\n", &saveptr); while (line != NULL) { /* line: "KEY=value" */ key = line; value = strchr(line, '='); if (!value) { goto next_line; } *value = '\0'; value++; if (strcmp(key, "HID_ID") == 0) { /** * type vendor product * HID_ID=0003:000005AC:00008242 **/ int ret = sscanf(value, "%x:%hx:%hx", bus_type, vendor_id, product_id); if (ret == 3) { found_id = 1; } } else if (strcmp(key, "HID_NAME") == 0) { /* The caller has to free the product name */ *product_name_utf8 = strdup(value); found_name = 1; } else if (strcmp(key, "HID_UNIQ") == 0) { /* The caller has to free the serial number */ *serial_number_utf8 = strdup(value); found_serial = 1; } next_line: line = strtok_r(NULL, "\n", &saveptr); } free(tmp); return (found_id && found_name && found_serial); } static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t *string, size_t maxlen) { struct udev *udev; struct udev_device *udev_dev, *parent, *hid_dev; struct stat s; int ret = -1; char *serial_number_utf8 = NULL; char *product_name_utf8 = NULL; /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); return -1; } /* Get the dev_t (major/minor numbers) from the file handle. */ fstat(dev->device_handle, &s); /* Open a udev device from the dev_t. 'c' means character device. */ udev_dev = udev_device_new_from_devnum(udev, 'c', s.st_rdev); if (udev_dev) { hid_dev = udev_device_get_parent_with_subsystem_devtype( udev_dev, "hid", NULL); if (hid_dev) { unsigned short dev_vid; unsigned short dev_pid; int bus_type; size_t retm; ret = parse_uevent_info( udev_device_get_sysattr_value(hid_dev, "uevent"), &bus_type, &dev_vid, &dev_pid, &serial_number_utf8, &product_name_utf8); if (bus_type == BUS_BLUETOOTH) { switch (key) { case DEVICE_STRING_MANUFACTURER: wcsncpy(string, L"", maxlen); ret = 0; break; case DEVICE_STRING_PRODUCT: retm = mbstowcs(string, product_name_utf8, maxlen); ret = (retm == (size_t)-1)? -1: 0; break; case DEVICE_STRING_SERIAL: retm = mbstowcs(string, serial_number_utf8, maxlen); ret = (retm == (size_t)-1)? -1: 0; break; case DEVICE_STRING_COUNT: default: ret = -1; break; } } else { /* This is a USB device. Find its parent USB Device node. */ parent = udev_device_get_parent_with_subsystem_devtype( udev_dev, "usb", "usb_device"); if (parent) { const char *str; const char *key_str = NULL; if (key >= 0 && key < DEVICE_STRING_COUNT) { key_str = device_string_names[key]; } else { ret = -1; goto end; } str = udev_device_get_sysattr_value(parent, key_str); if (str) { /* Convert the string from UTF-8 to wchar_t */ retm = mbstowcs(string, str, maxlen); ret = (retm == (size_t)-1)? -1: 0; goto end; } } } } } end: free(serial_number_utf8); free(product_name_utf8); udev_device_unref(udev_dev); /* parent and hid_dev don't need to be (and can't be) unref'd. I'm not sure why, but they'll throw double-free() errors. */ udev_unref(udev); return ret; } int HID_API_EXPORT hid_init(void) { const char *locale; /* Set the locale if it's not set. */ locale = setlocale(LC_CTYPE, NULL); if (!locale) setlocale(LC_CTYPE, ""); kernel_version = detect_kernel_version(); return 0; } int HID_API_EXPORT hid_exit(void) { /* Nothing to do for this in the Linux/hidraw implementation. */ return 0; } struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id) { struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct hid_device_info *root = NULL; /* return object */ struct hid_device_info *cur_dev = NULL; struct hid_device_info *prev_dev = NULL; /* previous device */ hid_init(); /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); return NULL; } /* Create a list of the devices in the 'hidraw' subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, "hidraw"); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); /* For each item, see if it matches the vid/pid, and if so create a udev_device record for it */ udev_list_entry_foreach(dev_list_entry, devices) { const char *sysfs_path; const char *dev_path; const char *str; struct udev_device *raw_dev; /* The device's hidraw udev node. */ struct udev_device *hid_dev; /* The device's HID udev node. */ struct udev_device *usb_dev; /* The device's USB udev node. */ struct udev_device *intf_dev; /* The device's interface (in the USB sense). */ unsigned short dev_vid; unsigned short dev_pid; char *serial_number_utf8 = NULL; char *product_name_utf8 = NULL; int bus_type; int result; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ sysfs_path = udev_list_entry_get_name(dev_list_entry); raw_dev = udev_device_new_from_syspath(udev, sysfs_path); dev_path = udev_device_get_devnode(raw_dev); hid_dev = udev_device_get_parent_with_subsystem_devtype( raw_dev, "hid", NULL); if (!hid_dev) { /* Unable to find parent hid device. */ goto next; } result = parse_uevent_info( udev_device_get_sysattr_value(hid_dev, "uevent"), &bus_type, &dev_vid, &dev_pid, &serial_number_utf8, &product_name_utf8); if (!result) { /* parse_uevent_info() failed for at least one field. */ goto next; } if (bus_type != BUS_USB && bus_type != BUS_BLUETOOTH) { /* We only know how to handle USB and BT devices. */ goto next; } /* Check the VID/PID against the arguments */ if ((vendor_id == 0x0 || vendor_id == dev_vid) && (product_id == 0x0 || product_id == dev_pid)) { struct hid_device_info *tmp; /* VID/PID match. Create the record. */ tmp = malloc(sizeof(struct hid_device_info)); if (cur_dev) { cur_dev->next = tmp; } else { root = tmp; } prev_dev = cur_dev; cur_dev = tmp; /* Fill out the record */ cur_dev->next = NULL; cur_dev->path = dev_path? strdup(dev_path): NULL; /* VID/PID */ cur_dev->vendor_id = dev_vid; cur_dev->product_id = dev_pid; /* Serial Number */ cur_dev->serial_number = utf8_to_wchar_t(serial_number_utf8); /* Release Number */ cur_dev->release_number = 0x0; /* Interface Number */ cur_dev->interface_number = -1; switch (bus_type) { case BUS_USB: /* The device pointed to by raw_dev contains information about the hidraw device. In order to get information about the USB device, get the parent device with the subsystem/devtype pair of "usb"/"usb_device". This will be several levels up the tree, but the function will find it. */ usb_dev = udev_device_get_parent_with_subsystem_devtype( raw_dev, "usb", "usb_device"); if (!usb_dev) { /* Free this device */ free(cur_dev->serial_number); free(cur_dev->path); free(cur_dev); /* Take it off the device list. */ if (prev_dev) { prev_dev->next = NULL; cur_dev = prev_dev; } else { cur_dev = root = NULL; } goto next; } /* Manufacturer and Product strings */ cur_dev->manufacturer_string = copy_udev_string(usb_dev, device_string_names[DEVICE_STRING_MANUFACTURER]); cur_dev->product_string = copy_udev_string(usb_dev, device_string_names[DEVICE_STRING_PRODUCT]); /* Release Number */ str = udev_device_get_sysattr_value(usb_dev, "bcdDevice"); cur_dev->release_number = (str)? strtol(str, NULL, 16): 0x0; /* Get a handle to the interface's udev node. */ intf_dev = udev_device_get_parent_with_subsystem_devtype( raw_dev, "usb", "usb_interface"); if (intf_dev) { str = udev_device_get_sysattr_value(intf_dev, "bInterfaceNumber"); cur_dev->interface_number = (str)? strtol(str, NULL, 16): -1; } break; case BUS_BLUETOOTH: /* Manufacturer and Product strings */ cur_dev->manufacturer_string = wcsdup(L""); cur_dev->product_string = utf8_to_wchar_t(product_name_utf8); break; default: /* Unknown device type - this should never happen, as we * check for USB and Bluetooth devices above */ break; } } next: free(serial_number_utf8); free(product_name_utf8); udev_device_unref(raw_dev); /* hid_dev, usb_dev and intf_dev don't need to be (and can't be) unref()d. It will cause a double-free() error. I'm not sure why. */ } /* Free the enumerator and udev objects. */ udev_enumerate_unref(enumerate); udev_unref(udev); return root; } void HID_API_EXPORT hid_free_enumeration(struct hid_device_info *devs) { struct hid_device_info *d = devs; while (d) { struct hid_device_info *next = d->next; free(d->path); free(d->serial_number); free(d->manufacturer_string); free(d->product_string); free(d); d = next; } } hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) { struct hid_device_info *devs, *cur_dev; const char *path_to_open = NULL; hid_device *handle = NULL; devs = hid_enumerate(vendor_id, product_id); cur_dev = devs; while (cur_dev) { if (cur_dev->vendor_id == vendor_id && cur_dev->product_id == product_id) { if (serial_number) { if (wcscmp(serial_number, cur_dev->serial_number) == 0) { path_to_open = cur_dev->path; break; } } else { path_to_open = cur_dev->path; break; } } cur_dev = cur_dev->next; } if (path_to_open) { /* Open the device */ handle = hid_open_path(path_to_open); } hid_free_enumeration(devs); return handle; } hid_device * HID_API_EXPORT hid_open_path(const char *path) { hid_device *dev = NULL; hid_init(); dev = new_hid_device(); /* OPEN HERE */ dev->device_handle = open(path, O_RDWR); /* If we have a good handle, return it. */ if (dev->device_handle > 0) { /* Get the report descriptor */ int res, desc_size = 0; struct hidraw_report_descriptor rpt_desc; memset(&rpt_desc, 0x0, sizeof(rpt_desc)); /* Get Report Descriptor Size */ res = ioctl(dev->device_handle, HIDIOCGRDESCSIZE, &desc_size); if (res < 0) perror("HIDIOCGRDESCSIZE"); /* Get Report Descriptor */ rpt_desc.size = desc_size; res = ioctl(dev->device_handle, HIDIOCGRDESC, &rpt_desc); if (res < 0) { perror("HIDIOCGRDESC"); } else { /* Determine if this device uses numbered reports. */ dev->uses_numbered_reports = uses_numbered_reports(rpt_desc.value, rpt_desc.size); } return dev; } else { /* Unable to open any devices. */ free(dev); return NULL; } } int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length) { int bytes_written; bytes_written = write(dev->device_handle, data, length); return bytes_written; } int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { int bytes_read; if (milliseconds >= 0) { /* Milliseconds is either 0 (non-blocking) or > 0 (contains a valid timeout). In both cases we want to call poll() and wait for data to arrive. Don't rely on non-blocking operation (O_NONBLOCK) since some kernels don't seem to properly report device disconnection through read() when in non-blocking mode. */ int ret; struct pollfd fds; fds.fd = dev->device_handle; fds.events = POLLIN; fds.revents = 0; ret = poll(&fds, 1, milliseconds); if (ret == -1 || ret == 0) { /* Error or timeout */ return ret; } else { /* Check for errors on the file descriptor. This will indicate a device disconnection. */ if (fds.revents & (POLLERR | POLLHUP | POLLNVAL)) return -1; } } bytes_read = read(dev->device_handle, data, length); if (bytes_read < 0 && (errno == EAGAIN || errno == EINPROGRESS)) bytes_read = 0; if (bytes_read >= 0 && kernel_version != 0 && kernel_version < KERNEL_VERSION(2,6,34) && dev->uses_numbered_reports) { /* Work around a kernel bug. Chop off the first byte. */ memmove(data, data+1, bytes_read); bytes_read--; } return bytes_read; } int HID_API_EXPORT hid_read(hid_device *dev, unsigned char *data, size_t length) { return hid_read_timeout(dev, data, length, (dev->blocking)? -1: 0); } int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) { /* Do all non-blocking in userspace using poll(), since it looks like there's a bug in the kernel in some versions where read() will not return -1 on disconnection of the USB device */ dev->blocking = !nonblock; return 0; /* Success */ } int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) { int res; res = ioctl(dev->device_handle, HIDIOCSFEATURE(length), data); if (res < 0) perror("ioctl (SFEATURE)"); return res; } int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length) { int res; res = ioctl(dev->device_handle, HIDIOCGFEATURE(length), data); if (res < 0) perror("ioctl (GFEATURE)"); return res; } void HID_API_EXPORT hid_close(hid_device *dev) { if (!dev) return; close(dev->device_handle); free(dev); } int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_device_string(dev, DEVICE_STRING_MANUFACTURER, string, maxlen); } int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_device_string(dev, DEVICE_STRING_PRODUCT, string, maxlen); } int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_device_string(dev, DEVICE_STRING_SERIAL, string, maxlen); } int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) { return -1; } HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) { return NULL; } 0707010000002F000081A4000003E800000064000000015D58261300003546000000000000000000000000000000000000003000000000gr-fcdproplus-3.8~git.20190817/lib/hid/hidapi.h/******************************************************* HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software 8/22/2009 Copyright 2009, All Rights Reserved. At the discretion of the user of this library, this software may be licensed under the terms of the GNU General Public License v3, a BSD-Style license, or the original HIDAPI license as outlined in the LICENSE.txt, LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt files located at the root of the source distribution. These files may also be found in the public source code repository located at: http://github.com/signal11/hidapi . ********************************************************/ /** @file * @defgroup API hidapi API */ #ifndef HIDAPI_H__ #define HIDAPI_H__ #include <wchar.h> #ifdef _WIN32 #define HID_API_EXPORT __declspec(dllexport) #define HID_API_CALL #else #define HID_API_EXPORT /**< API export macro */ #define HID_API_CALL /**< API call macro */ #endif #define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL /**< API export and call macro*/ #ifdef __cplusplus extern "C" { #endif struct hid_device_; typedef struct hid_device_ hid_device; /**< opaque hidapi structure */ /** hidapi info structure */ struct hid_device_info { /** Platform-specific device path */ char *path; /** Device Vendor ID */ unsigned short vendor_id; /** Device Product ID */ unsigned short product_id; /** Serial Number */ wchar_t *serial_number; /** Device Release Number in binary-coded decimal, also known as Device Version Number */ unsigned short release_number; /** Manufacturer String */ wchar_t *manufacturer_string; /** Product string */ wchar_t *product_string; /** Usage Page for this Device/Interface (Windows/Mac only). */ unsigned short usage_page; /** Usage for this Device/Interface (Windows/Mac only).*/ unsigned short usage; /** The USB interface which this logical device represents. Valid on both Linux implementations in all cases, and valid on the Windows implementation only if the device contains more than one interface. */ int interface_number; /** Pointer to the next device */ struct hid_device_info *next; }; /** @brief Initialize the HIDAPI library. This function initializes the HIDAPI library. Calling it is not strictly necessary, as it will be called automatically by hid_enumerate() and any of the hid_open_*() functions if it is needed. This function should be called at the beginning of execution however, if there is a chance of HIDAPI handles being opened by different threads simultaneously. @ingroup API @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_init(void); /** @brief Finalize the HIDAPI library. This function frees all of the static data associated with HIDAPI. It should be called at the end of execution to avoid memory leaks. @ingroup API @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_exit(void); /** @brief Enumerate the HID Devices. This function returns a linked list of all the HID devices attached to the system which match vendor_id and product_id. If @p vendor_id is set to 0 then any vendor matches. If @p product_id is set to 0 then any product matches. If @p vendor_id and @p product_id are both set to 0, then all HID devices will be returned. @ingroup API @param vendor_id The Vendor ID (VID) of the types of device to open. @param product_id The Product ID (PID) of the types of device to open. @returns This function returns a pointer to a linked list of type struct #hid_device, containing information about the HID devices attached to the system, or NULL in the case of failure. Free this linked list by calling hid_free_enumeration(). */ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id); /** @brief Free an enumeration Linked List This function frees a linked list created by hid_enumerate(). @ingroup API @param devs Pointer to a list of struct_device returned from hid_enumerate(). */ void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs); /** @brief Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number. If @p serial_number is NULL, the first device with the specified VID and PID is opened. @ingroup API @param vendor_id The Vendor ID (VID) of the device to open. @param product_id The Product ID (PID) of the device to open. @param serial_number The Serial Number of the device to open (Optionally NULL). @returns This function returns a pointer to a #hid_device object on success or NULL on failure. */ HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number); /** @brief Open a HID device by its path name. The path name be determined by calling hid_enumerate(), or a platform-specific path name can be used (eg: /dev/hidraw0 on Linux). @ingroup API @param path The path name of the device to open @returns This function returns a pointer to a #hid_device object on success or NULL on failure. */ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path); /** @brief Write an Output report to a HID device. The first byte of @p data[] must contain the Report ID. For devices which only support a single report, this must be set to 0x0. The remaining bytes contain the report data. Since the Report ID is mandatory, calls to hid_write() will always contain one more byte than the report contains. For example, if a hid report is 16 bytes long, 17 bytes must be passed to hid_write(), the Report ID (or 0x0, for devices with a single report), followed by the report data (16 bytes). In this example, the length passed in would be 17. hid_write() will send the data on the first OUT endpoint, if one exists. If it does not, it will send the data through the Control Endpoint (Endpoint 0). @ingroup API @param device A device handle returned from hid_open(). @param data The data to send, including the report number as the first byte. @param length The length in bytes of the data to send. @returns This function returns the actual number of bytes written and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length); /** @brief Read an Input report from a HID device with timeout. Input reports are returned to the host through the INTERRUPT IN endpoint. The first byte will contain the Report number if the device uses numbered reports. @ingroup API @param device A device handle returned from hid_open(). @param data A buffer to put the read data into. @param length The number of bytes to read. For devices with multiple reports, make sure to read an extra byte for the report number. @param milliseconds timeout in milliseconds or -1 for blocking wait. @returns This function returns the actual number of bytes read and -1 on error. If no packet was available to be read within the timeout period, this function returns 0. */ int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds); /** @brief Read an Input report from a HID device. Input reports are returned to the host through the INTERRUPT IN endpoint. The first byte will contain the Report number if the device uses numbered reports. @ingroup API @param device A device handle returned from hid_open(). @param data A buffer to put the read data into. @param length The number of bytes to read. For devices with multiple reports, make sure to read an extra byte for the report number. @returns This function returns the actual number of bytes read and -1 on error. If no packet was available to be read and the handle is in non-blocking mode, this function returns 0. */ int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length); /** @brief Set the device handle to be non-blocking. In non-blocking mode calls to hid_read() will return immediately with a value of 0 if there is no data to be read. In blocking mode, hid_read() will wait (block) until there is data to read before returning. Nonblocking can be turned on and off at any time. @ingroup API @param device A device handle returned from hid_open(). @param nonblock enable or not the nonblocking reads - 1 to enable nonblocking - 0 to disable nonblocking. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock); /** @brief Send a Feature report to the device. Feature reports are sent over the Control endpoint as a Set_Report transfer. The first byte of @p data[] must contain the Report ID. For devices which only support a single report, this must be set to 0x0. The remaining bytes contain the report data. Since the Report ID is mandatory, calls to hid_send_feature_report() will always contain one more byte than the report contains. For example, if a hid report is 16 bytes long, 17 bytes must be passed to hid_send_feature_report(): the Report ID (or 0x0, for devices which do not use numbered reports), followed by the report data (16 bytes). In this example, the length passed in would be 17. @ingroup API @param device A device handle returned from hid_open(). @param data The data to send, including the report number as the first byte. @param length The length in bytes of the data to send, including the report number. @returns This function returns the actual number of bytes written and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length); /** @brief Get a feature report from a HID device. Make sure to set the first byte of @p data[] to the Report ID of the report to be read. Make sure to allow space for this extra byte in @p data[]. @ingroup API @param device A device handle returned from hid_open(). @param data A buffer to put the read data into, including the Report ID. Set the first byte of @p data[] to the Report ID of the report to be read. @param length The number of bytes to read, including an extra byte for the report ID. The buffer can be longer than the actual report. @returns This function returns the number of bytes read and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length); /** @brief Close a HID device. @ingroup API @param device A device handle returned from hid_open(). */ void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device); /** @brief Get The Manufacturer String from a HID device. @ingroup API @param device A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen); /** @brief Get The Product String from a HID device. @ingroup API @param device A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen); /** @brief Get The Serial Number String from a HID device. @ingroup API @param device A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen); /** @brief Get a string from a HID device, based on its string index. @ingroup API @param device A device handle returned from hid_open(). @param string_index The index of the string to get. @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen); /** @brief Get a string describing the last error which occurred. @ingroup API @param device A device handle returned from hid_open(). @returns This function returns a string containing the last error which occurred or NULL if none has occurred. */ HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device); #ifdef __cplusplus } #endif #endif 07070100000030000081A4000003E800000064000000015D58261300006F08000000000000000000000000000000000000003000000000gr-fcdproplus-3.8~git.20190817/lib/hid/hidmac.c/******************************************************* HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software 2010-07-03 Copyright 2010, All Rights Reserved. At the discretion of the user of this library, this software may be licensed under the terms of the GNU General Public License v3, a BSD-Style license, or the original HIDAPI license as outlined in the LICENSE.txt, LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt files located at the root of the source distribution. These files may also be found in the public source code repository located at: http://github.com/signal11/hidapi . ********************************************************/ /* See Apple Technical Note TN2187 for details on IOHidManager. */ #include <IOKit/hid/IOHIDManager.h> #include <IOKit/hid/IOHIDKeys.h> #include <CoreFoundation/CoreFoundation.h> #include <wchar.h> #include <locale.h> #include <pthread.h> #include <sys/time.h> #include <unistd.h> #include "hidapi.h" /* Barrier implementation because Mac OSX doesn't have pthread_barrier. It also doesn't have clock_gettime(). So much for POSIX and SUSv2. This implementation came from Brent Priddy and was posted on StackOverflow. It is used with his permission. */ typedef int pthread_barrierattr_t; typedef struct pthread_barrier { pthread_mutex_t mutex; pthread_cond_t cond; int count; int trip_count; } pthread_barrier_t; static int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) { if(count == 0) { errno = EINVAL; return -1; } if(pthread_mutex_init(&barrier->mutex, 0) < 0) { return -1; } if(pthread_cond_init(&barrier->cond, 0) < 0) { pthread_mutex_destroy(&barrier->mutex); return -1; } barrier->trip_count = count; barrier->count = 0; return 0; } static int pthread_barrier_destroy(pthread_barrier_t *barrier) { pthread_cond_destroy(&barrier->cond); pthread_mutex_destroy(&barrier->mutex); return 0; } static int pthread_barrier_wait(pthread_barrier_t *barrier) { pthread_mutex_lock(&barrier->mutex); ++(barrier->count); if(barrier->count >= barrier->trip_count) { barrier->count = 0; pthread_cond_broadcast(&barrier->cond); pthread_mutex_unlock(&barrier->mutex); return 1; } else { pthread_cond_wait(&barrier->cond, &(barrier->mutex)); pthread_mutex_unlock(&barrier->mutex); return 0; } } static int return_data(hid_device *dev, unsigned char *data, size_t length); /* Linked List of input reports received from the device. */ struct input_report { uint8_t *data; size_t len; struct input_report *next; }; struct hid_device_ { IOHIDDeviceRef device_handle; int blocking; int uses_numbered_reports; int disconnected; CFStringRef run_loop_mode; CFRunLoopRef run_loop; CFRunLoopSourceRef source; uint8_t *input_report_buf; CFIndex max_input_report_len; struct input_report *input_reports; pthread_t thread; pthread_mutex_t mutex; /* Protects input_reports */ pthread_cond_t condition; pthread_barrier_t barrier; /* Ensures correct startup sequence */ pthread_barrier_t shutdown_barrier; /* Ensures correct shutdown sequence */ int shutdown_thread; }; static hid_device *new_hid_device(void) { hid_device *dev = calloc(1, sizeof(hid_device)); dev->device_handle = NULL; dev->blocking = 1; dev->uses_numbered_reports = 0; dev->disconnected = 0; dev->run_loop_mode = NULL; dev->run_loop = NULL; dev->source = NULL; dev->input_report_buf = NULL; dev->input_reports = NULL; dev->shutdown_thread = 0; /* Thread objects */ pthread_mutex_init(&dev->mutex, NULL); pthread_cond_init(&dev->condition, NULL); pthread_barrier_init(&dev->barrier, NULL, 2); pthread_barrier_init(&dev->shutdown_barrier, NULL, 2); return dev; } static void free_hid_device(hid_device *dev) { if (!dev) return; /* Delete any input reports still left over. */ struct input_report *rpt = dev->input_reports; while (rpt) { struct input_report *next = rpt->next; free(rpt->data); free(rpt); rpt = next; } /* Free the string and the report buffer. The check for NULL is necessary here as CFRelease() doesn't handle NULL like free() and others do. */ if (dev->run_loop_mode) CFRelease(dev->run_loop_mode); if (dev->source) CFRelease(dev->source); free(dev->input_report_buf); /* Clean up the thread objects */ pthread_barrier_destroy(&dev->shutdown_barrier); pthread_barrier_destroy(&dev->barrier); pthread_cond_destroy(&dev->condition); pthread_mutex_destroy(&dev->mutex); /* Free the structure itself. */ free(dev); } static IOHIDManagerRef hid_mgr = 0x0; #if 0 static void register_error(hid_device *device, const char *op) { } #endif static int32_t get_int_property(IOHIDDeviceRef device, CFStringRef key) { CFTypeRef ref; int32_t value; ref = IOHIDDeviceGetProperty(device, key); if (ref) { if (CFGetTypeID(ref) == CFNumberGetTypeID()) { CFNumberGetValue((CFNumberRef) ref, kCFNumberSInt32Type, &value); return value; } } return 0; } static unsigned short get_vendor_id(IOHIDDeviceRef device) { return get_int_property(device, CFSTR(kIOHIDVendorIDKey)); } static unsigned short get_product_id(IOHIDDeviceRef device) { return get_int_property(device, CFSTR(kIOHIDProductIDKey)); } static int32_t get_location_id(IOHIDDeviceRef device) { return get_int_property(device, CFSTR(kIOHIDLocationIDKey)); } static int32_t get_max_report_length(IOHIDDeviceRef device) { return get_int_property(device, CFSTR(kIOHIDMaxInputReportSizeKey)); } static int get_string_property(IOHIDDeviceRef device, CFStringRef prop, wchar_t *buf, size_t len) { CFStringRef str; if (!len) return 0; str = IOHIDDeviceGetProperty(device, prop); buf[0] = 0; if (str) { CFIndex str_len = CFStringGetLength(str); CFRange range; CFIndex used_buf_len; CFIndex chars_copied; len --; range.location = 0; range.length = ((size_t)str_len > len)? len: (size_t)str_len; chars_copied = CFStringGetBytes(str, range, kCFStringEncodingUTF32LE, (char)'?', FALSE, (UInt8*)buf, len * sizeof(wchar_t), &used_buf_len); if (chars_copied == len) buf[len] = 0; /* len is decremented above */ else buf[chars_copied] = 0; return 0; } else return -1; } static int get_string_property_utf8(IOHIDDeviceRef device, CFStringRef prop, char *buf, size_t len) { CFStringRef str; if (!len) return 0; str = IOHIDDeviceGetProperty(device, prop); buf[0] = 0; if (str) { len--; CFIndex str_len = CFStringGetLength(str); CFRange range; range.location = 0; range.length = str_len; CFIndex used_buf_len; CFIndex chars_copied; chars_copied = CFStringGetBytes(str, range, kCFStringEncodingUTF8, (char)'?', FALSE, (UInt8*)buf, len, &used_buf_len); if (used_buf_len == len) buf[len] = 0; /* len is decremented above */ else buf[used_buf_len] = 0; return used_buf_len; } else return 0; } static int get_serial_number(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDSerialNumberKey), buf, len); } static int get_manufacturer_string(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDManufacturerKey), buf, len); } static int get_product_string(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDProductKey), buf, len); } /* Implementation of wcsdup() for Mac. */ static wchar_t *dup_wcs(const wchar_t *s) { size_t len = wcslen(s); wchar_t *ret = malloc((len+1)*sizeof(wchar_t)); wcscpy(ret, s); return ret; } static int make_path(IOHIDDeviceRef device, char *buf, size_t len) { int res; unsigned short vid, pid; char transport[32]; int32_t location; buf[0] = '\0'; res = get_string_property_utf8( device, CFSTR(kIOHIDTransportKey), transport, sizeof(transport)); if (!res) return -1; location = get_location_id(device); vid = get_vendor_id(device); pid = get_product_id(device); res = snprintf(buf, len, "%s_%04hx_%04hx_%x", transport, vid, pid, location); buf[len-1] = '\0'; return res+1; } /* Initialize the IOHIDManager. Return 0 for success and -1 for failure. */ static int init_hid_manager(void) { /* Initialize all the HID Manager Objects */ hid_mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (hid_mgr) { IOHIDManagerSetDeviceMatching(hid_mgr, NULL); IOHIDManagerScheduleWithRunLoop(hid_mgr, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); return 0; } return -1; } /* Initialize the IOHIDManager if necessary. This is the public function, and it is safe to call this function repeatedly. Return 0 for success and -1 for failure. */ int HID_API_EXPORT hid_init(void) { if (!hid_mgr) { return init_hid_manager(); } /* Already initialized. */ return 0; } int HID_API_EXPORT hid_exit(void) { if (hid_mgr) { /* Close the HID manager. */ IOHIDManagerClose(hid_mgr, kIOHIDOptionsTypeNone); CFRelease(hid_mgr); hid_mgr = NULL; } return 0; } static void process_pending_events(void) { SInt32 res; do { res = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.001, FALSE); } while(res != kCFRunLoopRunFinished && res != kCFRunLoopRunTimedOut); } struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id) { struct hid_device_info *root = NULL; /* return object */ struct hid_device_info *cur_dev = NULL; CFIndex num_devices; int i; /* Set up the HID Manager if it hasn't been done */ if (hid_init() < 0) return NULL; /* give the IOHIDManager a chance to update itself */ process_pending_events(); /* Get a list of the Devices */ IOHIDManagerSetDeviceMatching(hid_mgr, NULL); CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr); /* Convert the list into a C array so we can iterate easily. */ num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); /* Iterate over each device, making an entry for it. */ for (i = 0; i < num_devices; i++) { unsigned short dev_vid; unsigned short dev_pid; #define BUF_LEN 256 wchar_t buf[BUF_LEN]; char cbuf[BUF_LEN]; IOHIDDeviceRef dev = device_array[i]; if (!dev) { continue; } dev_vid = get_vendor_id(dev); dev_pid = get_product_id(dev); /* Check the VID/PID against the arguments */ if ((vendor_id == 0x0 || vendor_id == dev_vid) && (product_id == 0x0 || product_id == dev_pid)) { struct hid_device_info *tmp; size_t len; /* VID/PID match. Create the record. */ tmp = malloc(sizeof(struct hid_device_info)); if (cur_dev) { cur_dev->next = tmp; } else { root = tmp; } cur_dev = tmp; /* Get the Usage Page and Usage for this device. */ cur_dev->usage_page = get_int_property(dev, CFSTR(kIOHIDPrimaryUsagePageKey)); cur_dev->usage = get_int_property(dev, CFSTR(kIOHIDPrimaryUsageKey)); /* Fill out the record */ cur_dev->next = NULL; len = make_path(dev, cbuf, sizeof(cbuf)); cur_dev->path = strdup(cbuf); /* Serial Number */ get_serial_number(dev, buf, BUF_LEN); cur_dev->serial_number = dup_wcs(buf); /* Manufacturer and Product strings */ get_manufacturer_string(dev, buf, BUF_LEN); cur_dev->manufacturer_string = dup_wcs(buf); get_product_string(dev, buf, BUF_LEN); cur_dev->product_string = dup_wcs(buf); /* VID/PID */ cur_dev->vendor_id = dev_vid; cur_dev->product_id = dev_pid; /* Release Number */ cur_dev->release_number = get_int_property(dev, CFSTR(kIOHIDVersionNumberKey)); /* Interface Number (Unsupported on Mac)*/ cur_dev->interface_number = -1; } } free(device_array); CFRelease(device_set); return root; } void HID_API_EXPORT hid_free_enumeration(struct hid_device_info *devs) { /* This function is identical to the Linux version. Platform independent. */ struct hid_device_info *d = devs; while (d) { struct hid_device_info *next = d->next; free(d->path); free(d->serial_number); free(d->manufacturer_string); free(d->product_string); free(d); d = next; } } hid_device * HID_API_EXPORT hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) { /* This function is identical to the Linux version. Platform independent. */ struct hid_device_info *devs, *cur_dev; const char *path_to_open = NULL; hid_device * handle = NULL; devs = hid_enumerate(vendor_id, product_id); cur_dev = devs; while (cur_dev) { if (cur_dev->vendor_id == vendor_id && cur_dev->product_id == product_id) { if (serial_number) { if (wcscmp(serial_number, cur_dev->serial_number) == 0) { path_to_open = cur_dev->path; break; } } else { path_to_open = cur_dev->path; break; } } cur_dev = cur_dev->next; } if (path_to_open) { /* Open the device */ handle = hid_open_path(path_to_open); } hid_free_enumeration(devs); return handle; } static void hid_device_removal_callback(void *context, IOReturn result, void *sender) { /* Stop the Run Loop for this device. */ hid_device *d = context; d->disconnected = 1; CFRunLoopStop(d->run_loop); } /* The Run Loop calls this function for each input report received. This function puts the data into a linked list to be picked up by hid_read(). */ static void hid_report_callback(void *context, IOReturn result, void *sender, IOHIDReportType report_type, uint32_t report_id, uint8_t *report, CFIndex report_length) { struct input_report *rpt; hid_device *dev = context; /* Make a new Input Report object */ rpt = calloc(1, sizeof(struct input_report)); rpt->data = calloc(1, report_length); memcpy(rpt->data, report, report_length); rpt->len = report_length; rpt->next = NULL; /* Lock this section */ pthread_mutex_lock(&dev->mutex); /* Attach the new report object to the end of the list. */ if (dev->input_reports == NULL) { /* The list is empty. Put it at the root. */ dev->input_reports = rpt; } else { /* Find the end of the list and attach. */ struct input_report *cur = dev->input_reports; int num_queued = 0; while (cur->next != NULL) { cur = cur->next; num_queued++; } cur->next = rpt; /* Pop one off if we've reached 30 in the queue. This way we don't grow forever if the user never reads anything from the device. */ if (num_queued > 30) { return_data(dev, NULL, 0); } } /* Signal a waiting thread that there is data. */ pthread_cond_signal(&dev->condition); /* Unlock */ pthread_mutex_unlock(&dev->mutex); } /* This gets called when the read_thred's run loop gets signaled by hid_close(), and serves to stop the read_thread's run loop. */ static void perform_signal_callback(void *context) { hid_device *dev = context; CFRunLoopStop(dev->run_loop); /*TODO: CFRunLoopGetCurrent()*/ } static void *read_thread(void *param) { hid_device *dev = param; SInt32 code; /* Move the device's run loop to this thread. */ IOHIDDeviceScheduleWithRunLoop(dev->device_handle, CFRunLoopGetCurrent(), dev->run_loop_mode); /* Create the RunLoopSource which is used to signal the event loop to stop when hid_close() is called. */ CFRunLoopSourceContext ctx; memset(&ctx, 0, sizeof(ctx)); ctx.version = 0; ctx.info = dev; ctx.perform = &perform_signal_callback; dev->source = CFRunLoopSourceCreate(kCFAllocatorDefault, 0/*order*/, &ctx); CFRunLoopAddSource(CFRunLoopGetCurrent(), dev->source, dev->run_loop_mode); /* Store off the Run Loop so it can be stopped from hid_close() and on device disconnection. */ dev->run_loop = CFRunLoopGetCurrent(); /* Notify the main thread that the read thread is up and running. */ pthread_barrier_wait(&dev->barrier); /* Run the Event Loop. CFRunLoopRunInMode() will dispatch HID input reports into the hid_report_callback(). */ while (!dev->shutdown_thread && !dev->disconnected) { code = CFRunLoopRunInMode(dev->run_loop_mode, 1000/*sec*/, FALSE); /* Return if the device has been disconnected */ if (code == kCFRunLoopRunFinished) { dev->disconnected = 1; break; } /* Break if The Run Loop returns Finished or Stopped. */ if (code != kCFRunLoopRunTimedOut && code != kCFRunLoopRunHandledSource) { /* There was some kind of error. Setting shutdown seems to make sense, but there may be something else more appropriate */ dev->shutdown_thread = 1; break; } } /* Now that the read thread is stopping, Wake any threads which are waiting on data (in hid_read_timeout()). Do this under a mutex to make sure that a thread which is about to go to sleep waiting on the condition acutally will go to sleep before the condition is signaled. */ pthread_mutex_lock(&dev->mutex); pthread_cond_broadcast(&dev->condition); pthread_mutex_unlock(&dev->mutex); /* Wait here until hid_close() is called and makes it past the call to CFRunLoopWakeUp(). This thread still needs to be valid when that function is called on the other thread. */ pthread_barrier_wait(&dev->shutdown_barrier); return NULL; } hid_device * HID_API_EXPORT hid_open_path(const char *path) { int i; hid_device *dev = NULL; CFIndex num_devices; dev = new_hid_device(); /* Set up the HID Manager if it hasn't been done */ if (hid_init() < 0) return NULL; /* give the IOHIDManager a chance to update itself */ process_pending_events(); CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr); num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); for (i = 0; i < num_devices; i++) { char cbuf[BUF_LEN]; size_t len; IOHIDDeviceRef os_dev = device_array[i]; len = make_path(os_dev, cbuf, sizeof(cbuf)); if (!strcmp(cbuf, path)) { /* Matched Paths. Open this Device. */ IOReturn ret = IOHIDDeviceOpen(os_dev, kIOHIDOptionsTypeSeizeDevice); if (ret == kIOReturnSuccess) { char str[32]; free(device_array); CFRetain(os_dev); CFRelease(device_set); dev->device_handle = os_dev; /* Create the buffers for receiving data */ dev->max_input_report_len = (CFIndex) get_max_report_length(os_dev); dev->input_report_buf = calloc(dev->max_input_report_len, sizeof(uint8_t)); /* Create the Run Loop Mode for this device. printing the reference seems to work. */ sprintf(str, "HIDAPI_%p", os_dev); dev->run_loop_mode = CFStringCreateWithCString(NULL, str, kCFStringEncodingASCII); /* Attach the device to a Run Loop */ IOHIDDeviceRegisterInputReportCallback( os_dev, dev->input_report_buf, dev->max_input_report_len, &hid_report_callback, dev); IOHIDDeviceRegisterRemovalCallback(dev->device_handle, hid_device_removal_callback, dev); /* Start the read thread */ pthread_create(&dev->thread, NULL, read_thread, dev); /* Wait here for the read thread to be initialized. */ pthread_barrier_wait(&dev->barrier); return dev; } else { goto return_error; } } } return_error: free(device_array); CFRelease(device_set); free_hid_device(dev); return NULL; } static int set_report(hid_device *dev, IOHIDReportType type, const unsigned char *data, size_t length) { const unsigned char *data_to_send; size_t length_to_send; IOReturn res; /* Return if the device has been disconnected. */ if (dev->disconnected) return -1; if (data[0] == 0x0) { /* Not using numbered Reports. Don't send the report number. */ data_to_send = data+1; length_to_send = length-1; } else { /* Using numbered Reports. Send the Report Number */ data_to_send = data; length_to_send = length; } if (!dev->disconnected) { res = IOHIDDeviceSetReport(dev->device_handle, type, data[0], /* Report ID*/ data_to_send, length_to_send); if (res == kIOReturnSuccess) { return length; } else return -1; } return -1; } int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length) { return set_report(dev, kIOHIDReportTypeOutput, data, length); } /* Helper function, so that this isn't duplicated in hid_read(). */ static int return_data(hid_device *dev, unsigned char *data, size_t length) { /* Copy the data out of the linked list item (rpt) into the return buffer (data), and delete the liked list item. */ struct input_report *rpt = dev->input_reports; size_t len = (length < rpt->len)? length: rpt->len; memcpy(data, rpt->data, len); dev->input_reports = rpt->next; free(rpt->data); free(rpt); return len; } static int cond_wait(const hid_device *dev, pthread_cond_t *cond, pthread_mutex_t *mutex) { while (!dev->input_reports) { int res = pthread_cond_wait(cond, mutex); if (res != 0) return res; /* A res of 0 means we may have been signaled or it may be a spurious wakeup. Check to see that there's acutally data in the queue before returning, and if not, go back to sleep. See the pthread_cond_timedwait() man page for details. */ if (dev->shutdown_thread || dev->disconnected) return -1; } return 0; } static int cond_timedwait(const hid_device *dev, pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) { while (!dev->input_reports) { int res = pthread_cond_timedwait(cond, mutex, abstime); if (res != 0) return res; /* A res of 0 means we may have been signaled or it may be a spurious wakeup. Check to see that there's acutally data in the queue before returning, and if not, go back to sleep. See the pthread_cond_timedwait() man page for details. */ if (dev->shutdown_thread || dev->disconnected) return -1; } return 0; } int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { int bytes_read = -1; /* Lock the access to the report list. */ pthread_mutex_lock(&dev->mutex); /* There's an input report queued up. Return it. */ if (dev->input_reports) { /* Return the first one */ bytes_read = return_data(dev, data, length); goto ret; } /* Return if the device has been disconnected. */ if (dev->disconnected) { bytes_read = -1; goto ret; } if (dev->shutdown_thread) { /* This means the device has been closed (or there has been an error. An error code of -1 should be returned. */ bytes_read = -1; goto ret; } /* There is no data. Go to sleep and wait for data. */ if (milliseconds == -1) { /* Blocking */ int res; res = cond_wait(dev, &dev->condition, &dev->mutex); if (res == 0) bytes_read = return_data(dev, data, length); else { /* There was an error, or a device disconnection. */ bytes_read = -1; } } else if (milliseconds > 0) { /* Non-blocking, but called with timeout. */ int res; struct timespec ts; struct timeval tv; gettimeofday(&tv, NULL); TIMEVAL_TO_TIMESPEC(&tv, &ts); ts.tv_sec += milliseconds / 1000; ts.tv_nsec += (milliseconds % 1000) * 1000000; if (ts.tv_nsec >= 1000000000L) { ts.tv_sec++; ts.tv_nsec -= 1000000000L; } res = cond_timedwait(dev, &dev->condition, &dev->mutex, &ts); if (res == 0) bytes_read = return_data(dev, data, length); else if (res == ETIMEDOUT) bytes_read = 0; else bytes_read = -1; } else { /* Purely non-blocking */ bytes_read = 0; } ret: /* Unlock */ pthread_mutex_unlock(&dev->mutex); return bytes_read; } int HID_API_EXPORT hid_read(hid_device *dev, unsigned char *data, size_t length) { return hid_read_timeout(dev, data, length, (dev->blocking)? -1: 0); } int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) { /* All Nonblocking operation is handled by the library. */ dev->blocking = !nonblock; return 0; } int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) { return set_report(dev, kIOHIDReportTypeFeature, data, length); } int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length) { CFIndex len = length; IOReturn res; /* Return if the device has been unplugged. */ if (dev->disconnected) return -1; res = IOHIDDeviceGetReport(dev->device_handle, kIOHIDReportTypeFeature, data[0], /* Report ID */ data, &len); if (res == kIOReturnSuccess) return len; else return -1; } void HID_API_EXPORT hid_close(hid_device *dev) { if (!dev) return; /* Disconnect the report callback before close. */ if (!dev->disconnected) { IOHIDDeviceRegisterInputReportCallback( dev->device_handle, dev->input_report_buf, dev->max_input_report_len, NULL, dev); IOHIDDeviceRegisterRemovalCallback(dev->device_handle, NULL, dev); IOHIDDeviceUnscheduleFromRunLoop(dev->device_handle, dev->run_loop, dev->run_loop_mode); IOHIDDeviceScheduleWithRunLoop(dev->device_handle, CFRunLoopGetMain(), kCFRunLoopDefaultMode); } /* Cause read_thread() to stop. */ dev->shutdown_thread = 1; /* Wake up the run thread's event loop so that the thread can exit. */ CFRunLoopSourceSignal(dev->source); CFRunLoopWakeUp(dev->run_loop); /* Notify the read thread that it can shut down now. */ pthread_barrier_wait(&dev->shutdown_barrier); /* Wait for read_thread() to end. */ pthread_join(dev->thread, NULL); /* Close the OS handle to the device, but only if it's not been unplugged. If it's been unplugged, then calling IOHIDDeviceClose() will crash. */ if (!dev->disconnected) { IOHIDDeviceClose(dev->device_handle, kIOHIDOptionsTypeSeizeDevice); } /* Clear out the queue of received reports. */ pthread_mutex_lock(&dev->mutex); while (dev->input_reports) { return_data(dev, NULL, 0); } pthread_mutex_unlock(&dev->mutex); CFRelease(dev->device_handle); free_hid_device(dev); } int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_manufacturer_string(dev->device_handle, string, maxlen); } int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_product_string(dev->device_handle, string, maxlen); } int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_serial_number(dev->device_handle, string, maxlen); } int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) { /* TODO: */ return 0; } HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) { /* TODO: */ return NULL; } #if 0 static int32_t get_usage(IOHIDDeviceRef device) { int32_t res; res = get_int_property(device, CFSTR(kIOHIDDeviceUsageKey)); if (!res) res = get_int_property(device, CFSTR(kIOHIDPrimaryUsageKey)); return res; } static int32_t get_usage_page(IOHIDDeviceRef device) { int32_t res; res = get_int_property(device, CFSTR(kIOHIDDeviceUsagePageKey)); if (!res) res = get_int_property(device, CFSTR(kIOHIDPrimaryUsagePageKey)); return res; } static int get_transport(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDTransportKey), buf, len); } int main(void) { IOHIDManagerRef mgr; int i; mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); IOHIDManagerSetDeviceMatching(mgr, NULL); IOHIDManagerOpen(mgr, kIOHIDOptionsTypeNone); CFSetRef device_set = IOHIDManagerCopyDevices(mgr); CFIndex num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); for (i = 0; i < num_devices; i++) { IOHIDDeviceRef dev = device_array[i]; printf("Device: %p\n", dev); printf(" %04hx %04hx\n", get_vendor_id(dev), get_product_id(dev)); wchar_t serial[256], buf[256]; char cbuf[256]; get_serial_number(dev, serial, 256); printf(" Serial: %ls\n", serial); printf(" Loc: %ld\n", get_location_id(dev)); get_transport(dev, buf, 256); printf(" Trans: %ls\n", buf); make_path(dev, cbuf, 256); printf(" Path: %s\n", cbuf); } return 0; } #endif 07070100000031000081A4000003E800000064000000015D58261300000461000000000000000000000000000000000000003400000000gr-fcdproplus-3.8~git.20190817/lib/qa_fcdproplus.cc/* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ /* * This class gathers together all the test cases for the gr-filter * directory into a single test suite. As you create new test cases, * add them here. */ #include "qa_fcdproplus.h" CppUnit::TestSuite * qa_fcdproplus::suite() { CppUnit::TestSuite *s = new CppUnit::TestSuite("fcdproplus"); return s; } 07070100000032000081A4000003E800000064000000015D58261300000494000000000000000000000000000000000000003300000000gr-fcdproplus-3.8~git.20190817/lib/qa_fcdproplus.h/* -*- c++ -*- */ /* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef _QA_FCDPROPLUS_H_ #define _QA_FCDPROPLUS_H_ #include <gruel/attributes.h> #include <cppunit/TestSuite.h> //! collect all the tests for the gr-filter directory class __GR_ATTR_EXPORT qa_fcdproplus { public: //! return suite of tests for all of gr-filter directory static CppUnit::TestSuite *suite(); }; #endif /* _QA_FCDPROPLUS_H_ */ 07070100000033000081A4000003E800000064000000015D58261300000548000000000000000000000000000000000000003600000000gr-fcdproplus-3.8~git.20190817/lib/test_fcdproplus.cc/* -*- c++ -*- */ /* * Copyright 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio 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, * 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 * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #include <cppunit/TextTestRunner.h> #include <cppunit/XmlOutputter.h> #include <gr_unittests.h> #include "qa_fcdproplus.h" #include <iostream> int main (int argc, char **argv) { CppUnit::TextTestRunner runner; std::ofstream xmlfile(get_unittest_path("fcdproplus.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest(qa_fcdproplus::suite()); runner.setOutputter(xmlout); bool was_successful = runner.run("", false); return was_successful ? 0 : 1; } 07070100000034000041ED000003E800000064000000025D58261300000000000000000000000000000000000000000000002600000000gr-fcdproplus-3.8~git.20190817/python07070100000035000081A4000003E800000064000000015D58261300000621000000000000000000000000000000000000003500000000gr-fcdproplus-3.8~git.20190817/python/CMakeLists.txt# Copyright 2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. ######################################################################## # Include python install macros ######################################################################## include(GrPython) if(NOT PYTHONINTERP_FOUND) return() endif() ######################################################################## # Install python sources ######################################################################## GR_PYTHON_INSTALL( FILES __init__.py DESTINATION ${GR_PYTHON_DIR}/fcdproplus ) ######################################################################## # Handle the unit tests ######################################################################## include(GrTest) set(GR_TEST_TARGET_DEPS gnuradio-fcdproplus) set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig) 07070100000036000081A4000003E800000064000000015D58261300000720000000000000000000000000000000000000003200000000gr-fcdproplus-3.8~git.20190817/python/__init__.py# # Copyright 2008,2009 Free Software Foundation, Inc. # # This application 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. # # This application 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 this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # The presence of this file turns this directory into a Python package ''' This is the GNU Radio FCDPROPLUS module. Place your Python package description here (python/__init__.py). ''' # ---------------------------------------------------------------- # Temporary workaround for ticket:181 (swig+python problem) import sys _RTLD_GLOBAL = 0 try: from dl import RTLD_GLOBAL as _RTLD_GLOBAL except ImportError: try: from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL except ImportError: pass if _RTLD_GLOBAL != 0: _dlopenflags = sys.getdlopenflags() sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) # ---------------------------------------------------------------- # import swig generated symbols into the fcdproplus namespace from .fcdproplus_swig import * # import any pure python here # # ---------------------------------------------------------------- # Tail of workaround if _RTLD_GLOBAL != 0: sys.setdlopenflags(_dlopenflags) # Restore original flags # ---------------------------------------------------------------- 07070100000037000041ED000003E800000064000000025D58261300000000000000000000000000000000000000000000002400000000gr-fcdproplus-3.8~git.20190817/swig07070100000038000081A4000003E800000064000000015D582613000008C2000000000000000000000000000000000000003300000000gr-fcdproplus-3.8~git.20190817/swig/CMakeLists.txt# Copyright 2011-2014 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, # 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 # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. ######################################################################## # Include swig generation macros ######################################################################## find_package(SWIG) find_package(PythonLibs) if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) return() endif() include(GrSwig) include(GrPython) ######################################################################## # Setup swig generation ######################################################################## set(GR_SWIG_INCLUDE_DIRS $<TARGET_PROPERTY:gnuradio::runtime_swig,INTERFACE_INCLUDE_DIRECTORIES>) set(GR_SWIG_TARGET_DEPS gnuradio::runtime_swig) set(GR_SWIG_LIBRARIES gnuradio-fcdproplus) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/fcdproplus_swig_doc.i) set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) GR_SWIG_MAKE(fcdproplus_swig fcdproplus_swig.i) ######################################################################## # Install the build swig module ######################################################################## GR_SWIG_INSTALL(TARGETS fcdproplus_swig DESTINATION ${GR_PYTHON_DIR}/fcdproplus) ######################################################################## # Install swig .i files for development ######################################################################## install( FILES fcdproplus_swig.i ${CMAKE_CURRENT_BINARY_DIR}/fcdproplus_swig_doc.i DESTINATION ${GR_INCLUDE_DIR}/fcdproplus/swig ) 07070100000039000081A4000003E800000064000000015D58261300000269000000000000000000000000000000000000003600000000gr-fcdproplus-3.8~git.20190817/swig/fcdproplus_swig.i/* -*- c++ -*- */ #define FCDPROPLUS_API %include "gnuradio.i" // the common stuff //load generated python docstrings %include "fcdproplus_swig_doc.i" %{ #include "fcdproplus/fcdproplus.h" #include "fcdproplus/fcdpp_control.h" #include "fcdproplus/fcd_control.h" #include "fcdproplus/fcd.h" %} %include "fcdproplus/fcdproplus.h" %include "fcdproplus/fcdpp_control.h" %include "fcdproplus/fcd_control.h" %include "fcdproplus/fcd.h" GR_SWIG_BLOCK_MAGIC2(fcdproplus, fcdproplus); GR_SWIG_BLOCK_MAGIC2(fcdproplus,fcdpp_control); GR_SWIG_BLOCK_MAGIC2(fcdproplus,fcd_control); GR_SWIG_BLOCK_MAGIC2(fcdproplus,fcd); 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!434 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor