Example #1
0
    def set_memory(self, mem):
        _mem, _flg, index = self._get_memory(mem.number)

        if mem.empty:
            _flg.empty = True
            self._set_bank(mem.number, None)
            return

        if _flg.empty:
            _mem.set_raw("\x00" * 16)
        _flg.empty = False

        _mem.alt_mult = chirp_common.is_fractional_step(mem.freq)
        _mem.freq = mem.freq / (_mem.alt_mult and 6250 or 5000)
        _mem.offset = mem.offset / 5000
        _mem.rtone = chirp_common.TONES.index(mem.rtone)
        _mem.ctone = chirp_common.TONES.index(mem.ctone)
        _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
        _mem.dtcs_polarity = DTCS_POL.index(mem.dtcs_polarity)
        _mem.duplex = DUPLEX.index(mem.duplex)
        _mem.tmode = TMODES.index(mem.tmode)
        _mem.is_fm = "FM" in mem.mode
        _mem.is_wide = mem.mode[0] != "N"
        _mem.tuning_step = STEPS.index(mem.tuning_step)
        set_name(_mem, mem.name)
        try:
            _mem.power = POWER.index(mem.power)
        except Exception:
            pass
        if not isinstance(mem.number, str):
            _flg.skip = mem.skip == "S"
            _flg.pskip = mem.skip == "P"
Example #2
0
File: icq7.py Project: cl4u2/chirp
    def set_memory(self, mem):
        _mem = self._memobj.memory[mem.number]
        _flag = self._memobj.flags[mem.number]
        
        if mem.empty:
            self._memobj.flags_whole[mem.number] = 0xFF
            return
            
        _mem.set_raw("\x00" * 8)    

        if mem.freq > to_GHz(1):
            _mem.freq = (mem.freq / 1000) - to_GHz(1)
            upper = from_GHz(mem.freq) << 4
            _mem.freq[0].clr_bits(0xF0)
            _mem.freq[0].set_bits(upper)
        else:
            _mem.freq = mem.freq / 1000
        _mem.fractional = chirp_common.is_fractional_step(mem.freq)
        _mem.offset = mem.offset / 1000
        _mem.rtone = chirp_common.TONES.index(mem.rtone)
        _mem.ctone = chirp_common.TONES.index(mem.ctone)
        _mem.tune_step = STEPS.index(mem.tuning_step)
        _flag.tmode = TMODES.index(mem.tmode)
        _flag.duplex = DUPLEX.index(mem.duplex)
        _flag.mode = MODES.index(mem.mode)
        _flag.skip = mem.skip == "S" and 1 or 0
        _flag.pskip = mem.skip == "P" and 1 or 0
Example #3
0
    def set_memory(self, mem):
        _mem, _flg, index = self._get_memory(mem.number)

        if mem.empty:
            _flg.empty = True
            self._set_bank(mem.number, None)
            return

        if _flg.empty:
            _mem.set_raw("\x00" * 16)
        _flg.empty = False

        _mem.alt_mult = chirp_common.is_fractional_step(mem.freq)
        _mem.freq = mem.freq / (_mem.alt_mult and 6250 or 5000)
        _mem.offset = mem.offset / 5000
        _mem.rtone = chirp_common.TONES.index(mem.rtone)
        _mem.ctone = chirp_common.TONES.index(mem.ctone)
        _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
        _mem.dtcs_polarity = DTCS_POL.index(mem.dtcs_polarity)
        _mem.duplex = DUPLEX.index(mem.duplex)
        _mem.tmode = TMODES.index(mem.tmode)
        _mem.is_fm = "FM" in mem.mode
        _mem.is_wide = mem.mode[0] != "N"
        _mem.tuning_step = STEPS.index(mem.tuning_step)
        set_name(_mem, mem.name)
        try:
            _mem.power = POWER.index(mem.power)
        except Exception:
            pass
        if not isinstance(mem.number, str):
            _flg.skip = mem.skip == "S"
            _flg.pskip = mem.skip == "P"
Example #4
0
    def set_memory(self, mem):
        _mem = self._memobj.memory[mem.number]
        _flag = self._memobj.flags[mem.number]

        if mem.empty:
            self._memobj.flags_whole[mem.number] = 0xFF
            return

        _mem.set_raw("\x00" * 8)

        if mem.freq > to_GHz(1):
            _mem.freq = (mem.freq // 1000) - to_GHz(1)
            upper = from_GHz(mem.freq) << 4
            _mem.freq[0].clr_bits(0xF0)
            _mem.freq[0].set_bits(upper)
        else:
            _mem.freq = mem.freq / 1000
        _mem.fractional = chirp_common.is_fractional_step(mem.freq)
        _mem.offset = mem.offset / 1000
        _mem.rtone = chirp_common.TONES.index(mem.rtone)
        _mem.ctone = chirp_common.TONES.index(mem.ctone)
        _mem.tune_step = STEPS.index(mem.tuning_step)
        _flag.tmode = TMODES.index(mem.tmode)
        _flag.duplex = DUPLEX.index(mem.duplex)
        _flag.mode = MODES.index(mem.mode)
        _flag.skip = mem.skip == "S" and 1 or 0
        _flag.pskip = mem.skip == "P" and 1 or 0
Example #5
0
def _encode_freq(freq):
    freqraw = freq / 10000
    flags = 0x00
    if ((freq / 1000) % 10) >= 5:
        flags += 0x80
    if chirp_common.is_fractional_step(freq):
        flags += 0x40
    return freqraw, flags
Example #6
0
def _encode_freq(freq):
    freqraw = freq / 10000
    flags = 0x00
    if ((freq / 1000) % 10) >= 5:
        flags += 0x80
    if chirp_common.is_fractional_step(freq):
        flags += 0x40
    return freqraw, flags
Example #7
0
def _set_freq(_mem, freq):
    if chirp_common.is_fractional_step(freq):
        mult = 6250
        flag = 0x00200000
    else:
        mult = 5000
        flag = 0x00000000

    _mem.freq = (freq / mult) | flag
Example #8
0
    def freq_chirp2icom(self, freq):
        if chirp_common.is_fractional_step(freq):
            mult = 6250
            multr = 1
        else:
            mult = 5000
            multr = 0

        return (freq / mult, multr)
Example #9
0
def _set_freq(_mem, freq):
    if chirp_common.is_fractional_step(freq):
        mult = 6250
        flag = 0x00200000
    else:
        mult = 5000
        flag = 0x00000000

    _mem.freq = (freq / mult) | flag
Example #10
0
def set_freq(mmap, freq, base):
    tflag = ord(mmap[POS_MULT_FLAG]) & 0x7F

    if chirp_common.is_fractional_step(freq):
        mult = 6250
        tflag |= 0x80
    else:
        mult = 5000

    value = (freq - to_MHz(base)) // mult

    mmap[POS_MULT_FLAG] = tflag
    mmap[POS_FREQ_START] = struct.pack("<H", value)
Example #11
0
def set_freq(mmap, freq, base):
    tflag = ord(mmap[POS_MULT_FLAG]) & 0x7F

    if chirp_common.is_fractional_step(freq):
        mult = 6250
        tflag |= 0x80
    else:
        mult = 5000

    value = (freq - to_MHz(base)) / mult

    mmap[POS_MULT_FLAG] = tflag
    mmap[POS_FREQ_START] = struct.pack("<H", value)
Example #12
0
    def set_memory(self, mem):
        if isinstance(mem.number, str):
            number = _get_special()[mem.number]
        else:
            number = mem.number

        _mem = self._memobj.memory[number]
        _flag = self._memobj.flags[number]

        was_empty = int(_flag.empty)

        _flag.empty = mem.empty
        if mem.empty:
            _wipe_memory(_mem, "\xFF")
            return

        if was_empty:
            _wipe_memory(_mem, "\x00")

        _mem.unknown8 = 0
        _mem.is_625 = chirp_common.is_fractional_step(mem.freq)
        mult = _mem.is_625 and 6250 or 5000
        _mem.freq = mem.freq / mult
        _mem.offset = mem.offset / mult
        _mem.rtone = chirp_common.TONES.index(mem.rtone)
        _mem.ctone = chirp_common.TONES.index(mem.ctone)
        _mem.tmode = TMODES.index(mem.tmode)
        _mem.duplex = DUPLEX.index(mem.duplex)
        _mem.mode_dv = mem.mode == "DV"
        _mem.mode_am = mem.mode.endswith("AM")
        _mem.mode_narrow = mem.mode.startswith("N")
        _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
        _mem.dtcs_polarity = DTCSP.index(mem.dtcs_polarity)
        _mem.tuning_step = STEPS.index(mem.tuning_step)
        _mem.name = mem.name.ljust(6)
        if mem.power:
            _mem.power = POWER_LEVELS.index(mem.power)
        else:
            _mem.power = 0

        if number < 200:
            _flag.skip = mem.skip != ""

        if isinstance(mem, chirp_common.DVMemory):
            urcalls = self.get_urcall_list()
            rptcalls = self.get_repeater_call_list()
            _mem.urcall = urcalls.index(mem.dv_urcall)
            _mem.r1call = rptcalls.index(mem.dv_rpt1call)
            _mem.r2call = rptcalls.index(mem.dv_rpt2call)
Example #13
0
    def set_memory(self, mem):
        if isinstance(mem.number, str):
            number = _get_special()[mem.number]
        else:
            number = mem.number

        _mem = self._memobj.memory[number]
        _flag = self._memobj.flags[number]

        was_empty = int(_flag.empty)

        _flag.empty = mem.empty
        if mem.empty:
            _wipe_memory(_mem, "\xFF")
            return

        if was_empty:
            _wipe_memory(_mem, "\x00")

        _mem.unknown8 = 0
        _mem.is_625 = chirp_common.is_fractional_step(mem.freq)
        mult = _mem.is_625 and 6250 or 5000
        _mem.freq = mem.freq / mult
        _mem.offset = mem.offset / mult
        _mem.rtone = chirp_common.TONES.index(mem.rtone)
        _mem.ctone = chirp_common.TONES.index(mem.ctone)
        _mem.tmode = TMODES.index(mem.tmode)
        _mem.duplex = DUPLEX.index(mem.duplex)
        _mem.mode_dv = mem.mode == "DV"
        _mem.mode_am = mem.mode.endswith("AM")
        _mem.mode_narrow = mem.mode.startswith("N")
        _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
        _mem.dtcs_polarity = DTCSP.index(mem.dtcs_polarity)
        _mem.tuning_step = STEPS.index(mem.tuning_step)
        _mem.name = mem.name.ljust(6)
        if mem.power:
            _mem.power = POWER_LEVELS.index(mem.power)
        else:
            _mem.power = 0

        if number < 200:
            _flag.skip = mem.skip != ""

        if isinstance(mem, chirp_common.DVMemory):
            urcalls = self.get_urcall_list()
            rptcalls = self.get_repeater_call_list()
            _mem.urcall = urcalls.index(mem.dv_urcall)
            _mem.r1call = rptcalls.index(mem.dv_rpt1call)
            _mem.r2call = rptcalls.index(mem.dv_rpt2call)
Example #14
0
File: id800.py Project: cl4u2/chirp
    def set_memory(self, mem):
        _mem = self._memobj.memory[mem.number-1]
        _flg = self._memobj.flags[mem.number-1]

        _flg.empty = mem.empty
        if mem.empty:
            self._set_bank(mem.number, None)
            return

        mult = chirp_common.is_fractional_step(mem.freq) and 6250 or 5000
        _mem.mult_flag = mult == 6250
        _mem.freq = mem.freq / mult
        _mem.offset = mem.offset / 5000
        _mem.duplex = DUPLEX.index(mem.duplex)
        _mem.mode = MODES.index(mem.mode)
        _mem.tmode = TMODES.index(mem.tmode)
        _mem.rtone = chirp_common.TONES.index(mem.rtone)
        _mem.ctone = chirp_common.TONES.index(mem.ctone)
        _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
        _mem.dtcs_polarity = DTCS_POL.index(mem.dtcs_polarity)
        _mem.tuning_step = STEPS.index(mem.tuning_step)
        set_name(_mem, mem.name)

        _flg.pskip = mem.skip == "P"
        _flg.skip = mem.skip == "S"

        if mem.mode == "DV":
            urcalls = self.get_urcall_list()
            rptcalls = self.get_repeater_call_list()
            if not isinstance(mem, chirp_common.DVMemory):
                raise errors.InvalidDataError("DV mode is not a DVMemory!")
            try:
                err = mem.dv_urcall
                _mem.urcall = urcalls.index(mem.dv_urcall)
                err = mem.dv_rpt1call
                _mem.rpt1call = rptcalls.index(mem.dv_rpt1call)
                err = mem.dv_rpt2call
                _mem.rpt2call = rptcalls.index(mem.dv_rpt2call)
            except IndexError:
                raise errors.InvalidDataError("DV Call %s not in list" % err)
        else:
            _mem.urcall = 0
            _mem.rpt1call = 0
            _mem.rpt2call = 0
Example #15
0
    def set_memory(self, mem):
        _mem = self._memobj.memory[mem.number - 1]
        _flg = self._memobj.flags[mem.number - 1]

        _flg.empty = mem.empty
        if mem.empty:
            self._set_bank(mem.number, None)
            return

        mult = chirp_common.is_fractional_step(mem.freq) and 6250 or 5000
        _mem.mult_flag = mult == 6250
        _mem.freq = mem.freq / mult
        _mem.offset = mem.offset / 5000
        _mem.duplex = DUPLEX.index(mem.duplex)
        _mem.mode = MODES.index(mem.mode)
        _mem.tmode = TMODES.index(mem.tmode)
        _mem.rtone = chirp_common.TONES.index(mem.rtone)
        _mem.ctone = chirp_common.TONES.index(mem.ctone)
        _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
        _mem.dtcs_polarity = DTCS_POL.index(mem.dtcs_polarity)
        _mem.tuning_step = STEPS.index(mem.tuning_step)
        set_name(_mem, mem.name)

        _flg.pskip = mem.skip == "P"
        _flg.skip = mem.skip == "S"

        if mem.mode == "DV":
            urcalls = self.get_urcall_list()
            rptcalls = self.get_repeater_call_list()
            if not isinstance(mem, chirp_common.DVMemory):
                raise errors.InvalidDataError("DV mode is not a DVMemory!")
            try:
                err = mem.dv_urcall
                _mem.urcall = urcalls.index(mem.dv_urcall)
                err = mem.dv_rpt1call
                _mem.rpt1call = rptcalls.index(mem.dv_rpt1call)
                err = mem.dv_rpt2call
                _mem.rpt2call = rptcalls.index(mem.dv_rpt2call)
            except IndexError:
                raise errors.InvalidDataError("DV Call %s not in list" % err)
        else:
            _mem.urcall = 0
            _mem.rpt1call = 0
            _mem.rpt2call = 0
Example #16
0
    def set_memory(self, mem):
        _mem = self._memobj.memory[mem.number - 1]
        bit = 1 << ((mem.number - 1) % 8)
        byte = (mem.number - 1) / 8

        if mem.empty:
            self._memobj.emptyflags[byte] |= bit
            _mem.set_raw("\xFF" * 16)
            return

        self._memobj.emptyflags[byte] &= ~bit

        if chirp_common.is_fractional_step(mem.freq):
            mult = 6250
            _mem.is625 = True
        else:
            mult = 5000
            _mem.is625 = False
        _mem.freq = mem.freq / mult
        _mem.offset = mem.offset / 5000
        _mem.duplex = THUV3R_DUPLEX.index(mem.duplex)
        _mem.iswide = mem.mode == "FM"
        self._encode_tone(mem, _mem)

        if mem.skip:
            self._memobj.skipflags[byte] |= bit
        else:
            self._memobj.skipflags[byte] &= ~bit

        name = []
        for char in mem.name.ljust(6):
            try:
                c = THUV3R_CHARSET.index(char)
            except:
                c = THUV3R_CHARSET.index(" ")
            name.append(c)
        _mem.name = name
        LOG.debug(repr(_mem))
Example #17
0
    def set_memory(self, mem):
        _mem = self._memobj.memory[mem.number - 1]
        bit = 1 << ((mem.number - 1) % 8)
        byte = (mem.number - 1) / 8

        if mem.empty:
            self._memobj.emptyflags[byte] |= bit
            _mem.set_raw("\xFF" * 16)
            return

        self._memobj.emptyflags[byte] &= ~bit

        if chirp_common.is_fractional_step(mem.freq):
            mult = 6250
            _mem.is625 = True
        else:
            mult = 5000
            _mem.is625 = False
        _mem.freq = mem.freq / mult
        _mem.offset = mem.offset / 5000
        _mem.duplex = THUV3R_DUPLEX.index(mem.duplex)
        _mem.iswide = mem.mode == "FM"
        self._encode_tone(mem, _mem)

        if mem.skip:
            self._memobj.skipflags[byte] |= bit
        else:
            self._memobj.skipflags[byte] &= ~bit

        name = []
        for char in mem.name.ljust(6):
            try:
                c = THUV3R_CHARSET.index(char)
            except:
                c = THUV3R_CHARSET.index(" ")
            name.append(c)
        _mem.name = name
        LOG.debug(repr(_mem))
Example #18
0
 def test_is_fractional_step(self):
     for freq in self._125 + self._625:
         print freq
         self.assertTrue(chirp_common.is_fractional_step(freq))
Example #19
0
 def test_is_fractional_step(self):
     for freq in self._125 + self._625:
         print freq
         self.assertTrue(chirp_common.is_fractional_step(freq))