DBGet

Description

Uploads a DB from AG.

 

This function is not subject to the security level set.

 

Only data is uploaded.

 

Declaration

 

int DBGet(uint16_t DBNumber, void *pUsrData, uint16_t *Size);

 

Parameters

 

Type

Dir.

 

DBNumber

uint16_t

In

DB Number

pUsrData

Pointer

in

Address of the user buffer

size

Pointer to uint16_t

In

Buffer size available

 

Out

Bytes uploaded

 

 

Return value

         0 : The function was accomplished with no errors.

         Other values : see the Errors Code List.

Remarks

This function first gathers the DB size via GetDBSize then calls ReadArea if the Buffer size is greater than the DB size, otherwise returns an error.

This is an utility function implemented as above.

int S7Client::DBGet(uint16_t DBNumber, void *ptrData, uint16_t *Size)

{

uint16_t Length;

int Result;

 

Result=GetDBSize(DBNumber, &Length);

if (Result==0)

{

if (Length<=*Size) // Check if the buffer supplied is big enough

{

Result=ReadArea(S7AreaDB, DBNumber, 0, Length, ptrData);

if (Result==0)

*Size=Length;

}

else

Result=errBufferTooSmall;

}

return Result;

}