ADS-sum command: Read or Write a list of variables with one single ADS-command

Download: ADS Sum Command : Read or Write multiple variables

This sample describes how to read multiple single variables with one single ADS API call.

ADS-sum command: Read or Write a list of variables with one single ADS-command 1:

Mind the ADS requirements

Note that ADS is just a transport layer, but there could be important side effects: So read these requirements and take care on limitations.

Background :

ADS offers powerful and fast communication to exchange any kind of information. It's possible to read single variables or complete arrays and structures with each one single ADS-API call.
This new ADS command offers to read with one singale ADS call multiple variables which are not structured within a linear memory.

As a result the ADS caller application (like scada Systems etc.) can extremly speed up cyclic polling :
Sample :

Requirements and important limitations:

Note that ADS is just a transport layer, but there could be important side effects. So read these requirements and take care on limitations:

Notice We highly recommend to not request more than 500 Ads-Sub commands.

// This code snippet using ADSIGRP_SUMUP_READ with IndexGroup 0xF080 and IndexOffset as number of ADS-sub-commands 
// Demonstrates how to read a list of variables, see full demo-code

// Use ADS-ReadWrite request : "Write" the requested data down to ADS device and "Read" the received answer

nErr = AdsSyncReadWriteReq( pAddr,
0xF080, // Sum-Command, response will contain ADS-error code for each ADS-Sub-command
reqNum, // number of ADS-Sub-Commands
4*reqNum+reqSize, // number requested bytes in the sample two variables each 4 bytes. NOTE : we request additional "error"-flag(long) for each ADS-sub commands
(void*)(mAdsSumBufferRes), // provide buffer for response
12*reqNum, // send 12 bytes for each variable (each ads-Sub command consist of 3 * ULONG : IG, IO, Len)
&parReq);
// This code snippet using ADSIGRP_SUMUP_WRITE with IndexGroup 0xF081 and IndexOffset as number of ADS-sub-commands 
// Demonstrates how to write a list of variables, see full demo-code

// Use ADS-ReadWrite request : "Write" the send a list of data to list of variables down to ADS device and "Read" the received return codes

nErr = AdsSyncReadWriteReq( pAddr,
0xF081, // ADS list-write command
reqNum, // number of ADS-Sub commands
4*reqNum, // we expect an ADS-error-return-code (long) for each ADS-Sub command
(void*)(mAdsSumBufferRes), // provide space for the response containing the return codes
16*reqNum, // cbyteLen : in THIS sample we send two variables each 4 byte
// --> send 16 bytes (IG1, IO1, Len1, IG2, IO2, Len2, Data1, Data2)
&parReq); // buffer with data