Driver Maintenance: tk760.py

1. Add to PEP8 manifest
2. Perform PEP8 cleanup

in preperaton to address #8245
This commit is contained in:
Jim Unroe 2021-03-06 11:34:49 -08:00
parent fe125ed6e9
commit 1eb4dccab5
2 changed files with 37 additions and 34 deletions

View File

@ -13,12 +13,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import time
import struct
import logging
LOG = logging.getLogger(__name__)
from chirp import chirp_common, directory, memmap from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util from chirp import bitwise, errors, util
from chirp.settings import RadioSettingGroup, RadioSetting, \ from chirp.settings import RadioSettingGroup, RadioSetting, \
@ -27,6 +21,12 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettings RadioSettings
from textwrap import dedent from textwrap import dedent
import time
import struct
import logging
LOG = logging.getLogger(__name__)
MEM_FORMAT = """ MEM_FORMAT = """
#seekto 0x0000; #seekto 0x0000;
struct { struct {
@ -92,7 +92,8 @@ KEYS = {
0x06: "Scan", 0x06: "Scan",
0x07: "Scan Del/Add", 0x07: "Scan Del/Add",
0x08: "Home Channel", 0x08: "Home Channel",
0x09: "Operator Selectable Tone" 0x09: "Operator Selectable Tone",
0x0C: "Unknown"
} }
MEM_SIZE = 0x400 MEM_SIZE = 0x400
@ -108,7 +109,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1),
MODES = ["NFM", "FM"] MODES = ["NFM", "FM"]
SKIP_VALUES = ["", "S"] SKIP_VALUES = ["", "S"]
TONES = chirp_common.TONES TONES = chirp_common.TONES
#TONES.remove(254.1) # TONES.remove(254.1)
DTCS_CODES = chirp_common.DTCS_CODES DTCS_CODES = chirp_common.DTCS_CODES
TOT = ["off"] + ["%s" % x for x in range(30, 330, 30)] TOT = ["off"] + ["%s" % x for x in range(30, 330, 30)]
@ -120,7 +121,7 @@ def rawrecv(radio, amount):
data = "" data = ""
try: try:
data = radio.pipe.read(amount) data = radio.pipe.read(amount)
#print("<= %02i: %s" % (len(data), util.hexprint(data))) # print("<= %02i: %s" % (len(data), util.hexprint(data)))
except: except:
raise errors.RadioError("Error reading data from radio") raise errors.RadioError("Error reading data from radio")
@ -131,7 +132,7 @@ def rawsend(radio, data):
"""Raw send to the radio device""" """Raw send to the radio device"""
try: try:
radio.pipe.write(data) radio.pipe.write(data)
#print("=> %02i: %s" % (len(data), util.hexprint(data))) # print("=> %02i: %s" % (len(data), util.hexprint(data)))
except: except:
raise errors.RadioError("Error sending data from radio") raise errors.RadioError("Error sending data from radio")
@ -162,7 +163,7 @@ def handshake(radio, msg="", full=False):
ack = rawrecv(radio, 1) ack = rawrecv(radio, 1)
# check ACK # check ACK
if ack != ACK_CMD: if ack != ACK_CMD:
#close_radio(radio) # close_radio(radio)
mesg = "Handshake failed: " + msg mesg = "Handshake failed: " + msg
raise errors.RadioError(mesg) raise errors.RadioError(mesg)
@ -229,7 +230,7 @@ def open_radio(radio):
ident = rawrecv(radio, 8) ident = rawrecv(radio, 8)
# validate the input # validate the input
if len(ident) != 8: if len(ident) != 8:
LOG.debug("Wrong ID, get only %s bytes, we expect 8" % len(ident)) LOG.debug("Wrong ID, get only %s bytes, we expect 8" % len(ident))
LOG.debug(hexprint(ident)) LOG.debug(hexprint(ident))
msg = "Bad ID received, just %s bytes, we want 8" % len(ident) msg = "Bad ID received, just %s bytes, we want 8" % len(ident)
@ -253,7 +254,7 @@ def do_download(radio):
"""This is your download function""" """This is your download function"""
open_radio(radio) open_radio(radio)
# UI progress # UI progress
status = chirp_common.Status() status = chirp_common.Status()
status.cur = 0 status.cur = 0
status.max = MEM_SIZE / BLOCK_SIZE status.max = MEM_SIZE / BLOCK_SIZE
@ -280,7 +281,7 @@ def do_upload(radio):
"""Upload info to radio""" """Upload info to radio"""
open_radio(radio) open_radio(radio)
# UI progress # UI progress
status = chirp_common.Status() status = chirp_common.Status()
status.cur = 0 status.cur = 0
status.max = MEM_SIZE / BLOCK_SIZE status.max = MEM_SIZE / BLOCK_SIZE
@ -324,7 +325,7 @@ def model_match(cls, data):
rid = get_rid(data) rid = get_rid(data)
# DEBUG # DEBUG
#print("Full ident string is %s" % util.hexprint(rid)) # print("Full ident string is %s" % util.hexprint(rid))
if (rid in cls.VARIANTS): if (rid in cls.VARIANTS):
# correct model # correct model
@ -333,7 +334,8 @@ def model_match(cls, data):
return False return False
class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio): class Kenwood_M60_Radio(chirp_common.CloneModeRadio,
chirp_common.ExperimentalRadio):
"""Kenwood Mobile Family 60 Radios""" """Kenwood Mobile Family 60 Radios"""
VENDOR = "Kenwood" VENDOR = "Kenwood"
_range = [136000000, 500000000] # don't mind, it will be overwritten _range = [136000000, 500000000] # don't mind, it will be overwritten
@ -346,7 +348,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
rp = chirp_common.RadioPrompts() rp = chirp_common.RadioPrompts()
rp.experimental = \ rp.experimental = \
('This driver is experimental; not all features have been ' ('This driver is experimental; not all features have been '
'implemented, but it has those features most used by hams.\n' 'implemented, but it has those features most used by hams.\n'
'\n' '\n'
'This radios are able to work slightly outside the OEM ' 'This radios are able to work slightly outside the OEM '
'frequency limits. After testing, the limit in Chirp has ' 'frequency limits. After testing, the limit in Chirp has '
@ -736,28 +738,28 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
basic.append(clone) basic.append(clone)
# front keys # front keys
mon = RadioSetting("settings.kMON", "MON", rs = RadioSettingValueList(KEYS.values(),
RadioSettingValueList(KEYS.values(), KEYS.values()[KEYS.keys().index(
KEYS.values()[KEYS.keys().index( int(sett.kMON))])
int(sett.kMON))])) mon = RadioSetting("settings.kMON", "MON", rs)
fkeys.append(mon) fkeys.append(mon)
a = RadioSetting("settings.kA", "A", rs = RadioSettingValueList(KEYS.values(),
RadioSettingValueList(KEYS.values(), KEYS.values()[KEYS.keys().index(
KEYS.values()[KEYS.keys().index( int(sett.kA))])
int(sett.kA))])) a = RadioSetting("settings.kA", "A", rs)
fkeys.append(a) fkeys.append(a)
scn = RadioSetting("settings.kSCN", "SCN", rs = RadioSettingValueList(KEYS.values(),
RadioSettingValueList(KEYS.values(), KEYS.values()[KEYS.keys().index(
KEYS.values()[KEYS.keys().index( int(sett.kSCN))])
int(sett.kSCN))])) scn = RadioSetting("settings.kSCN", "SCN", rs)
fkeys.append(scn) fkeys.append(scn)
da = RadioSetting("settings.kDA", "D/A", rs = RadioSettingValueList(KEYS.values(),
RadioSettingValueList(KEYS.values(), KEYS.values()[KEYS.keys().index(
KEYS.values()[KEYS.keys().index( int(sett.kDA))])
int(sett.kDA))])) da = RadioSetting("settings.kDA", "D/A", rs)
fkeys.append(da) fkeys.append(da)
return top return top
@ -803,7 +805,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# Apply al configs done # Apply al configs done
# DEBUG # DEBUG
#print("%s: %s" % (setting, value)) # print("%s: %s" % (setting, value))
setattr(obj, setting, value) setattr(obj, setting, value)

View File

@ -92,6 +92,7 @@
./chirp/drivers/th_uvf8d.py ./chirp/drivers/th_uvf8d.py
./chirp/drivers/thd72.py ./chirp/drivers/thd72.py
./chirp/drivers/thuv1f.py ./chirp/drivers/thuv1f.py
./chirp/drivers/tk760.py
./chirp/drivers/tk8102.py ./chirp/drivers/tk8102.py
./chirp/drivers/tk8180.py ./chirp/drivers/tk8180.py
./chirp/drivers/tmd710.py ./chirp/drivers/tmd710.py