Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Merge pull request keenerd#15 from librtlsdr/development
Browse files Browse the repository at this point in the history
Development to Master
  • Loading branch information
racerxdl authored Aug 19, 2016
2 parents eaae819 + 5cec665 commit 6b314e0
Show file tree
Hide file tree
Showing 33 changed files with 5,195 additions and 461 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ CMakeCache.txt
*/CMakeFiles
CMakeFiles
*.cmake
build

**/*.o
**/*.so*
**/*.a
src/rtl_adsb
src/rtl_eeprom
src/rtl_fm
src/rtl_power
src/rtl_test

debianize/*.deb
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ endif()

# Set the version information here
set(VERSION_INFO_MAJOR_VERSION 0) # increment major on api compatibility changes
set(VERSION_INFO_MINOR_VERSION 5) # increment minor on feature-level changes
set(VERSION_INFO_MINOR_VERSION 6) # increment minor on feature-level changes
set(VERSION_INFO_PATCH_VERSION git) # increment patch for bug fixes and docs
include(Version) # setup version info

Expand All @@ -57,6 +57,14 @@ if(CMAKE_COMPILER_IS_GNUCC AND NOT WIN32)
add_definitions(-fvisibility=hidden)
endif()

#########################################################################
# Bug Fix
#########################################################################
OPTION(NEED_PTHREADS_WORKARROUND "PThreads Workarround for timespec")
IF (DEFINED NEED_PTHREADS_WORKARROUND)
ADD_DEFINITIONS(-DNEED_PTHREADS_WORKARROUND)
ENDIF()

########################################################################
# Find build dependencies
########################################################################
Expand Down
43 changes: 43 additions & 0 deletions README.rtlsdr_rpc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
This implementation of librtlsdr makes remote dongles
appear to the local software as if they were on the
same computer. It works by forwarding librtlsdr calls
to the remote computer over TCP.

It allows one to use existing tools without modifying
them. Also, it allows a developer to use the same API
no matter weither the dongle is local or distant.

To use it, one must compile and install the library
with CMAKE the usual way. Note that you may need to
uninstall the existing librtlsdr, as people reported
runtime errors due to conflicting installs.

Then, a server (called rtl_rpcd) must be run on the
remote location.

In my case, the dongle is in a beagle bone black is
at address 192.168.0.43:
beagleboneblack #> ./rtl_rpcd

Then, the existing tool (for instance rtlizer) can be
run on the local computer using:
RTLSDR_RPC_IS_ENABLED=1 RTLSDR_RPC_SERV_ADDR=192.168.0.43 \
rtlizer

This implementation still has some limitations, but
works well in most cases. Please report any bug to
[email protected]

Also, note that the latest version of libusb should be
used as librtlsdr crashed when used with older version
(esp. the rtlsdr_read_async routine):
https://github.com/libusb/libusb.git

list of known working software:
rtl_fm
rtl_power
rtlsdr-waterfall
rtlizer
gnuradio-companion
cubicsdr
gqrx
8 changes: 0 additions & 8 deletions circle.yml

This file was deleted.

1 change: 1 addition & 0 deletions debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.deb
119 changes: 119 additions & 0 deletions debian/debianize
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash

REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../"

G_REV=`git rev-parse --short=8 HEAD`
DATE=`date +"%Y%m%d%H%M%S"`
#VERSION="0.5.3-git+${DATE}.${G_REV}~$1"
VERSION=`git describe | cut -dv -f2`
#
# librtlsdr0
#

rm -fr /tmp/librtlsdr0/
mkdir -p /tmp/librtlsdr0/
mkdir -p /tmp/librtlsdr0/usr/lib/x86_64-linux-gnu/
mkdir -p /tmp/librtlsdr0/DEBIAN

cat <<- EOF > /tmp/librtlsdr0/DEBIAN/control
Package: librtlsdr0
Source: rtl-sdr
Version: ${VERSION}
Architecture: amd64
Maintainer: Lucas Teske <[email protected]>
Pre-Depends: multiarch-support
Depends: libc6 (>= 2.14), libusb-1.0-0 (>= 2:1.0.9)
Section: libs
Priority: extra
Multi-Arch: same
Homepage: http://sdr.osmocom.org/trac/wiki/rtl-sdr
Description: Software defined radio receiver for Realtek RTL2832U (library)
rtl-sdr is a software defined radio (SDR) receiver software for certain
low-cost DVB-T/DAB(+) USB dongles based on the Realtek RTL2832U chip.
.
This package contains the shared library.
EOF

DEB_PKG="librtlsdr0_${VERSION}_amd64.deb"

cp -rf ${REPO_DIR}/build/src/lib*so* /tmp/librtlsdr0/usr/lib/x86_64-linux-gnu/
dpkg-deb -b /tmp/librtlsdr0/ ./${DEB_PKG}

echo ${DEB_PKG}

#
# rtl-sdr
#

rm -fr /tmp/rtl-sdr/
mkdir -p /tmp/rtl-sdr/
mkdir -p /tmp/rtl-sdr/usr/bin/
mkdir -p /tmp/rtl-sdr/DEBIAN

cat <<- EOF > /tmp/rtl-sdr/DEBIAN/control
Package: rtl-sdr
Version: ${VERSION}
Architecture: amd64
Maintainer: Lucas Teske <[email protected]>
Depends: librtlsdr0 (= ${VERSION}), libc6 (>= 2.15)
Section: libs
Priority: extra
Homepage: http://sdr.osmocom.org/trac/wiki/rtl-sdr
Description: Software defined radio receiver for Realtek RTL2832U (tools)
rtl-sdr is a software defined radio (SDR) receiver software for certain
low-cost DVB-T/DAB(+) USB dongles based on the Realtek RTL2832U chip.
.
This package contains a set of command line utilities:
* rtl_adsb: a simple ADS-B decoder for RTL2832 based DVB-T receivers
* rtl_eeprom: an EEPROM programming tool for RTL2832 based DVB-T receivers
* rtl_fm: a narrow band FM demodulator for RTL2832 based DVB-T receivers
* rtl_sdr: an I/Q recorder for RTL2832 based DVB-T receivers
* rtl_tcp: an I/Q spectrum server for RTL2832 based DVB-T receivers
* rtl_test: a benchmark tool for RTL2832 based DVB-T receivers
EOF

DEB_PKG="rtl-sdr_${VERSION}_amd64.deb"

cp -rf ${REPO_DIR}/build/src/rtl_* /tmp/rtl-sdr/usr/bin/
dpkg-deb -b /tmp/rtl-sdr/ ./${DEB_PKG}

echo ${DEB_PKG}


#
# librtlsdr-dev
#

rm -fr /tmp/librtlsdr-dev/
mkdir -p /tmp/librtlsdr-dev/
mkdir -p /tmp/librtlsdr-dev/usr/include
mkdir -p /tmp/librtlsdr-dev/usr/lib/x86_64-linux-gnu/pkgconfig
mkdir -p /tmp/librtlsdr-dev/DEBIAN

cat <<- EOF > /tmp/librtlsdr-dev/DEBIAN/control
Package: librtlsdr-dev
Source: rtl-sdr
Version: ${VERSION}
Architecture: amd64
Maintainer: Lucas Teske <[email protected]>
Pre-Depends: multiarch-support
Depends: librtlsdr0 (= ${VERSION})
Section: libdevel
Priority: extra
Homepage: http://sdr.osmocom.org/trac/wiki/rtl-sdr
Description: Software defined radio receiver for Realtek RTL2832U (development files)
rtl-sdr is a software defined radio (SDR) receiver software for certain
low-cost DVB-T/DAB(+) USB dongles based on the Realtek RTL2832U chip.
.
This package contains development files.
EOF

DEB_PKG="librtlsdr-dev_${VERSION}_amd64.deb"

cp -rf ${REPO_DIR}/include/*.h /tmp/librtlsdr-dev/usr/include
dpkg-deb -b /tmp/librtlsdr-dev/ ./${DEB_PKG}

echo ${DEB_PKG}
41 changes: 40 additions & 1 deletion include/rtl-sdr.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@
extern "C" {
#endif

#ifndef WIN32
#define _ENABLE_RPC
#endif


#include <stdint.h>
#include <rtl-sdr_export.h>
#include <rtl_tcp.h>

typedef struct rtlsdr_dev rtlsdr_dev_t;

Expand Down Expand Up @@ -142,6 +148,13 @@ RTLSDR_API int rtlsdr_write_eeprom(rtlsdr_dev_t *dev, uint8_t *data,
RTLSDR_API int rtlsdr_read_eeprom(rtlsdr_dev_t *dev, uint8_t *data,
uint8_t offset, uint16_t len);

/*!
* Set the frequency the device is tuned to.
*
* \param dev the device handle given by rtlsdr_open()
* \param frequency in Hz
* \return 0 on error, frequency in Hz otherwise
*/
RTLSDR_API int rtlsdr_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq);

/*!
Expand Down Expand Up @@ -220,9 +233,14 @@ RTLSDR_API int rtlsdr_set_tuner_gain(rtlsdr_dev_t *dev, int gain);
*
* \param dev the device handle given by rtlsdr_open()
* \param bw bandwidth in Hz. Zero means automatic BW selection.
* \param applied_bw is applied bandwidth in Hz, or 0 if unknown
* \param apply_bw: 1 to really apply configure the tuner chip; 0 for just returning applied_bw
* \return 0 on success
*/
RTLSDR_API int rtlsdr_set_tuner_bandwidth(rtlsdr_dev_t *dev, uint32_t bw);
RTLSDR_API int rtlsdr_set_and_get_tuner_bandwidth(rtlsdr_dev_t *dev, uint32_t bw, uint32_t *applied_bw, int apply_bw );

RTLSDR_API int rtlsdr_set_tuner_bandwidth(rtlsdr_dev_t *dev, uint32_t bw );


/*!
* Get actual gain the device is configured to.
Expand All @@ -232,6 +250,17 @@ RTLSDR_API int rtlsdr_set_tuner_bandwidth(rtlsdr_dev_t *dev, uint32_t bw);
*/
RTLSDR_API int rtlsdr_get_tuner_gain(rtlsdr_dev_t *dev);

/*!
* Set LNA / Mixer / VGA Device Gain for R820T device is configured to.
*
* \param dev the device handle given by rtlsdr_open()
* \param lna_gain in tenths of a dB, -30 means -3.0 dB.
* \param mixer_gain in tenths of a dB, -30 means -3.0 dB.
* \param vga_gain in tenths of a dB, -30 means -3.0 dB.
* \return 0 on success
*/
RTLSDR_API int rtlsdr_set_tuner_gain_ext(rtlsdr_dev_t *dev, int lna_gain, int mixer_gain, int vga_gain);

/*!
* Set the intermediate frequency gain for the device.
*
Expand Down Expand Up @@ -380,6 +409,16 @@ RTLSDR_API int rtlsdr_read_async(rtlsdr_dev_t *dev,
*/
RTLSDR_API int rtlsdr_cancel_async(rtlsdr_dev_t *dev);

/*!
* Read from the remote control (RC) infrared (IR) sensor
*
* \param dev the device handle given by rtlsdr_open()
* \param buf buffer to write IR signal (MSB=pulse/space, 7LSB=duration*20usec), recommended 128-bytes
* \param buf_len size of buf
* \return 0 if no signal, >0 number of bytes written into buf, <0 for error
*/
RTLSDR_API int rtlsdr_ir_query(rtlsdr_dev_t *dev, uint8_t *buf, size_t buf_len);

#ifdef __cplusplus
}
#endif
Expand Down
51 changes: 51 additions & 0 deletions include/rtl_tcp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver
* Copyright (C) 2012-2013 by Steve Markgraf <[email protected]>
* Copyright (C) 2012 by Dimitri Stolnikov <[email protected]>
*
* 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 2 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/>.
*/

#ifndef __RTL_TCP_H
#define __RTL_TCP_H

#ifdef __cplusplus
extern "C" {
#endif

/*!
* This enum defines the possible commands in rtl_tcp
*/
enum RTL_TCP_COMMANDS {
SET_FREQUENCY = 0x01,
SET_SAMPLE_RATE = 0x02,
SET_GAIN_MODE = 0x03,
SET_GAIN = 0x04,
SET_FREQUENCY_CORRECTION = 0x05,
SET_IF_STAGE = 0x06,
SET_TEST_MODE = 0x07,
SET_AGC_MODE = 0x08,
SET_DIRECT_SAMPLING = 0x09,
SET_OFFSET_TUNING = 0x0A,
SET_RTL_CRYSTAL = 0x0B,
SET_TUNER_CRYSTAL = 0x0C,
SET_TUNER_GAIN_BY_INDEX = 0x0D,
SET_TUNER_BANDWIDTH = 0x0E
};

#ifdef __cplusplus
}
#endif

#endif
Loading

0 comments on commit 6b314e0

Please sign in to comment.