Writes the state of one or more digital outputs.
- Parameters
-
| [in] | handle | Valid handle returned by SM_Open(). |
| [in] | start | Starting output (zero-indexed). |
| [in] | number | Quantity of outputs to write. |
| [in] | values | Desired output state(s). |
- Return values
-
| >=0 | Number of bytes successfully written. |
| -1 | Invalid SeaMAX handle. |
| -2 | Modbus: Connection is not established. Check the provided Connection object state. |
| -3 | Modbus: Read error waiting for response. Unknown Modbus exception. |
| -4 | Modbus: Illegal Modbus Function (Modbus Exception 0x01). |
| -5 | Modbus: Illegal Data Address (Modbus Exception 0x02). |
| -6 | Modbus: Illegal Data Value (Modbus Exception 0x03). |
| -7 | Modbus CRC was invalid. Possible communications problem. |
| -20 | SeaDAC Lite: Invalid model number. |
| -21 | SeaDAC Lite: Invalid addressing. |
| -22 | SeaDAC Lite: Error writing to the device. |
The desired output state(s) parameter (values) should be an array of bytes, where each byte represents 8 output states. The LSB of the first byte (values[0]) should contain the first 8 output states and should be ordered from LSB to MSB.
For instance, a write of 18 outputs should be an array of 3 bytes as such:
values[0] = Outputs 7 to 0 (MSB to LSB)
values[1] = Outputs 15 to Outputs 8
values[2] = 6 padded bits followed by outputs 17 - 16.
Referenced by SM_WriteCoils().