[chirp_devel] Patch for #8363
Rick (AA0RD) DeWitt
Mon Nov 16 14:25:24 PST 2020
Patch to Luiton LT-725uv (Baojie BJ-218) fixing garbled downloads.
Added delay between reads.
--
Rick DeWitt
AA0RD
Sequim, Washington, USA 98382
(360) 681-3494
-------------- next part --------------
# HG changeset patch
# User Rick DeWitt <aa0rd at yahoo.com>
# Date 1605564507 28800
# Mon Nov 16 14:08:27 2020 -0800
# Node ID 322a135bdf2bf42ad8b6f4026a488adad003e4c0
# Parent 98b8a850b0f136c77fe09a4922c32a2a28f708be
[lt725uv] BJ-218 alias. Issue #8363 add 100ms delay after each download read at line 347
Also includes many style corrections.
diff -r 98b8a850b0f1 -r 322a135bdf2b chirp/drivers/lt725uv.py
--- a/chirp/drivers/lt725uv.py Sun Oct 11 15:39:26 2020 -0400
+++ b/chirp/drivers/lt725uv.py Mon Nov 16 14:08:27 2020 -0800
@@ -1,6 +1,9 @@
# Copyright 2016:
# * Jim Unroe KC9HI, <rock.unroe at gmail.com>
-# Modified for Baojie BJ-218: 2018 by Rick DeWitt (RJD), <aa0rd at yahoo.com>#
+# Modified for Baojie BJ-218: 2018 by Rick DeWitt (RJD), <aa0rd at yahoo.com>
+# Patch for issue #8363:
+# Fixes Download errors due to reading too fast
+# Also includes many style fixes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
@@ -18,17 +21,18 @@
import struct
import logging
import re
-
-LOG = logging.getLogger(__name__)
-
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettingValueBoolean, RadioSettingValueList, \
RadioSettingValueString, RadioSettingValueInteger, \
- RadioSettingValueFloat, RadioSettings,InvalidValueError
+ RadioSettingValueFloat, RadioSettings, InvalidValueError
from textwrap import dedent
+
+LOG = logging.getLogger(__name__)
+
+
MEM_FORMAT = """
#seekto 0x0200;
struct {
@@ -199,36 +203,37 @@
for x in chirp_common.DTCS_CODES:
LIST_CTCSS.append("D{:03d}R".format(x))
LIST_BW = ["Narrow", "Wide"]
-LIST_SHIFT = ["Off"," + ", " - "]
+LIST_SHIFT = ["Off", " + ", " - "]
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
LIST_STEPS = [str(x) for x in STEPS]
LIST_STATE = ["Normal", "Stun", "Kill"]
LIST_SSF = ["1000", "1450", "1750", "2100"]
-LIST_DTMFTX = ["50", "100", "150", "200", "300","500"]
+LIST_DTMFTX = ["50", "100", "150", "200", "300", "500"]
SETTING_LISTS = {
-"init_bank": LIST_TDR_DEF ,
-"tot": LIST_TIMEOUT,
-"wtled": LIST_COLOR,
-"rxled": LIST_COLOR,
-"txled": LIST_COLOR,
-"sig_freq": LIST_SSF,
-"dtmf_txms": LIST_DTMFTX,
-"ledsw": LIST_LEDSW,
-"frq_chn_mode": LIST_VFOMODE,
-"rx_tone": LIST_CTCSS,
-"tx_tone": LIST_CTCSS,
-"rx_mode": LIST_RECVMODE,
-"launch_sig": LIST_SIGNAL,
-"tx_end_sig": LIST_SIGNAL,
-"bpower":LIST_BPOWER,
-"fm_bw": LIST_BW,
-"shift": LIST_SHIFT,
-"step": LIST_STEPS,
-"ring": LIST_RING,
-"state_now": LIST_STATE
+ "init_bank": LIST_TDR_DEF,
+ "tot": LIST_TIMEOUT,
+ "wtled": LIST_COLOR,
+ "rxled": LIST_COLOR,
+ "txled": LIST_COLOR,
+ "sig_freq": LIST_SSF,
+ "dtmf_txms": LIST_DTMFTX,
+ "ledsw": LIST_LEDSW,
+ "frq_chn_mode": LIST_VFOMODE,
+ "rx_tone": LIST_CTCSS,
+ "tx_tone": LIST_CTCSS,
+ "rx_mode": LIST_RECVMODE,
+ "launch_sig": LIST_SIGNAL,
+ "tx_end_sig": LIST_SIGNAL,
+ "bpower": LIST_BPOWER,
+ "fm_bw": LIST_BW,
+ "shift": LIST_SHIFT,
+ "step": LIST_STEPS,
+ "ring": LIST_RING,
+ "state_now": LIST_STATE
}
+
def _clean_buffer(radio):
radio.pipe.timeout = 0.005
junk = radio.pipe.read(256)
@@ -339,6 +344,7 @@
# Now we read
d = _recv(radio, addr, BLOCK_SIZE)
+ time.sleep(0.1)
# Aggregate the data
data += d
@@ -770,7 +776,7 @@
# Basic Settings
bnd_mode = RadioSetting("settings.init_bank", "TDR Band Default",
RadioSettingValueList(LIST_TDR_DEF,
- LIST_TDR_DEF[ _sets.init_bank]))
+ LIST_TDR_DEF[_sets.init_bank]))
basic.append(bnd_mode)
volume = RadioSetting("settings.volume", "Volume",
@@ -790,7 +796,7 @@
def my_word2raw(setting, obj, atrb, mlt=10):
"""Callback function to convert UI floating value to u16 int"""
if str(setting.value) == "Off":
- frq = 0x0FFFF
+ frq = 0x0FFFF
else:
frq = int(float(str(setting.value)) * float(mlt))
if frq == 0:
@@ -801,7 +807,7 @@
def my_adjraw(setting, obj, atrb, fix):
"""Callback: add or subtract fix from value."""
vx = int(str(setting.value))
- value = vx + int(fix)
+ value = vx + int(fix)
if value < 0:
value = 0
if atrb == "frq_chn_mode" and int(str(setting.value)) == 2:
@@ -829,7 +835,7 @@
def my_spcl(setting, obj, atrb):
"""Callback: Special handling based on atrb."""
if atrb == "frq_chn_mode":
- idx = LIST_VFOMODE.index (str(setting.value)) # Returns 0 or 1
+ idx = LIST_VFOMODE.index(str(setting.value)) # Returns 0 or 1
value = idx * 2 # Set bit 1
setattr(obj, atrb, value)
return
@@ -960,7 +966,7 @@
rs.set_apply_callback(my_spcl, _vfoa, "frq_chn_mode")
a_band.append(rs)
- val =_vfoa.chan_num + 1 # Add 1 for 1-128 displayed
+ val = _vfoa.chan_num + 1 # Add 1 for 1-128 displayed
rs = RadioSetting("upper.vfoa.chan_num", "Initial Chan",
RadioSettingValueInteger(1, 128, val))
rs.set_apply_callback(my_adjraw, _vfoa, "chan_num", -1)
@@ -994,11 +1000,11 @@
a_band.append(rs)
rs = RadioSetting("upper.vfoa.launch_sig", "Launch Signaling",
- RadioSettingValueList(LIST_SIGNAL,
- LIST_SIGNAL[_vfoa.launch_sig]))
+ RadioSettingValueList(LIST_SIGNAL, LIST_SIGNAL
+ [_vfoa.launch_sig]))
a_band.append(rs)
- rx = RadioSettingValueList(LIST_SIGNAL,LIST_SIGNAL[_vfoa.tx_end_sig])
+ rx = RadioSettingValueList(LIST_SIGNAL, LIST_SIGNAL[_vfoa.tx_end_sig])
rs = RadioSetting("upper.vfoa.tx_end_sig", "Xmit End Signaling", rx)
a_band.append(rs)
@@ -1028,7 +1034,7 @@
tmp = str(_vfoa.step / 100.0)
rs = RadioSetting("step", "Freq step (KHz)",
RadioSettingValueList(LIST_STEPS, tmp))
- rs.set_apply_callback(my_word2raw, _vfoa,"step", 100)
+ rs.set_apply_callback(my_word2raw, _vfoa, "step", 100)
a_band.append(rs)
# LOWER BAND SETTINGS
@@ -1071,11 +1077,11 @@
"txdtcs_pol", "tx_tone")
b_band.append(rs)
- rx = RadioSettingValueList(LIST_SIGNAL,LIST_SIGNAL[_vfob.launch_sig])
+ rx = RadioSettingValueList(LIST_SIGNAL, LIST_SIGNAL[_vfob.launch_sig])
rs = RadioSetting("lower.vfob.launch_sig", "Launch Signaling", rx)
b_band.append(rs)
- rx = RadioSettingValueList(LIST_SIGNAL,LIST_SIGNAL[_vfob.tx_end_sig])
+ rx = RadioSettingValueList(LIST_SIGNAL, LIST_SIGNAL[_vfob.tx_end_sig])
rs = RadioSetting("lower.vfob.tx_end_sig", "Xmit End Signaling", rx)
b_band.append(rs)
@@ -1120,14 +1126,16 @@
"""Callback: convert 7-char string to char array with count."""
ary = ""
knt = 7
- for j in range (6, -1, -1): # Strip trailing spaces
+ for j in range(6, -1, -1): # Strip trailing spaces
if str(setting.value)[j] == "" or str(setting.value)[j] == " ":
knt = knt - 1
else:
break
for j in range(0, 7, 1):
- if j < knt: ary += str(setting.value)[j]
- else: ary += chr(0xFF)
+ if j < knt:
+ ary += str(setting.value)[j]
+ else:
+ ary += chr(0xFF)
setattr(obj, atrba, ary)
setattr(obj, atrbc, knt)
return
@@ -1141,7 +1149,7 @@
tmp = chars2str(_lims.hello2, _lims.hello2_cnt)
rs = RadioSetting("hello_lims.hello2", "Power-On Message 2",
RadioSettingValueString(0, 7, tmp))
- rs.set_apply_callback(my_str2ary, _lims,"hello2", "hello2_cnt")
+ rs.set_apply_callback(my_str2ary, _lims, "hello2", "hello2_cnt")
lims.append(rs)
# VALID_BANDS = [(136000000, 176000000),400000000, 480000000)]
@@ -1184,7 +1192,7 @@
"""Generate the DTMF code 1-8, NOT a callback."""
tmp = ""
if knt > 0 and knt != 0xff:
- for val in ary[:knt]:
+ for val in ary[:knt]:
if val > 0 and val <= 9:
tmp += chr(val + 48)
elif val == 0x0a:
@@ -1210,7 +1218,7 @@
"""Callback: DTMF Code; sends 5 or 7-byte string."""
draw = []
knt = syz
- for j in range (syz - 1, -1, -1): # Strip trailing spaces
+ for j in range(syz - 1, -1, -1): # Strip trailing spaces
if str(setting.value)[j] == "" or str(setting.value)[j] == " ":
knt = knt - 1
else:
@@ -1220,19 +1228,19 @@
obx = ord(bx)
dig = 0x0ff
if j < knt and knt > 0: # (Else) is pads
- if bx == "0":
+ if bx == "0":
dig = 0x0a
- elif bx == "A":
+ elif bx == "A":
dig = 0x0d
- elif bx == "B":
+ elif bx == "B":
dig = 0x0e
- elif bx == "C":
+ elif bx == "C":
dig = 0x0f
- elif bx == "D":
+ elif bx == "D":
dig = 0x00
- elif bx == "*":
+ elif bx == "*":
dig = 0x0b
- elif bx == "#":
+ elif bx == "#":
dig = 0x0c
elif obx >= 49 and obx <= 57:
dig = obx - 48
@@ -1258,14 +1266,14 @@
rs = RadioSetting("codes.master_id_code", "Master Control ID Code",
RadioSettingValueString(0, 7, tmp))
rs.set_apply_callback(my_dtmf2raw, _codes, "master_id_code",
- "master_id_cnt",7)
+ "master_id_cnt", 7)
codes.append(rs)
tmp = make_dtmf(_codes.alarm_code, _codes.alarm_cnt)
rs = RadioSetting("codes.alarm_code", "Alarm Code",
- RadioSettingValueString(0, 5, tmp))
+ RadioSettingValueString(0, 5, tmp))
rs.set_apply_callback(my_dtmf2raw, _codes, "alarm_code",
- "alarm_cnt", 5)
+ "alarm_cnt", 5)
codes.append(rs)
tmp = make_dtmf(_codes.id_disp_code, _codes.id_disp_cnt)
@@ -1278,7 +1286,7 @@
tmp = make_dtmf(_codes.revive_code, _codes.revive_cnt)
rs = RadioSetting("codes.revive_code", "Revive Code",
RadioSettingValueString(0, 5, tmp))
- rs.set_apply_callback(my_dtmf2raw, _codes,"revive_code",
+ rs.set_apply_callback(my_dtmf2raw, _codes, "revive_code",
"revive_cnt", 5)
codes.append(rs)
@@ -1361,7 +1369,6 @@
return group # END get_settings()
-
def set_settings(self, settings):
_settings = self._memobj.settings
_mem = self._memobj
@@ -1397,7 +1404,6 @@
LOG.debug(element.get_name())
raise
-
@classmethod
def match_model(cls, filedata, filename):
match_size = False
More information about the chirp_devel
mailing list