mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
HackRF Output support: created a HackRF device library for Rx/Tx common routines and structures
This commit is contained in:
parent
1187ab99cb
commit
250a7f340c
@ -7,7 +7,13 @@ if(LIBUSB_FOUND AND LIBBLADERF_FOUND)
|
||||
add_subdirectory(bladerf)
|
||||
endif(LIBUSB_FOUND AND LIBBLADERF_FOUND)
|
||||
|
||||
find_package(LibHACKRF)
|
||||
if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
||||
add_subdirectory(hackrf)
|
||||
endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
||||
|
||||
if (BUILD_DEBIAN)
|
||||
add_subdirectory(bladerf)
|
||||
add_subdirectory(hackrf)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
|
@ -2,10 +2,13 @@ project(bladerfdevice)
|
||||
|
||||
set(bladerfdevice_SOURCES
|
||||
devicebladerf.cpp
|
||||
devicebladerfvalues.cpp
|
||||
)
|
||||
|
||||
set(bladerfdevice_HEADERS
|
||||
devicebladerf.h
|
||||
devicebladerfvalues.h
|
||||
devicebladerfparam.h
|
||||
)
|
||||
|
||||
if (BUILD_DEBIAN)
|
||||
|
45
devices/hackrf/CMakeLists.txt
Normal file
45
devices/hackrf/CMakeLists.txt
Normal file
@ -0,0 +1,45 @@
|
||||
project(hackrfdevice)
|
||||
|
||||
set(hackrfdevice_SOURCES
|
||||
devicehackrf.cpp
|
||||
)
|
||||
|
||||
set(hackrfdevice_HEADERS
|
||||
devicehackrf.h
|
||||
)
|
||||
|
||||
if (BUILD_DEBIAN)
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${LIBHACKRFLIBSRC}/include
|
||||
${LIBHACKRFLIBSRC}/src
|
||||
)
|
||||
else (BUILD_DEBIAN)
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${LIBHACKRF_INCLUDE_DIR}
|
||||
)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
#add_definitions(${QT_DEFINITIONS})
|
||||
#add_definitions(-DQT_SHARED)
|
||||
|
||||
add_library(hackrfdevice SHARED
|
||||
${hackrfdevice_SOURCES}
|
||||
)
|
||||
|
||||
if (BUILD_DEBIAN)
|
||||
target_link_libraries(hackrfdevice
|
||||
hackrf
|
||||
sdrbase
|
||||
)
|
||||
else (BUILD_DEBIAN)
|
||||
target_link_libraries(hackrfdevice
|
||||
${LIBHACKRF_LIBRARIES}
|
||||
sdrbase
|
||||
)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
install(TARGETS hackrfdevice DESTINATION lib)
|
38
devices/hackrf/devicehackrf.cpp
Normal file
38
devices/hackrf/devicehackrf.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 as version 3 of the License, or //
|
||||
// //
|
||||
// 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 V3 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "devicehackrf.h"
|
||||
|
||||
hackrf_device *DeviceHackRF::open_hackrf_from_sequence(int sequence)
|
||||
{
|
||||
hackrf_device_list_t *hackrf_devices = hackrf_device_list();
|
||||
hackrf_device *hackrf_ptr;
|
||||
hackrf_error rc;
|
||||
|
||||
rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, sequence, &hackrf_ptr);
|
||||
|
||||
if (rc == HACKRF_SUCCESS)
|
||||
{
|
||||
return hackrf_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
30
devices/hackrf/devicehackrf.h
Normal file
30
devices/hackrf/devicehackrf.h
Normal file
@ -0,0 +1,30 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 as version 3 of the License, or //
|
||||
// //
|
||||
// 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 V3 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DEVICES_HACKRF_DEVICEHACKRF_H_
|
||||
#define DEVICES_HACKRF_DEVICEHACKRF_H_
|
||||
|
||||
#include "libhackrf/hackrf.h"
|
||||
|
||||
class DeviceHackRF
|
||||
{
|
||||
public:
|
||||
static hackrf_device *open_hackrf_from_sequence(int sequence);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* DEVICES_HACKRF_DEVICEHACKRF_H_ */
|
@ -24,6 +24,7 @@ if (BUILD_DEBIAN)
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/devices
|
||||
${LIBHACKRFSRC}
|
||||
${LIBHACKRFSRC}/libhackrf/src
|
||||
)
|
||||
@ -31,6 +32,7 @@ else (BUILD_DEBIAN)
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/devices
|
||||
${LIBHACKRF_INCLUDE_DIR}
|
||||
)
|
||||
endif (BUILD_DEBIAN)
|
||||
@ -55,12 +57,14 @@ target_link_libraries(inputhackrf
|
||||
${QT_LIBRARIES}
|
||||
hackrf
|
||||
sdrbase
|
||||
hackrfdevice
|
||||
)
|
||||
else (BUILD_DEBIAN)
|
||||
target_link_libraries(inputhackrf
|
||||
${QT_LIBRARIES}
|
||||
${LIBHACKRF_LIBRARIES}
|
||||
sdrbase
|
||||
hackrfdevice
|
||||
)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include "dsp/dspengine.h"
|
||||
#include <device/devicesourceapi.h>
|
||||
|
||||
#include "../hackrfinput/hackrfinputgui.h"
|
||||
#include "../hackrfinput/hackrfinputthread.h"
|
||||
#include "hackrfinputgui.h"
|
||||
#include "hackrfinputthread.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgConfigureHackRF, Message)
|
||||
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgReportHackRF, Message)
|
||||
@ -73,7 +73,7 @@ bool HackRFInput::start(int device)
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((m_dev = open_hackrf_from_sequence(device)) == 0)
|
||||
if ((m_dev = DeviceHackRF::open_hackrf_from_sequence(device)) == 0)
|
||||
{
|
||||
qCritical("HackRFInput::start: could not open HackRF #%d", device);
|
||||
return false;
|
||||
@ -405,20 +405,20 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
|
||||
return true;
|
||||
}
|
||||
|
||||
hackrf_device *HackRFInput::open_hackrf_from_sequence(int sequence)
|
||||
{
|
||||
hackrf_device_list_t *hackrf_devices = hackrf_device_list();
|
||||
hackrf_device *hackrf_ptr;
|
||||
hackrf_error rc;
|
||||
|
||||
rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, sequence, &hackrf_ptr);
|
||||
|
||||
if (rc == HACKRF_SUCCESS)
|
||||
{
|
||||
return hackrf_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//hackrf_device *HackRFInput::open_hackrf_from_sequence(int sequence)
|
||||
//{
|
||||
// hackrf_device_list_t *hackrf_devices = hackrf_device_list();
|
||||
// hackrf_device *hackrf_ptr;
|
||||
// hackrf_error rc;
|
||||
//
|
||||
// rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, sequence, &hackrf_ptr);
|
||||
//
|
||||
// if (rc == HACKRF_SUCCESS)
|
||||
// {
|
||||
// return hackrf_ptr;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
|
@ -21,7 +21,8 @@
|
||||
#include "libhackrf/hackrf.h"
|
||||
#include <QString>
|
||||
|
||||
#include "../hackrfinput/hackrfinputsettings.h"
|
||||
#include "hackrf/devicehackrf.h"
|
||||
#include "hackrfinputsettings.h"
|
||||
|
||||
class DeviceSourceAPI;
|
||||
class HackRFInputThread;
|
||||
@ -81,7 +82,7 @@ public:
|
||||
|
||||
private:
|
||||
bool applySettings(const HackRFInputSettings& settings, bool force);
|
||||
hackrf_device *open_hackrf_from_sequence(int sequence);
|
||||
// hackrf_device *open_hackrf_from_sequence(int sequence);
|
||||
void setCenterFrequency(quint64 freq);
|
||||
|
||||
DeviceSourceAPI *m_deviceAPI;
|
||||
|
Loading…
Reference in New Issue
Block a user