[chirp_devel] [PATCH] [csv] Read KG-UV Commander CSV files. #1367
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1389397329 28800 # Node ID bb16a5d953d8170af322b6e3e9284c5bb05dbe4c # Parent b47ccb638b9bd90927ddf442368dde7df3ad0355 [csv] Read KG-UV Commander CSV files. #1367
diff -r b47ccb638b9b -r bb16a5d953d8 chirp/generic_csv.py --- a/chirp/generic_csv.py Fri Jan 10 09:50:34 2014 -0800 +++ b/chirp/generic_csv.py Fri Jan 10 15:42:09 2014 -0800 @@ -262,6 +262,89 @@
@directory.register +class CommanderCSVRadio(CSVRadio): + """A driver for reading CSV files generated by KG-UV Commander software""" + VENDOR = "Commander" + MODEL = "KG-UV" + FILE_EXTENSION = "csv" + + MODE_MAP = { + "NARR": "NFM", + "WIDE": "FM", + } + + SCAN_MAP = { + "ON": "", + "OFF": "S" + } + + ATTR_MAP = { + "#": (int, "number"), + "Name": (str, "name"), + "RX Freq": (chirp_common.parse_freq, "freq"), + "Scan": (lambda v: CommanderCSVRadio.SCAN_MAP.get(v), "skip"), + "TX Dev": (lambda v: CommanderCSVRadio.MODE_MAP.get(v), "mode"), + "Group/Notes": (str, "comment"), + } + + def _clean_number(self, headers, line, mem): + if mem.number == 0: + for memory in self.memories: + if memory.empty: + mem.number = memory.number + break + return mem + + def _clean_duplex(self, headers, line, mem): + try: + txfreq = chirp_common.parse_freq( + get_datum_by_header(headers, line, "TX Freq")) + except ValueError: + mem.duplex = "off" + return mem + + if mem.freq == txfreq: + mem.duplex = "" + elif txfreq: + mem.duplex = "split" + mem.offset = txfreq + + return mem + + def _clean_tmode(self, headers, line, mem): + rtone = get_datum_by_header(headers, line, "Encode") + ctone = get_datum_by_header(headers, line, "Decode") + if rtone == "OFF": + rtone = None + else: + rtone = float(rtone) + + if ctone == "OFF": + ctone = None + else: + ctone = float(ctone) + + if rtone: + mem.tmode = "Tone" + if ctone: + mem.tmode = "TSQL" + + mem.rtone = rtone or 88.5 + mem.ctone = ctone or mem.rtone + + return mem + + @classmethod + def match_model(cls, filedata, filename): + """Match files ending in .csv and using Commander column names.""" + return filename.lower().endswith("." + cls.FILE_EXTENSION) and \ + filedata.startswith("Name,RX Freq,TX Freq,Decode,Encode,TX Pwr," + "Scan,TX Dev,Busy Lck,Group/Notes") or \ + filedata.startswith('"#","Name","RX Freq","TX Freq","Decode",' + '"Encode","TX Pwr","Scan","TX Dev","Busy Lck","Group/Notes"') + + +@directory.register class RTCSVRadio(CSVRadio): """A driver for reading CSV files generated by RT Systems software""" VENDOR = "RT Systems"
participants (1)
-
Tom Hayward