|
int __stdcall SM_ReadHoldingRegisters |
( |
SM_HANDLE |
handle, |
|
|
int |
start, |
|
|
int |
number, |
|
|
unsigned char * |
values |
|
) |
| |
Reads a 16-bit value from the Sealevel I/O device, depending on the model.
- Deprecated:
- Version 3.0.4
- Parameters
-
[in] | handle | Valid handle returned by SM_Open(). |
[in] | start | Modbus address to begin the read (zero-indexed). |
[in] | number | Quantity of holding registers to read. |
[out] | values | Register state values. |
- Return values
-
>=0 | Number of bytes successfully returned in result array. |
-1 | Invalid SeaMAX handle. |
-2 | Connection is not established. Check the provided Connection object state. |
-3 | Read error waiting for response. Unkown Modbus exception. |
-4 | Illegal Modbus Function (Modbus Exception 0x01). |
-5 | Illegal Data Address (Modbus Exception 0x02). |
-6 | Illegal Data Value (Modbus Exception 0x03). |
-7 | Modbus CRC was invalid. Possible communications problem. |
This function performs different tasks depending on the model of Sealevel I/O device. For more information, see
- Note
- Modbus holding registers are 16-bit wide registers. Therefore, each read will result in 2 bytes in the result array. For multi-register reads, the high-order byte will reside in the first byte (result[0]) with the lower-order byte residing thereafter (result[1]). Other register bytes subsequently follow the same pattern.
- Warning
- The result array parameter should have enough allocated space, before calling this method, to hold 2 bytes for every register requested.
Referenced by CSeaMaxW32::Read().
|