LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extra '0' during hex conversion

Hello

 

I'm trying to create a bootloader app, which would send parts of intel hex file to the atmega128 we use. I have trimmed the intel hex file and tried to convert it to true hex (as opposed to ascii hex in which intel hex is written). I did so with typecast to string, but noticed that occasionally a stray '0' would be in the output string. 

 

Example:

AeroSoul_0-1659688123494.png

 

Instead of 'F1F' it's converted to 'F10F'.

 

Any ideas as to why this happens? Am i missing half a byte somewhere so it just appends it?

 

snip.png

0 Kudos
Message 1 of 9
(1,597 Views)

It was a line feed character...

0 Kudos
Message 2 of 9
(1,593 Views)

@AeroSoul wrote:

It was a line feed character...


So where did it come from?

Overall, you code could be greatly simplified because you know the numer of iterations from first principles (i.e. half the string length) so a FOR loop seems more appropriate.

 

One possible idea from a decades old post here . 😄

 

altenbach_0-1659702045901.png

 

Message 3 of 9
(1,557 Views)

Yep, log 2 ....didn't that change shape?


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 9
(1,543 Views)

@JÞB wrote:

Yep, log 2 ....didn't that change shape?


Sorry, I don't understand. Is your commend related to any particular part of this thread? Which one?

 

(I am not using log2 but "Scale by power of two" (AKA: "arithmetic shift", i.e. also scaling negative integers correctly)

0 Kudos
Message 5 of 9
(1,519 Views)

@altenbach wrote:

@AeroSoul wrote:

It was a line feed character...


So where did it come from?

 


I put it there in previous loop 😄

 

AeroSoul_0-1659943951449.png

 

Also thanks for the simplified code 🙂

 

0 Kudos
Message 6 of 9
(1,468 Views)

@AeroSoul wrote:

@altenbach wrote:

@AeroSoul wrote:

It was a line feed character...


So where did it come from?

 


I put it there in previous loop 😄

 

AeroSoul_0-1659943951449.png

 

Also thanks for the simplified code 🙂

 


Ah, it's good to know that there is an explanation for the stray linefeed. 😄

 

Somehow my gut feeling tells me that your "previous loop" code could also be simplified quite a bit, but it's hard to tell from a picture alone. 😉

0 Kudos
Message 7 of 9
(1,440 Views)

It basically just strips data from the hex file. Removes first 7 characters and last 2, then checks if the first characters from stripped row are '00' (which signifies data row in intel hex) and stores them if it is.

hex_strip.png

 

0 Kudos
Message 8 of 9
(1,383 Views)

Hi AeroSoul,

 

try this:

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 9
(1,373 Views)