[chirp_devel] [PATCH 1 of 2] [bf888] Clean up clone routines

Dan Smith
Sat Sep 7 14:59:05 PDT 2013


# HG changeset patch
# User Dan Smith <dsmith at danplanet.com>
# Date 1378591047 25200
# Node ID 43ba3ac0bb90717faec6a60ee3bc0c5fdc74b889
# Parent  266d4bbe22c2405860b79141a28584db9bd1792b
[bf888] Clean up clone routines

This avoids counting the blocks and otherwise streamlines the
clone upload and download routines.

Related to #701

diff -r 266d4bbe22c2 -r 43ba3ac0bb90 chirp/h777.py
--- a/chirp/h777.py	Sat Sep 07 14:39:10 2013 -0700
+++ b/chirp/h777.py	Sat Sep 07 14:57:27 2013 -0700
@@ -163,31 +163,20 @@
     status = chirp_common.Status()
     status.msg = "Cloning from radio"
 
-    block_count = 0
-    for start_addr, end_addr in radio._ranges:
-        # TODO: Count how many block we are going to attempt to read.
-        # This could be done better. :)
-        for block_addr in range(start_addr, end_addr, BLOCK_SIZE):
-            block_count += 1
+    status.cur = 0
+    status.max = radio._memsize
 
-    status.cur = 0
-    status.max = block_count
+    for addr in range(0, radio._memsize, BLOCK_SIZE):
+        status.cur = addr + BLOCK_SIZE
+        radio.status_fn(status)
 
-    for start_addr, end_addr in radio._ranges:
+        block = _h777_read_block(radio, addr, BLOCK_SIZE)
+        data += block
+
         if DEBUG:
-            print("Reading Data:")
-
-        for block_addr in range(start_addr, end_addr, BLOCK_SIZE):
-            status.cur += 1
-            radio.status_fn(status)
-
-            block = _h777_read_block(radio, block_addr, BLOCK_SIZE)
-            data += block
-
-            if DEBUG:
-                sys.stdout.write("%04x: " % (block_addr))
-                debug_print_hex(block)
-                print("")
+            sys.stdout.write("%04x: " % (addr))
+            debug_print_hex(block)
+            print("")
 
     _h777_exit_programming_mode(radio)
 
@@ -199,18 +188,14 @@
 
     _h777_enter_programming_mode(radio)
 
-    block_count = 0
-    for a in UPLOAD_BLOCKS:
-        block_count += len(a)
+    status.cur = 0
+    status.max = radio._memsize
 
-    status.cur = 0
-    status.max = block_count
-
-    for a in UPLOAD_BLOCKS:
-        for b in a:
-            status.cur += 1
+    for start_addr, end_addr in radio._ranges:
+        for addr in range(start_addr, end_addr, BLOCK_SIZE):
+            status.cur = addr + BLOCK_SIZE
             radio.status_fn(status)
-            _h777_write_block(radio, b, BLOCK_SIZE)
+            _h777_write_block(radio, addr, BLOCK_SIZE)
 
     _h777_exit_programming_mode(radio)
 
@@ -239,8 +224,11 @@
     # Memory starts looping at 0x1000... But not every 0x1000.
 
     _ranges = [
-        (0x0000, 0x03E0)
+        (0x0000, 0x0110),
+        (0x02B0, 0x02C0),
+        (0x0380, 0x03E0),
         ]
+    _memsize = 0x03E0
 
     def get_features(self):
         rf = chirp_common.RadioFeatures()



More information about the chirp_devel mailing list