TsctlDIOGetMultiDesc

From embeddedTS Manuals

The function returns the current state of all or some of the DIOs in this instance.

Each byte in the state array is packed with 8 DIO values. The most significant bit of bits[0] contains the value of the logical DIO numbered offset. The next most significant bit contains the value of logical DIO offset+1 and so forth, moving to the next element of bits every time the current element has be filled with the next 8 DIO values.

Each bit upon return contains only the value of the DIO, either 1 for HIGH or 0 for LOW. No indication is returned whether the DIO is an INPUT or OUTPUT.

It is up to the user to correctly size the state Array. If the size is longer than the remaining number of DIO from the starting offset the value of the remaining bits will be undefined. To find the optimal Array length for bits, take the number of DIOs in the instance, as reported by the Count function, and subtract the starting offset. Then, divide by 8, adding one if there is a remainder.

A smaller than optimal size can be specified in order to reduce the range of DIO values returned. In this way it is possible to use this function to return any contiguous subset of DIO values.

This function also supports a "quick" mode. If 32 or fewer bits are needed, pass a zero-length state Array or null pointer for bits, and the return value will be the first 32 DIOs starting at offset with the most significant bit being the value of the logical DIO numbered offset.