3. Operation
3.5 Using FbusIO_SendMsg
FbusIO_SendMsg is used to send an explicit message to a device and return a reply. This
command operates according to the protocol.
The syntax is as follows:
FbusIO_SendMsg bus, device, msgParam, sendBytes(), recvBytes()
There are two arrays passed to the function. The sendData array contains the data that is sent
to the device in bytes. This array must be dimensioned to the correct number of bytes to send.
If there are no bytes to send, you must use 0 as the parameter. The recvData array returns the
response in bytes. This array is automatically re-dimensioned to the number of bytes received.
For DeviceNet, you need to initialize the sendData array with the command, class, instance,
and attribute, as shown in the example below. Consult the documentation that came with the
device for the values that can be used. The msgParam parameter value is always 0 for
DeviceNet messages.
Here is an example for DeviceNet, EtherNet/IP:
' Send explicit message to the device
Byte sendData(5)
Byte recvData(10)
Integer i
sendData(0) = 14 ' Command
sendData(1) = 1 ' Class
sendData(3) = 1 ' Instance
sendData(5) = 7 ' Attribute
FbusIO_SendMsg 1, 1, 0, sendData(), recvData()
For i = 0 To UBound(recvData)
Print recvData(i)
Next i
For PROFIBUS DP, you need to specify the service number in the msgParam parameter.
Consult the documentation that came with the device for the services that are supported.
Some services require 0 send bytes. In this case, use 0 for the sendBytes parameter.
Here is an example for PROFIBUS DP:
' Send message to Profibus device
Byte recvData(10)
Integer i
' Service 56 - read all inputs
' sendBytes = 0
FbusIO_SendMsg 2, 1, 56, 0, recvData()
For i = 0 To UBound(recvData)
Print recvData(i)
Next i
Fieldbus I/O Rev.6 71