python-intelhex / intelhex

Python IntelHex library
BSD 3-Clause "New" or "Revised" License
198 stars 106 forks source link

Swapping of bytes #60

Closed HussainMughal1 closed 1 year ago

HussainMughal1 commented 1 year ago

Hello,

Your library has been very helpful for reading .hex files.

Context: I'm using the IntelHex library to read from a .hex file, which I then use to flash a microcontroller.

As you can appreciate, there are thousands of bytes contained in the .hex, and so I'm attempting to read and send the maximum number of bytes in one message at a time, which is 4095.

My code looks something like this:

startAddress = 0x00840000
maxFrameSize = 4095
data = []

"""  Send 100 blocks of data from hex file """
for blocks in range(100):

    """ Increment sequence number for every data block sent """
    for sequenceNumber in range(0x01, 0xFF):

          """ Read data from .hex and append to array """
           for i in range(maxFrameSize):

               data.append(int(IH[startAddress + I]))

           """ Send """
           client.transfer_data(sequence_number= sequenceNumber, data= bytes(data))

           """ Clear array """             
           data.clear()

           """ Update Start address for next block """
           startAddress += maxFrameSize

The issue I've encountered is that some bytes are swapped according to my trace, preventing me from finishing the data transfer.

The image is a diff containing my trace on the left, and a trace generated from another vendor-supplied microcontroller flashing tool, with the differences highlighted.

image

I hope I've provided enough information.

Any help would be appreciated!

HussainMughal1 commented 1 year ago

The maximum frame size of 4095 is given by CAN.

HussainMughal1 commented 1 year ago

The issue originated from another library. Closed.