I need the array ModBusData from the ModBus TCP Server 4 (library Modbus_TCP_7) in another function block. In this block I want to read and write elements of the array. (see attached images) I am aware that for an internal array I have to make a struct for a new datatype. → https://github.com/PLCnext/CSharpExamples/blob/master/PLCnext_CSharpExamples/04_UserArray/FBWithUserArray.cs But to connect the ModBusData Array to my function block I need the same datatype. Which is not the case when I create my own datatype. How can I use the ModBusData Array in my function block? Or is it possible to split the ModBusData Array into words and put them as input to my function block? If so, how can I do the separation?
Hello, You could create your own array type with as many elements as you need, and then copy values between the Modbus array and an array of your own type. This is not very efficient, but it is reasonably simple. After your earlier questions on the same topic, I have been discussing other options with Oliver, and - as Oliver has mentioned - we are considering adding relevant examples to the Github project. ~ Martin.
I currenttly use the following program. Can you tell me what is wrong? I can make the connection in the PLC with the datatype “ANY” but I still do not see any changes in the Modbus.
Hello, If you want to pass the Modbus array to an FB parameter of type ANY, then you could use something like this: (this sets all the bytes in the
INOUT variable to 0x7B, and assigns the length of INOUT (in bytes) to the OUT variable). In this case it is your responsibility to make sure the pointer in the unsafe code block never strays outside the bounds of the INOUT variable. Hope this helps. ~ Martin.

