Skip to content

Commit

Permalink
refactor how the P25 tx hang (tail) was handled, do not transmit sync…
Browse files Browse the repository at this point in the history
… instead transmit silence;
  • Loading branch information
gatekeep committed May 7, 2022
1 parent 94b903a commit c4d1796
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ typedef unsigned long long ulong64_t;
#define ENABLE_P25

// Normal Boxcar Filter for P25
#define P25_RX_NORMAL_BOXCAR
//#define P25_RX_NORMAL_BOXCAR

// Narrow Boxcar Filter for P25
//#define P25_RX_NARROW_BOXCAR
#define P25_RX_NARROW_BOXCAR

// Allow for the use of high quality external clock oscillators
// The number is the frequency of the oscillator in Hertz.
Expand Down
24 changes: 20 additions & 4 deletions p25/P25TX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ P25TX::P25TX() :
m_poLen(0U),
m_poPtr(0U),
m_preambleCnt(P25_FIXED_DELAY),
m_txHang(P25_FIXED_TX_HANG),
m_tailCnt(0U),
m_symLevel3Adj(0U),
m_symLevel1Adj(0U)
Expand Down Expand Up @@ -108,7 +109,7 @@ void P25TX::process()
uint16_t space = io.getSpace();

while (space > (4U * P25_RADIO_SYMBOL_LENGTH)) {
writeByte(P25_START_SYNC);
writeSilence();

space -= 4U * P25_RADIO_SYMBOL_LENGTH;
m_tailCnt--;
Expand Down Expand Up @@ -153,7 +154,7 @@ void P25TX::process()
writeByte(c);

space -= 4U * P25_RADIO_SYMBOL_LENGTH;
m_tailCnt = P25_FIXED_TAIL;
m_tailCnt = m_txHang;

if (m_poPtr >= m_poLen) {
m_poPtr = 0U;
Expand Down Expand Up @@ -203,14 +204,29 @@ void P25TX::clear()
/// <param name="preambleCnt">Count of preambles.</param>
void P25TX::setPreambleCount(uint8_t preambleCnt)
{
uint32_t preambles = (uint32_t)((float)preambleCnt / 0.2083F);
m_preambleCnt = P25_FIXED_DELAY + preambles;
m_preambleCnt = P25_FIXED_DELAY + preambleCnt;

// clamp preamble count to 250ms maximum
if (m_preambleCnt > 1200U)
m_preambleCnt = 1200U;
}

/// <summary>
/// Sets the Tx hang time.
/// </summary>
/// <param name="txHang">Transmit hang time in seconds.</param>
void P25TX::setTxHang(uint8_t txHang)
{
if (txHang > 0U)
m_txHang = txHang * 1200U;
else
m_txHang = P25_FIXED_TX_HANG;

// clamp tx hang count to 13s maximum
if (txHang > 13U)
m_txHang = 13U * 1200U;
}

/// <summary>
/// Sets the fine adjust 4FSK symbol levels.
/// </summary>
Expand Down
10 changes: 6 additions & 4 deletions p25/P25TX.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2020 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -40,9 +40,8 @@ namespace p25
// Constants
// ---------------------------------------------------------------------------

#define P25_FIXED_DELAY 300 // 300 = 62.49ms
// Delay Value * 0.2083 = Preamble Length (ms)
#define P25_FIXED_TAIL 600 // 600 = 500ms
#define P25_FIXED_DELAY 90 // 90 = 20ms
#define P25_FIXED_TX_HANG 750 // 750 = 625ms

enum P25TXSTATE {
P25TXSTATE_NORMAL,
Expand Down Expand Up @@ -70,6 +69,8 @@ namespace p25

/// <summary>Sets the FDMA preamble count.</summary>
void setPreambleCount(uint8_t preambleCnt);
/// <summary>Sets the transmit hang time.</summary>
void setTxHang(uint8_t txHang);
/// <summary>Sets the fine adjust 4FSK symbol levels.</summary>
void setSymbolLvlAdj(int8_t level3Adj, int8_t level1Adj);
/// <summary>Helper to set the calibration state for Tx.</summary>
Expand All @@ -94,6 +95,7 @@ namespace p25
uint16_t m_poPtr;

uint16_t m_preambleCnt;
uint16_t m_txHang;
uint16_t m_tailCnt;

int8_t m_symLevel3Adj;
Expand Down

0 comments on commit c4d1796

Please sign in to comment.