Skip to content

Commit

Permalink
Rename _send_and_receive to _exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
bessman committed May 21, 2024
1 parent 662dc89 commit 2842491
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/mcbootflash/flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _read_version(connection: Connection) -> tuple[int, int, int, int, int]:
Write block size. When writing to flash, the number of bytes to be
written must align with a write block.
"""
read_version_response = _send_and_receive(
read_version_response = _exchange(
connection,
Command(CommandCode.READ_VERSION),
)
Expand Down Expand Up @@ -139,7 +139,7 @@ def _get_memory_address_range(connection: Connection) -> tuple[int, int]:
The returned tuple is suitable for use in `range`, i.e. the upper bound is not
part of the writable range.
"""
mem_range_response = _send_and_receive(
mem_range_response = _exchange(
connection,
Command(CommandCode.GET_MEMORY_ADDRESS_RANGE),
)
Expand Down Expand Up @@ -194,7 +194,7 @@ def erase_flash(
raise ValueError(msg)

_logger.debug(f"Erasing addresses {start:#08x}:{end:#08x}")
_send_and_receive(
_exchange(
connection,
command=Command(
command=CommandCode.ERASE_FLASH,
Expand All @@ -216,7 +216,7 @@ def write_flash(connection: Connection, chunk: Chunk) -> None:
Firmware chunk to write to bootloader.
"""
_logger.debug(f"Writing {len(chunk.data)} bytes to {chunk.address:#08x}")
_send_and_receive(
_exchange(
connection,
Command(
command=CommandCode.WRITE_FLASH,
Expand All @@ -242,7 +242,7 @@ def self_verify(connection: Connection) -> None:
If the bootloader cannot detect a bootable application in program
memory.
"""
_send_and_receive(connection, Command(command=CommandCode.SELF_VERIFY))
_exchange(connection, Command(command=CommandCode.SELF_VERIFY))


def checksum(
Expand Down Expand Up @@ -285,7 +285,7 @@ def checksum(


def _get_remote_checksum(connection: Connection, address: int, length: int) -> int:
checksum_response = _send_and_receive(
checksum_response = _exchange(
connection,
Command(
command=CommandCode.CALC_CHECKSUM,
Expand Down Expand Up @@ -315,7 +315,7 @@ def reset(connection: Connection) -> None:
connection : Connection
Connection to device in bootloader mode.
"""
_send_and_receive(connection, Command(command=CommandCode.RESET_DEVICE))
_exchange(connection, Command(command=CommandCode.RESET_DEVICE))
_logger.debug("Device reset")


Expand Down Expand Up @@ -387,7 +387,7 @@ def _get_response(connection: Connection, in_response_to: Command) -> ResponseBa
return response_type.from_bytes(bytes(response) + remainder)


def _send_and_receive(
def _exchange(
connection: Connection,
command: Command,
data: bytes = b"",
Expand Down

0 comments on commit 2842491

Please sign in to comment.