int __stdcall SM_ReadAnalogInputs ( SM_HANDLE  handle,
int  start,
int  number,
double *  analogValues,
unsigned char *  ranges,
unsigned char *  byteValues 
)

Reads one or more Sealevel I/O device analog input(s).

Parameters
[in]handleValid handle returned by SM_Open().
[in]startStarting input.
[in]numberQuantity of analog inputs to read.
[out]analogValuesInput values as floating point values (voltages).
[in]rangesArray of channel ranges that correspond directly to each requested input.
[out]byteValuesRegister state values as 16-bit byte pairs.
Return values
>=0Number of bytes successfully returned in result array.
-1Invalid SeaMAX handle.
-2Both 'byteValues' or 'analogValues' are null. Supply either one or both.
-3If an array of doubles is supplied, a similar array of analog input ranges must also be supplied.
-4One or more of the analog input ranges in the 'ranges' array is invalid.
-5Connection is not established. Check the provided Connection object state.
-6Read error waiting for response. Unknown Modbus exception.
-7Illegal Modbus Function (Modbus Exception 0x01).
-8Illegal Data Address (Modbus Exception 0x02).
-9Illegal Data Value (Modbus Exception 0x03).
-10Modbus CRC was invalid. Possible communications problem.

Reads one or more analog inputs. There are two ways that the analog input values can be returned: an array of 16-bit byte values, or as an array of double (floating-point) values.

Note
This function will return, via parameters, either an array of bytes, an array of doubles, or both. If you pass either the byte array or double array as null, that type of data will not be returned.

Double Array - Voltage Values

If an array of doubles is supplied, the array must contain at least one double for each analog input requested. The array will be filled with floating point voltage values after a successful completion. An array of analog input ranges is also required to convert the device's response to appropriate floating point values. The ranges array must have one byte corresponding to an appropriate channel range for each input requested. For instance, if three analog inputs are requested starting at input 2, the ranges array should contain:

    ranges[0] = Input 2 Channel Range
    ranges[1] = Input 3 Channel Range
    ranges[2] = Input 4 Channel Range

The channel ranges for any analog I/O device can be retrieved using the SM_GetAnalogInputRanges() function.

Byte Array - 16-bit Byte Values

If an array of bytes is supplied, the array must contain at least two bytes for every analog input request. If only a byte array is supplied, the ranges parameter is not required. The byte array will be filled with the two byte values read directly from the analog I/O device. The byte order is such that the high-byte always comes first. For instance, if two analog inputs are read starting at input 4, the byte array returned will contain:

    byteValues[0] = Input 4 (High Byte)
    byteValues[1] = Input 4 (Low Byte)
    byteValues[2] = Input 5 (High Byte)
    byteValues[3] = Input 5 (Low Byte)
Warning
If a doubles array is supplied, it should contain space allocated for one double for each of the analog inputs requested. If a byte array is supplied, it should contain two bytes of space allocated for each input.

Referenced by SM_ReadInputRegisters().

 
 
Generated on Mon Nov 26 2018.