# Command: 0x01 0x00 + 5 BCD bytes + checksum cmd = bytes([0x01, 0x00] + freq_bcd) cmd += bytes([calc_checksum(cmd)])
def calc_checksum(cmd): """Calculate Yaesu checksum (two's complement of sum of bytes)""" total = sum(cmd) return (~total + 1) & 0xFF ft-817 programming software
ser.write(cmd) time.sleep(0.05) # Read response: 0x01 + status resp = ser.read(2) return resp def get_frequency(): """Read current VFO A frequency from FT-817""" cmd = bytes([0x03, 0x00, 0x00]) # Read frequency command cmd += bytes([calc_checksum(cmd)]) # Command: 0x01 0x00 + 5 BCD bytes