Instrument Neutral Distributed Interface INDI 2.2.5
indi_rtlsdr.h
Go to the documentation of this file.
1/*
2 indi_rtlsdr - a software defined radio driver for INDI
3 Copyright (C) 2017 Ilia Platone - Jasem Mutlaq
4 Collaborators:
5 - Ilia Platone <[email protected]>
6 - Jasem Mutlaq - INDI library - <http://indilib.org>
7 - Monroe Pattillo - Fox Observatory - South Florida Amateur Astronomers Association <http://www.sfaaa.com/>
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*/
23
24#pragma once
25
26#include <rtl-sdr.h>
27#include "indireceiver.h"
29
37class RTLSDR : public INDI::Receiver
38{
39 public:
40 RTLSDR(int32_t index);
41
42 void grabData();
43 rtlsdr_dev *rtl_dev = { nullptr };
45 // Are we integrating?
47 uint8_t *buffer;
49 bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
50
51 protected:
52 // General device functions
53 bool Connect() override;
54 bool Disconnect() override;
55 const char *getDefaultName() override;
56 bool initProperties() override;
57 bool updateProperties() override;
58
59 // Receiver specific functions
60 bool StartIntegration(double duration) override;
61 void setupParams(float sr, float freq, float gain);
62 bool AbortIntegration() override;
63 void TimerHit() override;
64
65 bool StartStreaming() override;
66 bool StopStreaming() override;
67 void * streamCapture();
68
69 bool Handshake() override;
70
71 private:
72 void Callback();
73
74 // Utility functions
75 float CalcTimeLeft();
76
77 // Struct to keep timing
78 struct timeval IntStart;
79 float IntegrationRequest;
80 uint8_t *real;
81 uint8_t *imaginary;
82
83 int32_t receiverIndex = { 0 };
84
85 int streamPredicate;
86 pthread_t primary_thread;
87 bool terminateThread;
88
89 bool sendTcpCommand(int cmd, int value);
90 enum TcpCommands
91 {
92 CMD_SET_FREQ = 0x1,
93 CMD_SET_SAMPLE_RATE = 0x2,
94 CMD_SET_TUNER_GAIN_MODE = 0x3,
95 CMD_SET_GAIN = 0x4,
96 CMD_SET_FREQ_COR = 0x5,
97 CMD_SET_AGC_MODE = 0x8,
98 CMD_SET_TUNER_GAIN_INDEX = 0xd
99 };
100};
Class to provide general functionality of Monodimensional Receiver.
int to_read
Definition indi_rtlsdr.h:44
bool InIntegration
Definition indi_rtlsdr.h:46
bool AbortIntegration() override
Abort ongoing Integration.
bool StopStreaming() override
StopStreaming Stop live video streaming.
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
void * streamCapture()
bool Disconnect() override
Disconnect from device.
rtlsdr_dev * rtl_dev
Definition indi_rtlsdr.h:43
bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
uint8_t * buffer
Definition indi_rtlsdr.h:47
void setupParams(float sr, float freq, float gain)
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
const char * getDefaultName() override
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
bool Handshake() override
perform handshake with device to check communication
int n_read
Definition indi_rtlsdr.h:48
void grabData()
bool StartIntegration(double duration) override
Start integration from the Sensor device.
int b_read
Definition indi_rtlsdr.h:48
bool StartStreaming() override
StartStreaming Start live video streaming.
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Settings
Definition indi_rtlsdr.h:31
@ NUM_SETTINGS
Definition indi_rtlsdr.h:35
@ FREQUENCY_N
Definition indi_rtlsdr.h:32
@ BANDWIDTH_N
Definition indi_rtlsdr.h:34
@ SAMPLERATE_N
Definition indi_rtlsdr.h:33
uint8_t cmd[4]
Definition pwc-ioctl.h:2