Giter VIP home page Giter VIP logo

Comments (3)

eerimoq avatar eerimoq commented on July 17, 2024

Can the format be handed without a flag to Bincopy? I prefer to have format logic in add*() methods.

from bincopy.

bessman avatar bessman commented on July 17, 2024

It could be done like this:

def add_microchip_hex(self, records, overwrite=False):
    self.word_size_bytes = 1
    self.add_ihex(records, overwrite)
    self.word_size_bytes = 2
    self.segments.word_size_bytes = 2
    for segment in self.segments:
        segment.word_size_bytes = 2

def add_microchip_hex_file(self, filename, overwrite=False):
    with open(filename, 'r') as fin:
        self.add_microchip_hex(fin.read(), overwrite)

However, since Microchip's format is indistinguishable12 from Intel, users would have to directly call add_microchip_hex_file:

import bincopy
# binfile = BinFile("microchip.hex")  # Won't work.
binfile = BinFile()
binfile.add_microchip_hex_file("microchip.hex")

Footnotes

  1. In practice, I think every fourth byte in a Microchip HEX is guaranteed to be zero (even though the example given in Microchip's format definition contradicts this), which could in theory be used to determine if a file is a normal Intel HEX or a Microchip HEX. Seems a little fragile to rely on that, since it's not explicit in the format definition.

  2. Scratch that, that is only the case for 16-bit word / 24-bit instruction. For PIC18 (8-bit word / 16-bit instruction) there is no such pattern. I think the formats are truly indistinguishable.

from bincopy.

eerimoq avatar eerimoq commented on July 17, 2024

Looks like a good plan.

from bincopy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.