[chirp_devel] [PATCH] [UV-5R] "radio refused to send block code 0x1ec0" patch
# HG changeset patch # User Jim Unroe rock.unroe@gmail.com # Date 1426370486 14400 # Node ID ecba19b26da64ecd03be7d47e04d1ad21d1ae08f # Parent c9c9128ca29ea21f54249788a9c0e47c9d5fbdc4 [UV-5R] "radio refused to send block code 0x1ec0" patch
Fix downloading/uploading issue for UV-5R.
Mathieu Rozon created the original patch. Updated by Jim Unroe for better uploading compatiblilty.
Fixes #2317
diff -r c9c9128ca29e -r ecba19b26da6 chirp/drivers/uv5r.py --- a/chirp/drivers/uv5r.py Thu Mar 12 09:49:32 2015 +0100 +++ b/chirp/drivers/uv5r.py Sat Mar 14 18:01:26 2015 -0400 @@ -442,10 +442,16 @@ return ident
-def _read_block(radio, start, size): +def _read_block(radio, start, size, first_command = False): msg = struct.pack(">BHB", ord("S"), start, size) radio.pipe.write(msg)
+ if(first_command == False): + ack = radio.pipe.read(1) + if ack != "\x06": + raise errors.RadioError("Radio refused to send second block 0x%04x" % + start) + answer = radio.pipe.read(4) if len(answer) != 4: raise errors.RadioError("Radio refused to send block 0x%04x" % start) @@ -464,28 +470,25 @@ raise errors.RadioError("Radio sent incomplete block 0x%04x" % start)
radio.pipe.write("\x06") - - ack = radio.pipe.read(1) - if ack != "\x06": - raise errors.RadioError("Radio refused to send block 0x%04x" % start) + time.sleep(0.005)
return chunk
def _get_radio_firmware_version(radio): if radio.MODEL == "BJ-UV55": - block = _read_block(radio, 0x1FF0, 0x40) + block = _read_block(radio, 0x1FF0, 0x40, True) version = block[0:6] else: - block1 = _read_block(radio, 0x1EC0, 0x40) - block2 = _read_block(radio, 0x1F00, 0x40) + block1 = _read_block(radio, 0x1EC0, 0x40, True) + block2 = _read_block(radio, 0x1F00, 0x40, False) block = block1 + block2 version = block[48:62] return version
def _get_radio_special_block(radio): - block = _read_block(radio, 0xCF0, 0x40) + block = _read_block(radio, 0xCF0, 0x40, False) special_block = block[2:9] return special_block
@@ -517,14 +520,14 @@ # Main block LOG.debug("downloading main block...") for i in range(0, 0x1800, 0x40): - data += _read_block(radio, i, 0x40) + data += _read_block(radio, i, 0x40, False) _do_status(radio, i) _do_status(radio, radio.get_memsize()) LOG.debug("done.") LOG.debug("downloading aux block...") # Auxiliary block starts at 0x1ECO (?) for i in range(0x1EC0, 0x2000, 0x40): - data += _read_block(radio, i, 0x40) + data += _read_block(radio, i, 0x40, False) LOG.debug("done.") return memmap.MemoryMap(data)
@@ -532,6 +535,7 @@ def _send_block(radio, addr, data): msg = struct.pack(">BHB", ord("X"), addr, len(data)) radio.pipe.write(msg + data) + time.sleep(0.05)
ack = radio.pipe.read(1) if ack != "\x06":
I currently cannot run the "run_tests" script. Sorry.
Jim
On Sat, Mar 14, 2015 at 6:03 PM, Jim Unroe rock.unroe@gmail.com wrote:
# HG changeset patch # User Jim Unroe rock.unroe@gmail.com # Date 1426370486 14400 # Node ID ecba19b26da64ecd03be7d47e04d1ad21d1ae08f # Parent c9c9128ca29ea21f54249788a9c0e47c9d5fbdc4 [UV-5R] "radio refused to send block code 0x1ec0" patch
Fix downloading/uploading issue for UV-5R.
Mathieu Rozon created the original patch. Updated by Jim Unroe for better uploading compatiblilty.
Fixes #2317
diff -r c9c9128ca29e -r ecba19b26da6 chirp/drivers/uv5r.py --- a/chirp/drivers/uv5r.py Thu Mar 12 09:49:32 2015 +0100 +++ b/chirp/drivers/uv5r.py Sat Mar 14 18:01:26 2015 -0400 @@ -442,10 +442,16 @@ return ident
-def _read_block(radio, start, size): +def _read_block(radio, start, size, first_command = False): msg = struct.pack(">BHB", ord("S"), start, size) radio.pipe.write(msg)
- if(first_command == False):
ack = radio.pipe.read(1)
if ack != "\x06":
raise errors.RadioError("Radio refused to send second block 0x%04x" %
start)
- answer = radio.pipe.read(4) if len(answer) != 4: raise errors.RadioError("Radio refused to send block 0x%04x" % start)
@@ -464,28 +470,25 @@ raise errors.RadioError("Radio sent incomplete block 0x%04x" % start)
radio.pipe.write("\x06")
- ack = radio.pipe.read(1)
- if ack != "\x06":
raise errors.RadioError("Radio refused to send block 0x%04x" % start)
time.sleep(0.005)
return chunk
def _get_radio_firmware_version(radio): if radio.MODEL == "BJ-UV55":
block = _read_block(radio, 0x1FF0, 0x40)
else:block = _read_block(radio, 0x1FF0, 0x40, True) version = block[0:6]
block1 = _read_block(radio, 0x1EC0, 0x40)
block2 = _read_block(radio, 0x1F00, 0x40)
block1 = _read_block(radio, 0x1EC0, 0x40, True)
return versionblock2 = _read_block(radio, 0x1F00, 0x40, False) block = block1 + block2 version = block[48:62]
def _get_radio_special_block(radio):
- block = _read_block(radio, 0xCF0, 0x40)
- block = _read_block(radio, 0xCF0, 0x40, False) special_block = block[2:9] return special_block
@@ -517,14 +520,14 @@ # Main block LOG.debug("downloading main block...") for i in range(0, 0x1800, 0x40):
data += _read_block(radio, i, 0x40)
_do_status(radio, radio.get_memsize()) LOG.debug("done.") LOG.debug("downloading aux block...") # Auxiliary block starts at 0x1ECO (?) for i in range(0x1EC0, 0x2000, 0x40):data += _read_block(radio, i, 0x40, False) _do_status(radio, i)
data += _read_block(radio, i, 0x40)
LOG.debug("done.") return memmap.MemoryMap(data)data += _read_block(radio, i, 0x40, False)
@@ -532,6 +535,7 @@ def _send_block(radio, addr, data): msg = struct.pack(">BHB", ord("X"), addr, len(data)) radio.pipe.write(msg + data)
time.sleep(0.05)
ack = radio.pipe.read(1) if ack != "\x06":
I currently cannot run the "run_tests" script. Sorry.
Also, I'm now running the pep8 checker on commit. You should be able to run that on windows with something like:
python tools/cpep8.py
I can try to see if I can make a batch file that will run normal tests and the pep8 checker from the top level like the run_all_tests.sh we have for linux.
Anyway, I fixed up the pep8 complaints in this patch. Thanks for picking it up!
--Dan
On Sun, Mar 15, 2015 at 12:19 PM, Dan Smith dsmith@danplanet.com wrote:
I currently cannot run the "run_tests" script. Sorry.
Also, I'm now running the pep8 checker on commit. You should be able to run that on windows with something like:
python tools/cpep8.py
I can try to see if I can make a batch file that will run normal tests and the pep8 checker from the top level like the run_all_tests.sh we have for linux.
Anyway, I fixed up the pep8 complaints in this patch. Thanks for picking it up!
--Dan
C:\Users\Root\chirp.hg\tools>python cpep8.py Traceback (most recent call last): File "cpep8.py", line 24, in <module> import pep8 ImportError: No module named pep8
C:\Users\Root\chirp.hg\tools>
No go with this either. I'll have to look at it later when I get back home.
Jim
No go with this either. I'll have to look at it later when I get back home.
This is an easy one, you just need the pep8 module on your system. If you have pip, just do this:
pip install pep8==1.6.2
Looks like it should be installed automatically with python 2.7.9 or later. If not, here are details for it:
https://pip.pypa.io/en/latest/installing.html
I installed my pip like the link above, and it ended up in C:\Python27\Scripts\pip.exe. So if you do that, you will want to put that in your PATH so it's easy to run for things in the future.
Thanks for your patience, Jim. The pep8 checker is a pretty handy way to make sure that our code looks more consistent.
--Dan
participants (2)
-
Dan Smith
-
Jim Unroe