bincopy

20.1.1 · active · verified Mon Apr 13

bincopy is a Python library for manipulating various binary information file formats, including Motorola S-Record, Intel HEX, TI-TXT, Verilog VMEM, ELF, and raw binary files. The current version is 20.1.1, and the library is actively maintained with regular updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse Intel HEX data from a string, add it to a `bincopy.BinFile` object, and then convert it to Motorola S-Record format. It also shows how to access basic information like memory addresses.

import bincopy
import io

# Example Intel HEX content as a string
intel_hex_content = (
    ":10010000214601360121470136007EFE09D219012146017E17C20001FF5F16002148011973\n"
    ":0C011000194E79234623965778239EDA3F0199\n"
    ":00000001FF"
)

# Create an in-memory file-like object from the string
hex_file_stream = io.StringIO(intel_hex_content)

# Initialize BinFile and add the Intel HEX data
bin_file = bincopy.BinFile()
bin_file.add_ihex(hex_file_stream)

# Convert to Motorola S-Record format
srec_output = bin_file.as_srec()
print("Motorola S-Record output:")
print(srec_output)

# Access properties like minimum and maximum address
print(f"Minimum address: {bin_file.minimum_address:#x}")
print(f"Maximum address: {bin_file.maximum_address:#x}")

view raw JSON →