HackRF Output support: created a HackRF device library for Rx/Tx common routines and structures

pull/27/head
f4exb 2017-01-07 11:24:09 +01:00
rodzic 1187ab99cb
commit 250a7f340c
8 zmienionych plików z 149 dodań i 22 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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)

Wyświetl plik

@ -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)

Wyświetl plik

@ -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;
}
}

Wyświetl plik

@ -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_ */

Wyświetl plik

@ -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)

Wyświetl plik

@ -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;
// }
//}

Wyświetl plik

@ -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;