コード例 #1
0
    def _load_address_counter(self, address, force_load):
        if address == self.address_counter and not force_load:
            return False

        (hi, lo) = _split_address(address)
        (current_hi, current_lo) = _split_address(self.address_counter)

        if hi != current_hi or force_load:
            load_address_counter_hi(self.interface, hi)

        if lo != current_lo or force_load:
            load_address_counter_lo(self.interface, lo)

        self.address_counter = address

        return True
コード例 #2
0
ファイル: 20_char_map.py プロジェクト: markbirss/coax
from common import create_serial, create_interface

from coax import Control, read_address_counter_hi, read_address_counter_lo, load_address_counter_hi, load_address_counter_lo, write_data, load_control_register

DIGIT_MAP = [
    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x80, 0x81,
    0x82, 0x83, 0x84, 0x85
]

with create_serial() as serial:
    interface = create_interface(serial)

    load_control_register(interface, Control(cursor_inhibit=True))

    load_address_counter_hi(interface, 0)
    load_address_counter_lo(interface, 80)

    buffer = b'\x00' * 4

    # Header Row
    for lo in range(16):
        buffer += bytes([0x2f, DIGIT_MAP[lo]]) + (b'\x00' * 2)

    buffer += b'\x00' * 12

    # Rows
    for hi in range(16):
        buffer += bytes([DIGIT_MAP[hi], 0x2f]) + (b'\x00' * 2)

        for lo in range(16):
コード例 #3
0
ファイル: 40_eab.py プロジェクト: lowobservable/coax
def eab_alternate_zip(regen_buffer, eab_buffer):
    return bytes(chain(*zip(regen_buffer, eab_buffer)))


with open_example_serial_interface() as interface:
    features = get_features(interface)

    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'
    )