Esempio n. 1
0
    def set_memory(self, memory):
        if memory.number < 0 or memory.number > self._upper:
            raise errors.InvalidMemoryLocation(
                "Number must be between 0 and %i" % self._upper)

        spec = self._make_mem_spec(memory)
        spec = "".join(spec)
        r1 = command(self.pipe, *self._cmd_set_memory(memory.number, spec))
        if not iserr(r1):
            memory.name = memory.name.rstrip()
            self._memcache[memory.number] = memory

            # if we're tuned to the channel, reload it
            r1 = command(self.pipe, *self._cmd_cur_memory(memory.number))
            if not iserr(r1):
                pattern = re.compile("MC([0-9]{3})")
                match = pattern.search(r1)
                if match is not None:
                    cur_mem = int(match.group(1))
                    if cur_mem == memory.number:
                        cur_mem = \
                            command(self.pipe,
                                    *self._cmd_recall_memory(memory.number))
        else:
            raise errors.InvalidDataError("Radio refused %i" % memory.number)

        # FIXME
        if memory.duplex == "split" and self._kenwood_split:
            spec = "".join(self._make_split_spec(memory))
            result = command(self.pipe,
                             *self._cmd_set_split(memory.number, spec))
            if iserr(result):
                raise errors.InvalidDataError("Radio refused %i" %
                                              memory.number)
Esempio n. 2
0
    def set_memory(self, memory):
        if memory.number < 0 or memory.number > self._upper:
            raise errors.InvalidMemoryLocation("Number must be between 0 and %i" % self._upper)

        spec = self._make_mem_spec(memory)
        spec = "".join(spec)
        r1 = command(self.pipe, *self._cmd_set_memory(memory.number, spec))
        if not iserr(r1):
            memory.name = memory.name.rstrip()
            self._memcache[memory.number] = memory

            # if we're tuned to the channel, reload it
            r1 = command(self.pipe, *self._cmd_cur_memory(memory.number))
            if not iserr(r1):
                pattern = re.compile("MC([0-9]{3})")
                match = pattern.search(r1)
                if match is not None:
                    cur_mem = int(match.group(1))
                    if cur_mem == memory.number:
                        cur_mem = command(self.pipe, *self._cmd_recall_memory(memory.number))
        else:
            raise errors.InvalidDataError("Radio refused %i" % memory.number)

        # FIXME
        if memory.duplex == "split" and self._kenwood_split:
            spec = "".join(self._make_split_spec(memory))
            result = command(self.pipe, *self._cmd_set_split(memory.number, spec))
            if iserr(result):
                raise errors.InvalidDataError("Radio refused %i" % memory.number)
Esempio n. 3
0
    def erase_memory(self, number):
        if number not in self._memcache:
            return

        resp = command(self.pipe, *self._cmd_erase_memory(number))
        if iserr(resp):
            raise errors.RadioError("Radio refused delete of %i" % number)
        del self._memcache[number]
Esempio n. 4
0
    def erase_memory(self, number):
        if number not in self._memcache:
            return

        resp = command(self.pipe, *self._cmd_erase_memory(number))
        if iserr(resp):
            raise errors.RadioError("Radio refused delete of %i" % number)
        del self._memcache[number]
Esempio n. 5
0
    def set_memory(self, memory):
        if memory.number < 0 or memory.number > self._upper:
            raise errors.InvalidMemoryLocation(
                "Number must be between 0 and %i" % self._upper)

        if memory.number > 90:
            if memory.duplex == TS850_DUPLEX[0]:
                memory.duplex = TS850_DUPLEX[1]
                memory.offset = memory.freq
            else:
                if memory.freq > memory.offset:
                    temp = memory.freq
                    memory.freq = memory.offset
                    memory.offset = temp

        # Clear out memory contents to prevent errors
        spec = self._make_base_spec(memory, 0)
        spec = "".join(spec)
        result = command(self.pipe, *self._cmd_set_memory(memory.number, spec))

        if iserr(result):
            raise errors.InvalidDataError("Radio refused %i" %
                                          memory.number)

        # If we have a split set the transmit frequency first.
        if memory.duplex == TS850_DUPLEX[1]:
            spec = "".join(self._make_split_spec(memory))
            result = command(self.pipe, *self._cmd_set_split(memory.number,
                                                             spec))
            if iserr(result):
                raise errors.InvalidDataError("Radio refused %i" %
                                              memory.number)

        spec = self._make_mem_spec(memory)
        spec = "".join(spec)
        result = command(self.pipe, *self._cmd_set_memory(memory.number, spec))
        if iserr(result):
            raise errors.InvalidDataError("Radio refused %i" % memory.number)