Sends a custom modbus message to the selected device, and retrieves the response.
- Parameters
-
[in] | handle | Valid handle returned by SM_Open(). |
[in] | message | Message to send beginning with the function code. It will also contain the response on success. |
[in] | messageSize | Size in bytes of the outgoing message. Must be less than 1017 bytes. |
[in] | expectedBytes | Size in bytes of the expected response. Must be less than 1017 bytes. |
- Return values
-
>=0 | Number of bytes successfully read. |
-1 | Invalid SeaMAX handle or connection type or invalid parameter. |
-2 | Modbus: Connection is not established. Check the provided Connection object state. |
-3 | Modbus: Read error waiting for response. Unknown Modbus exception. |
-7 | Modbus CRC was invalid. Possible communications problem. |
The message parameter should contain the function code and remaining bytes in the message. The header, the Slave ID and the CRC are not required because SeaMAX handles these elements of the message.
- Note
- The message parameter must contain an array large enough to hold the return message.
- See also
- http://www.modbus.org