{"id":5133,"library":"bincopy","title":"bincopy","description":"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.","status":"active","version":"20.1.1","language":"en","source_language":"en","source_url":"https://github.com/eerimoq/bincopy","tags":["srecord","srec","intel hex","binary","hex","firmware","embedded","ti-txt","verilog vmem","elf"],"install":[{"cmd":"pip install bincopy","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Command-line argument parsing enhancements.","package":"argparse-addons","optional":false},{"reason":"Human-readable data formatting (e.g., sizes).","package":"humanfriendly","optional":false},{"reason":"Required for parsing and manipulating ELF files.","package":"pyelftools","optional":false}],"imports":[{"note":"The class for handling binary files was renamed from 'File' to 'BinFile' in more recent versions. Using 'File' will result in an AttributeError or NameError.","wrong":"from bincopy import File","symbol":"BinFile","correct":"from bincopy import BinFile"}],"quickstart":{"code":"import bincopy\nimport io\n\n# Example Intel HEX content as a string\nintel_hex_content = (\n    \":10010000214601360121470136007EFE09D219012146017E17C20001FF5F16002148011973\\n\"\n    \":0C011000194E79234623965778239EDA3F0199\\n\"\n    \":00000001FF\"\n)\n\n# Create an in-memory file-like object from the string\nhex_file_stream = io.StringIO(intel_hex_content)\n\n# Initialize BinFile and add the Intel HEX data\nbin_file = bincopy.BinFile()\nbin_file.add_ihex(hex_file_stream)\n\n# Convert to Motorola S-Record format\nsrec_output = bin_file.as_srec()\nprint(\"Motorola S-Record output:\")\nprint(srec_output)\n\n# Access properties like minimum and maximum address\nprint(f\"Minimum address: {bin_file.minimum_address:#x}\")\nprint(f\"Maximum address: {bin_file.maximum_address:#x}\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to Python 3.9 or a newer version (e.g., `python3.9 -m pip install bincopy`).","message":"bincopy versions 20.x.x and newer require Python 3.9 or higher. Attempting to install or run these versions on Python 2.x will result in installation errors or runtime exceptions due to syntax incompatibility and dropped support.","severity":"breaking","affected_versions":">=20.0.0"},{"fix":"Always use `bincopy.BinFile()` for instantiating the binary file object.","message":"The primary class for handling binary files was `bincopy.File` in older versions. It has been renamed to `bincopy.BinFile` in current versions. Using `bincopy.File()` will raise an `AttributeError` or `NameError` if the older class is not available or if you're following outdated examples.","severity":"gotcha","affected_versions":"All versions >=17.0.0 (approx.)"},{"fix":"Wrap string content in `io.StringIO(your_string_data)` before passing it to methods like `add_ihex()` or `add_srec()`.","message":"When adding data, methods like `add_ihex()` expect a file-like object. For directly adding a string containing Intel HEX or S-Record data, it's generally best to create an `io.StringIO` object from the string and pass that, or check for specific `add_*_string` methods if available (though `add_ihex` with `StringIO` is robust). Incorrectly passing a raw string to methods expecting a file object can lead to unexpected parsing errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}