[chirp_devel] [PATCH] Add a new FileBackedRadio subclass between CloneModeRadio and Radio
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1333721605 25200 # Node ID f7942039927ba8cafc1ebeead03e7dfbce14f993 # Parent 0cb945b5cf54eebf4573871bef8fd9923286863a Add a new FileBackedRadio subclass between CloneModeRadio and Radio
This helps to distinguish between purely file-based drivers (such as CSV and XML) and a file-backed radio that can be uploaded (such as all the current clone-type radios). This also changes the logic in chirpui/clone.py that filters out drivers that can't be connected to an actual device.
Related to Bug #102
diff -r 0cb945b5cf54 -r f7942039927b chirp/chirp_common.py --- a/chirp/chirp_common.py Thu Apr 05 21:27:41 2012 -0700 +++ b/chirp/chirp_common.py Fri Apr 06 07:13:25 2012 -0700 @@ -904,28 +904,10 @@
return msgs
-class CloneModeRadio(Radio): - """A clone-mode radio does a full memory dump in and out and we store - an image of the radio into an image file""" - - _memsize = 0 - +class FileBackedRadio(Radio): + """A file-backed radio stores its data in a file""" FILE_EXTENSION = "img"
- def __init__(self, pipe): - self.errors = [] - self._mmap = None - - if isinstance(pipe, str): - self.pipe = None - self.load_mmap(pipe) - elif isinstance(pipe, memmap.MemoryMap): - self.pipe = None - self._mmap = pipe - self.process_mmap() - else: - Radio.__init__(self, pipe) - def save(self, filename): self.save_mmap(filename)
@@ -953,20 +935,12 @@ except IOError,e: raise Exception("File Access Error")
- def sync_in(self): - "Initiate a radio-to-PC clone operation" - pass - - def sync_out(self): - "Initiate a PC-to-radio clone operation" - pass + def get_mmap(self): + return self._mmap
def get_memsize(self): return self._memsize
- def get_mmap(self): - return self._mmap - @classmethod def match_model(cls, filedata, filename): """Given contents of a stored file (@filedata), return True if @@ -979,6 +953,35 @@ # memories of the same size. return len(filedata) == cls._memsize
+ +class CloneModeRadio(FileBackedRadio): + """A clone-mode radio does a full memory dump in and out and we store + an image of the radio into an image file""" + + _memsize = 0 + + def __init__(self, pipe): + self.errors = [] + self._mmap = None + + if isinstance(pipe, str): + self.pipe = None + self.load_mmap(pipe) + elif isinstance(pipe, memmap.MemoryMap): + self.pipe = None + self._mmap = pipe + self.process_mmap() + else: + Radio.__init__(self, pipe) + + def sync_in(self): + "Initiate a radio-to-PC clone operation" + pass + + def sync_out(self): + "Initiate a PC-to-radio clone operation" + pass + class LiveRadio(Radio): pass
diff -r 0cb945b5cf54 -r f7942039927b chirp/generic_csv.py --- a/chirp/generic_csv.py Thu Apr 05 21:27:41 2012 -0700 +++ b/chirp/generic_csv.py Fri Apr 06 07:13:25 2012 -0700 @@ -22,7 +22,7 @@ pass
@directory.register -class CSVRadio(chirp_common.CloneModeRadio, chirp_common.IcomDstarSupport): +class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport): VENDOR = "Generic" MODEL = "CSV" FILE_EXTENSION = "csv" diff -r 0cb945b5cf54 -r f7942039927b chirp/xml.py --- a/chirp/xml.py Thu Apr 05 21:27:41 2012 -0700 +++ b/chirp/xml.py Fri Apr 06 07:13:25 2012 -0700 @@ -62,7 +62,7 @@ return banks
@directory.register -class XMLRadio(chirp_common.CloneModeRadio, chirp_common.IcomDstarSupport): +class XMLRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport): VENDOR = "Generic" MODEL = "XML" FILE_EXTENSION = "chirp" diff -r 0cb945b5cf54 -r f7942039927b chirpui/clone.py --- a/chirpui/clone.py Thu Apr 05 21:27:41 2012 -0700 +++ b/chirpui/clone.py Fri Apr 06 07:13:25 2012 -0700 @@ -65,7 +65,8 @@ def __make_vendor(self, model): vendors = {} for rclass in sorted(directory.DRV_TO_RADIO.values()): - if rclass.VENDOR == "Generic": + if not issubclass(rclass, chirp_common.CloneModeRadio) and \ + not issubclass(rclass, chirp_common.LiveRadio): continue
if not vendors.has_key(rclass.VENDOR):
participants (1)
-
Dan Smith