def _checksums(self): return [ yaesu_clone.YaesuChecksum(0x064A, 0x06C8), yaesu_clone.YaesuChecksum(0x06CA, 0x0748), yaesu_clone.YaesuChecksum(0x074A, 0x07C8), yaesu_clone.YaesuChecksum(0x07CA, 0x0848), yaesu_clone.YaesuChecksum(0x0000, 0xFEC9) ]
def _read(self, block, blocknum, lastblock): # be very patient at first block if blocknum == 0: attempts = 60 else: attempts = 5 for _i in range(0, attempts): data = self.pipe.read(block+2) if data: break time.sleep(0.5) if len(data) == block+2 and data[0] == chr(blocknum): checksum = yaesu_clone.YaesuChecksum(1, block) if checksum.get_existing(data) != \ checksum.get_calculated(data): raise Exception("Checksum Failed [%02X<>%02X] block %02X" % (checksum.get_existing(data), checksum.get_calculated(data), blocknum)) data = data[1:block+1] # Chew away the block number and the checksum else: if lastblock and self._US_model: raise Exception(_("Unable to read last block. " "This often happens when the selected model is US " "but the radio is a non-US one (or widebanded). " "Please choose the correct model and try again.")) else: raise Exception("Unable to read block %02X expected %i got %i" % (blocknum, block+2, len(data))) if os.getenv("CHIRP_DEBUG"): print "Read %i" % len(data) return data
def _clone_out(self): looppredelay = 0.4 looppostdelay = 1.9 start = time.time() blocknum = 0 pos = 0 status = chirp_common.Status() status.msg = "Cloning to radio..." self.status_fn(status) status.max = len(self._block_lengths) for blocksize in self._block_lengths: checksum = yaesu_clone.YaesuChecksum(pos, pos + blocksize - 1) blocknumbyte = chr(blocknum) payloadbytes = self.get_mmap()[pos:pos + blocksize] checksumbyte = chr(checksum.get_calculated(self.get_mmap())) if CHIRP_DEBUG: print "Block %i - will send from %i to %i byte " % \ (blocknum, pos, pos + blocksize) print util.hexprint(blocknumbyte) print util.hexprint(payloadbytes) print util.hexprint(checksumbyte) # send wrapped bytes time.sleep(looppredelay) self.pipe.write(blocknumbyte) self.pipe.write(payloadbytes) self.pipe.write(checksumbyte) tmp = self.pipe.read(blocksize + 2) #chew echo if CHIRP_DEBUG: print "bytes echoed: " print util.hexprint(tmp) # radio is slow to write/ack: time.sleep(looppostdelay) buf = self.pipe.read(1) if CHIRP_DEBUG: print "ack recd:" print util.hexprint(buf) if buf != CMD_ACK: raise Exception("Radio did not ack block %i" % blocknum) pos += blocksize blocknum += 1 status.cur = blocknum self.status_fn(status) print "Clone completed in %i seconds" % (time.time() - start)
def _clone_out(self): delay = 0.5 start = time.time() blocks = 0 pos = 0 status = chirp_common.Status() status.msg = _("Cloning to radio") status.max = len(self._block_lengths) + 39 for block in self._block_lengths: if blocks == 8: # repeated read of 40 block same size (memory area) repeat = 40 else: repeat = 1 for _i in range(0, repeat): time.sleep(0.01) checksum = yaesu_clone.YaesuChecksum(pos, pos+block-1) if os.getenv("CHIRP_DEBUG"): print "Block %i - will send from %i to %i byte " % \ (blocks, pos, pos + block) print util.hexprint(chr(blocks)) print util.hexprint(self.get_mmap()[pos:pos+block]) print util.hexprint(chr(checksum.get_calculated( self.get_mmap()))) self.pipe.write(chr(blocks)) self.pipe.write(self.get_mmap()[pos:pos+block]) self.pipe.write(chr(checksum.get_calculated(self.get_mmap()))) buf = self.pipe.read(1) if not buf or buf[0] != chr(CMD_ACK): time.sleep(delay) buf = self.pipe.read(1) if not buf or buf[0] != chr(CMD_ACK): if os.getenv("CHIRP_DEBUG"): print util.hexprint(buf) raise Exception(_("Radio did not ack block %i") % blocks) pos += block blocks += 1 status.cur = blocks self.status_fn(status) print "Clone completed in %i seconds" % (time.time() - start)
def _read(self, blocksize, blocknum): data = self.pipe.read(blocksize + 2) # chew echo'd ack self.pipe.write(CMD_ACK) time.sleep(0.02) self.pipe.read(1) # chew echoed ACK from 1-wire serial if len(data) == blocksize + 2 and data[0] == chr(blocknum): checksum = yaesu_clone.YaesuChecksum(1, blocksize) if checksum.get_existing(data) != checksum.get_calculated(data): raise Exception( "Checksum Failed [%02X<>%02X] block %02X, data len: %i" % (checksum.get_existing(data), checksum.get_calculated(data), blocknum, len(data))) data = data[1:blocksize + 1] # Chew blocknum and checksum else: raise Exception( "Unable to read blocknum %02X expected blocksize %i got %i." % (blocknum, blocksize + 2, len(data))) return data
def _checksums(self): return [ yaesu_clone.YaesuChecksum(0x0000, 0x7F51) ]
def _checksums(self): return [yaesu_clone.YaesuChecksum(0, self._memsize - 2)]
def _checksums(self): return [ yaesu_clone.YaesuChecksum(0x0592, 0x0610), yaesu_clone.YaesuChecksum(0x0612, 0x0690), yaesu_clone.YaesuChecksum(0x0000, 0x3F51), ]