Jump to content

buffer to struct : position of variables


pascal

Recommended Posts

I have following question :

I'm using modbus communication to read some values of a powermeter. Instead of reading 40 variables - one by one - I read them in one modbus cyle, into a buffer...

with the command buffer to struct, I can copy the values from the buffer to the struct. But when defining the structure, can I be 100% sure that the position of my variables in the structure is like I programmed the structure ?

I give an example :

I read 12 bytes via modbus ( 3 floating values) into buffer read[0..11]

I have a struct with variables float1 - float 2 - float 3

then I use buffer to struct....

are the first 4 bytes going to float1, second 4 bytes to float 2 and last 4 bytes to float3 ? I tested this, yes they do......but is this always like this?

I need to know if when recompiling the program, or copying this UDFB to another PLC program, will be always working with the "correct postioned" structure... 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.