Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change NEEDS_COMPAT_SERIAL default #1066

Merged
merged 6 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ The following must be true before PRs can be merged:
1. Commits in a single PR should be related. Squash intermediate commits into logical units (i.e. "fix tests" commits need not survive on their own). Keep cleanup commits separate from functional changes.
1. Major new features or bug fixes should reference a [CHIRP issue](https://chirpmyradio.com/projects/chirp/issues) _in the commit message_. Do this with the pattern `Fixes #1234` or `Related to #1234` so that the ticket system links the commit to the issue.
1. Please write a reasonable commit message, especially if making some change that isn't totally obvious (such as adding a new model, adding a feature, etc). The first line of every commit is emailed to the users' list after each build. It should be short, but meaningful for regular users (examples: "thd74: Fixed tone decoding" or "uv5r: Added settings support").
1. New drivers should be accompanied by a test image in `tests/images` (except for thin aliases where the driver is sufficiently tested already). All new drivers should set `NEEDS_COMPAT_SERIAL=False` and use `MemoryMapBytes`. New drivers and radio models will affect the Python3 test matrix. You should regenerate this file with `tox -emakesupported` and include it in your commit.
1. New drivers should be accompanied by a test image in `tests/images` (except for thin aliases where the driver is sufficiently tested already). All new drivers must use `MemoryMapBytes`. New drivers and radio models will affect the Python3 test matrix. You should regenerate this file with `tox -emakesupported` and include it in your commit.
1. All files must be GPLv3 licensed or contain no license verbiage. No additional restrictions can be placed on the usage (i.e. such as noncommercial).
1. Do not add new py2-compatibility code (No new uses of `six`, `future`, etc).
2 changes: 1 addition & 1 deletion chirp/chirp_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ class Radio(Alias):
# Whether or not we should assert RTS when opening the serial port
WANTS_RTS = True
ALIASES = []
NEEDS_COMPAT_SERIAL = True
NEEDS_COMPAT_SERIAL = False
FORMATS: list[str] = []

def status_fn(self, status):
Expand Down
3 changes: 3 additions & 0 deletions chirp/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ class DynamicRadioAlias(rclass):
MODEL = meta_model
VARIANT = metadata.get('variant')

def __repr__(self):
return repr(self._orig_rclass)

return DynamicRadioAlias(image_file)

if metadata:
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/alinco.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class AlincoStyleRadio(chirp_common.CloneModeRadio):
"""Base class for all known Alinco radios"""
_memsize = 0
_model = b"NONE"
NEEDS_COMPAT_SERIAL = False

def _send(self, data):
LOG.debug("PC->R: (%2i)\n%s" % (len(data), util.hexprint(data)))
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/alinco_dr735t.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class AlincoDR735T(chirp_common.CloneModeRadio):
VENDOR = "Alinco"
MODEL = "DR735T"
BAUD_RATE = 38400
NEEDS_COMPAT_SERIAL = False

TONE_MODE_MAP = {
0x00: "",
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/anytone.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
MODEL = "5888UV"
BAUD_RATE = 9600
_file_ident = [b"QX588UV", b"588UVN"]
NEEDS_COMPAT_SERIAL = False

# May try to mirror the OEM behavior later
_ranges = [
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/anytone778uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ class AnyTone778UVBase(chirp_common.CloneModeRadio,
chirp_common.ExperimentalRadio):
'''AnyTone 778UV and probably Retevis RT95 and others'''
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False
NAME_LENGTH = 5
HAS_VOX = False

Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/anytone_ht.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
VENDOR = "AnyTone"
MODEL = "TERMN-8R"
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False
_file_ident = b"TERMN8R"

# May try to mirror the OEM behavior later
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/anytone_iii.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ class AnyTone5888UVIIIRadio(chirp_common.CloneModeRadio,
VENDOR = "AnyTone"
MODEL = "5888UVIII"
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False
_file_ident = b"588UVP"

_ranges = [
Expand Down
1 change: 1 addition & 0 deletions chirp/drivers/ap510.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class AP510Radio(chirp_common.CloneModeRadio):
BAUD_RATE = 9600
VENDOR = "Sainsonic"
MODEL = "AP510"
NEEDS_COMPAT_SERIAL = True

_model = b"AVRT5"
mem_upper_limit = 0
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/baofeng_uv17.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class UV17(baofeng_uv17Pro.UV17Pro):
"""Baofeng UV-17"""
VENDOR = "Baofeng"
MODEL = "UV-17"
NEEDS_COMPAT_SERIAL = False

download_function = _download
upload_function = _upload
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/baofeng_uv17Pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ class UV17Pro(bfc.BaofengCommonHT):
"""Baofeng UV-17Pro"""
VENDOR = "Baofeng"
MODEL = "UV-17Pro"
NEEDS_COMPAT_SERIAL = False

MEM_STARTS = [0x0000, 0x9000, 0xA000, 0xD000]
MEM_SIZES = [0x8040, 0x0040, 0x02C0, 0x0040]
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/baofeng_uv3r.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ class UV3RRadio(chirp_common.CloneModeRadio):
"""Baofeng UV-3R"""
VENDOR = "Baofeng"
MODEL = "UV-3R"
NEEDS_COMPAT_SERIAL = False

def get_features(self):
rf = chirp_common.RadioFeatures()
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/baofeng_wp970i.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class WP970I(bfc.BaofengCommonHT):
"""Baofeng WP970I"""
VENDOR = "Baofeng"
MODEL = "WP970I"
NEEDS_COMPAT_SERIAL = False

_tri_band = False
_fileid = []
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/bf_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
"""Baofeng BT-F1 radio & possibly alike radios"""
VENDOR = "Baofeng"
MODEL = "BF-T1"
NEEDS_COMPAT_SERIAL = False
_vhf_range = (130000000, 174000000)
_uhf_range = (400000000, 520000000)
_upper = 20
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/bf_t8.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ class BFT8Radio(chirp_common.CloneModeRadio):
VENDOR = "Baofeng"
MODEL = "BF-T8"
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False
BLOCK_SIZE = BLOCK_SIZE_UP = 0x10
ODD_SPLIT = True
HAS_NAMES = False
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/bj9900.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
MODEL = "BJ-9900"
VARIANT = ""
BAUD_RATE = 115200
NEEDS_COMPAT_SERIAL = False

DUPLEX = ["", "-", "+", "split"]
MODES = ["NFM", "FM"]
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/bjuv55.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@
class BaojieBJUV55Radio(uv5r.BaofengUV5R):
VENDOR = "Baojie"
MODEL = "BJ-UV55"
NEEDS_COMPAT_SERIAL = False
_basetype = [b"BJ55"]
_idents = [BJUV55_MODEL]
_mem_params = (0x1928 # poweron_msg offset
Expand Down
1 change: 1 addition & 0 deletions chirp/drivers/boblov_x3plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class BoblovX3Plus(chirp_common.CloneModeRadio,
VENDOR = 'Boblov'
MODEL = 'X3Plus'
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = True
CHANNELS = 16

MEM_FORMAT = """
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/btech.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
COLOR_LCD3 = False # Color HT Radios
COLOR_LCD4 = False # Waterproof Mobile Radios
NAME_LENGTH = 6
NEEDS_COMPAT_SERIAL = False
UPLOAD_MEM_SIZE = 0X3100
_power_levels = [chirp_common.PowerLevel("High", watts=25),
chirp_common.PowerLevel("Low", watts=10)]
Expand Down
1 change: 1 addition & 0 deletions chirp/drivers/fd268.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class FeidaxinFD2x8yRadio(chirp_common.CloneModeRadio):
VENDOR = "Feidaxin"
MODEL = "FD-268 & alike Radios"
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = True
_memsize = MEM_SIZE
_upper = 99
_VFO_DEFAULT = 0
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/ft4.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
MODEL = "SCU-35Generic" # No radio directly uses the base class
BAUD_RATE = 9600
MAX_MEM_SLOT = 200
NEEDS_COMPAT_SERIAL = False
DUPLEX_OFF_VIA_OFFSET = False

# These settings are common to all radios in this family.
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/ft450d.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
COM_PRTY = 'N' # parity checking
COM_STOP = 1 # stop bits
MODEL = "FT-450D"
NEEDS_COMPAT_SERIAL = False

DUPLEX = ["", "-", "+"]
MODES = ["LSB", "USB", "CW", "AM", "FM", "DIG",
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/ft7100.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ class FT7100Radio(YaesuCloneModeRadio):
VARIANT = ""
IDBLOCK = b"Vartex Standard AH003M M-Map V04"
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False

# Return information about this radio's features, including
# how many memories it has, what bands it supports, etc
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/ft7800.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ class FTx800Radio(yaesu_clone.YaesuCloneModeRadio):
BAUD_RATE = 9600
VENDOR = "Yaesu"
MODES = list(MODES)
NEEDS_COMPAT_SERIAL = False
_block_size = 64

POWER_LEVELS_VHF = [chirp_common.PowerLevel("Hi", watts=50),
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/ft817.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
"""Yaesu FT-817"""
BAUD_RATE = 9600
MODEL = "FT-817"
NEEDS_COMPAT_SERIAL = False
_model = ""
_US_model = False

Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/ft90.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio):
VENDOR = "Yaesu"
MODEL = "FT-90"
ID = b"\x8E\xF6"
NEEDS_COMPAT_SERIAL = False

_memsize = 4063
# block 03 (200 Bytes long) repeats 18 times; channel memories
Expand Down
1 change: 1 addition & 0 deletions chirp/drivers/ftlx011.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def int_to_bcd(data):
class ftlx011(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
"""Vertex FTL1011/2011/7011 4/8/12/24 channels"""
VENDOR = "Vertex Standard"
NEEDS_COMPAT_SERIAL = True
_memsize = MEM_SIZE
_upper = 0
_range = []
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/ftm350.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio):
BAUD_RATE = 48000
VENDOR = "Yaesu"
MODEL = "FTM-350"
NEEDS_COMPAT_SERIAL = False

_model = ""
_memsize = 65536
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/ga510.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ class RadioddityGA510Radio(chirp_common.CloneModeRadio):
VENDOR = 'Radioddity'
MODEL = 'GA-510'
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False
POWER_LEVELS = [
chirp_common.PowerLevel('H', watts=10),
chirp_common.PowerLevel('L', watts=1),
Expand Down
44 changes: 39 additions & 5 deletions chirp/drivers/generic_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class CSVRadio(chirp_common.FileBackedRadio):
"""A driver for Generic CSV files"""
VENDOR = "Generic"
MODEL = "CSV"
NEEDS_COMPAT_SERIAL = True
FILE_EXTENSION = "csv"
FORMATS = [directory.register_format('CSV', '*.csv')]

Expand Down Expand Up @@ -230,6 +231,10 @@ def _load(self, f):

try:
mem = self._parse_csv_data_line(header, line)
if mem is None:
LOG.debug('Line %i did not contain a valid memory',
lineno)
continue
if mem.number is None:
raise Exception("Invalid Location field" % lineno)
except Exception as e:
Expand Down Expand Up @@ -449,6 +454,7 @@ class RTCSVRadio(CSVRadio):
"On": "S",
"P Scan": "P",
"Skip": "S",
"Scan": "",
}

TMODE_MAP = {
Expand All @@ -461,13 +467,17 @@ class RTCSVRadio(CSVRadio):
"On": True,
}

MODE_MAP = {
'FM Narrow': 'NFM',
}

ATTR_MAP = {
"Channel Number": (int, "number"),
"Receive Frequency": (chirp_common.parse_freq, "freq"),
"Offset Frequency": (chirp_common.parse_freq, "offset"),
"Offset Direction": (lambda v:
RTCSVRadio.DUPLEX_MAP.get(v, v), "duplex"),
"Operating Mode": (str, "mode"),
"Operating Mode": (lambda v: RTCSVRadio.MODE_MAP.get(v, v), 'mode'),
"Name": (str, "name"),
"Tone Mode": (lambda v:
RTCSVRadio.TMODE_MAP.get(v, v), "tmode"),
Expand All @@ -483,6 +493,10 @@ class RTCSVRadio(CSVRadio):
"Comment": (str, "comment"),
}

def __init__(self, pipe):
self._last_loaded = 0
super().__init__(pipe)

def _clean_duplex(self, headers, line, mem):
if mem.duplex == "split":
try:
Expand Down Expand Up @@ -510,6 +524,21 @@ def _clean_ctone(self, headers, line, mem):
mem.ctone = mem.rtone
return mem

def _clean_number(self, headers, line, mem):
if 'Channel Number' not in headers and self.memories:
# Some RTSystems software generates this with an empty header name?
self._last_loaded += 1
mem.number = self._last_loaded
LOG.debug('No location column, calculated %i from %r',
mem.number, self.memories[-1])
return mem

def _parse_csv_data_line(self, headers, line):
val = get_datum_by_header(headers, line, "Receive Frequency")
if not val.strip():
return
return super()._parse_csv_data_line(headers, line)

@classmethod
def match_model(cls, filedata, filename):
"""Match files ending in .csv and using RT Systems column names."""
Expand All @@ -521,8 +550,13 @@ def match_model(cls, filedata, filename):
except UnicodeDecodeError:
# CSV files are text
return False

try:
firstline, rest = filedata.split('\n', 1)
firstline_fields = firstline.split(',')
except Exception as e:
LOG.warning('Failed to detect file as RTCSV: %s', e)
return False

return filename.lower().endswith("." + cls.FILE_EXTENSION) and \
filedata.startswith("Channel Number,Receive Frequency,"
"Transmit Frequency,Offset Frequency,"
"Offset Direction,Operating Mode,"
"Name,Tone Mode,CTCSS,DCS")
'Receive Frequency' in firstline_fields
1 change: 0 additions & 1 deletion chirp/drivers/gmrsuv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class GMRSV1(bfc.BaofengCommonHT):
"""BTech GMRS-V1"""
VENDOR = "BTECH"
MODEL = "GMRS-V1"
NEEDS_COMPAT_SERIAL = False

_fileid = [GMRSV1_fp4, GMRSV1_fp3, GMRSV1_fp2, GMRSV1_fp1, ]
_is_orig = [GMRSV1_fp2, GMRSV1_fp1, GMRSV1_fp4, ]
Expand Down
2 changes: 0 additions & 2 deletions chirp/drivers/gmrsv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class GMRSV2base(bfc.BaofengCommonHT):
"""BTech GMRS-V2base"""
VENDOR = ""
MODEL = ""
NEEDS_COMPAT_SERIAL = False

_fw_ver_start = 0x1EF0
_recv_block_size = 0x40
Expand Down Expand Up @@ -1055,7 +1054,6 @@ class GMRSV2(GMRSV2base):
"""BTech GMRS-V2"""
VENDOR = "BTECH"
MODEL = "GMRS-V2"
NEEDS_COMPAT_SERIAL = False

_fileid = [GMRSV2_fp1, ]

Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/h777.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ class H777Radio(chirp_common.CloneModeRadio):
PROGRAM_CMD = b'PROGRAM'
IDENT = [b"P3107", ]
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False

# TODO: Is it 1 watt?
POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00),
Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/hf90.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class HF90StyleRadio(chirp_common.CloneModeRadio,
MODES = ["LSB", "USB"]
DUPLEX = ["", "+", "-", "split", "off"]
BAUD_RATE = 4800
NEEDS_COMPAT_SERIAL = False

HF90_POWER_LEVELS = ["Low", "High"]

Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/hg_uv98.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ class LanchonlhHG_UV98(chirp_common.CloneModeRadio, chirp_common.ExperimentalRad
MODEL = "HG-UV98"
IDENT = b"P3107\0\0\0"
BAUD_RATE = 9600
NEEDS_COMPAT_SERIAL = False

_upper = MAX_CHANNELS

Expand Down
1 change: 0 additions & 1 deletion chirp/drivers/hobbypcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class HobbyPCBRSUV3Radio(chirp_common.LiveRadio):
VENDOR = "HobbyPCB"
MODEL = "RS-UV3"
BAUD_RATE = 19200
NEEDS_COMPAT_SERIAL = False

def __init__(self, *args, **kwargs):
super(HobbyPCBRSUV3Radio, self).__init__(*args, **kwargs)
Expand Down
Loading
Loading