mirror of
https://github.com/kk7ds/chirp.git
synced 2024-09-21 18:47:18 +00:00
Fix style issues in yaesu_clone.py (#2355)
This commit is contained in:
parent
76b5efe312
commit
84ad1824b5
@ -13,30 +13,35 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
CMD_ACK = 0x06
|
||||
|
||||
from chirp import chirp_common, util, memmap, errors
|
||||
import time, os, logging
|
||||
import time
|
||||
import os
|
||||
import logging
|
||||
from textwrap import dedent
|
||||
|
||||
from chirp import chirp_common, util, memmap, errors
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
CMD_ACK = 0x06
|
||||
|
||||
|
||||
def _safe_read(pipe, count):
|
||||
buf = ""
|
||||
first = True
|
||||
for _i in range(0, 60):
|
||||
buf += pipe.read(count - len(buf))
|
||||
#print "safe_read: %i/%i\n" % (len(buf), count)
|
||||
# print "safe_read: %i/%i\n" % (len(buf), count)
|
||||
if buf:
|
||||
if first and buf[0] == chr(CMD_ACK):
|
||||
#print "Chewed an ack"
|
||||
buf = buf[1:] # Chew an echo'd ack if using a 2-pin cable
|
||||
# print "Chewed an ack"
|
||||
buf = buf[1:] # Chew an echo'd ack if using a 2-pin cable
|
||||
first = False
|
||||
if len(buf) == count:
|
||||
break
|
||||
print util.hexprint(buf)
|
||||
return buf
|
||||
|
||||
|
||||
def _chunk_read(pipe, count, status_fn):
|
||||
block = 32
|
||||
data = ""
|
||||
@ -44,15 +49,16 @@ def _chunk_read(pipe, count, status_fn):
|
||||
data += pipe.read(block)
|
||||
if data:
|
||||
if data[0] == chr(CMD_ACK):
|
||||
data = data[1:] # Chew an echo'd ack if using a 2-pin cable
|
||||
#print "Chewed an ack"
|
||||
data = data[1:] # Chew an echo'd ack if using a 2-pin cable
|
||||
# print "Chewed an ack"
|
||||
status = chirp_common.Status()
|
||||
status.msg = "Cloning from radio"
|
||||
status.max = count
|
||||
status.cur = len(data)
|
||||
status_fn(status)
|
||||
LOG.debug("Read %i/%i" % (len(data), count))
|
||||
return data
|
||||
return data
|
||||
|
||||
|
||||
def __clone_in(radio):
|
||||
pipe = radio.pipe
|
||||
@ -79,12 +85,14 @@ def __clone_in(radio):
|
||||
|
||||
return memmap.MemoryMap(data)
|
||||
|
||||
|
||||
def _clone_in(radio):
|
||||
try:
|
||||
return __clone_in(radio)
|
||||
except Exception, e:
|
||||
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
|
||||
|
||||
|
||||
def _chunk_write(pipe, data, status_fn, block):
|
||||
delay = 0.03
|
||||
count = 0
|
||||
@ -92,7 +100,7 @@ def _chunk_write(pipe, data, status_fn, block):
|
||||
chunk = data[i:i+block]
|
||||
pipe.write(chunk)
|
||||
count += len(chunk)
|
||||
LOG.debug("@_chunk_write, count: %i, blocksize: %i" % (count,block))
|
||||
LOG.debug("@_chunk_write, count: %i, blocksize: %i" % (count, block))
|
||||
time.sleep(delay)
|
||||
|
||||
status = chirp_common.Status()
|
||||
@ -100,7 +108,8 @@ def _chunk_write(pipe, data, status_fn, block):
|
||||
status.max = len(data)
|
||||
status.cur = count
|
||||
status_fn(status)
|
||||
|
||||
|
||||
|
||||
def __clone_out(radio):
|
||||
pipe = radio.pipe
|
||||
block_lengths = radio._block_lengths
|
||||
@ -132,16 +141,18 @@ def __clone_out(radio):
|
||||
radio.status_fn, radio._block_size)
|
||||
pos += block
|
||||
|
||||
pipe.read(pos) # Chew the echo if using a 2-pin cable
|
||||
pipe.read(pos) # Chew the echo if using a 2-pin cable
|
||||
|
||||
print "Clone completed in %i seconds" % (time.time() - start)
|
||||
|
||||
|
||||
def _clone_out(radio):
|
||||
try:
|
||||
return __clone_out(radio)
|
||||
except Exception, e:
|
||||
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
|
||||
|
||||
|
||||
class YaesuChecksum:
|
||||
"""A Yaesu Checksum Object"""
|
||||
def __init__(self, start, stop, address=None):
|
||||
@ -172,6 +183,7 @@ class YaesuChecksum:
|
||||
self._stop,
|
||||
self._address)
|
||||
|
||||
|
||||
class YaesuCloneModeRadio(chirp_common.CloneModeRadio):
|
||||
"""Base class for all Yaesu clone-mode radios"""
|
||||
_block_lengths = [8, 65536]
|
||||
@ -194,7 +206,7 @@ class YaesuCloneModeRadio(chirp_common.CloneModeRadio):
|
||||
3. Prepare radio for clone.
|
||||
4. Press the key to receive the image."""))
|
||||
return rp
|
||||
|
||||
|
||||
def _checksums(self):
|
||||
"""Return a list of checksum objects that need to be calculated"""
|
||||
return []
|
||||
|
@ -61,4 +61,3 @@
|
||||
./chirp/drivers/vxa700.py
|
||||
./chirp/drivers/wouxun.py
|
||||
./chirp/drivers/wouxun_common.py
|
||||
./chirp/drivers/yaesu_clone.py
|
||||
|
Loading…
Reference in New Issue
Block a user