GX5290, File
Pack an array of data to a single DWord.
DioDataPack (nNumPins, nDataSize, dwOffset, nUnpackedDataType, pdwPackedData, pvUnpackedData, pnStatus)
Name |
Type |
Comments |
nNumPins |
SHORT |
Number of pins: 1, 2, 4, 8, 16, 32 |
nDataSize |
SHORT |
Number of elements to pack from the unpacked data buffer. |
dwOffset |
SHORT |
Offset to start packing the data from, e.g. if offset=1 and nNumPins=4 then the packed data will start from bit 4. |
nUnpackedDataType |
SHORT |
The array data type in bytes:1 Byte2 Word4 DWord |
pdwPackedData |
PDWORD |
Pointer to a DWORD returning the packed data as single DWord. |
pvUnpackedData |
PVOID |
Pointer to the unpacked data buffer. |
pnStatus |
PSHORT |
Returned status: 0 on success, negative number on failure. |
The function helps packing data to 32-bit when the number of active channels is set programmatically to be less then 32-bits.
Note: By default the DIO needs data to be on 32-bits boundaries.
The following example packs an array of data to a single DWord:
SHORT nStatus;
BYTE aucUnpackedData[8];
DWORD dwPackedData
for (int i=0; i<8; i++)
aucUnpackedData[i]=i;
DioDataPack (4, 8, 0, 1, &dwPackedData, ucUnpackedData, &nStatus);