Struc

2021-09-15
2021-10-04
  • Reinier Geers - 2021-09-15

    I copy an array into a strucure but somehowe it moves a byte. Why 36 54 7a 41 schould be 15.46 but it is 6.0.139E-39 witch is 54 7a 41 00

     
  • Reinier Geers - 2021-09-15

     
  • aliazzz

    aliazzz - 2021-09-15

    What exactly is your question?

     
  • Reinier Geers - 2021-09-15

    Both are the same. rMeasure_value_1 starts at byte 4. but is not the right value. If i memcpy Byte 4-7 to real ive got the right value. So why not as a struc . It looks likes it moves a byte

     
    • aliazzz

      aliazzz - 2021-09-15

      I am very sorry that I do not understand your explanation, here are some hints to help you describe your issue in a clear and concise way so we (the audience) can help you way better =)

      1) Describe your problem in a concise way without referring to previous posts. So prevent stuff like "Both are the same" .. Remember that we, the audience, need context.
      2) Provide IDE and system versions,
      3) Provide actual outcome,
      4) Provide expected outcome.

      I hope the above hints help you write posts which people can immediately anwser in a meaningful way :-)

       
      πŸ‘
      1
  • aliazzz

    aliazzz - 2021-09-15

    *I copy an array into a strucure but somehowe it moves a byte. *

    I think you have byte alignment issues. Maybe a UNION of the DUT (STRUCT) and ARRAY will help you. Otherwise you could try to use SysMemCopy to copy data from the ARRAY to the STRUCT and VICE VERSA.

     
  • i-campbell

    i-campbell - 2021-09-15

    In ARM, REALs MUST be aligned to 4byte addresses.
    In other architectures, they are more efficient went aligned, so they are aligned.
    You could change the sendor of the byte array, to add a padding byte to your serialized data, or do as you say, a memcpy.

     
  • Reinier Geers - 2021-09-16

    System version is 9.2
    I recieve by RS232 a array of data

    When i copy byte 4-7 into an array of bytes and then syscpy to a real ive got the right value.

    when i copy it strait to a structure where the position of byte 4-7 is a real. Then the value is moved. I put in a Union struc so you can also see it as an array of byte. witch shows the movement.

     
    • dFx

      dFx - 2021-10-04

      Feels like endiantness issue between your 2 systems. Try word swaping and/or byte swaping.

      With A=15,B=8E,C=41,D=00
      Result shown by your screenshot is Little Endian, DCBA.
      I bet you expect 8.005262, which is Mid-Little Endian, CDAB (just byte swaping, in each words).

      More tries here :
      https://www.scadacore.com/tools/programming-calculators/online-hex-converter/

       

      Last edit: dFx 2021-10-04

Log in to post a comment.