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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
*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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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).
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
What exactly is your question?
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
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 :-)
*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.
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.
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.
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
Maybe the pack mode of the structure can help. See the following help topic on the standard behavior and also how you can set it specifically for your structure:
https://help.codesys.com/webapp/_cds_pragma_attribute_pack_mode;product=codesys;version=3.5.17.0