Dawn Framework 1.0
Universal data acquisition framework for embedded systems
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
dawn::CDescriptor Class Reference

Binary device descriptor manager. More...

#include <descriptor.hxx>

Classes

struct  SDescriptorBin
 Complete binary descriptor container. More...
 
struct  SDescriptorBinFtr
 Binary descriptor footer structure. More...
 
struct  SDescriptorBinHdr
 Binary descriptor header structure. More...
 

Public Types

enum  
 Descriptor metadata configuration IDs.
 
typedef std::function< void(CHandler &obj, CDescObject &desc)> allocobj_func_t
 Thread function callback storage.
 

Public Member Functions

 CDescriptor ()
 Constructor - initialize empty descriptor.
 
 ~CDescriptor ()
 Destructor - release loaded descriptor resources.
 
SDescriptorBingetBin ()
 Get loaded descriptor binary structure.
 
size_t getBinLen ()
 Get loaded descriptor size in bytes.
 
bool getNoIdleQuit () const
 Return true if the descriptor requests no idle quit.
 
int loadBin (uint32_t *bin, size_t len, bool force_valid=false, bool dump=false)
 Load binary descriptor from memory.
 
SObjectCfg::SObjectCfgDataobjectCfgAtOffset (size_t offset)
 Get object configuration at offset.
 
SObjectCfg::UObjectCfgIdobjectCfgIdAtOffset (size_t offset)
 Get configuration ID at offset.
 
void reset ()
 Clear currently loaded descriptor state.
 

Static Public Member Functions

static int binCheckFill (uint32_t *bin, size_t len)
 Calculate and store descriptor CRC32 checksum.
 
static bool binCheckValid (const uint32_t *bin, size_t len)
 Validate descriptor CRC32 checksum.
 
static void binDump (const uint32_t *bin, size_t len)
 Print descriptor contents to console (debug).
 
static int binValid (const uint32_t *bin, size_t len)
 Validate binary descriptor integrity.
 
static SObjectCfg::ObjectCfgId cfgId (bool rw, uint8_t dtype, uint8_t size, uint8_t id)
 Create ConfigID for metadata.
 
static SObjectCfg::ObjectCfgId cfgIdString (uint16_t size, bool rw=false)
 Create ConfigID for device string.
 
static SObjectCfg::ObjectCfgId cfgIdVersion (bool rw=false)
 Create ConfigID for firmware version.
 
static SObjectId::ObjectId objectId (uint16_t inst)
 Construct 32-bit ObjectID from component fields.
 

Static Public Attributes

static uint32_t DAWN_DESCRIPTOR_FOOT = 0x02030a0d
 Footer magic number (0x02030a0d).
 
static uint32_t DAWN_DESCRIPTOR_HDR = 0x0d0a0302
 Header magic number (0x0d0a0302).
 

Detailed Description

Binary device descriptor manager.

Definition at line 20 of file descriptor.hxx.

Member Typedef Documentation

◆ allocobj_func_t

typedef std::function<void(CHandler &obj, CDescObject &desc)> dawn::CDescriptor::allocobj_func_t

Thread function callback storage.

std::function allows storing any callable type set via setThreadFunc().

Parameters
hHandler that will manage allocated objects.
funcCallback invoked for each object.

Definition at line 191 of file descriptor.hxx.

Member Function Documentation

◆ binCheckFill()

int CDescriptor::binCheckFill ( uint32_t *  bin,
size_t  len 
)
static

Calculate and store descriptor CRC32 checksum.

Parameters
binPointer to binary descriptor data.
lenLength in 32-bit words.
Returns
OK on success, negative error code on failure.

Definition at line 209 of file descriptor.cxx.

References DAWN_DESCRIPTOR_FOOT.

Here is the caller graph for this function:

◆ binCheckValid()

bool CDescriptor::binCheckValid ( const uint32_t *  bin,
size_t  len 
)
static

Validate descriptor CRC32 checksum.

Parameters
binPointer to binary descriptor data.
lenLength in 32-bit words.
Returns
True if CRC32 matches, false otherwise.

Definition at line 202 of file descriptor.cxx.

Here is the caller graph for this function:

◆ binDump()

void CDescriptor::binDump ( const uint32_t *  bin,
size_t  len 
)
static

Print descriptor contents to console (debug).

Parameters
binPointer to binary descriptor data.
lenLength in 32-bit words.

Definition at line 99 of file descriptor.cxx.

References dawn::SObjectCfg::UObjectCfgId::s, dawn::SObjectCfg::UObjectCfgId::size, and dawn::SObjectCfg::UObjectCfgId::v.

Here is the caller graph for this function:

◆ binValid()

int CDescriptor::binValid ( const uint32_t *  bin,
size_t  len 
)
static

Validate binary descriptor integrity.

Parameters
binPointer to binary descriptor data.
lenLength in 32-bit words.
Returns
OK on success, negative error code on failure.

Definition at line 160 of file descriptor.cxx.

References binCheckValid(), DAWN_DESCRIPTOR_HDR, and dawn::CObject::validateDesc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cfgId()

static SObjectCfg::ObjectCfgId dawn::CDescriptor::cfgId ( bool  rw,
uint8_t  dtype,
uint8_t  size,
uint8_t  id 
)
inlinestatic

Create ConfigID for metadata.

Parameters
rwRead-write flag.
dtypeData type.
sizeConfiguration data size in 32-bit words.
idConfiguration identifier.
Returns
Properly formatted ConfigID.

Definition at line 91 of file descriptor.hxx.

References dawn::SObjectCfg::objectCfg(), and dawn::SObjectId::OBJTYPE_ANY.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cfgIdString()

static SObjectCfg::ObjectCfgId dawn::CDescriptor::cfgIdString ( uint16_t  size,
bool  rw = false 
)
inlinestatic

Create ConfigID for device string.

Parameters
sizeConfiguration data size in 32-bit words.
rwRead-write flag (default: false).
Returns
Properly formatted ConfigID for string.

Definition at line 116 of file descriptor.hxx.

References cfgId(), and dawn::SObjectId::DTYPE_CHAR.

Here is the call graph for this function:

◆ cfgIdVersion()

static SObjectCfg::ObjectCfgId dawn::CDescriptor::cfgIdVersion ( bool  rw = false)
inlinestatic

Create ConfigID for firmware version.

Parameters
rwRead-write flag (default: false).
Returns
Properly formatted ConfigID for version.

Definition at line 103 of file descriptor.hxx.

References cfgId(), and dawn::SObjectId::DTYPE_UINT32.

Here is the call graph for this function:

◆ getBin()

CDescriptor::SDescriptorBin * CDescriptor::getBin ( )

Get loaded descriptor binary structure.

Returns
Pointer to SDescriptorBin, nullptr if not loaded.

Definition at line 359 of file descriptor.cxx.

◆ getBinLen()

size_t CDescriptor::getBinLen ( )

Get loaded descriptor size in bytes.

Returns
SDescriptorBin length in bytes.

Definition at line 364 of file descriptor.cxx.

◆ loadBin()

int CDescriptor::loadBin ( uint32_t *  bin,
size_t  len,
bool  force_valid = false,
bool  dump = false 
)

Load binary descriptor from memory.

Parameters
binPointer to binary descriptor data (32-bit aligned).
lenLength in 32-bit words.
force_validRecalculate and fill descriptor CRC if true.
dumpDump descriptor contents if true (default false).
Returns
OK on success, negative error code on failure.

Definition at line 317 of file descriptor.cxx.

References binCheckFill(), binDump(), binValid(), DAWN_DESCRIPTOR_FOOT, and reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ objectCfgAtOffset()

SObjectCfg::SObjectCfgData * CDescriptor::objectCfgAtOffset ( size_t  offset)

Get object configuration at offset.

Parameters
offsetOffset in 32-bit words.
Returns
Pointer to SObjectCfgData, nullptr if out of bounds.

Definition at line 391 of file descriptor.cxx.

◆ objectCfgIdAtOffset()

SObjectCfg::UObjectCfgId * CDescriptor::objectCfgIdAtOffset ( size_t  offset)

Get configuration ID at offset.

Parameters
offsetOffset in 32-bit words.
Returns
Pointer to UObjectCfgId, nullptr if out of bounds.

Definition at line 402 of file descriptor.cxx.

◆ objectId()

static SObjectId::ObjectId dawn::CDescriptor::objectId ( uint16_t  inst)
inlinestatic

Construct 32-bit ObjectID from component fields.

Packs individual fields into a single 32-bit ObjectID value.

Parameters
instInstance number (typically 0).
Returns
Properly formatted ObjectID.

Definition at line 76 of file descriptor.hxx.

References dawn::SObjectId::objectId(), and dawn::SObjectId::OBJTYPE_ANY.

Here is the call graph for this function:

◆ reset()

void CDescriptor::reset ( )

Clear currently loaded descriptor state.

Releases cached descriptor object wrappers and clears binary pointers.

Definition at line 303 of file descriptor.cxx.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: