GNU Radio's HPSDR Package: HermesProxyW.h Source File

GNU Radio's HPSDR Package

HermesProxyW.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2013-2015 Tom McDermott, N5EG
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21//
22// Proxy for Hermes board wideband mode, communicates with
23// only one hardware module.
24// Version: March 21, 2015
25
26#include <gnuradio/io_signature.h>
27#include "HermesProxy.h" // typedefs and enums
28
29#ifndef HermesProxyW_H
30#define HermesProxyW_H
31
32#define NUMRXIQBUFS 128 // number of receiver IQ buffers in circular queue.
33 // Must be integral power of 2 (2,4,8,16,32,64, etc.)
34
35#define RXBUFSIZE 256 // number of floats in one RxIQBuf, #complexes is half
36 // Must be integral power of 2 (2,4,8,16,32,64, etc.)
37
38#define NUMTXBUFS 128 // number of transmit buffers in circular queue
39 // Must be integral power of 2
40
41#define TXBUFSIZE 512 // number of bytes in one TxBuf
42
43
44
45//typedef float* IQBuf_t; // IQ buffer type (IQ samples as floats)
46//typedef unsigned char* RawBuf_t; // Raw transmit buffer type
47
48//enum { PTTOff, // PTT disabled
49// PTTVox, // PTT vox mode (examines TxFrame to decide whether to Tx)
50// PTTOn }; // PTT force Tx on
51
52 class HermesProxyW
53{
54
55private:
56
57 IQBuf_t RxIQBuf[NUMRXIQBUFS]; // ReceiveIQ buffers
58 unsigned RxWriteCounter; // Which Rx buffer to write to
59 unsigned RxReadCounter; // Which Rx buffer to read from
60 unsigned RxWriteFill; // Fill level of the RxWrite buffer
61
62 RawBuf_t TxBuf[NUMTXBUFS]; // Transmit buffers
63 unsigned TxWriteCounter; // Which Tx buffer to write to
64 unsigned TxReadCounter; // Which Tx buffer to read from
65 unsigned TxControlCycler; // Which Tx control register set to send
66 unsigned TxFrameIdleCount; // How long we've gone since sending a TxFrame
67
68 unsigned long LostRxBufCount; // Lost-buffer counter for packets we actually got
69 unsigned long TotalRxBufCount; // Total buffer count (may roll over)
70 unsigned long LostTxBufCount; //
71 unsigned long TotalTxBufCount; //
72 unsigned long CorruptRxCount; //
73 unsigned long LostEthernetRx; //
74 unsigned long CurrentEthSeqNum; // Diagnostic
75
76public:
77
78 unsigned Receive0Frequency; // 1st rcvr. Corresponds to out0 in gnuradio
79 unsigned Receive1Frequency; // 2nd rcvr. Corresponds to out1 in gnuradio
80 unsigned TransmitFrequency;
81 int NumReceivers;
82 int RxSampleRate;
83
84 unsigned char TxDrive;
85 unsigned char RxAtten; // not yet used (requires Hermes firmware V2.0)
86
87 unsigned int ClockSource; // upper 6-bits of clock control register
88
89 unsigned char AlexRxAnt; // Select Alex Receive Antenna or from T/R relay
90 unsigned char AlexTxAnt; // Select Alex Tx Antenna
91 unsigned char AlexRxHPF; // Select Alex Receive High Pass Filter
92 unsigned char AlexTxLPF; // Select Alex Transmit Low Pass Filter
93
94 int PTTMode;
95 bool RxPreamp;
96 bool ADCdither;
97 bool ADCrandom;
98 bool ADCoverload;
99 bool Duplex;
100
101 unsigned char HermesVersion;
102 unsigned int AIN1, AIN2, AIN3, AIN4, AIN5, AIN6; // Analog inputs to Hermes
103 unsigned int AlexRevPwr;
104 unsigned int SlowCount;
105 int Verbose;
106
107 bool TxStop;
108 bool PTTOffMutesTx; // PTT Off mutes the transmitter
109 bool PTTOnMutesRx; // PTT On receiver
110 char interface[16];
111
112 char mactarget[18]; // Requested target's MAC address as string
113 // "HH:HH:HH:HH:HH:HH" HH is hexadecimal string.
114 unsigned int metis_entry; // Index into Metis_card MAC table
115
116
117 HermesProxyW(int RxPre, const char* Intfc, const char * ClkS,
118 int AlexRA, int AlexTA, int AlexHPF, int AlexRPF,
119 const char* MACAddr); // constructor
120
121 ~HermesProxyW(); // destructor
122
123 void Stop(); // stop ethernet I/O
124 void Start(); // start rx stream
125
126 void SendTxIQ(); // send an IQ buffer to Hermes transmit hardware
127 void BuildControlRegs(unsigned, RawBuf_t); // fill in the 8 byte sync+control registers from RegNum
128 void PutTxIQ(); // post a transmit TxIQ buffer
129 void ScheduleTxFrame(); // Schedule a Tx frame
130 RawBuf_t GetNextTxBuf(); // get an empty Tx Buffer
131
132 void UpdateHermes(); // update control registers in Hermes without any Tx data
133
134 void ReceiveRxIQ(unsigned char *); // receive an IQ buffer from Hermes hardware via metis.cc thread
135
136 IQBuf_t GetNextRxWriteBuf(); // Used to be named GetRxIQ()
137 IQBuf_t GetNextRxReadBuf(); // Used to be named GetNextRxBuf(IQBuf_t)
138 IQBuf_t GetCurrentRxReadBuf(); //
139 IQBuf_t GetCurrentRxWriteBuf(); //
140 bool RxReadBufAligned(); // True if the current Rcv Read Buffer is aligned on a 64 buffer boundary
141 bool RxWriteBufAligned(); // True if the current Rcv Write Buffer is aligned on a 64 buffer boundary
142 int RxBufFillCount(); // how many RxBuffers are filled?
143
144 void PrintRawBuf(RawBuf_t); // for debugging
145
146
147
148};
149
150#endif // #ifndef HermesProxyW_H
151
NUMTXBUFS
#define NUMTXBUFS
Definition: HermesProxyW.h:38
NUMRXIQBUFS
#define NUMRXIQBUFS
Definition: HermesProxyW.h:32
HermesProxy.h
RawBuf_t
unsigned char * RawBuf_t
Definition: HermesProxy.h:59
IQBuf_t
float * IQBuf_t
Definition: HermesProxy.h:58
HermesProxyW
Definition: HermesProxyW.h:53
HermesProxyW::AlexRxHPF
unsigned char AlexRxHPF
Definition: HermesProxyW.h:91
HermesProxyW::RxBufFillCount
int RxBufFillCount()
HermesProxyW::metis_entry
unsigned int metis_entry
Definition: HermesProxyW.h:114
HermesProxyW::ScheduleTxFrame
void ScheduleTxFrame()
HermesProxyW::TransmitFrequency
unsigned TransmitFrequency
Definition: HermesProxyW.h:80
HermesProxyW::ADCoverload
bool ADCoverload
Definition: HermesProxyW.h:98
HermesProxyW::NumReceivers
int NumReceivers
Definition: HermesProxyW.h:81
HermesProxyW::Duplex
bool Duplex
Definition: HermesProxyW.h:99
HermesProxyW::AIN3
unsigned int AIN3
Definition: HermesProxyW.h:102
HermesProxyW::Verbose
int Verbose
Definition: HermesProxyW.h:105
HermesProxyW::RxAtten
unsigned char RxAtten
Definition: HermesProxyW.h:85
HermesProxyW::RxSampleRate
int RxSampleRate
Definition: HermesProxyW.h:82
HermesProxyW::HermesProxyW
HermesProxyW(int RxPre, const char *Intfc, const char *ClkS, int AlexRA, int AlexTA, int AlexHPF, int AlexRPF, const char *MACAddr)
HermesProxyW::SlowCount
unsigned int SlowCount
Definition: HermesProxyW.h:104
HermesProxyW::AlexTxLPF
unsigned char AlexTxLPF
Definition: HermesProxyW.h:92
HermesProxyW::AIN1
unsigned int AIN1
Definition: HermesProxyW.h:102
HermesProxyW::BuildControlRegs
void BuildControlRegs(unsigned, RawBuf_t)
HermesProxyW::AIN6
unsigned int AIN6
Definition: HermesProxyW.h:102
HermesProxyW::ADCrandom
bool ADCrandom
Definition: HermesProxyW.h:97
HermesProxyW::interface
char interface[16]
Definition: HermesProxyW.h:110
HermesProxyW::Receive0Frequency
unsigned Receive0Frequency
Definition: HermesProxyW.h:78
HermesProxyW::Stop
void Stop()
HermesProxyW::RxWriteBufAligned
bool RxWriteBufAligned()
HermesProxyW::RxReadBufAligned
bool RxReadBufAligned()
HermesProxyW::AIN2
unsigned int AIN2
Definition: HermesProxyW.h:102
HermesProxyW::AlexTxAnt
unsigned char AlexTxAnt
Definition: HermesProxyW.h:90
HermesProxyW::PTTOffMutesTx
bool PTTOffMutesTx
Definition: HermesProxyW.h:108
HermesProxyW::PutTxIQ
void PutTxIQ()
HermesProxyW::ADCdither
bool ADCdither
Definition: HermesProxyW.h:96
HermesProxyW::RxPreamp
bool RxPreamp
Definition: HermesProxyW.h:95
HermesProxyW::AlexRevPwr
unsigned int AlexRevPwr
Definition: HermesProxyW.h:103
HermesProxyW::ReceiveRxIQ
void ReceiveRxIQ(unsigned char *)
HermesProxyW::PTTMode
int PTTMode
Definition: HermesProxyW.h:94
HermesProxyW::PrintRawBuf
void PrintRawBuf(RawBuf_t)
HermesProxyW::GetCurrentRxWriteBuf
IQBuf_t GetCurrentRxWriteBuf()
HermesProxyW::GetNextRxWriteBuf
IQBuf_t GetNextRxWriteBuf()
HermesProxyW::~HermesProxyW
~HermesProxyW()
HermesProxyW::GetNextTxBuf
RawBuf_t GetNextTxBuf()
HermesProxyW::mactarget
char mactarget[18]
Definition: HermesProxyW.h:112
HermesProxyW::Receive1Frequency
unsigned Receive1Frequency
Definition: HermesProxyW.h:79
HermesProxyW::SendTxIQ
void SendTxIQ()
HermesProxyW::TxStop
bool TxStop
Definition: HermesProxyW.h:107
HermesProxyW::GetNextRxReadBuf
IQBuf_t GetNextRxReadBuf()
HermesProxyW::AIN5
unsigned int AIN5
Definition: HermesProxyW.h:102
HermesProxyW::GetCurrentRxReadBuf
IQBuf_t GetCurrentRxReadBuf()
HermesProxyW::AIN4
unsigned int AIN4
Definition: HermesProxyW.h:102
HermesProxyW::UpdateHermes
void UpdateHermes()
HermesProxyW::AlexRxAnt
unsigned char AlexRxAnt
Definition: HermesProxyW.h:89
HermesProxyW::HermesVersion
unsigned char HermesVersion
Definition: HermesProxyW.h:101
HermesProxyW::Start
void Start()
HermesProxyW::ClockSource
unsigned int ClockSource
Definition: HermesProxyW.h:87
HermesProxyW::TxDrive
unsigned char TxDrive
Definition: HermesProxyW.h:84
HermesProxyW::PTTOnMutesRx
bool PTTOnMutesRx
Definition: HermesProxyW.h:109