[chirp_devel] [PATCH 0 of 4 ] Because things can always be done better
A message in 817 list suggested me feature #1375 Then I noticed some possible sophistications to do ...
73 de IZ3GME Marco
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1389908793 -3600 # Node ID fe6805f6f632016c4cf63fc3f6a75560533e5ae8 # Parent d3be34229ec9102037aad4b211d06425adc83349 [ft8x7] Do detect "non-us driver used to clone us radio" only in non us driver Refine feature #957
diff -r d3be34229ec9 -r fe6805f6f632 chirp/ft817.py --- a/chirp/ft817.py Sat Jan 11 10:13:38 2014 -0600 +++ b/chirp/ft817.py Thu Jan 16 22:46:33 2014 +0100 @@ -32,6 +32,7 @@ BAUD_RATE = 9600 MODEL = "FT-817" _model = "" + _US_model = False
DUPLEX = ["", "-", "+", "split"] # narrow modes has to be at end @@ -339,14 +340,15 @@ status.cur = blocks self.status_fn(status)
- status.msg = _("Clone completed, checking for spurious bytes") - self.status_fn(status) - moredata = self.pipe.read(2) - if moredata: - raise Exception(_("Radio sent data after the last awaited block, " - "this happens when the selected model is a non-US " - "but the radio is a US one. " - "Please choose the correct model and try again.")) + if not self._US_model: + status.msg = _("Clone completed, checking for spurious bytes") + self.status_fn(status) + moredata = self.pipe.read(2) + if moredata: + raise Exception(_("Radio sent data after the last awaited block, " + "this happens when the selected model is a non-US " + "but the radio is a US one. " + "Please choose the correct model and try again."))
print "Clone completed in %i seconds" % (time.time() - start) @@ -1080,6 +1082,7 @@ MODEL = "FT-817ND (US)"
_model = "" + _US_model = True _memsize = 6651 # block 9 (130 Bytes long) is to be repeted 40 times _block_lengths = [ 2, 40, 208, 182, 208, 182, 198, 53, 130, 118, 130, 130] diff -r d3be34229ec9 -r fe6805f6f632 chirp/ft857.py --- a/chirp/ft857.py Sat Jan 11 10:13:38 2014 -0600 +++ b/chirp/ft857.py Thu Jan 16 22:46:33 2014 +0100 @@ -1028,6 +1028,7 @@ MODEL = "FT-857/897 (US)"
_model = "" + _US_model = True _memsize = 7481 # block 9 (140 Bytes long) is to be repeted 40 times # should be 42 times but this way I can use original 817 functions
# HG changeset patch # User Marco Filippi iz3gme.marco@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
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1389912343 -3600 # Node ID 2542bd064fff967c696d05ff39397de2592e4786 # Parent 5236e0423182974b1c7c8851105fa3f3fa1d173e [ft8x7] Reduce timeout during clone-in for blocks after the first A long delay is necessary for the first block to give user the time to start clone procedure on the radio but for subsequent blocks a 10 sec timeout is more then enough Help feature #1375
diff -r 5236e0423182 -r 2542bd064fff chirp/ft817.py --- a/chirp/ft817.py Thu Jan 16 23:00:01 2014 +0100 +++ b/chirp/ft817.py Thu Jan 16 23:45:43 2014 +0100 @@ -295,7 +295,12 @@ return rp
def _read(self, block, blocknum, lastblock): - for _i in range(0, 60): + # be very patient at first block + if blocknum == 0: + attempts = 60 + else: + attempts = 5 + for _i in range(0, attempts): data = self.pipe.read(block+2) if data: break
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1389912907 -3600 # Node ID b06a05dff6afadda4d6bd353eda7c10f2c71048a # Parent 2542bd064fff967c696d05ff39397de2592e4786 Fix commit message line lenght test
Do not add a linefeed to line being tested
Noticed at commit time for #1375
diff -r 2542bd064fff -r b06a05dff6af tools/checkpatch.sh --- a/tools/checkpatch.sh Thu Jan 16 23:45:43 2014 +0100 +++ b/tools/checkpatch.sh Thu Jan 16 23:55:07 2014 +0100 @@ -35,7 +35,7 @@ read line if [ -z "$line" ]; then break - elif [ $(echo "$line" | wc -c) -ge 80 ]; then + elif [ $(echo -n "$line" | wc -c) -ge 80 ]; then return 1 fi done
participants (1)
-
Marco Filippi IZ3GME