From b7b88b3c840a293094153d68d845b23ac142d92d Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Thu, 6 May 2021 15:58:47 +0000 Subject: [PATCH] better support simplex channel selection via iden table; update iden_channel_calc.py helper to support doing conversion to channel no and FROM channel no; --- host/Host.cpp | 30 ++++++++++++++++--------- iden_channel_calc.py | 53 +++++++++++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/host/Host.cpp b/host/Host.cpp index 464ffe2e..b2d69d74 100644 --- a/host/Host.cpp +++ b/host/Host.cpp @@ -1241,14 +1241,6 @@ bool Host::readParams() return false; } - if (entry.txOffsetMhz() == 0U) { - ::LogError(LOG_HOST, "Channel Id %u has an invalid Tx offset.", m_channelId); - return false; - } - - uint32_t calcSpace = (uint32_t)(entry.chSpaceKhz() / 0.125); - float calcTxOffset = entry.txOffsetMhz() * 1000000; - m_channelNo = (uint32_t)::strtoul(rfssConfig["channelNo"].as("1").c_str(), NULL, 16); if (m_channelNo == 0U) { // clamp to 1 m_channelNo = 1U; @@ -1257,10 +1249,26 @@ bool Host::readParams() m_channelNo = 4095U; } - m_rxFrequency = (uint32_t)((entry.baseFrequency() + ((calcSpace * 125) * m_channelNo)) + calcTxOffset); - m_txFrequency = (uint32_t)((entry.baseFrequency() + ((calcSpace * 125) * m_channelNo))); + if (m_duplex) { + if (entry.txOffsetMhz() == 0U) { + ::LogError(LOG_HOST, "Channel Id %u has an invalid Tx offset.", m_channelId); + return false; + } + + uint32_t calcSpace = (uint32_t)(entry.chSpaceKhz() / 0.125); + float calcTxOffset = entry.txOffsetMhz() * 1000000; + + m_rxFrequency = (uint32_t)((entry.baseFrequency() + ((calcSpace * 125) * m_channelNo)) + calcTxOffset); + m_txFrequency = (uint32_t)((entry.baseFrequency() + ((calcSpace * 125) * m_channelNo))); + } + else { + uint32_t calcSpace = (uint32_t)(entry.chSpaceKhz() / 0.125); + + m_rxFrequency = (uint32_t)((entry.baseFrequency() + ((calcSpace * 125) * m_channelNo))); + m_txFrequency = m_rxFrequency; + } - yaml::Node & voiceChList = rfssConfig["voiceChNo"]; + yaml::Node& voiceChList = rfssConfig["voiceChNo"]; for (size_t i = 0; i < voiceChList.size(); i++) { uint32_t chNo = (uint32_t)::strtoul(voiceChList[i].as("1").c_str(), NULL, 16); m_voiceChNo.push_back(chNo); diff --git a/iden_channel_calc.py b/iden_channel_calc.py index 136c909a..be929593 100644 --- a/iden_channel_calc.py +++ b/iden_channel_calc.py @@ -46,17 +46,25 @@ if __name__ == '__main__': parser.add_argument('--spacing', action = 'store', dest = 'Spacing', type = float, help = 'Channel Spacing (in KHz)', required = True) parser.add_argument('--offset', action = 'store', dest = 'InputOffset', type = float, help = 'Input Offset (in MHz)', required = True) parser.add_argument('--bandwidth', action = 'store', dest = 'Bandwidth', type = float, help = 'Bandwidth (in KHz)', required = True) - parser.add_argument('--tx', action = 'store', dest = 'TxFrequency', type = int, help = 'Transmit Frequency (in Hz, this should be within the band of the Base Frequency)', required = True) + parser.add_argument('--tx', action = 'store', dest = 'TxFrequency', type = int, help = 'Transmit Frequency (in Hz, this should be within the band of the Base Frequency)', required = False) + parser.add_argument('--ch-no', action = 'store', dest = 'ChannelNo', type = str, help = 'Logical Channel Number', required = False) cli_args = parser.parse_args() - if (cli_args.TxFrequency < cli_args.BaseFrequency): - print ('ERROR: Tx Frequency (' + '%.5f' % float(cli_args.TxFrequency / HZ_MHZ) + ') is out of band range for base frequency (' + '%.5f' % float(cli_args.BaseFrequency / HZ_MHZ) + '). ' + \ - 'Tx Frequency must be greater then the base frequency!') + if (not cli_args.TxFrequency) and (not cli_args.ChannelNo): + print ('ERROR: Tx Frequency or Channel Number must be spcified!') quit() - if (cli_args.TxFrequency > (cli_args.BaseFrequency + MAX_FREQ_GAP)): - print ('ERROR: Tx Frequency (' + '%.5f' % float(cli_args.TxFrequency / HZ_MHZ) + ') is out of band range for base frequency (' + '%.5f' % float(cli_args.BaseFrequency / HZ_MHZ) + '). ' + \ - 'Tx Frequency must be no more then 25.5 Mhz higher then the base frequency!') + if (cli_args.TxFrequency) and (cli_args.ChannelNo): + print ('ERROR: Tx Frequency or Channel Number must be spcified!') quit() + if (cli_args.TxFrequency): + if (cli_args.TxFrequency < cli_args.BaseFrequency): + print ('ERROR: Tx Frequency (' + '%.5f' % float(cli_args.TxFrequency / HZ_MHZ) + ') is out of band range for base frequency (' + '%.5f' % float(cli_args.BaseFrequency / HZ_MHZ) + '). ' + \ + 'Tx Frequency must be greater then the base frequency!') + quit() + if (cli_args.TxFrequency > (cli_args.BaseFrequency + MAX_FREQ_GAP)): + print ('ERROR: Tx Frequency (' + '%.5f' % float(cli_args.TxFrequency / HZ_MHZ) + ') is out of band range for base frequency (' + '%.5f' % float(cli_args.BaseFrequency / HZ_MHZ) + '). ' + \ + 'Tx Frequency must be no more then 25.5 Mhz higher then the base frequency!') + quit() print ('\r\nIdentity Data:') @@ -69,16 +77,29 @@ if __name__ == '__main__': '%.3f' % cli_args.InputOffset + ',' + str(cli_args.Bandwidth) + ',"') print ('\r\nChannel Data:') - offsetHz = cli_args.InputOffset * HZ_MHZ - rxFrequency = int(cli_args.TxFrequency + offsetHz) - print ('Tx Frequency: ' + '%.5f' % (float(cli_args.TxFrequency / HZ_MHZ)) + ' MHz' + - '\r\nRx Frequency: ' + '%.5f' % (float(rxFrequency / HZ_MHZ)) + ' MHz') - spaceHz = int(cli_args.Spacing * 1000) - offsetHz = int(cli_args.InputOffset * HZ_MHZ) + if cli_args.ChannelNo: + space = cli_args.Spacing / 0.125 + chNo = int(cli_args.ChannelNo, 16) + + rxFrequency = (cli_args.BaseFrequency + ((space * 125) * chNo)) + offsetHz + txFrequency = (cli_args.BaseFrequency + ((space * 125) * chNo)) + + print ('\r\nChannel Number: ' + '%x' % chNo) + + print ('\r\nTx Frequency: ' + '%.5f' % (float(txFrequency / HZ_MHZ)) + ' MHz' + + '\r\nRx Frequency: ' + '%.5f' % (float(rxFrequency / HZ_MHZ)) + ' MHz') + else: + rxFrequency = int(cli_args.TxFrequency + offsetHz) + + print ('Tx Frequency: ' + '%.5f' % (float(cli_args.TxFrequency / HZ_MHZ)) + ' MHz' + + '\r\nRx Frequency: ' + '%.5f' % (float(rxFrequency / HZ_MHZ)) + ' MHz') + + spaceHz = int(cli_args.Spacing * 1000) + offsetHz = int(cli_args.InputOffset * HZ_MHZ) - rootFreq = cli_args.TxFrequency - cli_args.BaseFrequency - chNo = rootFreq / spaceHz + rootFreq = cli_args.TxFrequency - cli_args.BaseFrequency + chNo = rootFreq / spaceHz - print ('\r\nChannel Number: ' + '%x' % chNo) + print ('\r\nChannel Number: ' + '%x' % chNo)