Dawn Framework 1.0
Universal data acquisition framework for embedded systems
capabilities.hxx
1// dawn/include/dawn/io/capabilities.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/io/common.hxx"
9#include "dawn/porting/config.hxx"
10
11namespace dawn
12{
20{
21public:
22 enum
23 {
24 CAPS_BUILD_OS_NUTTX = (1u << 0),
25 CAPS_BUILD_FILESYSTEM = (1u << 1),
26 CAPS_BUILD_IO_NOTIFY = (1u << 2),
27 CAPS_BUILD_IO_HAS_STATS = (1u << 3),
28 CAPS_BUILD_OBJECT_HASNAME = (1u << 4),
29 CAPS_BUILD_DESC_DYNAMIC = (1u << 5),
30 };
31
32 explicit CIOCapabilities(CDescObject &desc)
33 : CIOCommon(desc)
34 {
35 }
36
37 ~CIOCapabilities() override;
38
39#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
40 const char *getClassNameStr() const override
41 {
42 return "capabilities";
43 }
44#endif
45
46 int configure() override;
47 int deinit() override;
48 int getDataImpl(IODataCmn &data, size_t len) override;
49 int setDataImpl(IODataCmn &data) override;
50 int getDataAtImpl(IODataCmn &data, size_t len, size_t offset) override;
51 size_t getDataSize() const override;
52 size_t getDataDim() const override;
53
54 bool isRead() const override
55 {
56 return true;
57 }
58
59 bool isWrite() const override
60 {
61 return false;
62 }
63
64 bool isNotify() const override
65 {
66 return false;
67 }
68
69 bool isBatch() const override
70 {
71 return false;
72 }
73
74 bool isSeekable() const override
75 {
76 return true;
77 }
78
79 using ObjectIdHelper =
81
82 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
83 {
84 return ObjectIdHelper::create(inst);
85 }
86
87private:
88 constexpr static size_t CAPS_HDR_SIZE = 8;
89 constexpr static uint8_t CAPS_VERSION = 2;
90 constexpr static size_t CAPS_BITMAP_WORDS = 16;
91 constexpr static size_t CAPS_TOTAL_SIZE = 512;
92 constexpr static size_t CAPS_BITMAP_BYTES = (CAPS_BITMAP_WORDS * 4);
93 constexpr static size_t CAPS_PAYLOAD_SIZE = CAPS_TOTAL_SIZE - CAPS_HDR_SIZE;
94 constexpr static size_t CAPS_IO_BITMAP_OFFSET = 0;
95 constexpr static size_t CAPS_PROG_BITMAP_OFFSET = CAPS_BITMAP_BYTES;
96 constexpr static size_t CAPS_PROTO_BITMAP_OFFSET = CAPS_BITMAP_BYTES * 2;
97 constexpr static size_t CAPS_META_OFFSET = CAPS_BITMAP_BYTES * 3;
98 constexpr static size_t CAPS_META_WORDS = (CAPS_PAYLOAD_SIZE - (CAPS_BITMAP_BYTES * 3)) / 4;
99
100 uint8_t payloadBuf[CAPS_PAYLOAD_SIZE];
101
102 int configureDesc(const CDescObject &desc);
103 int configurePayload();
104 void buildIoBitmap();
105 void buildProgBitmap();
106 void buildProtoBitmap();
107 void buildMetaPayload();
108 void setBitmapBit(uint8_t *bitmap, uint16_t bit);
109 void setMetaWord(uint16_t index, uint32_t value);
110 size_t copyFromBlob(uint8_t *dst, size_t offset, size_t len) const;
111};
112
113} // Namespace dawn
Descriptor wrapper for individual object configuration.
Read-only seekable capability bitmap IO.
int getDataAtImpl(IODataCmn &data, size_t len, size_t offset)
Get data at byte offset (override in seekable IOs).
bool isRead() const
Check if IO supports read operations.
bool isWrite() const
Check if IO supports write operations.
int deinit()
De-initialize object.
size_t getDataDim() const
Get data vector dimension.
bool isNotify() const
Check if IO supports notifications.
bool isSeekable() const
Check if IO supports partial (seekable) access.
int configure()
Configure object from descriptor data.
size_t getDataSize() const
Get data size in bytes.
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
bool isBatch() const
Check if IO supports batch operations.
Template helper for creating ObjectIDs for I/O types without timestamp support.
Definition common.hxx:303
static SObjectId::ObjectId create(uint16_t inst)
Create ObjectID with fixed data type and no timestamp.
Definition common.hxx:312
Base class for all I/O objects.
Definition common.hxx:27
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Base interface for I/O data buffers (static and dynamic).
Definition idata.hxx:21
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44