Get data from CDB

C: sof_cdb_get (int icdb, int kwh, void *Data, int *DataLen, int Pos)

Fortran: subroutine cdget (icdb, kwh, kwl, data, DataLen, pos, ie)

In: integer icdb, In: integer kwl
In/Out: integer datalen, Out: integer ie=ReturnValue
In: integer kwh, Out: integecdbr / real data(*)
In: integer pos

A record is read from the active database or the read pointer is set to a specific position (seek). Only keys with their directory in memory will be found. To get access to the actual complete set of keys call sof_cdb_flush() before.

With the first reading a lock will be set to this key which is released after reaching the end of the key.

The return values are very important and to read the data, 4 error conditions are defined:

(0) no error CD_ERR_NONE
(1) Item is longer than data CD_ERR_TOOLONG
(2) End of file is reached CD_ERR_DATAEND
(3) Key does not exist CD_ERR_NOTFOUND

If a specific datalen is defined and if it matches to the length of the reading record, the return value will be 0. For reading the whole set of data it is necessary to make loops by using e.g. ‘’do loop while the get function is < 2, but include also the values when the return value reaches first time =2’’. How to do it depends individually of the programmer. Parameters:

  • Index - Index received from sof_cdb_init()

  • kwh/kwl - ‘’key’’ to specify the data

  • data - structure to store the read data

  • datalen - first the length of data in byte and after the function call the length of effective read data in byte

  • pos - position of the current item, starting with ‘’0’’

You can check whether all data being part of the data structure really exist. In order to that the length of datalen is compared before and after the call of sof_cdb_get(). If datalen is smaller after calling the function the data record is not complete.

Important

It is very important to set datalen to the normal length of data before next call, to avoid that some last values are missing.