[chirp_devel] [PATCH 2 of 4] [ft8x7] Detect us driver used to clone non us radio
Marco Filippi IZ3GME
Thu Jan 16 15:24:29 PST 2014
# HG changeset patch
# User Marco Filippi <iz3gme.marco at gmail.com>
# Date 1389909601 -3600
# Node ID 5236e0423182974b1c7c8851105fa3f3fa1d173e
# Parent fe6805f6f632016c4cf63fc3f6a75560533e5ae8
[ft8x7] Detect us driver used to clone non us radio
Implement feature #1375
diff -r fe6805f6f632 -r 5236e0423182 chirp/ft817.py
--- a/chirp/ft817.py Thu Jan 16 22:46:33 2014 +0100
+++ b/chirp/ft817.py Thu Jan 16 23:00:01 2014 +0100
@@ -294,7 +294,7 @@
4. Press the [C] key ("RX" will appear on the LCD)."""))
return rp
- def _read(self, block, blocknum):
+ def _read(self, block, blocknum, lastblock):
for _i in range(0, 60):
data = self.pipe.read(block+2)
if data:
@@ -309,7 +309,13 @@
checksum.get_calculated(data), blocknum))
data = data[1:block+1] # Chew away the block number and the checksum
else:
- raise Exception("Unable to read block %02X expected %i got %i" %
+ if lastblock and self._US_model:
+ raise Exception(_("Unable to read last block. "
+ "This often happens when the selected model is US "
+ "but the radio is a non-US one (or widebanded). "
+ "Please choose the correct model and try again."))
+ else:
+ raise Exception("Unable to read block %02X expected %i got %i" %
(blocknum, block+2, len(data)))
if os.getenv("CHIRP_DEBUG"):
@@ -326,7 +332,8 @@
blocks = 0
status = chirp_common.Status()
status.msg = _("Cloning from radio")
- status.max = len(self._block_lengths) + 39
+ nblocks = len(self._block_lengths) + 39
+ status.max = nblocks
for block in self._block_lengths:
if blocks == 8:
# repeated read of 40 block same size (memory area)
@@ -334,7 +341,7 @@
else:
repeat = 1
for _i in range(0, repeat):
- data += self._read(block, blocks)
+ data += self._read(block, blocks, blocks == nblocks-1)
self.pipe.write(chr(CMD_ACK))
blocks += 1
status.cur = blocks
More information about the chirp_devel
mailing list