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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...