|
# Copyright 2016-2022:
|
|
# * Pavel Milanes CO7WT, <pavelmc@gmail.com>
|
|
# * Jim Unroe KC9HI, <rock.unroe@gmail.com>
|
|
#
|
|
# 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/>.
|
|
|
|
import time
|
|
import struct
|
|
import logging
|
|
|
|
from time import sleep
|
|
from chirp import chirp_common, directory, memmap
|
|
from chirp import bitwise, errors, util
|
|
from chirp.settings import RadioSettingGroup, RadioSetting, \
|
|
RadioSettingValueBoolean, RadioSettingValueList, \
|
|
RadioSettingValueString, RadioSettingValueInteger, \
|
|
RadioSettingValueFloat, RadioSettings, InvalidValueError
|
|
from textwrap import dedent
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
# A note about the memmory in these radios
|
|
#
|
|
# The real memory of these radios extends to 0x4000
|
|
# On read the factory software only uses up to 0x3200
|
|
# On write it just uploads the contents up to 0x3100
|
|
#
|
|
# The mem beyond 0x3200 holds the ID data
|
|
|
|
MEM_SIZE = 0x4000
|
|
BLOCK_SIZE = 0x40
|
|
TX_BLOCK_SIZE = 0x10
|
|
ACK_CMD = "\x06"
|
|
MODES = ["FM", "NFM"]
|
|
SKIP_VALUES = ["S", ""]
|
|
TONES = chirp_common.TONES
|
|
DTCS = sorted(chirp_common.DTCS_CODES + [645])
|
|
|
|
# lists related to "extra" settings
|
|
PTTID_LIST = ["OFF", "BOT", "EOT", "BOTH"]
|
|
PTTIDCODE_LIST = ["%s" % x for x in range(1, 16)]
|
|
OPTSIG_LIST = ["OFF", "DTMF", "2TONE", "5TONE"]
|
|
SPMUTE_LIST = ["Tone/DTCS", "Tone/DTCS and Optsig", "Tone/DTCS or Optsig"]
|
|
|
|
# lists
|
|
LIST_AB = ["A", "B"]
|
|
LIST_ABCD = LIST_AB + ["C", "D"]
|
|
LIST_ANIL = ["3", "4", "5"]
|
|
LIST_APO = ["Off"] + ["%s minutes" % x for x in range(30, 330, 30)]
|
|
LIST_COLOR4 = ["Off", "Blue", "Orange", "Purple"]
|
|
LIST_COLOR8 = ["White", "Red", "Blue", "Green", "Yellow", "Indego",
|
|
"Purple", "Gray"]
|
|
LIST_COLOR9 = ["Black"] + LIST_COLOR8
|
|
LIST_DTMFST = ["OFF", "Keyboard", "ANI", "Keyboad + ANI"]
|
|
LIST_EMCTP = ["TX alarm sound", "TX ANI", "Both"]
|
|
LIST_EMCTPX = ["Off"] + LIST_EMCTP
|
|
LIST_LANGUA = ["English", "Chinese"]
|
|
LIST_MDF = ["Frequency", "Channel", "Name"]
|
|
LIST_OFF1TO9 = ["Off"] + ["%s seconds" % x for x in range(1, 10)]
|
|
LIST_OFF1TO10 = ["Off"] + ["%s seconds" % x for x in range(1, 11)]
|
|
LIST_OFF1TO50 = ["Off"] + ["%s seconds" % x for x in range(1, 51)]
|
|
LIST_OFF1TO60 = ["Off"] + ["%s seconds" % x for x in range(1, 61)]
|
|
LIST_PONMSG = ["Full", "Message", "Battery voltage"]
|
|
LIST_REPM = ["Off", "Carrier", "CTCSS or DCS", "Tone", "DTMF"]
|
|
LIST_REPS = ["1000 Hz", "1450 Hz", "1750 Hz", "2100Hz"]
|
|
LIST_REPSW = ["Off", "RX", "TX"]
|
|
LIST_RPTDL = ["Off"] + ["%s ms" % x for x in range(1, 11)]
|
|
LIST_SCMODE = ["Off", "PTT-SC", "MEM-SC", "PON-SC"]
|
|
LIST_SHIFT = ["Off", "+", "-"]
|
|
LIST_SKIPTX = ["Off", "Skip 1", "Skip 2"]
|
|
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
|
|
LIST_STEP = [str(x) for x in STEPS]
|
|
LIST_SYNC = ["Off", "AB", "CD", "AB+CD"]
|
|
LIST_SYNCV2 = ["Off", "AB", "AC", "BC", "ABC"]
|
|
# the first 12 TMR choices common to all 4-line color display mobile radios
|
|
LIST_TMR12 = ["OFF", "M+A", "M+B", "M+C", "M+D", "M+A+B", "M+A+C", "M+A+D",
|
|
"M+B+C", "M+B+D", "M+C+D", "M+A+B+C"]
|
|
# the 16 choice list for color display mobile radios that correctly implement
|
|
# the full 16 TMR choices
|
|
LIST_TMR16 = LIST_TMR12 + ["M+A+B+D", "M+A+C+D", "M+B+C+D", "A+B+C+D"]
|
|
# the 15 choice list for color mobile radios that are missing the M+A+B+D
|
|
# choice in the TMR menu
|
|
LIST_TMR15 = LIST_TMR12 + ["M+A+C+D", "M+B+C+D", "A+B+C+D"]
|
|
# the 7 TMR choices for the 3-line color display mobile radios
|
|
LIST_TMR7 = ["OFF", "M+A", "M+B", "M+C", "M+AB", "M+AC", "M+BC", "M+ABC"]
|
|
LIST_TMRTX = ["Track", "Fixed"]
|
|
LIST_TOT = ["%s sec" % x for x in range(15, 615, 15)]
|
|
LIST_TXDISP = ["Power", "Mic Volume"]
|
|
LIST_TXP = ["High", "Low"]
|
|
LIST_TXP3 = ["High", "Mid", "Low"]
|
|
LIST_SCREV = ["TO (timeout)", "CO (carrier operated)", "SE (search)"]
|
|
LIST_VFOMR = ["Frequency", "Channel"]
|
|
LIST_VOICE = ["Off"] + LIST_LANGUA
|
|
LIST_VOX = ["Off"] + ["%s" % x for x in range(1, 11)]
|
|
LIST_VOXT = ["%s seconds" % x for x in range(0, 21)]
|
|
LIST_WIDE = ["Wide", "Narrow"]
|
|
|
|
# lists related to DTMF, 2TONE and 5TONE settings
|
|
LIST_5TONE_STANDARDS = ["CCIR1", "CCIR2", "PCCIR", "ZVEI1", "ZVEI2", "ZVEI3",
|
|
"PZVEI", "DZVEI", "PDZVEI", "EEA", "EIA", "EURO",
|
|
"CCITT", "NATEL", "MODAT", "none"]
|
|
LIST_5TONE_STANDARDS_without_none = ["CCIR1", "CCIR2", "PCCIR", "ZVEI1",
|
|
"ZVEI2", "ZVEI3",
|
|
"PZVEI", "DZVEI", "PDZVEI", "EEA", "EIA",
|
|
"EURO", "CCITT", "NATEL", "MODAT"]
|
|
LIST_5TONE_STANDARD_PERIODS = ["20", "30", "40", "50", "60", "70", "80", "90",
|
|
"100", "110", "120", "130", "140", "150", "160",
|
|
"170", "180", "190", "200"]
|
|
LIST_5TONE_DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
|
|
"B", "C", "D", "E", "F"]
|
|
LIST_5TONE_DELAY = ["%s ms" % x for x in range(0, 1010, 10)]
|
|
LIST_5TONE_RESET = ["%s ms" % x for x in range(100, 8100, 100)]
|
|
LIST_5TONE_RESET_COLOR = ["%s ms" % x for x in range(100, 20100, 100)]
|
|
LIST_DTMF_SPEED = ["%s ms" % x for x in range(50, 2010, 10)]
|
|
LIST_DTMF_DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
|
|
"C", "D", "#", "*"]
|
|
LIST_DTMF_VALUES = [0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
|
0x0D, 0x0E, 0x0F, 0x00, 0x0C, 0x0B]
|
|
LIST_DTMF_SPECIAL_DIGITS = ["*", "#", "A", "B", "C", "D"]
|
|
LIST_DTMF_SPECIAL_VALUES = [0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00]
|
|
LIST_DTMF_DELAY = ["%s ms" % x for x in range(100, 4100, 100)]
|
|
CHARSET_DTMF_DIGITS = "0123456789AaBbCcDd#*"
|
|
LIST_2TONE_DEC = ["A-B", "A-C", "A-D",
|
|
"B-A", "B-C", "B-D",
|
|
"C-A", "C-B", "C-D",
|
|
"D-A", "D-B", "D-C"]
|
|
LIST_2TONE_RESPONSE = ["None", "Alert", "Transpond", "Alert+Transpond"]
|
|
|
|
# This is a general serial timeout for all serial read functions.
|
|
STIMEOUT = 0.25
|
|
|
|
# this var controls the verbosity in the debug and by default it's low (False)
|
|
# make it True and you will to get a very verbose debug.log
|
|
debug = True ##False
|
|
|
|
# valid chars on the LCD, Note that " " (space) is stored as "\xFF"
|
|
VALID_CHARS = chirp_common.CHARSET_ALPHANUMERIC + \
|
|
"`{|}!\"#$%&'()*+,-./:;<=>?@[]^_"
|
|
|
|
GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
|
|
462.6875, 462.7125]
|
|
GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
|
|
467.6875, 467.7125]
|
|
GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
|
|
462.6750, 462.7000, 462.7250]
|
|
GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
|
|
|
|
|
|
# #### ID strings #####################################################
|
|
|
|
# BTECH UV2501 pre-production units
|
|
UV2501pp_fp = "M2C294"
|
|
# BTECH UV2501 pre-production units 2 + and 1st Gen radios
|
|
UV2501pp2_fp = "M29204"
|
|
# B-TECH UV-2501 second generation (2G) radios
|
|
UV2501G2_fp = "BTG214"
|
|
# B-TECH UV-2501 third generation (3G) radios
|
|
UV2501G3_fp = "BTG324"
|
|
|
|
# B-TECH UV-2501+220 pre-production units
|
|
UV2501_220pp_fp = "M3C281"
|
|
# B-TECH UV-2501+220
|
|
UV2501_220_fp = "M3G201"
|
|
# new variant, let's call it Generation 2
|
|
UV2501_220G2_fp = "BTG211"
|
|
# B-TECH UV-2501+220 third generation (3G)
|
|
UV2501_220G3_fp = "BTG311"
|
|
|
|
# B-TECH UV-5001 pre-production units + 1st Gen radios
|
|
UV5001pp_fp = "V19204"
|
|
# B-TECH UV-5001 alpha units
|
|
UV5001alpha_fp = "V28204"
|
|
# B-TECH UV-5001 second generation (2G) radios
|
|
UV5001G2_fp = "BTG214"
|
|
# B-TECH UV-5001 second generation (2G2)
|
|
UV5001G22_fp = "V2G204"
|
|
# B-TECH UV-5001 third generation (3G)
|
|
UV5001G3_fp = "BTG304"
|
|
|
|
# B-TECH UV-25X2
|
|
UV25X2_fp = "UC2012"
|
|
|
|
# B-TECH UV-25X4
|
|
UV25X4_fp = "UC4014"
|
|
|
|
# B-TECH UV-50X2
|
|
UV50X2_fp = "UC2M12"
|
|
|
|
# B-TECH GMRS-50X1
|
|
GMRS50X1_fp = "NC1802"
|
|
GMRS50X1_fp1 = "NC1932"
|
|
|
|
# B-TECH GMRS-20V2
|
|
GMRS20V2_fp = "WP4204"
|
|
|
|
# special var to know when we found a BTECH Gen 3
|
|
BTECH3 = [UV2501G3_fp, UV2501_220G3_fp, UV5001G3_fp]
|
|
|
|
|
|
# WACCOM Mini-8900
|
|
MINI8900_fp = "M28854"
|
|
|
|
|
|
# QYT KT-UV980
|
|
KTUV980_fp = "H28854"
|
|
|
|
# QYT KT8900
|
|
KT8900_fp = "M29154"
|
|
# New generations KT8900
|
|
KT8900_fp1 = "M2C234"
|
|
KT8900_fp2 = "M2G1F4"
|
|
KT8900_fp3 = "M2G2F4"
|
|
KT8900_fp4 = "M2G304"
|
|
KT8900_fp5 = "M2G314"
|
|
KT8900_fp6 = "M2G424"
|
|
KT8900_fp7 = "M27184"
|
|
|
|
# KT8900R
|
|
KT8900R_fp = "M3G1F4"
|
|
# Second Generation
|
|
KT8900R_fp1 = "M3G214"
|
|
# another model
|
|
KT8900R_fp2 = "M3C234"
|
|
# another model G4?
|
|
KT8900R_fp3 = "M39164"
|
|
# another model
|
|
KT8900R_fp4 = "M3G314"
|
|
# AC3MB: another id
|
|
KT8900R_fp5 = "M3B064"
|
|
|
|
# KT7900D (quad band)
|
|
KT7900D_fp = "VC4004"
|
|
KT7900D_fp1 = "VC4284"
|
|
KT7900D_fp2 = "VC4264"
|
|
KT7900D_fp3 = "VC4114"
|
|
KT7900D_fp4 = "VC4104"
|
|
KT7900D_fp5 = "VC4254"
|
|
KT7900D_fp6 = "VC5264"
|
|
KT7900D_fp7 = "VC9204"
|
|
|
|
# QB25 (quad band) - a clone of KT7900D
|
|
QB25_fp = "QB-25"
|
|
|
|
# KT8900D (dual band)
|
|
KT8900D_fp = "VC2002"
|
|
KT8900D_fp1 = "VC8632"
|
|
KT8900D_fp2 = "VC3402"
|
|
KT8900D_fp3 = "VC7062"
|
|
|
|
# LUITON LT-588UV
|
|
LT588UV_fp = "V2G1F4"
|
|
# Added by rstrickoff gen 2 id
|
|
LT588UV_fp1 = "V2G214"
|
|
|
|
# QYT KT-8R (quad band ht)
|
|
KT8R_fp = "MCB264"
|
|
KT8R_fp1 = "MCB284"
|
|
KT8R_fp2 = "MC5264"
|
|
|
|
# QYT KT5800 (dual band)
|
|
KT5800_fp = "VCB222"
|
|
|
|
# QYT KT980Plus (dual band)
|
|
KT980PLUS_fp = "VC2002"
|
|
KT980PLUS_fp1 = "VC6042"
|
|
|
|
# Radioddity DB25-G (gmrs)
|
|
DB25G_fp = "VC6182"
|
|
DB25G_fp1 = "VC7062"
|
|
|
|
# Anysecu WP-9900
|
|
WP9900_fp = "WP3094"
|
|
|
|
|
|
# ### MAGICS
|
|
# for the Waccom Mini-8900
|
|
MSTRING_MINI8900 = "\x55\xA5\xB5\x45\x55\x45\x4d\x02"
|
|
# for the B-TECH UV-2501+220 (including pre production ones)
|
|
MSTRING_220 = "\x55\x20\x15\x12\x12\x01\x4d\x02"
|
|
# for the QYT KT8900 & R
|
|
MSTRING_KT8900 = "\x55\x20\x15\x09\x16\x45\x4D\x02"
|
|
MSTRING_KT8900R = "\x55\x20\x15\x09\x25\x01\x4D\x02"
|
|
# magic string for all other models
|
|
MSTRING = "\x55\x20\x15\x09\x20\x45\x4d\x02"
|
|
# for the QYT KT7900D & KT8900D
|
|
MSTRING_KT8900D = "\x55\x20\x16\x08\x01\xFF\xDC\x02"
|
|
# for the BTECH UV-25X2 and UV-50X2
|
|
MSTRING_UV25X2 = "\x55\x20\x16\x12\x28\xFF\xDC\x02"
|
|
# for the BTECH UV-25X4
|
|
MSTRING_UV25X4 = "\x55\x20\x16\x11\x18\xFF\xDC\x02"
|
|
# for the BTECH GMRS-50X1
|
|
MSTRING_GMRS50X1 = "\x55\x20\x18\x10\x18\xFF\xDC\x02"
|
|
# for the BTECH GMRS-20V2
|
|
MSTRING_GMRS20V2 = "\x55\x20\x21\x03\x27\xFF\xDC\x02"
|
|
# for the QYT KT-8R
|
|
MSTRING_KT8R = "\x55\x20\x17\x07\x03\xFF\xDC\x02"
|
|
# for the Anysecu WP-9900
|
|
MSTRING_WP9900 = "\x55\x20\x18\x11\x02\xFF\xDC\x02"
|
|
|
|
|
|
def _clean_buffer(radio):
|
|
"""Cleaning the read serial buffer, hard timeout to survive an infinite
|
|
data stream"""
|
|
|
|
# touching the serial timeout to optimize the flushing
|
|
# restored at the end to the default value
|
|
radio.pipe.timeout = 0.1
|
|
dump = "1"
|
|
datacount = 0
|
|
|
|
try:
|
|
while len(dump) > 0:
|
|
dump = radio.pipe.read(100)
|
|
datacount += len(dump)
|
|
# hard limit to survive a infinite serial data stream
|
|
# 5 times bigger than a normal rx block (69 bytes)
|
|
if datacount > 345:
|
|
seriale = "Please check your serial port selection."
|
|
raise errors.RadioError(seriale)
|
|
|
|
# restore the default serial timeout
|
|
radio.pipe.timeout = STIMEOUT
|
|
|
|
except Exception:
|
|
raise errors.RadioError("Unknown error cleaning the serial buffer")
|
|
|
|
|
|
def _rawrecv(radio, amount):
|
|
"""Raw read from the radio device, less intensive way"""
|
|
|
|
data = ""
|
|
|
|
try:
|
|
data = radio.pipe.read(amount)
|
|
|
|
# DEBUG
|
|
if debug is True:
|
|
LOG.debug("<== (%d) bytes:\n\n%s" %
|
|
(len(data), util.hexprint(data)))
|
|
|
|
# fail if no data is received
|
|
if len(data) == 0:
|
|
raise errors.RadioError("No data received from radio")
|
|
|
|
# notice on the logs if short
|
|
if len(data) < amount:
|
|
LOG.warn("Short reading %d bytes from the %d requested." %
|
|
(len(data), amount))
|
|
|
|
except:
|
|
raise errors.RadioError("Error reading data from radio")
|
|
|
|
return data
|
|
|
|
|
|
def _send(radio, data):
|
|
"""Send data to the radio device"""
|
|
|
|
try:
|
|
radio.pipe.write(data)
|
|
|
|
# DEBUG
|
|
if debug is True:
|
|
LOG.debug("==> (%d) bytes:\n\n%s" %
|
|
(len(data), util.hexprint(data)))
|
|
except:
|
|
raise errors.RadioError("Error sending data to radio")
|
|
|
|
|
|
def _make_frame(cmd, addr, length, data=""):
|
|
"""Pack the info in the headder format"""
|
|
frame = "\x06" + struct.pack(">BHB", ord(cmd), addr, length)
|
|
# add the data if set
|
|
if len(data) != 0:
|
|
frame += data
|
|
|
|
return frame
|
|
|
|
|
|
def _recv(radio, addr):
|
|
"""Get data from the radio all at once to lower syscalls load"""
|
|
|
|
# Get the full 69 bytes at a time to reduce load
|
|
# 1 byte ACK + 4 bytes header + 64 bytes of data (BLOCK_SIZE)
|
|
|
|
# get the whole block
|
|
block = _rawrecv(radio, BLOCK_SIZE + 5)
|
|
|
|
# basic check
|
|
if len(block) < (BLOCK_SIZE + 5):
|
|
raise errors.RadioError("Short read of the block 0x%04x" % addr)
|
|
|
|
# checking for the ack
|
|
if block[0] != ACK_CMD:
|
|
raise errors.RadioError("Bad ack from radio in block 0x%04x" % addr)
|
|
|
|
# header validation
|
|
c, a, l = struct.unpack(">BHB", block[1:5])
|
|
if a != addr or l != BLOCK_SIZE or c != ord("X"):
|
|
LOG.debug("Invalid header for block 0x%04x" % addr)
|
|
LOG.debug("CMD: %s ADDR: %04x SIZE: %02x" % (c, a, l))
|
|
raise errors.RadioError("Invalid header for block 0x%04x:" % addr)
|
|
|
|
# return the data
|
|
return block[5:]
|
|
|
|
|
|
def _do_ident(radio, status, upload=False):
|
|
"""Put the radio in PROGRAM mode & identify it"""
|
|
# set the serial discipline
|
|
radio.pipe.baudrate = 9600
|
|
radio.pipe.parity = "N"
|
|
|
|
# lengthen the timeout here as these radios are reseting due to timeout
|
|
radio.pipe.timeout = 0.75
|
|
|
|
# send the magic word
|
|
_send(radio, radio._magic)
|
|
|
|
# Now you get a 50 byte reply if all goes well
|
|
ident = _rawrecv(radio, 50)
|
|
|
|
# checking for the ack
|
|
if ident[0] != ACK_CMD:
|
|
raise errors.RadioError("Bad ack from radio")
|
|
|
|
# basic check for the ident block
|
|
if len(ident) != 50:
|
|
raise errors.RadioError("Radio send a short ident block.")
|
|
|
|
# check if ident is OK
|
|
itis = False
|
|
for fp in radio._fileid:
|
|
if fp in ident:
|
|
# got it!
|
|
itis = True
|
|
# checking if we are dealing with a Gen 3 BTECH
|
|
if radio.VENDOR == "BTECH" and fp in BTECH3:
|
|
radio.btech3 = True
|
|
|
|
break
|
|
|
|
if itis is False:
|
|
LOG.debug("Incorrect model ID, got this:\n\n" + util.hexprint(ident))
|
|
raise errors.RadioError("Radio identification failed.")
|
|
|
|
# pause here for the radio to catch up
|
|
sleep(0.1)
|
|
|
|
# the OEM software reads this additional block, so we will, too
|
|
|
|
# Get the full 21 bytes at a time to reduce load
|
|
# 1 byte ACK + 4 bytes header + 16 bytes of data (BLOCK_SIZE)
|
|
frame = _make_frame("S", 0x3DF0, 16)
|
|
_send(radio, frame)
|
|
id2 = _rawrecv(radio, 21)
|
|
|
|
# restore the default serial timeout
|
|
radio.pipe.timeout = STIMEOUT
|
|
|
|
# checking for the ack
|
|
if id2[0] not in "\x06\x05":
|
|
raise errors.RadioError("Bad ack from radio")
|
|
|
|
# basic check for the additional block
|
|
if len(id2) < 21:
|
|
raise errors.RadioError("The extra ID is short, aborting.")
|
|
|
|
# this radios need a extra request/answer here on the upload
|
|
# the amount of data received depends of the radio type
|
|
#
|
|
# also the first block of TX must no have the ACK at the beginning
|
|
# see _upload for this.
|
|
if upload is True:
|
|
# send an ACK
|
|
_send(radio, ACK_CMD)
|
|
|
|
# the amount of data depend on the radio, so far we have two radios
|
|
# reading two bytes with an ACK at the end and just ONE with just
|
|
# one byte (QYT KT8900)
|
|
# the JT-6188 appears a clone of the last, but reads TWO bytes.
|
|
#
|
|
# we will read two bytes with a custom timeout to not penalize the
|
|
# users for this.
|
|
#
|
|
# we just check for a response and last byte being a ACK, that is
|
|
# the common stone for all radios (3 so far)
|
|
ack = _rawrecv(radio, 2)
|
|
|
|
# checking
|
|
if len(ack) == 0 or ack[-1:] != ACK_CMD:
|
|
raise errors.RadioError("Radio didn't ACK the upload")
|
|
|
|
# DEBUG
|
|
LOG.info("Positive ident, this is a %s %s" % (radio.VENDOR, radio.MODEL))
|
|
|
|
return True
|
|
|
|
|
|
def _download(radio):
|
|
"""Get the memory map"""
|
|
|
|
# UI progress
|
|
status = chirp_common.Status()
|
|
|
|
# put radio in program mode and identify it
|
|
_do_ident(radio, status)
|
|
|
|
# reset the progress bar in the UI
|
|
status.max = MEM_SIZE / BLOCK_SIZE
|
|
status.msg = "Cloning from radio..."
|
|
status.cur = 0
|
|
radio.status_fn(status)
|
|
|
|
data = ""
|
|
for addr in range(0, MEM_SIZE, BLOCK_SIZE):
|
|
# sending the read request
|
|
_send(radio, _make_frame("S", addr, BLOCK_SIZE))
|
|
|
|
# read
|
|
d = _recv(radio, addr)
|
|
|
|
# aggregate the data
|
|
data += d
|
|
|
|
# UI Update
|
|
status.cur = addr / BLOCK_SIZE
|
|
status.msg = "Cloning from radio..."
|
|
radio.status_fn(status)
|
|
|
|
return data
|
|
|
|
|
|
def _upload(radio):
|
|
"""Upload procedure"""
|
|
|
|
## uploads not implemented
|
|
|
|
|
|
def model_match(cls, data):
|
|
"""Match the opened/downloaded image to the correct version"""
|
|
rid = data[0x3f70:0x3f76]
|
|
|
|
if rid in cls._fileid:
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
def _decode_ranges(low, high):
|
|
"""Unpack the data in the ranges zones in the memmap and return
|
|
a tuple with the integer corresponding to the Mhz it means"""
|
|
ilow = int(low[0]) * 100 + int(low[1]) * 10 + int(low[2])
|
|
ihigh = int(high[0]) * 100 + int(high[1]) * 10 + int(high[2])
|
|
ilow *= 1000000
|
|
ihigh *= 1000000
|
|
|
|
return (ilow, ihigh)
|
|
|
|
|
|
def _split(rf, f1, f2):
|
|
"""Returns False if the two freqs are in the same band (no split)
|
|
or True otherwise"""
|
|
|
|
# determine if the two freqs are in the same band
|
|
for low, high in rf.valid_bands:
|
|
if f1 >= low and f1 <= high and \
|
|
f2 >= low and f2 <= high:
|
|
# if the two freqs are on the same Band this is not a split
|
|
return False
|
|
|
|
# if you get here is because the freq pairs are split
|
|
return True
|
|
|
|
|
|
class BTechMobileCommon(chirp_common.CloneModeRadio,
|
|
chirp_common.ExperimentalRadio):
|
|
"""BTECH's UV-5001 and alike radios"""
|
|
VENDOR = "BTECH"
|
|
MODEL = ""
|
|
IDENT = ""
|
|
BANDS = 2
|
|
COLOR_LCD = False
|
|
COLOR_LCD2 = False # BTech Original GMRS Radios
|
|
COLOR_LCD3 = False # Color HT Radios
|
|
COLOR_LCD4 = False # Waterproof Mobile Radios
|
|
NAME_LENGTH = 6
|
|
UPLOAD_MEM_SIZE = 0X3100
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=25),
|
|
chirp_common.PowerLevel("Low", watts=10)]
|
|
_vhf_range = (130000000, 180000000)
|
|
_220_range = (200000000, 271000000)
|
|
_uhf_range = (400000000, 521000000)
|
|
_350_range = (350000000, 391000000)
|
|
_upper = 199
|
|
_magic = MSTRING
|
|
_fileid = None
|
|
_id2 = False
|
|
btech3 = False
|
|
_gmrs = False
|
|
|
|
@classmethod
|
|
def get_prompts(cls):
|
|
rp = chirp_common.RadioPrompts()
|
|
rp.experimental = \
|
|
('This driver is experimental.\n'
|
|
'\n'
|
|
'Please keep a copy of your memories with the original software '
|
|
'if you treasure them, this driver is new and may contain'
|
|
' bugs.\n'
|
|
'\n'
|
|
)
|
|
rp.pre_download = _(dedent("""\
|
|
Follow these instructions to download your info:
|
|
|
|
1 - Turn off your radio
|
|
2 - Connect your interface cable
|
|
3 - Turn on your radio
|
|
4 - Do the download of your radio data
|
|
|
|
"""))
|
|
rp.pre_upload = _(dedent("""\
|
|
Follow these instructions to upload your info:
|
|
|
|
1 - Turn off your radio
|
|
2 - Connect your interface cable
|
|
3 - Turn on your radio
|
|
4 - Do the upload of your radio data
|
|
|
|
"""))
|
|
return rp
|
|
|
|
def get_features(self):
|
|
"""Get the radio's features"""
|
|
|
|
# we will use the following var as global
|
|
global POWER_LEVELS
|
|
|
|
rf = chirp_common.RadioFeatures()
|
|
rf.has_settings = False ##
|
|
rf.has_bank = False
|
|
rf.has_tuning_step = False
|
|
rf.can_odd_split = True
|
|
rf.has_name = True
|
|
rf.has_offset = True
|
|
rf.has_mode = True
|
|
rf.has_dtcs = True
|
|
rf.has_rx_dtcs = True
|
|
rf.has_dtcs_polarity = True
|
|
rf.has_ctone = True
|
|
rf.has_cross = True
|
|
rf.valid_modes = MODES
|
|
rf.valid_characters = VALID_CHARS
|
|
rf.valid_name_length = self.NAME_LENGTH
|
|
rf.valid_duplexes = ["", "-", "+", "split", "off"]
|
|
rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
|
|
rf.valid_cross_modes = [
|
|
"Tone->Tone",
|
|
"DTCS->",
|
|
"->DTCS",
|
|
"Tone->DTCS",
|
|
"DTCS->Tone",
|
|
"->Tone",
|
|
"DTCS->DTCS"]
|
|
rf.valid_skips = SKIP_VALUES
|
|
rf.valid_dtcs_codes = DTCS
|
|
rf.valid_tuning_steps = STEPS
|
|
rf.memory_bounds = (0, self._upper)
|
|
|
|
# power levels
|
|
POWER_LEVELS = self._power_levels
|
|
rf.valid_power_levels = POWER_LEVELS
|
|
|
|
# normal dual bands
|
|
rf.valid_bands = [self._vhf_range, self._uhf_range]
|
|
|
|
# 220 band
|
|
if self.BANDS == 3 or self.BANDS == 4:
|
|
rf.valid_bands.append(self._220_range)
|
|
|
|
# 350 band
|
|
if self.BANDS == 4:
|
|
rf.valid_bands.append(self._350_range)
|
|
|
|
return rf
|
|
|
|
def validate_memory(self, mem):
|
|
msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)
|
|
|
|
_msg_duplex1 = 'Memory location only supports "Low"'
|
|
_msg_duplex2 = 'Memory location only supports "off"'
|
|
_msg_duplex3 = 'Memory location only supports "(None)", "+" or "off"'
|
|
|
|
## need to evaluate this code
|
|
"""
|
|
if self._gmrs:
|
|
if mem.number < 1 or mem.number > 30:
|
|
if float(mem.freq) / 1000000 in GMRS_FREQS1:
|
|
if mem.duplex not in ['', 'off']:
|
|
# warn user wrong Duplex
|
|
msgs.append(chirp_common.ValidationError(_msg_duplex2))
|
|
if mem.power != self._power_levels[2]:
|
|
# warn user wrong Duplex
|
|
msgs.append(chirp_common.ValidationError(_msg_duplex1))
|
|
|
|
if float(mem.freq) / 1000000 in GMRS_FREQS2:
|
|
if mem.duplex not in ['off', ]:
|
|
# warn user wrong Duplex
|
|
msgs.append(chirp_common.ValidationError(_msg_duplex2))
|
|
|
|
if float(mem.freq) / 1000000 in GMRS_FREQS3:
|
|
if mem.duplex not in ['', '+', 'off']:
|
|
# warn user wrong Duplex
|
|
msgs.append(chirp_common.ValidationError(_msg_duplex3))
|
|
"""
|
|
|
|
return msgs
|
|
|
|
def sync_in(self):
|
|
"""Download from radio"""
|
|
data = _download(self)
|
|
self._mmap = memmap.MemoryMap(data)
|
|
self.process_mmap()
|
|
|
|
def sync_out(self):
|
|
"""Upload to radio"""
|
|
try:
|
|
_upload(self)
|
|
except errors.RadioError:
|
|
raise
|
|
except Exception, e:
|
|
raise errors.RadioError("Error: %s" % e)
|
|
|
|
def get_raw_memory(self, number):
|
|
return repr(self._memobj.memory[number])
|
|
|
|
def _decode_tone(self, val):
|
|
"""Parse the tone data to decode from mem, it returns:
|
|
Mode (''|DTCS|Tone), Value (None|###), Polarity (None,N,R)"""
|
|
pol = None
|
|
|
|
if val in [0, 65535]:
|
|
return '', None, None
|
|
elif val > 0x0258:
|
|
a = val / 10.0
|
|
return 'Tone', a, pol
|
|
else:
|
|
if val > 0x69:
|
|
index = val - 0x6A
|
|
pol = "R"
|
|
else:
|
|
index = val - 1
|
|
pol = "N"
|
|
|
|
tone = DTCS[index]
|
|
return 'DTCS', tone, pol
|
|
|
|
def _encode_tone(self, memval, mode, val, pol):
|
|
"""Parse the tone data to encode from UI to mem"""
|
|
if mode == '' or mode is None:
|
|
memval.set_raw("\x00\x00")
|
|
elif mode == 'Tone':
|
|
memval.set_value(val * 10)
|
|
elif mode == 'DTCS':
|
|
# detect the index in the DTCS list
|
|
try:
|
|
index = DTCS.index(val)
|
|
if pol == "N":
|
|
index += 1
|
|
else:
|
|
index += 0x6A
|
|
memval.set_value(index)
|
|
except:
|
|
msg = "Digital Tone '%d' is not supported" % value
|
|
LOG.error(msg)
|
|
raise errors.RadioError(msg)
|
|
else:
|
|
msg = "Internal error: invalid mode '%s'" % mode
|
|
LOG.error(msg)
|
|
raise errors.InvalidDataError(msg)
|
|
|
|
def get_memory(self, number):
|
|
"""Get the mem representation from the radio image"""
|
|
_mem = self._memobj.memory[number]
|
|
_names = self._memobj.names[number]
|
|
|
|
# Create a high-level memory object to return to the UI
|
|
mem = chirp_common.Memory()
|
|
|
|
# Memory number
|
|
mem.number = number
|
|
|
|
if _mem.get_raw()[0] == "\xFF":
|
|
mem.empty = True
|
|
return mem
|
|
|
|
# Freq and offset
|
|
mem.freq = int(_mem.rxfreq) * 10
|
|
# tx freq can be blank
|
|
if _mem.get_raw()[4] == "\xFF":
|
|
# TX freq not set
|
|
mem.offset = 0
|
|
mem.duplex = "off"
|
|
else:
|
|
# TX freq set
|
|
offset = (int(_mem.txfreq) * 10) - mem.freq
|
|
if offset != 0:
|
|
if _split(self.get_features(), mem.freq, int(
|
|
_mem.txfreq) * 10):
|
|
mem.duplex = "split"
|
|
mem.offset = int(_mem.txfreq) * 10
|
|
elif offset < 0:
|
|
mem.offset = abs(offset)
|
|
mem.duplex = "-"
|
|
elif offset > 0:
|
|
mem.offset = offset
|
|
mem.duplex = "+"
|
|
else:
|
|
mem.offset = 0
|
|
|
|
# name TAG of the channel
|
|
mem.name = str(_names.name).rstrip("\xFF").replace("\xFF", " ")
|
|
|
|
# power
|
|
mem.power = POWER_LEVELS[int(_mem.power)]
|
|
|
|
# wide/narrow
|
|
mem.mode = MODES[int(_mem.wide)]
|
|
|
|
# skip
|
|
mem.skip = SKIP_VALUES[_mem.add]
|
|
|
|
# tone data
|
|
rxtone = txtone = None
|
|
txtone = self._decode_tone(_mem.txtone)
|
|
rxtone = self._decode_tone(_mem.rxtone)
|
|
chirp_common.split_tone_decode(mem, txtone, rxtone)
|
|
|
|
# Extra
|
|
mem.extra = RadioSettingGroup("extra", "Extra")
|
|
|
|
if not self.COLOR_LCD or \
|
|
(self.COLOR_LCD and not self.VENDOR == "BTECH"):
|
|
scramble = RadioSetting("scramble", "Scramble",
|
|
RadioSettingValueBoolean(bool(
|
|
_mem.scramble)))
|
|
mem.extra.append(scramble)
|
|
|
|
bcl = RadioSetting("bcl", "Busy channel lockout",
|
|
RadioSettingValueBoolean(bool(_mem.bcl)))
|
|
mem.extra.append(bcl)
|
|
|
|
pttid = RadioSetting("pttid", "PTT ID",
|
|
RadioSettingValueList(PTTID_LIST,
|
|
PTTID_LIST[_mem.pttid]))
|
|
mem.extra.append(pttid)
|
|
|
|
# validating scode
|
|
scode = _mem.scode if _mem.scode != 15 else 0
|
|
pttidcode = RadioSetting("scode", "PTT ID signal code",
|
|
RadioSettingValueList(
|
|
PTTIDCODE_LIST,
|
|
PTTIDCODE_LIST[scode]))
|
|
mem.extra.append(pttidcode)
|
|
|
|
optsig = RadioSetting("optsig", "Optional signaling",
|
|
RadioSettingValueList(
|
|
OPTSIG_LIST,
|
|
OPTSIG_LIST[_mem.optsig]))
|
|
mem.extra.append(optsig)
|
|
|
|
spmute = RadioSetting("spmute", "Speaker mute",
|
|
RadioSettingValueList(
|
|
SPMUTE_LIST,
|
|
SPMUTE_LIST[_mem.spmute]))
|
|
mem.extra.append(spmute)
|
|
|
|
return mem
|
|
|
|
def set_memory(self, mem):
|
|
"""Set the memory data in the eeprom img from the UI"""
|
|
# get the eprom representation of this channel
|
|
_mem = self._memobj.memory[mem.number]
|
|
_names = self._memobj.names[mem.number]
|
|
|
|
mem_was_empty = False
|
|
# same method as used in get_memory for determining if mem is empty
|
|
# doing this BEFORE overwriting it with new values ...
|
|
if _mem.get_raw()[0] == "\xFF":
|
|
LOG.debug("This mem was empty before")
|
|
mem_was_empty = True
|
|
|
|
# if empty memmory
|
|
if mem.empty:
|
|
# the channel itself
|
|
_mem.set_raw("\xFF" * 16)
|
|
# the name tag
|
|
_names.set_raw("\xFF" * 16)
|
|
return
|
|
|
|
if mem_was_empty:
|
|
# Zero the whole memory if we're making it unempty for
|
|
# the first time
|
|
LOG.debug('Zeroing new memory')
|
|
_mem.set_raw('\x00' * 16)
|
|
|
|
if self._gmrs:
|
|
if mem.number >= 1 and mem.number <= 30:
|
|
GMRS_FREQ = int(GMRS_FREQS[mem.number - 1] * 1000000)
|
|
mem.freq = GMRS_FREQ
|
|
if mem.number <= 22:
|
|
mem.duplex = ''
|
|
mem.offset = 0
|
|
mem.mode = "FM"
|
|
mem.power = POWER_LEVELS[0]
|
|
if mem.number >= 8 and mem.number <= 14:
|
|
mem.duplex = 'off'
|
|
mem.offset = 0
|
|
mem.mode = "NFM"
|
|
mem.power = POWER_LEVELS[2]
|
|
if mem.number > 22:
|
|
mem.duplex = '+'
|
|
mem.offset = 5000000
|
|
mem.mode = "FM"
|
|
mem.power = POWER_LEVELS[0]
|
|
elif float(mem.freq) / 1000000 in GMRS_FREQS:
|
|
if float(mem.freq) / 1000000 in GMRS_FREQS1:
|
|
mem.duplex = ''
|
|
mem.offset = 0
|
|
mem.mode = "FM"
|
|
mem.power = POWER_LEVELS[0]
|
|
if float(mem.freq) / 1000000 in GMRS_FREQS2:
|
|
mem.duplex = 'off'
|
|
mem.offset = 0
|
|
mem.mode = "NFM"
|
|
mem.power = POWER_LEVELS[2]
|
|
if float(mem.freq) / 1000000 in GMRS_FREQS3:
|
|
if mem.duplex == '+':
|
|
mem.offset = 5000000
|
|
else:
|
|
mem.offset = 0
|
|
mem.mode = "FM"
|
|
mem.power = POWER_LEVELS[0]
|
|
else:
|
|
mem.duplex = 'off'
|
|
mem.offset = 0
|
|
|
|
# frequency
|
|
_mem.rxfreq = mem.freq / 10
|
|
|
|
# duplex
|
|
if mem.duplex == "+":
|
|
_mem.txfreq = (mem.freq + mem.offset) / 10
|
|
elif mem.duplex == "-":
|
|
_mem.txfreq = (mem.freq - mem.offset) / 10
|
|
elif mem.duplex == "off":
|
|
for i in _mem.txfreq:
|
|
i.set_raw("\xFF")
|
|
elif mem.duplex == "split":
|
|
_mem.txfreq = mem.offset / 10
|
|
else:
|
|
_mem.txfreq = mem.freq / 10
|
|
|
|
# tone data
|
|
((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \
|
|
chirp_common.split_tone_encode(mem)
|
|
self._encode_tone(_mem.txtone, txmode, txtone, txpol)
|
|
self._encode_tone(_mem.rxtone, rxmode, rxtone, rxpol)
|
|
|
|
# name TAG of the channel
|
|
if len(mem.name) < self.NAME_LENGTH:
|
|
# we must pad to self.NAME_LENGTH chars, " " = "\xFF"
|
|
mem.name = str(mem.name).ljust(self.NAME_LENGTH, " ")
|
|
_names.name = str(mem.name).replace(" ", "\xFF")
|
|
|
|
# power, # default power level is high
|
|
_mem.power = 0 if mem.power is None else POWER_LEVELS.index(mem.power)
|
|
|
|
# wide/narrow
|
|
_mem.wide = MODES.index(mem.mode)
|
|
|
|
# scan add property
|
|
_mem.add = SKIP_VALUES.index(mem.skip)
|
|
|
|
# reseting unknowns, this have to be set by hand
|
|
_mem.unknown0 = 0
|
|
_mem.unknown1 = 0
|
|
_mem.unknown2 = 0
|
|
_mem.unknown3 = 0
|
|
_mem.unknown4 = 0
|
|
_mem.unknown5 = 0
|
|
_mem.unknown6 = 0
|
|
|
|
def _zero_settings():
|
|
_mem.spmute = 0
|
|
_mem.optsig = 0
|
|
_mem.scramble = 0
|
|
_mem.bcl = 0
|
|
_mem.pttid = 0
|
|
_mem.scode = 0
|
|
|
|
if self.COLOR_LCD and _mem.scramble:
|
|
LOG.info('Resetting scramble bit for BTECH COLOR_LCD variant')
|
|
_mem.scramble = 0
|
|
|
|
# extra settings
|
|
if len(mem.extra) > 0:
|
|
# there are setting, parse
|
|
LOG.debug("Extra-Setting supplied. Setting them.")
|
|
# Zero them all first so any not provided by model don't
|
|
# stay set
|
|
_zero_settings()
|
|
for setting in mem.extra:
|
|
setattr(_mem, setting.get_name(), setting.value)
|
|
else:
|
|
if mem.empty:
|
|
LOG.debug("New mem is empty.")
|
|
else:
|
|
LOG.debug("New mem is NOT empty")
|
|
# set extra-settings to default ONLY when apreviously empty or
|
|
# deleted memory was edited to prevent errors such as #4121
|
|
if mem_was_empty:
|
|
LOG.debug("old mem was empty. Setting default for extras.")
|
|
_zero_settings()
|
|
|
|
return mem
|
|
|
|
def set_settings(self, settings):
|
|
_settings = self._memobj.settings
|
|
for element in settings:
|
|
if not isinstance(element, RadioSetting):
|
|
if element.get_name() == "fm_preset":
|
|
self._set_fm_preset(element)
|
|
else:
|
|
self.set_settings(element)
|
|
continue
|
|
else:
|
|
try:
|
|
name = element.get_name()
|
|
if "." in name:
|
|
bits = name.split(".")
|
|
obj = self._memobj
|
|
for bit in bits[:-1]:
|
|
if "/" in bit:
|
|
bit, index = bit.split("/", 1)
|
|
index = int(index)
|
|
obj = getattr(obj, bit)[index]
|
|
else:
|
|
obj = getattr(obj, bit)
|
|
setting = bits[-1]
|
|
else:
|
|
obj = _settings
|
|
setting = element.get_name()
|
|
|
|
if element.has_apply_callback():
|
|
LOG.debug("Using apply callback")
|
|
element.run_apply_callback()
|
|
elif setting == "volume" and self.MODEL == "WP-9900":
|
|
setattr(obj, setting, int(element.value) - 1)
|
|
elif element.value.get_mutable():
|
|
LOG.debug("Setting %s = %s" % (setting, element.value))
|
|
setattr(obj, setting, element.value)
|
|
except Exception, e:
|
|
LOG.debug(element.get_name())
|
|
raise
|
|
|
|
@classmethod
|
|
def match_model(cls, filedata, filename):
|
|
match_size = False
|
|
match_model = False
|
|
|
|
# testing the file data size
|
|
if len(filedata) == MEM_SIZE:
|
|
match_size = True
|
|
|
|
# testing the firmware model fingerprint
|
|
match_model = model_match(cls, filedata)
|
|
|
|
if match_size and match_model:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
MEM_FORMAT = """
|
|
#seekto 0x0000;
|
|
struct {
|
|
lbcd rxfreq[4];
|
|
lbcd txfreq[4];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 unknown0:4,
|
|
scode:4;
|
|
u8 unknown1:2,
|
|
spmute:2,
|
|
unknown2:2,
|
|
optsig:2;
|
|
u8 unknown3:3,
|
|
scramble:1,
|
|
unknown4:3,
|
|
power:1;
|
|
u8 unknown5:1,
|
|
wide:1,
|
|
unknown6:2,
|
|
bcl:1,
|
|
add:1,
|
|
pttid:2;
|
|
} memory[200];
|
|
|
|
#seekto 0x0E00;
|
|
struct {
|
|
u8 tdr;
|
|
u8 unknown1;
|
|
u8 sql;
|
|
u8 unknown2[2];
|
|
u8 tot;
|
|
u8 apo; // BTech radios use this as the Auto Power Off time
|
|
// other radios use this as pre-Time Out Alert
|
|
u8 unknown3;
|
|
u8 abr;
|
|
u8 beep;
|
|
u8 unknown4[4];
|
|
u8 dtmfst;
|
|
u8 unknown5[2];
|
|
u8 prisc;
|
|
u8 prich;
|
|
u8 screv;
|
|
u8 unknown6[2];
|
|
u8 pttid;
|
|
u8 pttlt;
|
|
u8 unknown7;
|
|
u8 emctp;
|
|
u8 emcch;
|
|
u8 ringt;
|
|
u8 unknown8;
|
|
u8 camdf;
|
|
u8 cbmdf;
|
|
u8 sync; // BTech radios use this as the display sync setting
|
|
// other radios use this as the auto keypad lock setting
|
|
u8 ponmsg;
|
|
u8 wtled;
|
|
u8 rxled;
|
|
u8 txled;
|
|
u8 unknown9[5];
|
|
u8 anil;
|
|
u8 reps;
|
|
u8 repm;
|
|
u8 tdrab;
|
|
u8 ste;
|
|
u8 rpste;
|
|
u8 rptdl;
|
|
u8 mgain;
|
|
u8 dtmfg;
|
|
} settings;
|
|
|
|
#seekto 0x0E80;
|
|
struct {
|
|
u8 unknown1;
|
|
u8 vfomr;
|
|
u8 keylock;
|
|
u8 unknown2;
|
|
u8 unknown3:4,
|
|
vfomren:1,
|
|
unknown4:1,
|
|
reseten:1,
|
|
menuen:1;
|
|
u8 unknown5[11];
|
|
u8 dispab;
|
|
u8 mrcha;
|
|
u8 mrchb;
|
|
u8 menu;
|
|
} settings2;
|
|
|
|
#seekto 0x0EC0;
|
|
struct {
|
|
char line1[6];
|
|
char line2[6];
|
|
} poweron_msg;
|
|
|
|
struct settings_vfo {
|
|
u8 freq[8];
|
|
u8 offset[6];
|
|
u8 unknown2[2];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 scode;
|
|
u8 spmute;
|
|
u8 optsig;
|
|
u8 scramble;
|
|
u8 wide;
|
|
u8 power;
|
|
u8 shiftd;
|
|
u8 step;
|
|
u8 unknown3[4];
|
|
};
|
|
|
|
#seekto 0x0F00;
|
|
struct {
|
|
struct settings_vfo a;
|
|
struct settings_vfo b;
|
|
} vfo;
|
|
|
|
#seekto 0x1000;
|
|
struct {
|
|
char name[6];
|
|
u8 unknown1[10];
|
|
} names[200];
|
|
|
|
#seekto 0x2400;
|
|
struct {
|
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
|
u8 group_tone;
|
|
u8 repeat_tone;
|
|
u8 unused[13];
|
|
} _5tone_std_settings[15];
|
|
|
|
#seekto 0x2500;
|
|
struct {
|
|
u8 frame1[5];
|
|
u8 frame2[5];
|
|
u8 frame3[5];
|
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
|
} _5tone_codes[15];
|
|
|
|
#seekto 0x25F0;
|
|
struct {
|
|
u8 _5tone_delay1; // * 10ms
|
|
u8 _5tone_delay2; // * 10ms
|
|
u8 _5tone_delay3; // * 10ms
|
|
u8 _5tone_first_digit_ext_length;
|
|
u8 unknown1;
|
|
u8 unknown2;
|
|
u8 unknown3;
|
|
u8 unknown4;
|
|
u8 decode_standard;
|
|
u8 unknown5:5,
|
|
_5tone_decode_call_frame3:1,
|
|
_5tone_decode_call_frame2:1,
|
|
_5tone_decode_call_frame1:1;
|
|
u8 unknown6:5,
|
|
_5tone_decode_disp_frame3:1,
|
|
_5tone_decode_disp_frame2:1,
|
|
_5tone_decode_disp_frame1:1;
|
|
u8 decode_reset_time; // * 100 + 100ms
|
|
} _5tone_settings;
|
|
|
|
#seekto 0x2900;
|
|
struct {
|
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
|
} dtmf_codes[15];
|
|
|
|
#seekto 0x29F0;
|
|
struct {
|
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
|
u8 unknown0[14];
|
|
u8 inspection[16];
|
|
u8 monitor[16];
|
|
u8 alarmcode[16];
|
|
u8 stun[16];
|
|
u8 kill[16];
|
|
u8 revive[16];
|
|
u8 unknown1[16];
|
|
u8 unknown2[16];
|
|
u8 unknown3[16];
|
|
u8 unknown4[16];
|
|
u8 unknown5[16];
|
|
u8 unknown6[16];
|
|
u8 unknown7[16];
|
|
u8 masterid[16];
|
|
u8 viceid[16];
|
|
u8 unused01:7,
|
|
mastervice:1;
|
|
u8 unused02:3,
|
|
mrevive:1,
|
|
mkill:1,
|
|
mstun:1,
|
|
mmonitor:1,
|
|
minspection:1;
|
|
u8 unused03:3,
|
|
vrevive:1,
|
|
vkill:1,
|
|
vstun:1,
|
|
vmonitor:1,
|
|
vinspection:1;
|
|
u8 unused04:6,
|
|
txdisable:1,
|
|
rxdisable:1;
|
|
u8 groupcode;
|
|
u8 spacecode;
|
|
u8 delayproctime; // * 100 + 100ms
|
|
u8 resettime; // * 100 + 100ms
|
|
} dtmf_settings;
|
|
|
|
#seekto 0x2D00;
|
|
struct {
|
|
struct {
|
|
ul16 freq1;
|
|
u8 unused01[6];
|
|
ul16 freq2;
|
|
u8 unused02[6];
|
|
} _2tone_encode[15];
|
|
u8 duration_1st_tone; // *10ms
|
|
u8 duration_2nd_tone; // *10ms
|
|
u8 duration_gap; // *10ms
|
|
u8 unused03[13];
|
|
struct {
|
|
struct {
|
|
u8 dec; // one out of LIST_2TONE_DEC
|
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
|
u8 alert; // 1-16
|
|
} decs[4];
|
|
u8 unused04[4];
|
|
} _2tone_decode[15];
|
|
u8 unused05[16];
|
|
|
|
struct {
|
|
ul16 freqA;
|
|
ul16 freqB;
|
|
ul16 freqC;
|
|
ul16 freqD;
|
|
// unknown what those values mean, but they are
|
|
// derived from configured frequencies
|
|
ul16 derived_from_freqA; // 2304000/freqA
|
|
ul16 derived_from_freqB; // 2304000/freqB
|
|
ul16 derived_from_freqC; // 2304000/freqC
|
|
ul16 derived_from_freqD; // 2304000/freqD
|
|
}freqs[15];
|
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
|
} _2tone;
|
|
|
|
#seekto 0x3000;
|
|
struct {
|
|
u8 freq[8];
|
|
char broadcast_station_name[6];
|
|
u8 unknown[2];
|
|
} fm_radio_preset[16];
|
|
|
|
#seekto 0x3C90;
|
|
struct {
|
|
u8 vhf_low[3];
|
|
u8 vhf_high[3];
|
|
u8 uhf_low[3];
|
|
u8 uhf_high[3];
|
|
} ranges;
|
|
|
|
// the UV-2501+220 & KT8900R has different zones for storing ranges
|
|
|
|
#seekto 0x3CD0;
|
|
struct {
|
|
u8 vhf_low[3];
|
|
u8 vhf_high[3];
|
|
u8 unknown1[4];
|
|
u8 unknown2[6];
|
|
u8 vhf2_low[3];
|
|
u8 vhf2_high[3];
|
|
u8 unknown3[4];
|
|
u8 unknown4[6];
|
|
u8 uhf_low[3];
|
|
u8 uhf_high[3];
|
|
} ranges220;
|
|
|
|
#seekto 0x3F70;
|
|
struct {
|
|
char fp[6];
|
|
} fingerprint;
|
|
|
|
"""
|
|
|
|
|
|
class BTech(BTechMobileCommon):
|
|
"""BTECH's UV-5001 and alike radios"""
|
|
BANDS = 2
|
|
COLOR_LCD = False
|
|
NAME_LENGTH = 6
|
|
|
|
def set_options(self):
|
|
"""This is to read the options from the image and set it in the
|
|
environment, for now just the limits of the freqs in the VHF/UHF
|
|
ranges"""
|
|
|
|
# setting the correct ranges for each radio type
|
|
if self.MODEL in ["UV-2501+220", "KT8900R"]:
|
|
# the model 2501+220 has a segment in 220
|
|
# and a different position in the memmap
|
|
# also the QYT KT8900R
|
|
ranges = self._memobj.ranges220
|
|
else:
|
|
ranges = self._memobj.ranges
|
|
|
|
# the normal dual bands
|
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
|
|
|
# DEBUG
|
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
|
|
|
# 220Mhz radios case
|
|
if self.MODEL in ["UV-2501+220", "KT8900R"]:
|
|
vhf2 = _decode_ranges(ranges.vhf2_low, ranges.vhf2_high)
|
|
LOG.info("Radio ranges: VHF(220) %d to %d" % vhf2)
|
|
self._220_range = vhf2
|
|
|
|
# set the class with the real data
|
|
self._vhf_range = vhf
|
|
self._uhf_range = uhf
|
|
|
|
def process_mmap(self):
|
|
"""Process the mem map into the mem object"""
|
|
|
|
# Get it
|
|
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
|
|
|
|
# load specific parameters from the radio image
|
|
self.set_options()
|
|
|
|
|
|
# Declaring Aliases (Clones of the real radios)
|
|
class JT2705M(chirp_common.Alias):
|
|
VENDOR = "Jetstream"
|
|
MODEL = "JT2705M"
|
|
|
|
|
|
class JT6188Mini(chirp_common.Alias):
|
|
VENDOR = "Juentai"
|
|
MODEL = "JT-6188 Mini"
|
|
|
|
|
|
class JT6188Plus(chirp_common.Alias):
|
|
VENDOR = "Juentai"
|
|
MODEL = "JT-6188 Plus"
|
|
|
|
|
|
class SSGT890(chirp_common.Alias):
|
|
VENDOR = "Sainsonic"
|
|
MODEL = "GT-890"
|
|
|
|
|
|
class ZastoneMP300(chirp_common.Alias):
|
|
VENDOR = "Zastone"
|
|
MODEL = "MP-300"
|
|
|
|
|
|
# real radios
|
|
@directory.register
|
|
class UV2501(BTech):
|
|
"""Baofeng Tech UV2501"""
|
|
MODEL = "UV-2501"
|
|
_fileid = [UV2501G3_fp,
|
|
UV2501G2_fp,
|
|
UV2501pp2_fp,
|
|
UV2501pp_fp]
|
|
|
|
|
|
@directory.register
|
|
class UV2501_220(BTech):
|
|
"""Baofeng Tech UV2501+220"""
|
|
MODEL = "UV-2501+220"
|
|
BANDS = 3
|
|
_magic = MSTRING_220
|
|
_fileid = [UV2501_220G3_fp,
|
|
UV2501_220G2_fp,
|
|
UV2501_220_fp,
|
|
UV2501_220pp_fp]
|
|
|
|
|
|
@directory.register
|
|
class UV5001(BTech):
|
|
"""Baofeng Tech UV5001"""
|
|
MODEL = "UV-5001"
|
|
_fileid = [UV5001G3_fp,
|
|
UV5001G22_fp,
|
|
UV5001G2_fp,
|
|
UV5001alpha_fp,
|
|
UV5001pp_fp]
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=50),
|
|
chirp_common.PowerLevel("Low", watts=10)]
|
|
|
|
|
|
@directory.register
|
|
class MINI8900(BTech):
|
|
"""WACCOM MINI-8900"""
|
|
VENDOR = "WACCOM"
|
|
MODEL = "MINI-8900"
|
|
_magic = MSTRING_MINI8900
|
|
_fileid = [MINI8900_fp, ]
|
|
# Clones
|
|
ALIASES = [JT6188Plus, ]
|
|
|
|
|
|
@directory.register
|
|
class KTUV980(BTech):
|
|
"""QYT KT-UV980"""
|
|
VENDOR = "QYT"
|
|
MODEL = "KT-UV980"
|
|
_vhf_range = (136000000, 175000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_magic = MSTRING_MINI8900
|
|
_fileid = [KTUV980_fp, ]
|
|
# Clones
|
|
ALIASES = [JT2705M, ]
|
|
|
|
# Please note that there is a version of this radios that is a clone of the
|
|
# Waccom Mini8900, maybe an early version?
|
|
|
|
|
|
class OTGRadioV1(chirp_common.Alias):
|
|
VENDOR = 'OTGSTUFF'
|
|
MODEL = 'OTG Radio v1'
|
|
|
|
|
|
@directory.register
|
|
class KT9800(BTech):
|
|
"""QYT KT8900"""
|
|
VENDOR = "QYT"
|
|
MODEL = "KT8900"
|
|
_vhf_range = (136000000, 175000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_magic = MSTRING_KT8900
|
|
_fileid = [KT8900_fp,
|
|
KT8900_fp1,
|
|
KT8900_fp2,
|
|
KT8900_fp3,
|
|
KT8900_fp4,
|
|
KT8900_fp5,
|
|
KT8900_fp6,
|
|
KT8900_fp7]
|
|
# Clones
|
|
ALIASES = [JT6188Mini, SSGT890, ZastoneMP300]
|
|
|
|
|
|
@directory.register
|
|
class KT9800R(BTech):
|
|
"""QYT KT8900R"""
|
|
VENDOR = "QYT"
|
|
MODEL = "KT8900R"
|
|
BANDS = 3
|
|
_vhf_range = (136000000, 175000000)
|
|
_220_range = (240000000, 271000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_magic = MSTRING_KT8900R
|
|
_fileid = [KT8900R_fp,
|
|
KT8900R_fp1,
|
|
KT8900R_fp2,
|
|
KT8900R_fp3,
|
|
KT8900R_fp4,
|
|
KT8900R_fp5]
|
|
|
|
|
|
@directory.register
|
|
class LT588UV(BTech):
|
|
"""LUITON LT-588UV"""
|
|
VENDOR = "LUITON"
|
|
MODEL = "LT-588UV"
|
|
_vhf_range = (136000000, 175000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_magic = MSTRING_KT8900
|
|
_fileid = [LT588UV_fp,
|
|
LT588UV_fp1]
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=60),
|
|
chirp_common.PowerLevel("Low", watts=10)]
|
|
|
|
|
|
COLOR_MEM_FORMAT = """
|
|
#seekto 0x0000;
|
|
struct {
|
|
lbcd rxfreq[4];
|
|
lbcd txfreq[4];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 unknown0:4,
|
|
scode:4;
|
|
u8 unknown1:2,
|
|
spmute:2,
|
|
unknown2:2,
|
|
optsig:2;
|
|
u8 unknown3:3,
|
|
scramble:1,
|
|
unknown4:2,
|
|
power:2;
|
|
u8 unknown5:1,
|
|
wide:1,
|
|
unknown6:2,
|
|
bcl:1,
|
|
add:1,
|
|
pttid:2;
|
|
} memory[200];
|
|
|
|
#seekto 0x0E00;
|
|
struct {
|
|
u8 tmr;
|
|
u8 unknown1;
|
|
u8 sql;
|
|
u8 unknown2;
|
|
u8 mgain2;
|
|
u8 tot;
|
|
u8 apo;
|
|
u8 unknown3;
|
|
u8 abr;
|
|
u8 beep;
|
|
u8 unknown4[4];
|
|
u8 dtmfst;
|
|
u8 unknown5[2];
|
|
u8 screv;
|
|
u8 unknown6[2];
|
|
u8 pttid;
|
|
u8 pttlt;
|
|
u8 unknown7;
|
|
u8 emctp;
|
|
u8 emcch;
|
|
u8 sigbp;
|
|
u8 unknown8;
|
|
u8 camdf;
|
|
u8 cbmdf;
|
|
u8 ccmdf;
|
|
u8 cdmdf;
|
|
u8 langua;
|
|
u8 sync; // BTech radios use this as the display sync
|
|
// setting, other radios use this as the auto
|
|
// keypad lock setting
|
|
u8 mainfc;
|
|
u8 mainbc;
|
|
u8 menufc;
|
|
u8 menubc;
|
|
u8 stafc;
|
|
u8 stabc;
|
|
u8 sigfc;
|
|
u8 sigbc;
|
|
u8 rxfc;
|
|
u8 txfc;
|
|
u8 txdisp;
|
|
u8 unknown9[5];
|
|
u8 anil;
|
|
u8 reps;
|
|
u8 repm;
|
|
u8 tmrmr;
|
|
u8 ste;
|
|
u8 rpste;
|
|
u8 rptdl;
|
|
u8 dtmfg;
|
|
u8 mgain; // used by db25-g for ponyey
|
|
u8 skiptx;
|
|
u8 scmode;
|
|
} settings;
|
|
|
|
#seekto 0x0E80;
|
|
struct {
|
|
u8 unknown1;
|
|
u8 vfomr;
|
|
u8 keylock;
|
|
u8 unknown2;
|
|
u8 unknown3:4,
|
|
vfomren:1,
|
|
unknown4:1,
|
|
reseten:1,
|
|
menuen:1;
|
|
u8 unknown5[11];
|
|
u8 dispab;
|
|
u8 unknown6[2];
|
|
u8 menu;
|
|
u8 unknown7[7];
|
|
u8 vfomra;
|
|
u8 vfomrb;
|
|
u8 vfomrc;
|
|
u8 vfomrd;
|
|
u8 mrcha;
|
|
u8 mrchb;
|
|
u8 mrchc;
|
|
u8 mrchd;
|
|
} settings2;
|
|
|
|
struct settings_vfo {
|
|
u8 freq[8];
|
|
u8 offset[6];
|
|
u8 unknown2[2];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 scode;
|
|
u8 spmute;
|
|
u8 optsig;
|
|
u8 scramble;
|
|
u8 wide;
|
|
u8 power;
|
|
u8 shiftd;
|
|
u8 step;
|
|
u8 unknown3[4];
|
|
};
|
|
|
|
#seekto 0x0F00;
|
|
struct {
|
|
struct settings_vfo a;
|
|
struct settings_vfo b;
|
|
struct settings_vfo c;
|
|
struct settings_vfo d;
|
|
} vfo;
|
|
|
|
#seekto 0x0F80;
|
|
struct {
|
|
char line1[8];
|
|
char line2[8];
|
|
char line3[8];
|
|
char line4[8];
|
|
char line5[8];
|
|
char line6[8];
|
|
char line7[8];
|
|
char line8[8];
|
|
} poweron_msg;
|
|
|
|
#seekto 0x1000;
|
|
struct {
|
|
char name[8];
|
|
u8 unknown1[8];
|
|
} names[200];
|
|
|
|
#seekto 0x2400;
|
|
struct {
|
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
|
u8 group_tone;
|
|
u8 repeat_tone;
|
|
u8 unused[13];
|
|
} _5tone_std_settings[15];
|
|
|
|
#seekto 0x2500;
|
|
struct {
|
|
u8 frame1[5];
|
|
u8 frame2[5];
|
|
u8 frame3[5];
|
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
|
} _5tone_codes[15];
|
|
|
|
#seekto 0x25F0;
|
|
struct {
|
|
u8 _5tone_delay1; // * 10ms
|
|
u8 _5tone_delay2; // * 10ms
|
|
u8 _5tone_delay3; // * 10ms
|
|
u8 _5tone_first_digit_ext_length;
|
|
u8 unknown1;
|
|
u8 unknown2;
|
|
u8 unknown3;
|
|
u8 unknown4;
|
|
u8 decode_standard;
|
|
u8 unknown5:5,
|
|
_5tone_decode_call_frame3:1,
|
|
_5tone_decode_call_frame2:1,
|
|
_5tone_decode_call_frame1:1;
|
|
u8 unknown6:5,
|
|
_5tone_decode_disp_frame3:1,
|
|
_5tone_decode_disp_frame2:1,
|
|
_5tone_decode_disp_frame1:1;
|
|
u8 decode_reset_time; // * 100 + 100ms
|
|
} _5tone_settings;
|
|
|
|
#seekto 0x2900;
|
|
struct {
|
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
|
} dtmf_codes[15];
|
|
|
|
#seekto 0x29F0;
|
|
struct {
|
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
|
u8 unknown0[14];
|
|
u8 inspection[16];
|
|
u8 monitor[16];
|
|
u8 alarmcode[16];
|
|
u8 stun[16];
|
|
u8 kill[16];
|
|
u8 revive[16];
|
|
u8 unknown1[16];
|
|
u8 unknown2[16];
|
|
u8 unknown3[16];
|
|
u8 unknown4[16];
|
|
u8 unknown5[16];
|
|
u8 unknown6[16];
|
|
u8 unknown7[16];
|
|
u8 masterid[16];
|
|
u8 viceid[16];
|
|
u8 unused01:7,
|
|
mastervice:1;
|
|
u8 unused02:3,
|
|
mrevive:1,
|
|
mkill:1,
|
|
mstun:1,
|
|
mmonitor:1,
|
|
minspection:1;
|
|
u8 unused03:3,
|
|
vrevive:1,
|
|
vkill:1,
|
|
vstun:1,
|
|
vmonitor:1,
|
|
vinspection:1;
|
|
u8 unused04:6,
|
|
txdisable:1,
|
|
rxdisable:1;
|
|
u8 groupcode;
|
|
u8 spacecode;
|
|
u8 delayproctime; // * 100 + 100ms
|
|
u8 resettime; // * 100 + 100ms
|
|
} dtmf_settings;
|
|
|
|
#seekto 0x2D00;
|
|
struct {
|
|
struct {
|
|
ul16 freq1;
|
|
u8 unused01[6];
|
|
ul16 freq2;
|
|
u8 unused02[6];
|
|
} _2tone_encode[15];
|
|
u8 duration_1st_tone; // *10ms
|
|
u8 duration_2nd_tone; // *10ms
|
|
u8 duration_gap; // *10ms
|
|
u8 unused03[13];
|
|
struct {
|
|
struct {
|
|
u8 dec; // one out of LIST_2TONE_DEC
|
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
|
u8 alert; // 1-16
|
|
} decs[4];
|
|
u8 unused04[4];
|
|
} _2tone_decode[15];
|
|
u8 unused05[16];
|
|
|
|
struct {
|
|
ul16 freqA;
|
|
ul16 freqB;
|
|
ul16 freqC;
|
|
ul16 freqD;
|
|
// unknown what those values mean, but they are
|
|
// derived from configured frequencies
|
|
ul16 derived_from_freqA; // 2304000/freqA
|
|
ul16 derived_from_freqB; // 2304000/freqB
|
|
ul16 derived_from_freqC; // 2304000/freqC
|
|
ul16 derived_from_freqD; // 2304000/freqD
|
|
}freqs[15];
|
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
|
} _2tone;
|
|
|
|
#seekto 0x3D80;
|
|
struct {
|
|
u8 vhf_low[3];
|
|
u8 vhf_high[3];
|
|
u8 unknown1[4];
|
|
u8 unknown2[6];
|
|
u8 vhf2_low[3];
|
|
u8 vhf2_high[3];
|
|
u8 unknown3[4];
|
|
u8 unknown4[6];
|
|
u8 uhf_low[3];
|
|
u8 uhf_high[3];
|
|
u8 unknown5[4];
|
|
u8 unknown6[6];
|
|
u8 uhf2_low[3];
|
|
u8 uhf2_high[3];
|
|
} ranges;
|
|
|
|
#seekto 0x3F70;
|
|
struct {
|
|
char fp[6];
|
|
} fingerprint;
|
|
|
|
"""
|
|
|
|
|
|
class BTechColor(BTechMobileCommon):
|
|
"""BTECH's Color LCD Mobile and alike radios"""
|
|
COLOR_LCD = True
|
|
NAME_LENGTH = 8
|
|
LIST_TMR = LIST_TMR16
|
|
|
|
def process_mmap(self):
|
|
"""Process the mem map into the mem object"""
|
|
|
|
# Get it
|
|
self._memobj = bitwise.parse(COLOR_MEM_FORMAT, self._mmap)
|
|
|
|
# load specific parameters from the radio image
|
|
self.set_options()
|
|
|
|
def set_options(self):
|
|
"""This is to read the options from the image and set it in the
|
|
environment, for now just the limits of the freqs in the VHF/UHF
|
|
ranges"""
|
|
|
|
# setting the correct ranges for each radio type
|
|
ranges = self._memobj.ranges
|
|
|
|
# the normal dual bands
|
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
|
|
|
# DEBUG
|
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
|
|
|
# the additional bands
|
|
if self.MODEL in ["UV-25X4", "KT7900D"]:
|
|
# 200Mhz band
|
|
vhf2 = _decode_ranges(ranges.vhf2_low, ranges.vhf2_high)
|
|
LOG.info("Radio ranges: VHF(220) %d to %d" % vhf2)
|
|
self._220_range = vhf2
|
|
|
|
# 350Mhz band
|
|
uhf2 = _decode_ranges(ranges.uhf2_low, ranges.uhf2_high)
|
|
LOG.info("Radio ranges: UHF(350) %d to %d" % uhf2)
|
|
self._350_range = uhf2
|
|
|
|
# set the class with the real data
|
|
self._vhf_range = vhf
|
|
self._uhf_range = uhf
|
|
|
|
|
|
# Declaring Aliases (Clones of the real radios)
|
|
class SKT8900D(chirp_common.Alias):
|
|
VENDOR = "Surecom"
|
|
MODEL = "S-KT8900D"
|
|
|
|
|
|
class QB25(chirp_common.Alias):
|
|
VENDOR = "Radioddity"
|
|
MODEL = "QB25"
|
|
|
|
|
|
# real radios
|
|
@directory.register
|
|
class UV25X2(BTechColor):
|
|
"""Baofeng Tech UV25X2"""
|
|
MODEL = "UV-25X2"
|
|
BANDS = 2
|
|
_vhf_range = (130000000, 180000000)
|
|
_uhf_range = (400000000, 521000000)
|
|
_magic = MSTRING_UV25X2
|
|
_fileid = [UV25X2_fp, ]
|
|
|
|
|
|
@directory.register
|
|
class UV25X4(BTechColor):
|
|
"""Baofeng Tech UV25X4"""
|
|
MODEL = "UV-25X4"
|
|
BANDS = 4
|
|
_vhf_range = (130000000, 180000000)
|
|
_220_range = (200000000, 271000000)
|
|
_uhf_range = (400000000, 521000000)
|
|
_350_range = (350000000, 391000000)
|
|
_magic = MSTRING_UV25X4
|
|
_fileid = [UV25X4_fp, ]
|
|
|
|
|
|
@directory.register
|
|
class UV50X2(BTechColor):
|
|
"""Baofeng Tech UV50X2"""
|
|
MODEL = "UV-50X2"
|
|
BANDS = 2
|
|
_vhf_range = (130000000, 180000000)
|
|
_uhf_range = (400000000, 521000000)
|
|
_magic = MSTRING_UV25X2
|
|
_fileid = [UV50X2_fp, ]
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=50),
|
|
chirp_common.PowerLevel("Low", watts=10)]
|
|
|
|
|
|
@directory.register
|
|
class KT7900D(BTechColor):
|
|
"""QYT KT7900D"""
|
|
VENDOR = "QYT"
|
|
MODEL = "KT7900D"
|
|
BANDS = 4
|
|
LIST_TMR = LIST_TMR15
|
|
_vhf_range = (136000000, 175000000)
|
|
_220_range = (200000000, 271000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_350_range = (350000000, 371000000)
|
|
_magic = MSTRING_KT8900D
|
|
_fileid = [KT7900D_fp, KT7900D_fp1, KT7900D_fp2, KT7900D_fp3, KT7900D_fp4,
|
|
KT7900D_fp5, KT7900D_fp6, KT7900D_fp7, QB25_fp, ]
|
|
# Clones
|
|
ALIASES = [SKT8900D, QB25, ]
|
|
|
|
|
|
@directory.register
|
|
class KT8900D(BTechColor):
|
|
"""QYT KT8900D"""
|
|
VENDOR = "QYT"
|
|
MODEL = "KT8900D"
|
|
BANDS = 2
|
|
LIST_TMR = LIST_TMR15
|
|
_vhf_range = (136000000, 175000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_magic = MSTRING_KT8900D
|
|
_fileid = [KT8900D_fp3, KT8900D_fp2, KT8900D_fp1, KT8900D_fp]
|
|
|
|
# Clones
|
|
ALIASES = [OTGRadioV1]
|
|
|
|
|
|
@directory.register
|
|
class KT5800(BTechColor):
|
|
"""QYT KT5800"""
|
|
VENDOR = "QYT"
|
|
MODEL = "KT5800"
|
|
BANDS = 2
|
|
LIST_TMR = LIST_TMR15
|
|
_vhf_range = (136000000, 175000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_magic = MSTRING_KT8900D
|
|
_fileid = [KT5800_fp, ]
|
|
|
|
|
|
@directory.register
|
|
class KT980PLUS(BTechColor):
|
|
"""QYT KT980PLUS"""
|
|
VENDOR = "QYT"
|
|
MODEL = "KT980PLUS"
|
|
BANDS = 2
|
|
LIST_TMR = LIST_TMR15
|
|
_vhf_range = (136000000, 175000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_magic = MSTRING_KT8900D
|
|
_fileid = [KT980PLUS_fp1, KT980PLUS_fp]
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=75),
|
|
chirp_common.PowerLevel("Low", watts=55)]
|
|
|
|
@classmethod
|
|
def match_model(cls, filedata, filename):
|
|
# This model is only ever matched via metadata
|
|
return False
|
|
|
|
|
|
@directory.register
|
|
class DB25G(BTechColor):
|
|
"""Radioddity DB25-G"""
|
|
VENDOR = "Radioddity"
|
|
MODEL = "DB25-G"
|
|
BANDS = 2
|
|
LIST_TMR = LIST_TMR15
|
|
_vhf_range = (136000000, 175000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_magic = MSTRING_KT8900D
|
|
_fileid = [DB25G_fp1, DB25G_fp]
|
|
_gmrs = True
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=25),
|
|
chirp_common.PowerLevel("Mid", watts=15),
|
|
chirp_common.PowerLevel("Low", watts=5)]
|
|
|
|
@classmethod
|
|
def match_model(cls, filedata, filename):
|
|
# This model is only ever matched via metadata
|
|
return False
|
|
|
|
|
|
GMRS_MEM_FORMAT = """
|
|
#seekto 0x0000;
|
|
struct {
|
|
lbcd rxfreq[4];
|
|
lbcd txfreq[4];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 unknown0:4,
|
|
scode:4;
|
|
u8 unknown1:2,
|
|
spmute:2,
|
|
unknown2:2,
|
|
optsig:2;
|
|
u8 unknown3:3,
|
|
scramble:1,
|
|
unknown4:2,
|
|
power:2;
|
|
u8 unknown5:1,
|
|
wide:1,
|
|
unknown6:2,
|
|
bcl:1,
|
|
add:1,
|
|
pttid:2;
|
|
} memory[256];
|
|
|
|
#seekto 0x1000;
|
|
struct {
|
|
char name[7];
|
|
u8 unknown1[9];
|
|
} names[256];
|
|
|
|
#seekto 0x2400;
|
|
struct {
|
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
|
u8 group_tone;
|
|
u8 repeat_tone;
|
|
u8 unused[13];
|
|
} _5tone_std_settings[15];
|
|
|
|
#seekto 0x2500;
|
|
struct {
|
|
u8 frame1[5];
|
|
u8 frame2[5];
|
|
u8 frame3[5];
|
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
|
} _5tone_codes[15];
|
|
|
|
#seekto 0x25F0;
|
|
struct {
|
|
u8 _5tone_delay1; // * 10ms
|
|
u8 _5tone_delay2; // * 10ms
|
|
u8 _5tone_delay3; // * 10ms
|
|
u8 _5tone_first_digit_ext_length;
|
|
u8 unknown1;
|
|
u8 unknown2;
|
|
u8 unknown3;
|
|
u8 unknown4;
|
|
u8 decode_standard;
|
|
u8 unknown5:5,
|
|
_5tone_decode_call_frame3:1,
|
|
_5tone_decode_call_frame2:1,
|
|
_5tone_decode_call_frame1:1;
|
|
u8 unknown6:5,
|
|
_5tone_decode_disp_frame3:1,
|
|
_5tone_decode_disp_frame2:1,
|
|
_5tone_decode_disp_frame1:1;
|
|
u8 decode_reset_time; // * 100 + 100ms
|
|
} _5tone_settings;
|
|
|
|
#seekto 0x2900;
|
|
struct {
|
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
|
} dtmf_codes[15];
|
|
|
|
#seekto 0x29F0;
|
|
struct {
|
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
|
u8 unknown0[14];
|
|
u8 inspection[16];
|
|
u8 monitor[16];
|
|
u8 alarmcode[16];
|
|
u8 stun[16];
|
|
u8 kill[16];
|
|
u8 revive[16];
|
|
u8 unknown1[16];
|
|
u8 unknown2[16];
|
|
u8 unknown3[16];
|
|
u8 unknown4[16];
|
|
u8 unknown5[16];
|
|
u8 unknown6[16];
|
|
u8 unknown7[16];
|
|
u8 masterid[16];
|
|
u8 viceid[16];
|
|
u8 unused01:7,
|
|
mastervice:1;
|
|
u8 unused02:3,
|
|
mrevive:1,
|
|
mkill:1,
|
|
mstun:1,
|
|
mmonitor:1,
|
|
minspection:1;
|
|
u8 unused03:3,
|
|
vrevive:1,
|
|
vkill:1,
|
|
vstun:1,
|
|
vmonitor:1,
|
|
vinspection:1;
|
|
u8 unused04:6,
|
|
txdisable:1,
|
|
rxdisable:1;
|
|
u8 groupcode;
|
|
u8 spacecode;
|
|
u8 delayproctime; // * 100 + 100ms
|
|
u8 resettime; // * 100 + 100ms
|
|
} dtmf_settings;
|
|
|
|
#seekto 0x2D00;
|
|
struct {
|
|
struct {
|
|
ul16 freq1;
|
|
u8 unused01[6];
|
|
ul16 freq2;
|
|
u8 unused02[6];
|
|
} _2tone_encode[15];
|
|
u8 duration_1st_tone; // *10ms
|
|
u8 duration_2nd_tone; // *10ms
|
|
u8 duration_gap; // *10ms
|
|
u8 unused03[13];
|
|
struct {
|
|
struct {
|
|
u8 dec; // one out of LIST_2TONE_DEC
|
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
|
u8 alert; // 1-16
|
|
} decs[4];
|
|
u8 unused04[4];
|
|
} _2tone_decode[15];
|
|
u8 unused05[16];
|
|
|
|
struct {
|
|
ul16 freqA;
|
|
ul16 freqB;
|
|
ul16 freqC;
|
|
ul16 freqD;
|
|
// unknown what those values mean, but they are
|
|
// derived from configured frequencies
|
|
ul16 derived_from_freqA; // 2304000/freqA
|
|
ul16 derived_from_freqB; // 2304000/freqB
|
|
ul16 derived_from_freqC; // 2304000/freqC
|
|
ul16 derived_from_freqD; // 2304000/freqD
|
|
}freqs[15];
|
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
|
} _2tone;
|
|
|
|
#seekto 0x3000;
|
|
struct {
|
|
u8 freq[8];
|
|
char broadcast_station_name[6];
|
|
u8 unknown[2];
|
|
} fm_radio_preset[16];
|
|
|
|
#seekto 0x3200;
|
|
struct {
|
|
u8 tmr;
|
|
u8 unknown1;
|
|
u8 sql;
|
|
u8 unknown2;
|
|
u8 autolk;
|
|
u8 tot;
|
|
u8 apo;
|
|
u8 unknown3;
|
|
u8 abr;
|
|
u8 beep;
|
|
u8 unknown4[4];
|
|
u8 dtmfst;
|
|
u8 unknown5[2];
|
|
u8 screv;
|
|
u8 unknown6[2];
|
|
u8 pttid;
|
|
u8 pttlt;
|
|
u8 unknown7;
|
|
u8 emctp;
|
|
u8 emcch;
|
|
u8 sigbp;
|
|
u8 unknown8;
|
|
u8 camdf;
|
|
u8 cbmdf;
|
|
u8 ccmdf;
|
|
u8 cdmdf;
|
|
u8 langua;
|
|
u8 sync;
|
|
|
|
|
|
u8 stfc;
|
|
u8 mffc;
|
|
u8 sfafc;
|
|
u8 sfbfc;
|
|
u8 sfcfc;
|
|
u8 sfdfc;
|
|
u8 subfc;
|
|
u8 fmfc;
|
|
u8 sigfc;
|
|
u8 modfc;
|
|
u8 menufc;
|
|
u8 txfc;
|
|
u8 txdisp;
|
|
u8 unknown9[5];
|
|
u8 anil;
|
|
u8 reps;
|
|
u8 repm;
|
|
u8 tmrmr;
|
|
u8 ste;
|
|
u8 rpste;
|
|
u8 rptdl;
|
|
u8 dtmfg;
|
|
u8 mgain;
|
|
u8 skiptx;
|
|
u8 scmode;
|
|
} settings;
|
|
|
|
#seekto 0x3280;
|
|
struct {
|
|
u8 unknown1;
|
|
u8 vfomr;
|
|
u8 keylock;
|
|
u8 unknown2;
|
|
u8 unknown3:4,
|
|
vfomren:1,
|
|
unknown4:1,
|
|
reseten:1,
|
|
menuen:1;
|
|
u8 unknown5[11];
|
|
u8 dispab;
|
|
u8 unknown6[2];
|
|
u8 smenu;
|
|
u8 unknown7[7];
|
|
u8 vfomra;
|
|
u8 vfomrb;
|
|
u8 vfomrc;
|
|
u8 vfomrd;
|
|
u8 mrcha;
|
|
u8 mrchb;
|
|
u8 mrchc;
|
|
u8 mrchd;
|
|
} settings2;
|
|
|
|
struct settings_vfo {
|
|
u8 freq[8];
|
|
u8 offset[6];
|
|
u8 unknown2[2];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 scode;
|
|
u8 spmute;
|
|
u8 optsig;
|
|
u8 scramble;
|
|
u8 wide;
|
|
u8 power;
|
|
u8 shiftd;
|
|
u8 step;
|
|
u8 unknown3[4];
|
|
};
|
|
|
|
#seekto 0x3300;
|
|
struct {
|
|
struct settings_vfo a;
|
|
struct settings_vfo b;
|
|
struct settings_vfo c;
|
|
struct settings_vfo d;
|
|
} vfo;
|
|
|
|
#seekto 0x3D80;
|
|
struct {
|
|
u8 vhf_low[3];
|
|
u8 vhf_high[3];
|
|
u8 unknown1[4];
|
|
u8 unknown2[6];
|
|
u8 vhf2_low[3];
|
|
u8 vhf2_high[3];
|
|
u8 unknown3[4];
|
|
u8 unknown4[6];
|
|
u8 uhf_low[3];
|
|
u8 uhf_high[3];
|
|
u8 unknown5[4];
|
|
u8 unknown6[6];
|
|
u8 uhf2_low[3];
|
|
u8 uhf2_high[3];
|
|
} ranges;
|
|
|
|
#seekto 0x33B0;
|
|
struct {
|
|
char line[16];
|
|
} static_msg;
|
|
|
|
#seekto 0x3F70;
|
|
struct {
|
|
char fp[6];
|
|
} fingerprint;
|
|
|
|
"""
|
|
|
|
|
|
class BTechGMRS(BTechMobileCommon):
|
|
"""BTECH's GMRS Mobile"""
|
|
COLOR_LCD = True
|
|
COLOR_LCD2 = True
|
|
NAME_LENGTH = 7
|
|
UPLOAD_MEM_SIZE = 0X3400
|
|
|
|
def process_mmap(self):
|
|
"""Process the mem map into the mem object"""
|
|
|
|
# Get it
|
|
self._memobj = bitwise.parse(GMRS_MEM_FORMAT, self._mmap)
|
|
|
|
# load specific parameters from the radio image
|
|
self.set_options()
|
|
|
|
def set_options(self):
|
|
"""This is to read the options from the image and set it in the
|
|
environment, for now just the limits of the freqs in the VHF/UHF
|
|
ranges"""
|
|
|
|
# setting the correct ranges for each radio type
|
|
ranges = self._memobj.ranges
|
|
|
|
# the normal dual bands
|
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
|
|
|
# DEBUG
|
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
|
|
|
# set the class with the real data
|
|
self._vhf_range = vhf
|
|
self._uhf_range = uhf
|
|
|
|
|
|
# real radios
|
|
@directory.register
|
|
class GMRS50X1(BTechGMRS):
|
|
"""Baofeng Tech GMRS50X1"""
|
|
MODEL = "GMRS-50X1"
|
|
BANDS = 2
|
|
LIST_TMR = LIST_TMR16
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=50),
|
|
chirp_common.PowerLevel("Mid", watts=10),
|
|
chirp_common.PowerLevel("Low", watts=5)]
|
|
_vhf_range = (136000000, 175000000)
|
|
_uhf_range = (400000000, 521000000)
|
|
_upper = 255
|
|
_magic = MSTRING_GMRS50X1
|
|
_fileid = [GMRS50X1_fp1, GMRS50X1_fp, ]
|
|
|
|
|
|
COLORHT_MEM_FORMAT = """
|
|
#seekto 0x0000;
|
|
struct {
|
|
lbcd rxfreq[4];
|
|
lbcd txfreq[4];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 unknown0:4,
|
|
scode:4;
|
|
u8 unknown1:2,
|
|
spmute:2,
|
|
unknown2:2,
|
|
optsig:2;
|
|
u8 unknown3:3,
|
|
scramble:1,
|
|
unknown4:3,
|
|
power:1;
|
|
u8 unknown5:1,
|
|
wide:1,
|
|
unknown6:2,
|
|
bcl:1,
|
|
add:1,
|
|
pttid:2;
|
|
} memory[200];
|
|
|
|
#seekto 0x0E00;
|
|
struct {
|
|
u8 tmr;
|
|
u8 unknownE01;
|
|
u8 sql;
|
|
u8 unknownE03[2];
|
|
u8 tot;
|
|
u8 save;
|
|
u8 unknownE07;
|
|
u8 abr;
|
|
u8 beep;
|
|
u8 unknownE0A[4];
|
|
u8 dsub;
|
|
u8 dtmfst;
|
|
u8 screv;
|
|
u8 unknownE11[3];
|
|
u8 pttid;
|
|
u8 unknownE15;
|
|
u8 pttlt;
|
|
u8 unknownE17;
|
|
u8 emctp;
|
|
u8 emcch;
|
|
u8 sigbp;
|
|
u8 unknownE1B;
|
|
u8 camdf;
|
|
u8 cbmdf;
|
|
u8 ccmdf;
|
|
u8 cdmdf;
|
|
u8 langua;
|
|
u8 voice;
|
|
u8 vox;
|
|
u8 voxt;
|
|
u8 sync; // BTech radios use this as the display sync setting
|
|
// other radios use this as the auto keypad lock setting
|
|
u8 stfc;
|
|
u8 mffc;
|
|
u8 sfafc;
|
|
u8 sfbfc;
|
|
u8 sfcfc;
|
|
u8 sfdfc;
|
|
u8 subfc;
|
|
u8 fmfc;
|
|
u8 sigfc;
|
|
u8 menufc;
|
|
u8 txfc;
|
|
u8 rxfc;
|
|
u8 unknownE31[5];
|
|
u8 anil;
|
|
u8 reps;
|
|
u8 tmrmr;
|
|
u8 ste;
|
|
u8 rpste;
|
|
u8 rptdl;
|
|
u8 dtmfg;
|
|
u8 tmrtx;
|
|
} settings;
|
|
|
|
#seekto 0x0E80;
|
|
struct {
|
|
u8 unknown1;
|
|
u8 vfomr;
|
|
u8 keylock;
|
|
u8 unknown2;
|
|
u8 unknown3:4,
|
|
vfomren:1,
|
|
unknown4:1,
|
|
reseten:1,
|
|
menuen:1;
|
|
u8 unknown5[11];
|
|
u8 dispab;
|
|
u8 unknown6[2];
|
|
u8 menu;
|
|
u8 unknown7[7];
|
|
u8 vfomra;
|
|
u8 vfomrb;
|
|
u8 vfomrc;
|
|
u8 vfomrd;
|
|
u8 mrcha;
|
|
u8 mrchb;
|
|
u8 mrchc;
|
|
u8 mrchd;
|
|
} settings2;
|
|
|
|
struct settings_vfo {
|
|
u8 freq[8];
|
|
u8 offset[6];
|
|
u8 unknown2[2];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 scode;
|
|
u8 spmute;
|
|
u8 optsig;
|
|
u8 scramble;
|
|
u8 wide;
|
|
u8 power;
|
|
u8 shiftd;
|
|
u8 step;
|
|
u8 unknown3[4];
|
|
};
|
|
|
|
#seekto 0x0F00;
|
|
struct {
|
|
struct settings_vfo a;
|
|
struct settings_vfo b;
|
|
struct settings_vfo c;
|
|
struct settings_vfo d;
|
|
} vfo;
|
|
|
|
#seekto 0x0FE0;
|
|
struct {
|
|
char line[16];
|
|
} static_msg;
|
|
|
|
#seekto 0x1000;
|
|
struct {
|
|
char name[8];
|
|
u8 unknown1[8];
|
|
} names[200];
|
|
|
|
#seekto 0x2400;
|
|
struct {
|
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
|
u8 group_tone;
|
|
u8 repeat_tone;
|
|
u8 unused[13];
|
|
} _5tone_std_settings[15];
|
|
|
|
#seekto 0x2500;
|
|
struct {
|
|
u8 frame1[5];
|
|
u8 frame2[5];
|
|
u8 frame3[5];
|
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
|
} _5tone_codes[15];
|
|
|
|
#seekto 0x25F0;
|
|
struct {
|
|
u8 _5tone_delay1; // * 10ms
|
|
u8 _5tone_delay2; // * 10ms
|
|
u8 _5tone_delay3; // * 10ms
|
|
u8 _5tone_first_digit_ext_length;
|
|
u8 unknown1;
|
|
u8 unknown2;
|
|
u8 unknown3;
|
|
u8 unknown4;
|
|
u8 decode_standard;
|
|
u8 unknown5:5,
|
|
_5tone_decode_call_frame3:1,
|
|
_5tone_decode_call_frame2:1,
|
|
_5tone_decode_call_frame1:1;
|
|
u8 unknown6:5,
|
|
_5tone_decode_disp_frame3:1,
|
|
_5tone_decode_disp_frame2:1,
|
|
_5tone_decode_disp_frame1:1;
|
|
u8 decode_reset_time; // * 100 + 100ms
|
|
} _5tone_settings;
|
|
|
|
#seekto 0x2900;
|
|
struct {
|
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
|
} dtmf_codes[15];
|
|
|
|
#seekto 0x29F0;
|
|
struct {
|
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
|
u8 unknown0[14];
|
|
u8 inspection[16];
|
|
u8 monitor[16];
|
|
u8 alarmcode[16];
|
|
u8 stun[16];
|
|
u8 kill[16];
|
|
u8 revive[16];
|
|
u8 unknown1[16];
|
|
u8 unknown2[16];
|
|
u8 unknown3[16];
|
|
u8 unknown4[16];
|
|
u8 unknown5[16];
|
|
u8 unknown6[16];
|
|
u8 unknown7[16];
|
|
u8 masterid[16];
|
|
u8 viceid[16];
|
|
u8 unused01:7,
|
|
mastervice:1;
|
|
u8 unused02:3,
|
|
mrevive:1,
|
|
mkill:1,
|
|
mstun:1,
|
|
mmonitor:1,
|
|
minspection:1;
|
|
u8 unused03:3,
|
|
vrevive:1,
|
|
vkill:1,
|
|
vstun:1,
|
|
vmonitor:1,
|
|
vinspection:1;
|
|
u8 unused04:6,
|
|
txdisable:1,
|
|
rxdisable:1;
|
|
u8 groupcode;
|
|
u8 spacecode;
|
|
u8 delayproctime; // * 100 + 100ms
|
|
u8 resettime; // * 100 + 100ms
|
|
} dtmf_settings;
|
|
|
|
#seekto 0x2D00;
|
|
struct {
|
|
struct {
|
|
ul16 freq1;
|
|
u8 unused01[6];
|
|
ul16 freq2;
|
|
u8 unused02[6];
|
|
} _2tone_encode[15];
|
|
u8 duration_1st_tone; // *10ms
|
|
u8 duration_2nd_tone; // *10ms
|
|
u8 duration_gap; // *10ms
|
|
u8 unused03[13];
|
|
struct {
|
|
struct {
|
|
u8 dec; // one out of LIST_2TONE_DEC
|
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
|
u8 alert; // 1-16
|
|
} decs[4];
|
|
u8 unused04[4];
|
|
} _2tone_decode[15];
|
|
u8 unused05[16];
|
|
|
|
struct {
|
|
ul16 freqA;
|
|
ul16 freqB;
|
|
ul16 freqC;
|
|
ul16 freqD;
|
|
// unknown what those values mean, but they are
|
|
// derived from configured frequencies
|
|
ul16 derived_from_freqA; // 2304000/freqA
|
|
ul16 derived_from_freqB; // 2304000/freqB
|
|
ul16 derived_from_freqC; // 2304000/freqC
|
|
ul16 derived_from_freqD; // 2304000/freqD
|
|
}freqs[15];
|
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
|
} _2tone;
|
|
|
|
#seekto 0x3D80;
|
|
struct {
|
|
u8 vhf_low[3];
|
|
u8 vhf_high[3];
|
|
u8 unknown1[4];
|
|
u8 unknown2[6];
|
|
u8 vhf2_low[3];
|
|
u8 vhf2_high[3];
|
|
u8 unknown3[4];
|
|
u8 unknown4[6];
|
|
u8 uhf_low[3];
|
|
u8 uhf_high[3];
|
|
u8 unknown5[4];
|
|
u8 unknown6[6];
|
|
u8 uhf2_low[3];
|
|
u8 uhf2_high[3];
|
|
} ranges;
|
|
|
|
#seekto 0x3F70;
|
|
struct {
|
|
char fp[6];
|
|
} fingerprint;
|
|
|
|
"""
|
|
|
|
|
|
class QYTColorHT(BTechMobileCommon):
|
|
"""QTY's Color LCD Handheld and alike radios"""
|
|
COLOR_LCD = True
|
|
COLOR_LCD3 = True
|
|
NAME_LENGTH = 8
|
|
LIST_TMR = LIST_TMR15
|
|
|
|
def process_mmap(self):
|
|
"""Process the mem map into the mem object"""
|
|
|
|
# Get it
|
|
self._memobj = bitwise.parse(COLORHT_MEM_FORMAT, self._mmap)
|
|
|
|
# load specific parameters from the radio image
|
|
self.set_options()
|
|
|
|
def set_options(self):
|
|
"""This is to read the options from the image and set it in the
|
|
environment, for now just the limits of the freqs in the VHF/UHF
|
|
ranges"""
|
|
|
|
# setting the correct ranges for each radio type
|
|
ranges = self._memobj.ranges
|
|
|
|
# the normal dual bands
|
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
|
|
|
# DEBUG
|
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
|
|
|
# the additional bands
|
|
if self.MODEL in ["KT-8R"]:
|
|
# 200Mhz band
|
|
vhf2 = _decode_ranges(ranges.vhf2_low, ranges.vhf2_high)
|
|
LOG.info("Radio ranges: VHF(220) %d to %d" % vhf2)
|
|
self._220_range = vhf2
|
|
|
|
# 350Mhz band
|
|
uhf2 = _decode_ranges(ranges.uhf2_low, ranges.uhf2_high)
|
|
LOG.info("Radio ranges: UHF(350) %d to %d" % uhf2)
|
|
self._350_range = uhf2
|
|
|
|
# set the class with the real data
|
|
self._vhf_range = vhf
|
|
self._uhf_range = uhf
|
|
|
|
|
|
# real radios
|
|
@directory.register
|
|
class KT8R(QYTColorHT):
|
|
"""QYT KT8R"""
|
|
VENDOR = "QYT"
|
|
MODEL = "KT-8R"
|
|
BANDS = 4
|
|
LIST_TMR = LIST_TMR16
|
|
_vhf_range = (136000000, 175000000)
|
|
_220_range = (200000000, 261000000)
|
|
_uhf_range = (400000000, 481000000)
|
|
_350_range = (350000000, 391000000)
|
|
_magic = MSTRING_KT8R
|
|
_fileid = [KT8R_fp2, KT8R_fp1, KT8R_fp, ]
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=5),
|
|
chirp_common.PowerLevel("Low", watts=1)]
|
|
|
|
|
|
COLOR9900_MEM_FORMAT = """
|
|
#seekto 0x0000;
|
|
struct {
|
|
lbcd rxfreq[4];
|
|
lbcd txfreq[4];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 unknown0:4,
|
|
scode:4;
|
|
u8 unknown1:2,
|
|
spmute:2,
|
|
unknown2:2,
|
|
optsig:2;
|
|
u8 unknown3:3,
|
|
scramble:1,
|
|
unknown4:2,
|
|
power:2;
|
|
u8 unknown5:1,
|
|
wide:1,
|
|
unknown6:2,
|
|
bcl:1,
|
|
add:1,
|
|
pttid:2;
|
|
} memory[200];
|
|
|
|
#seekto 0x0E00;
|
|
struct {
|
|
u8 tmr; // e00 00 confirmed
|
|
u8 unknown1; // e01
|
|
u8 sql; // e02 02 confirmed
|
|
u8 unknown2[2]; // e03-e04
|
|
u8 tot; // e05 05 confirmed
|
|
u8 volume; // e06 06 confirmed
|
|
u8 unknown3; // e07
|
|
u8 abr; // e08 08 confirmed
|
|
u8 beep; // e09 09 confirmed
|
|
u8 unknown4[4]; // e0a-e0d
|
|
u8 dsub; // e0e 14 confirmed
|
|
u8 dtmfst; // e0f 15 confirmed
|
|
u8 unknown_e10; // e10
|
|
u8 unknown_e11; // e11
|
|
u8 screv; // e12 18 confirmed
|
|
u8 unknown_e13; // e13
|
|
u8 unknown_e14; // e14
|
|
u8 pttid; // e15 21 confirmed
|
|
u8 pttlt; // e16 22 confirmed
|
|
u8 unknown7; // e17
|
|
u8 emctp; // e18 24 confirmed
|
|
u8 emcch; // e19 25 confirmed
|
|
u8 sigbp; // e1a 26 confirmed
|
|
u8 unknown8; // e1b
|
|
u8 camdf; // e1c 28 confirmed
|
|
u8 cbmdf; // e1d 29 confirmed
|
|
u8 ccmdf; // e1e 30 confirmed
|
|
u8 language; // e1f 31 confirmed
|
|
u8 tmrtx; // e20 32 confirmed
|
|
u8 vox; // e21 33 confirmed
|
|
u8 voxt; // e22 34 confirmed
|
|
u8 autolock; // e23 35 confirmed
|
|
u8 asfc; // e24 36 confirmed above stat fore color
|
|
u8 mainfc; // e25 37 confirmed main fore color
|
|
u8 a_fc; // e26 38 confirmed a - fore color
|
|
u8 b_fc; // e27 39 confirmed b - fore color
|
|
u8 c_fc; // e28 40 confirmed c - fore color
|
|
u8 subfc; // e29 41 confirmed sub fore color
|
|
u8 battfc; // e2a 42 confirmed batt fore color
|
|
u8 sigfc; // e2b 43 confirmed signale fore color
|
|
u8 menufc; // e2c 44 confirmed menu fore color
|
|
u8 txfc; // e2d 45 confirmed tx fore color
|
|
u8 rxfc; // e2e 46 confirmed rx fore color
|
|
u8 unknown_e2f; // e2f
|
|
u8 unknown_e30; // e30
|
|
u8 unknown9[3]; // e31-e33
|
|
u8 anil; // e34 52 confirmed
|
|
u8 reps; // e35 53 confirmed
|
|
u8 tmrmr; // e36 54 confirmed
|
|
u8 ste; // e37 55 confirmed
|
|
u8 rpste; // e38 56 confirmed
|
|
u8 rptdl; // e39 57 confirmed
|
|
u8 dtmfg; // e3a 58 confirmed
|
|
} settings;
|
|
|
|
#seekto 0x0E80;
|
|
struct {
|
|
u8 unknown1;
|
|
u8 vfomr;
|
|
u8 keylock;
|
|
u8 unknown2;
|
|
u8 unknown3:4,
|
|
vfomren:1,
|
|
unknown4:1,
|
|
reseten:1,
|
|
menuen:1;
|
|
u8 unknown5[11];
|
|
u8 dispab;
|
|
u8 unknown6[2];
|
|
u8 menu;
|
|
u8 unknown7[7];
|
|
u8 vfomra;
|
|
u8 vfomrb;
|
|
u8 vfomrc;
|
|
u8 vfomrd;
|
|
u8 mrcha;
|
|
u8 mrchb;
|
|
u8 mrchc;
|
|
u8 mrchd;
|
|
} settings2;
|
|
|
|
struct settings_vfo {
|
|
u8 freq[8];
|
|
u8 offset[6];
|
|
u8 unknown2[2];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 scode;
|
|
u8 spmute;
|
|
u8 optsig;
|
|
u8 scramble;
|
|
u8 wide;
|
|
u8 power;
|
|
u8 shiftd;
|
|
u8 step;
|
|
u8 unknown3[4];
|
|
};
|
|
|
|
#seekto 0x0F00;
|
|
struct {
|
|
struct settings_vfo a;
|
|
struct settings_vfo b;
|
|
struct settings_vfo c;
|
|
struct settings_vfo d;
|
|
} vfo;
|
|
|
|
#seekto 0x0F80;
|
|
struct {
|
|
char line1[8];
|
|
char line2[8];
|
|
char line3[8];
|
|
char line4[8];
|
|
char line5[8];
|
|
char line6[8];
|
|
char line7[8];
|
|
char line8[8];
|
|
} poweron_msg;
|
|
|
|
#seekto 0x0FE0;
|
|
struct {
|
|
char line[16];
|
|
} static_msg;
|
|
|
|
#seekto 0x1000;
|
|
struct {
|
|
char name[7];
|
|
u8 unknown1[9];
|
|
} names[200];
|
|
|
|
#seekto 0x2400;
|
|
struct {
|
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
|
u8 group_tone;
|
|
u8 repeat_tone;
|
|
u8 unused[13];
|
|
} _5tone_std_settings[15];
|
|
|
|
#seekto 0x2500;
|
|
struct {
|
|
u8 frame1[5];
|
|
u8 frame2[5];
|
|
u8 frame3[5];
|
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
|
} _5tone_codes[15];
|
|
|
|
#seekto 0x25F0;
|
|
struct {
|
|
u8 _5tone_delay1; // * 10ms
|
|
u8 _5tone_delay2; // * 10ms
|
|
u8 _5tone_delay3; // * 10ms
|
|
u8 _5tone_first_digit_ext_length;
|
|
u8 unknown1;
|
|
u8 unknown2;
|
|
u8 unknown3;
|
|
u8 unknown4;
|
|
u8 decode_standard;
|
|
u8 unknown5:5,
|
|
_5tone_decode_call_frame3:1,
|
|
_5tone_decode_call_frame2:1,
|
|
_5tone_decode_call_frame1:1;
|
|
u8 unknown6:5,
|
|
_5tone_decode_disp_frame3:1,
|
|
_5tone_decode_disp_frame2:1,
|
|
_5tone_decode_disp_frame1:1;
|
|
u8 decode_reset_time; // * 100 + 100ms
|
|
} _5tone_settings;
|
|
|
|
#seekto 0x2900;
|
|
struct {
|
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
|
} dtmf_codes[15];
|
|
|
|
#seekto 0x29F0;
|
|
struct {
|
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10 // 9f0
|
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10 // 9f1
|
|
u8 unknown0[14]; // 9f2-9ff
|
|
u8 inspection[16]; // a00-a0f
|
|
u8 monitor[16]; // a10-a1f
|
|
u8 alarmcode[16]; // a20-a2f
|
|
u8 stun[16]; // a30-a3f
|
|
u8 kill[16]; // a40-a4f
|
|
u8 revive[16]; // a50-a5f
|
|
u8 unknown1[16]; // a60-a6f
|
|
u8 unknown2[16]; // a70-a7f
|
|
u8 unknown3[16]; // a80-a8f
|
|
u8 unknown4[16]; // a90-a9f
|
|
u8 unknown5[16]; // aa0-aaf
|
|
u8 unknown6[16]; // ab0-abf
|
|
u8 unknown7[16]; // ac0-acf
|
|
u8 masterid[16]; // ad0-adf
|
|
u8 viceid[16]; // ae0-aef
|
|
u8 unused01:7, // af0
|
|
mastervice:1;
|
|
u8 unused02:3, // af1
|
|
mrevive:1,
|
|
mkill:1,
|
|
mstun:1,
|
|
mmonitor:1,
|
|
minspection:1;
|
|
u8 unused03:3, // af2
|
|
vrevive:1,
|
|
vkill:1,
|
|
vstun:1,
|
|
vmonitor:1,
|
|
vinspection:1;
|
|
u8 unused04:6, // af3
|
|
txdisable:1,
|
|
rxdisable:1;
|
|
u8 groupcode; // af4
|
|
u8 spacecode; // af5
|
|
u8 delayproctime; // * 100 + 100ms // af6
|
|
u8 resettime; // * 100 + 100ms // af7
|
|
} dtmf_settings;
|
|
|
|
#seekto 0x2D00;
|
|
struct {
|
|
struct {
|
|
ul16 freq1;
|
|
u8 unused01[6];
|
|
ul16 freq2;
|
|
u8 unused02[6];
|
|
} _2tone_encode[15];
|
|
u8 duration_1st_tone; // *10ms
|
|
u8 duration_2nd_tone; // *10ms
|
|
u8 duration_gap; // *10ms
|
|
u8 unused03[13];
|
|
struct {
|
|
struct {
|
|
u8 dec; // one out of LIST_2TONE_DEC
|
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
|
u8 alert; // 1-16
|
|
} decs[4];
|
|
u8 unused04[4];
|
|
} _2tone_decode[15];
|
|
u8 unused05[16];
|
|
|
|
struct {
|
|
ul16 freqA;
|
|
ul16 freqB;
|
|
ul16 freqC;
|
|
ul16 freqD;
|
|
// unknown what those values mean, but they are
|
|
// derived from configured frequencies
|
|
ul16 derived_from_freqA; // 2304000/freqA
|
|
ul16 derived_from_freqB; // 2304000/freqB
|
|
ul16 derived_from_freqC; // 2304000/freqC
|
|
ul16 derived_from_freqD; // 2304000/freqD
|
|
}freqs[15];
|
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
|
} _2tone;
|
|
|
|
#seekto 0x3D80;
|
|
struct {
|
|
u8 vhf_low[3];
|
|
u8 vhf_high[3];
|
|
u8 unknown1[4];
|
|
u8 unknown2[6];
|
|
u8 vhf2_low[3];
|
|
u8 vhf2_high[3];
|
|
u8 unknown3[4];
|
|
u8 unknown4[6];
|
|
u8 uhf_low[3];
|
|
u8 uhf_high[3];
|
|
u8 unknown5[4];
|
|
u8 unknown6[6];
|
|
u8 uhf2_low[3];
|
|
u8 uhf2_high[3];
|
|
} ranges;
|
|
|
|
#seekto 0x3F70;
|
|
struct {
|
|
char fp[6];
|
|
} fingerprint;
|
|
|
|
"""
|
|
|
|
|
|
COLOR20V2_MEM_FORMAT = """
|
|
#seekto 0x0000;
|
|
struct {
|
|
lbcd rxfreq[4];
|
|
lbcd txfreq[4];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 unknown0:4,
|
|
scode:4;
|
|
u8 unknown1:2,
|
|
spmute:2,
|
|
unknown2:2,
|
|
optsig:2;
|
|
u8 unknown3:3,
|
|
scramble:1,
|
|
unknown4:2,
|
|
power:2;
|
|
u8 unknown5:1,
|
|
wide:1,
|
|
unknown6:2,
|
|
bcl:1,
|
|
add:1,
|
|
pttid:2;
|
|
} memory[200];
|
|
|
|
#seekto 0x0E00;
|
|
struct {
|
|
u8 tmr; // e00 00 confirmed
|
|
u8 unknown1; // e01
|
|
u8 sql; // e02 02 confirmed
|
|
u8 unknown2; // e03
|
|
u8 autolock; // e04 04 confirmed
|
|
u8 tot; // e05 05 confirmed
|
|
u8 apo; // e06 06 confirmed
|
|
u8 unknown3; // e07
|
|
u8 abr; // e08 08 confirmed
|
|
u8 beep; // e09 09 confirmed
|
|
u8 unknown4[4]; // e0a-e0d
|
|
u8 dtmfst; // e0e 14 confirmed
|
|
u8 unknown5[2]; // e0f-e10
|
|
u8 screv; // e11 17 confirmed
|
|
u8 unknown6[2]; // e12-e13
|
|
u8 pttid; // e14 20 confirmed
|
|
u8 pttlt; // e15 21 confirmed
|
|
u8 unknown7; // e16
|
|
u8 emctp; // e17 23 confirmed
|
|
u8 emcch; // e18 24 confirmed
|
|
u8 sigbp; // e19 25confirmed
|
|
u8 unknown8; // e1a
|
|
u8 camdf; // e1b 27 confirmed
|
|
u8 cbmdf; // e1c 28 confirmed
|
|
u8 ccmdf; // e1d 29 confirmed
|
|
u8 vox; // e1e 30 confirmed
|
|
u8 voxt; // e1f 31 confirmed
|
|
u8 sync; // e20 32 confirmed
|
|
u8 asfc; // e21 33 confirmed above stat fore color
|
|
u8 mainfc; // e22 34 confirmed main fore color
|
|
u8 a_fc; // e23 35 confirmed a - fore color
|
|
u8 b_fc; // e24 36 confirmed b - fore color
|
|
u8 c_fc; // e25 37 confirmed c - fore color
|
|
u8 subfc; // e26 38 confirmed sub fore color
|
|
u8 battfc; // e27 39 confirmed batt fore color
|
|
u8 sigfc; // e28 40 confirmed signale fore color
|
|
u8 menufc; // e29 41 confirmed menu fore color
|
|
u8 txfc; // e2a 42 confirmed tx fore color
|
|
u8 rxfc; // e2b 43 confirmed rx fore color
|
|
u8 repsw; // e2c 44 confirmed
|
|
u8 dsub; // e2d 45 confirmed
|
|
u8 unknown9[5]; // e2e-e32
|
|
u8 anil; // e33 51 confirmed
|
|
u8 reps; // e34 52 confirmed
|
|
u8 repm; // e35 53 confirmed
|
|
u8 tmrmr; // e36 54 confirmed
|
|
u8 ste; // e37 55 confirmed
|
|
u8 rpste; // e38 56 confirmed
|
|
u8 rptdl; // e39 57 confirmed
|
|
u8 dtmfg; // e3a 58 confirmed
|
|
u8 mgain; // e3b 59 confirmed
|
|
u8 skiptx; // e3c 60 confirmed
|
|
u8 scmode; // e3d 61 confirmed
|
|
u8 tmrtx; // e3e 62 confirmed
|
|
u8 volume; // e3f 63 confirmed
|
|
u8 unknown_10; // e40
|
|
u8 save; // e41 65 confirmed
|
|
} settings;
|
|
|
|
#seekto 0x0E80;
|
|
struct {
|
|
u8 unknown1;
|
|
u8 vfomr;
|
|
u8 keylock;
|
|
u8 unknown2;
|
|
u8 unknown3:4,
|
|
vfomren:1,
|
|
unknown4:1,
|
|
reseten:1,
|
|
menuen:1;
|
|
u8 unknown5[11];
|
|
u8 dispab;
|
|
u8 unknown6[2];
|
|
u8 menu;
|
|
u8 unknown7[7];
|
|
u8 vfomra;
|
|
u8 vfomrb;
|
|
u8 vfomrc;
|
|
u8 vfomrd;
|
|
u8 mrcha;
|
|
u8 mrchb;
|
|
u8 mrchc;
|
|
u8 mrchd;
|
|
} settings2;
|
|
|
|
struct settings_vfo {
|
|
u8 freq[8];
|
|
u8 offset[6];
|
|
u8 unknown2[2];
|
|
ul16 rxtone;
|
|
ul16 txtone;
|
|
u8 scode;
|
|
u8 spmute;
|
|
u8 optsig;
|
|
u8 scramble;
|
|
u8 wide;
|
|
u8 power;
|
|
u8 shiftd;
|
|
u8 step;
|
|
u8 unknown3[4];
|
|
};
|
|
|
|
#seekto 0x0F00;
|
|
struct {
|
|
struct settings_vfo a;
|
|
struct settings_vfo b;
|
|
struct settings_vfo c;
|
|
struct settings_vfo d;
|
|
} vfo;
|
|
|
|
#seekto 0x0F80;
|
|
struct {
|
|
char line1[8];
|
|
char line2[8];
|
|
char line3[8];
|
|
char line4[8];
|
|
char line5[8];
|
|
char line6[8];
|
|
char line7[8];
|
|
char line8[8];
|
|
} poweron_msg;
|
|
|
|
#seekto 0x0FE0;
|
|
struct {
|
|
char line[16];
|
|
} static_msg;
|
|
|
|
#seekto 0x1000;
|
|
struct {
|
|
char name[7];
|
|
u8 unknown1[9];
|
|
} names[200];
|
|
|
|
#seekto 0x2400;
|
|
struct {
|
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
|
u8 group_tone;
|
|
u8 repeat_tone;
|
|
u8 unused[13];
|
|
} _5tone_std_settings[15];
|
|
|
|
#seekto 0x2500;
|
|
struct {
|
|
u8 frame1[5];
|
|
u8 frame2[5];
|
|
u8 frame3[5];
|
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
|
} _5tone_codes[15];
|
|
|
|
#seekto 0x25F0;
|
|
struct {
|
|
u8 _5tone_delay1; // * 10ms
|
|
u8 _5tone_delay2; // * 10ms
|
|
u8 _5tone_delay3; // * 10ms
|
|
u8 _5tone_first_digit_ext_length;
|
|
u8 unknown1;
|
|
u8 unknown2;
|
|
u8 unknown3;
|
|
u8 unknown4;
|
|
u8 decode_standard;
|
|
u8 unknown5:5,
|
|
_5tone_decode_call_frame3:1,
|
|
_5tone_decode_call_frame2:1,
|
|
_5tone_decode_call_frame1:1;
|
|
u8 unknown6:5,
|
|
_5tone_decode_disp_frame3:1,
|
|
_5tone_decode_disp_frame2:1,
|
|
_5tone_decode_disp_frame1:1;
|
|
u8 decode_reset_time; // * 100 + 100ms
|
|
} _5tone_settings;
|
|
|
|
#seekto 0x2900;
|
|
struct {
|
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
|
} dtmf_codes[15];
|
|
|
|
#seekto 0x29F0;
|
|
struct {
|
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
|
u8 unknown0[14];
|
|
u8 inspection[16];
|
|
u8 monitor[16];
|
|
u8 alarmcode[16];
|
|
u8 stun[16];
|
|
u8 kill[16];
|
|
u8 revive[16];
|
|
u8 unknown1[16];
|
|
u8 unknown2[16];
|
|
u8 unknown3[16];
|
|
u8 unknown4[16];
|
|
u8 unknown5[16];
|
|
u8 unknown6[16];
|
|
u8 unknown7[16];
|
|
u8 masterid[16];
|
|
u8 viceid[16];
|
|
u8 unused01:7,
|
|
mastervice:1;
|
|
u8 unused02:3,
|
|
mrevive:1,
|
|
mkill:1,
|
|
mstun:1,
|
|
mmonitor:1,
|
|
minspection:1;
|
|
u8 unused03:3,
|
|
vrevive:1,
|
|
vkill:1,
|
|
vstun:1,
|
|
vmonitor:1,
|
|
vinspection:1;
|
|
u8 unused04:6,
|
|
txdisable:1,
|
|
rxdisable:1;
|
|
u8 groupcode;
|
|
u8 spacecode;
|
|
u8 delayproctime; // * 100 + 100ms
|
|
u8 resettime; // * 100 + 100ms
|
|
} dtmf_settings;
|
|
|
|
#seekto 0x2D00;
|
|
struct {
|
|
struct {
|
|
ul16 freq1;
|
|
u8 unused01[6];
|
|
ul16 freq2;
|
|
u8 unused02[6];
|
|
} _2tone_encode[15];
|
|
u8 duration_1st_tone; // *10ms
|
|
u8 duration_2nd_tone; // *10ms
|
|
u8 duration_gap; // *10ms
|
|
u8 unused03[13];
|
|
struct {
|
|
struct {
|
|
u8 dec; // one out of LIST_2TONE_DEC
|
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
|
u8 alert; // 1-16
|
|
} decs[4];
|
|
u8 unused04[4];
|
|
} _2tone_decode[15];
|
|
u8 unused05[16];
|
|
|
|
struct {
|
|
ul16 freqA;
|
|
ul16 freqB;
|
|
ul16 freqC;
|
|
ul16 freqD;
|
|
// unknown what those values mean, but they are
|
|
// derived from configured frequencies
|
|
ul16 derived_from_freqA; // 2304000/freqA
|
|
ul16 derived_from_freqB; // 2304000/freqB
|
|
ul16 derived_from_freqC; // 2304000/freqC
|
|
ul16 derived_from_freqD; // 2304000/freqD
|
|
}freqs[15];
|
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
|
} _2tone;
|
|
|
|
#seekto 0x3D80;
|
|
struct {
|
|
u8 vhf_low[3];
|
|
u8 vhf_high[3];
|
|
u8 unknown1[4];
|
|
u8 unknown2[6];
|
|
u8 vhf2_low[3];
|
|
u8 vhf2_high[3];
|
|
u8 unknown3[4];
|
|
u8 unknown4[6];
|
|
u8 uhf_low[3];
|
|
u8 uhf_high[3];
|
|
u8 unknown5[4];
|
|
u8 unknown6[6];
|
|
u8 uhf2_low[3];
|
|
u8 uhf2_high[3];
|
|
} ranges;
|
|
|
|
#seekto 0x3F70;
|
|
struct {
|
|
char fp[6];
|
|
} fingerprint;
|
|
|
|
"""
|
|
|
|
|
|
class BTechColorWP(BTechMobileCommon):
|
|
"""BTECH's Color WP Mobile and alike radios"""
|
|
COLOR_LCD = True
|
|
COLOR_LCD4 = True
|
|
NAME_LENGTH = 7
|
|
LIST_TMR = LIST_TMR7
|
|
|
|
#def process_mmap(self):
|
|
# """Process the mem map into the mem object"""
|
|
|
|
# # Get it
|
|
# self._memobj = bitwise.parse(COLORWP_MEM_FORMAT, self._mmap)
|
|
|
|
# # load specific parameters from the radio image
|
|
# self.set_options()
|
|
|
|
def set_options(self):
|
|
"""This is to read the options from the image and set it in the
|
|
environment, for now just the limits of the freqs in the VHF/UHF
|
|
ranges"""
|
|
|
|
# setting the correct ranges for each radio type
|
|
ranges = self._memobj.ranges
|
|
|
|
# the normal dual bands
|
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
|
|
|
# DEBUG
|
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
|
|
|
# set the class with the real data
|
|
self._vhf_range = vhf
|
|
self._uhf_range = uhf
|
|
|
|
|
|
@directory.register
|
|
class WP9900(BTechColorWP):
|
|
"""Anysecu WP-9900"""
|
|
VENDOR = "Anysecu"
|
|
MODEL = "WP-9900"
|
|
BANDS = 2
|
|
##LIST_TMR = LIST_TMR7
|
|
UPLOAD_MEM_SIZE = 0X3100
|
|
##UPLOAD_MEM_SIZE = 0X4000
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=25),
|
|
chirp_common.PowerLevel("Low", watts=5)]
|
|
_upper = 199
|
|
_magic = MSTRING_WP9900
|
|
_fileid = [WP9900_fp, ]
|
|
_gmrs = False ##True
|
|
|
|
|
|
def process_mmap(self):
|
|
"""Process the mem map into the mem object"""
|
|
|
|
# Get it
|
|
self._memobj = bitwise.parse(COLOR9900_MEM_FORMAT, self._mmap)
|
|
|
|
# load specific parameters from the radio image
|
|
self.set_options()
|
|
|
|
|
|
# real radios
|
|
@directory.register
|
|
class GMRS20V2(BTechColorWP):
|
|
"""Baofeng Tech GMRS-20V2"""
|
|
MODEL = "GMRS-20V2"
|
|
BANDS = 2
|
|
##LIST_TMR = LIST_TMR7
|
|
UPLOAD_MEM_SIZE = 0X3100
|
|
##UPLOAD_MEM_SIZE = 0X4000
|
|
_power_levels = [chirp_common.PowerLevel("High", watts=20),
|
|
chirp_common.PowerLevel("", watts=6),
|
|
chirp_common.PowerLevel("Low", watts=5)]
|
|
_upper = 199
|
|
_magic = MSTRING_GMRS20V2
|
|
_fileid = [GMRS20V2_fp, ]
|
|
_gmrs = True
|
|
|
|
def process_mmap(self):
|
|
"""Process the mem map into the mem object"""
|
|
|
|
# Get it
|
|
self._memobj = bitwise.parse(COLOR20V2_MEM_FORMAT, self._mmap)
|
|
|
|
# load specific parameters from the radio image
|
|
self.set_options()
|