def _write(self, data, address=None, restore_original_address=False): if restore_original_address: original_address = self.address_counter if original_address is None: original_address = self._read_address_counter() if address is not None: self._load_address_counter(address, force_load=False) write_data(self.interface, data) if isinstance(address, tuple): length = len(data[0]) * data[1] else: length = len(data) self.address_counter = self._calculate_address_after_write( address, length) if restore_original_address: self._load_address_counter(original_address, force_load=True)
# Rows for hi in range(16): buffer += bytes([DIGIT_MAP[hi], 0x2f]) + (b'\x00' * 2) for lo in range(16): if hi < 12: buffer += bytes([0x00, (hi << 4) | lo, 0xc0, 0x00]) else: buffer += bytes([(hi << 4) | lo, 0x32, 0xc0, 0x00]) buffer += b'\x00' * 12 buffer += b'\x00' * 560 write_data(interface, buffer) # Status Line load_address_counter_hi(interface, 7) load_address_counter_lo(interface, 48) buffer = b'' for hi in range(12, 16): buffer += bytes([DIGIT_MAP[hi]]) + (b'\x00' * 15) buffer += b'\x00' * 16 for hi in range(12, 16): for lo in range(0, 16): buffer += bytes([DIGIT_MAP[lo]])
#!/usr/bin/env python from common import open_example_serial_interface from coax import SecondaryControl, read_address_counter_hi, read_address_counter_lo, read_multiple, load_address_counter_hi, load_address_counter_lo, load_secondary_control, write_data with open_example_serial_interface() as interface: load_address_counter_hi(interface, 0) load_address_counter_lo(interface, 80) write_data(interface, bytes.fromhex('a7 84 8b 8b 8e 33 00 96 8e 91 8b 83 19')) load_address_counter_hi(interface, 0) load_address_counter_lo(interface, 81) print('READ_MULTIPLE...') print(read_multiple(interface)) hi = read_address_counter_hi(interface) lo = read_address_counter_lo(interface) print(f'hi = {hi}, lo = {lo}') load_address_counter_hi(interface, 0) load_address_counter_lo(interface, 81) print('LOAD_SECONDARY_CONTROL big') load_secondary_control(interface, SecondaryControl(big=True))
if Feature.EAB not in features: sys.exit('No EAB feature found.') eab_address = features[Feature.EAB] print(f'EAB feature found at address {eab_address}') # Protected Normal load_address_counter_hi(interface, 0) load_address_counter_lo(interface, 80) regen_buffer = bytes.fromhex( 'e0 08 00 af 91 8e 93 84 82 93 84 83 00 ad 8e 91 8c 80 8b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09' ) write_data(interface, regen_buffer) # Protected Intense load_address_counter_hi(interface, 0) load_address_counter_lo(interface, 160) regen_buffer = bytes.fromhex( 'e8 08 00 af 91 8e 93 84 82 93 84 83 00 a8 8d 93 84 8d 92 84 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09' ) write_data(interface, regen_buffer) # Normal EFA load_address_counter_hi(interface, 1) load_address_counter_lo(interface, 64)