Merge integral hertz with mainline

This commit is contained in:
Dan Smith 2011-05-16 16:05:51 -07:00
commit effdd459be
6 changed files with 102 additions and 49 deletions

View File

@ -123,6 +123,12 @@ class DataElement:
def set_value(self, value):
raise Exception("Not implemented for %s" % self.__class__)
def get_raw(self):
return self._data[self._offset:self._offset+self._size]
def set_raw(self, data):
self._data[self._offset] = data[:self._size]
class arrayDataElement(DataElement):
def __init__(self):
self.__items = []

View File

@ -18,6 +18,7 @@
import time
from chirp import chirp_common, yaesu_clone, memmap
from chirp import bitwise, util, errors
from decimal import Decimal
ACK = chr(0x06)
@ -170,7 +171,7 @@ class FT7800Radio(yaesu_clone.YaesuCloneModeRadio):
rf.valid_modes = ["FM", "AM"]
rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS"]
rf.valid_duplexes = ["", "-", "+", "split"]
rf.valid_tuning_steps = list(chirp_common.TUNING_STEPS)
rf.valid_tuning_steps = STEPS
rf.valid_bands = [(108.0, 520.0), (700.0, 990.0)]
rf.valid_skips = ["", "S", "P"]
rf.valid_power_levels = POWER_LEVELS_VHF
@ -203,19 +204,27 @@ class FT7800Radio(yaesu_clone.YaesuCloneModeRadio):
return self._memobj.memory[number-1].get_raw()
def _get_mem_freq(self, mem, _mem):
if mem.freq > 4000:
# Dirty hack because the high-order digit has 0x40
# if 12.5kHz step
return (mem.freq - 4000) + 0.00250
else:
return mem.freq
f = Decimal("%f" % int(_mem.freq)) / 100
# Ugh. The 0x80 and 0x40 indicate values to add to get the
# real frequency. Gross. Even gross-er until I get
# integral hertz in here :)
if f > 8000:
f = (f - 8000) + Decimal("0.00500")
if f > 4000:
f -= 4000
while chirp_common.required_step(f) != 12.5:
f += Decimal("0.00250")
return float(f)
def _set_mem_freq(self, mem, _mem):
if chirp_common.is_12_5(mem.freq):
f = mem.freq - 0.0025
f = Decimal("%f" % mem.freq)
if ((f * 1000) % 10) == 5:
f += 8000
elif chirp_common.is_fractional_step(mem.freq):
f += 4000
else:
f = mem.freq
return int(f * 100)
@ -329,8 +338,8 @@ struct {
u8 used:1,
unknown1:2,
mode_am:1,
unknown2:2,
duplex:2;
unknown2:1,
duplex:3;
bbcd freq[3];
u8 unknown3:1,
tune_step:3,
@ -387,23 +396,6 @@ class FT8800Radio(FT7800Radio):
self._memobj = bitwise.parse(mem_format_8800 % self._memstart,
self._mmap)
def _get_mem_freq(self, mem, _mem):
if mem.freq > 8000:
# Dirty hack because the high-order digit has 0x80
# if 12.5kHz step
return (mem.freq - 8000) + 0.00250
else:
return mem.freq
def _set_mem_freq(self, mem, _mem):
if chirp_common.is_12_5(mem.freq):
f = mem.freq - 0.0025
f += 8000
else:
f = mem.freq
return int(f * 100)
def _get_mem_offset(self, mem, _mem):
if mem.duplex == "split":
return int(_mem.split) / 100.0
@ -456,8 +448,8 @@ struct {
u8 used:1,
skip:2,
sub_used:1,
unknown2:2,
duplex:2;
unknown2:1,
duplex:3;
bbcd freq[3];
u8 mode_am:1,
tune_step:3,

View File

@ -34,7 +34,8 @@ struct {
skip:1,
tmode:2,
duplex:2,
unk3:2;
unk3:1,
am:1;
} flag[111];
#seekto 0x0F20;
@ -67,14 +68,17 @@ class ICW32ARadio(icf.IcomCloneModeRadio):
rf = chirp_common.RadioFeatures()
rf.memory_bounds = (0, 99)
rf.valid_bands = [self._limits]
if int(self._limits[0] / 100) == 1:
rf.valid_modes = ["FM", "AM"]
else:
rf.valid_modes = ["FM"]
rf.valid_tmodes = ["", "Tone", "TSQL"]
rf.has_sub_devices = self.VARIANT == ""
rf.has_ctone = True
rf.has_dtcs = False
rf.has_dtcs_polarity = False
rf.has_mode = False
rf.has_mode = "AM" in rf.valid_modes
rf.has_tuning_step = False
rf.has_bank = False
@ -119,13 +123,14 @@ class ICW32ARadio(icf.IcomCloneModeRadio):
mem.empty = True
return mem
mem.freq = int(_mem.freq) / 1000.0
mem.freq = chirp_common.fix_rounded_step(int(_mem.freq) / 1000.0)
mem.offset = int(_mem.offset) / 10000.0
if str(_mem.name)[0] != chr(0xFF):
mem.name = str(_mem.name).rstrip()
mem.rtone = chirp_common.TONES[_mem.rtone]
mem.ctone = chirp_common.TONES[_mem.ctone]
mem.mode = _flg.am and "AM" or "FM"
mem.duplex = DUPLEX[_flg.duplex]
mem.tmode = TONE[_flg.tmode]
@ -154,6 +159,7 @@ class ICW32ARadio(icf.IcomCloneModeRadio):
_flg.duplex = DUPLEX.index(mem.duplex)
_flg.tmode = TONE.index(mem.tmode)
_flg.skip = mem.skip == "S"
_flg.am = mem.mode == "AM"
def get_sub_devices(self):
return [ICW32ARadioVHF(self._mmap), ICW32ARadioUHF(self._mmap)]

View File

@ -75,7 +75,7 @@ def _import_power(dst_radio, mem):
if not levels:
mem.power = None
return
elif not mem.power:
elif mem.power is None:
# Source radio did not support power levels, so choose the
# first (highest) level from the destination radio.
mem.power = levels[0]

View File

@ -15,9 +15,27 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from chirp import chirp_common, yaesu_clone, vx6_ll
from chirp import chirp_common, yaesu_clone
from chirp import bitwise
# flags.{even|odd}_pskip: These are actually "preferential *scan* channels".
# Is that what they mean on other radios as well?
# memory {
# step_changed: Channel step has been changed. Bit stays on even after
# you switch back to default step. Don't know why you would
# care
# half_deviation: 2.5 kHz deviation
# cpu_shifted: CPU freq has been shifted (to move a birdie out of channel)
# power: 0-3: ["L1", "L2", "L3", "Hi"]
# pager: Set if this is a paging memory
# tmodes: 0-7: ["", "Tone", "TSQL", "DTCS", "Rv Tn", "D Code", "T DCS", "D Tone"]
# Rv Tn: Reverse CTCSS - mutes receiver on tone
# The final 3 are for split:
# D Code: DCS Encode only
# T DCS: Encodes tone, decodes DCS code
# D Tone: Encodes DCS code, decodes tone
# }
mem_format = """
#seekto 0x1ECA;
struct {
@ -33,13 +51,19 @@ struct {
#seekto 0x21CA;
struct {
u8 unknown1;
u8 unknown11:1,
step_changed:1,
half_deviation:1,
cpu_shifted:1,
unknown12:4;
u8 mode:2,
duplex:2,
tune_step:4;
bbcd freq[3];
u8 unknown2:6,
tmode:2;
u8 power:2,
unknown2:2,
pager:1,
tmode:3;
u8 name[6];
bbcd offset[3];
u8 unknown3:2,
@ -67,9 +91,11 @@ CHARSET = ["%i" % int(x) for x in range(0, 10)] + \
POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=5.00),
chirp_common.PowerLevel("L3", watts=2.50),
chirp_common.PowerLevel("L2", watts=1.00),
chirp_common.PowerLevel("L1", watts=0.05)]
POWER_LEVELS_220 = [chirp_common.PowerLevel("L2", watts=0.30),
chirp_common.PowerLevel("L1", watts=0.05)]
chirp_common.PowerLevel("L1", watts=0.30)]
POWER_LEVELS_220 = [chirp_common.PowerLevel("Hi", watts=1.50),
chirp_common.PowerLevel("L3", watts=1.00),
chirp_common.PowerLevel("L2", watts=0.50),
chirp_common.PowerLevel("L1", watts=0.20)]
class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
BAUD_RATE = 19200
@ -81,9 +107,6 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
_block_lengths = [10, 32578]
_block_size = 16
def _update_checksum(self):
vx6_ll.update_checksum(self._mmap)
def _checksums(self):
return [ yaesu_clone.YaesuChecksum(0x0000, 0x7F49) ]
@ -94,8 +117,9 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
rf = chirp_common.RadioFeatures()
rf.has_bank = False
rf.has_dtcs_polarity = False
rf.valid_modes = ["FM", "WFM", "AM"]
rf.valid_modes = ["FM", "WFM", "AM", "NFM"]
rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS"]
rf.valid_power_levels = POWER_LEVELS
rf.memory_bounds = (1, 900)
rf.valid_bands = [(0.5, 998.990)]
rf.can_odd_split = True
@ -118,6 +142,7 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
mem.number = number
if not used:
mem.empty = True
mem.power = POWER_LEVELS[0]
return mem
mem.freq = chirp_common.fix_rounded_step(int(_mem.freq) / 1000.0)
@ -126,10 +151,17 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
mem.tmode = TMODES[_mem.tmode]
mem.duplex = DUPLEX[_mem.duplex]
mem.mode = MODES[_mem.mode]
if mem.mode == "FM" and _mem.half_deviation:
mem.mode = "NFM"
mem.dtcs = chirp_common.DTCS_CODES[_mem.dcs]
mem.tuning_step = STEPS[_mem.tune_step]
mem.skip = pskip and "P" or skip and "S" or ""
if mem.freq > 220 and mem.freq < 225:
mem.power = POWER_LEVELS_220[3 - _mem.power]
else:
mem.power = POWER_LEVELS[3 - _mem.power]
for i in _mem.name:
if i == 0xFF:
break
@ -156,9 +188,18 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
_mem.tone = chirp_common.TONES.index(mem.rtone)
_mem.tmode = TMODES.index(mem.tmode)
_mem.duplex = DUPLEX.index(mem.duplex)
if mem.mode == "NFM":
_mem.mode = MODES.index("FM")
_mem.half_deviation = 1
else:
_mem.mode = MODES.index(mem.mode)
_mem.half_deviation = 0
_mem.dcs = chirp_common.DTCS_CODES.index(mem.dtcs)
_mem.tune_step = STEPS.index(mem.tuning_step)
if mem.power:
_mem.power = 3 - POWER_LEVELS.index(mem.power)
else:
_mem.power = 0
_flag["%s_pskip" % nibble] = mem.skip == "P"
_flag["%s_skip" % nibble] = mem.skip == "S"

View File

@ -416,6 +416,14 @@ class TestRunner:
return run_list
def report(self, rclass, tc, msg, e):
if os.isatty(1):
if msg == "PASSED":
msg = "\033[1;32m%s\033[0m" % msg
elif msg == "FAILED":
msg = "\033[1;41m%s\033[0m" % msg
elif msg == "CRASHED":
msg = "\033[1;45m%s\033[0m" % msg
print "%9s %-13s %-10s %8s: %s" % (rclass.VENDOR,
("%s %s" % (rclass.MODEL,
rclass.VARIANT)),