Skip to content

Commit 8aa3ce7

Browse files
committed
Added howot11 showing an ability to decode variant as sup-protocol.
1 parent 078345e commit 8aa3ce7

File tree

81 files changed

+9098
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+9098
-0
lines changed

howtos/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ add_subdirectory (howto7)
2020
add_subdirectory (howto8)
2121
add_subdirectory (howto9)
2222
add_subdirectory (howto10)
23+
add_subdirectory (howto11)
2324

howtos/howto11/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
get_filename_component(name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
2+
3+
set (schema_files
4+
${CMAKE_CURRENT_SOURCE_DIR}/dsl/schema.xml
5+
)
6+
7+
set (server_src
8+
src/ServerSession.cpp
9+
)
10+
11+
set (client_src
12+
src/ClientSession.cpp
13+
)
14+
15+
16+
dsl_howto_parse(${name} SCHEMAS ${schema_files})
17+
18+
bin_howto_server(${name} ${server_src})
19+
bin_howto_client(${name} ${client_src})
20+

howtos/howto11/README.md

Lines changed: 647 additions & 0 deletions
Large diffs are not rendered by default.

howtos/howto11/dsl/schema.xml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<schema name="howto11" endian="big">
3+
<ns name="var1">
4+
<fields>
5+
<enum name="PropKey" type="uint8" semanticType="messageId">
6+
<validValue name="K1" val="0" />
7+
<validValue name="K2" val="2" />
8+
<validValue name="K3" val="5" />
9+
</enum>
10+
</fields>
11+
12+
<interface name="Interface" />
13+
14+
<frame name="KeyValueProp">
15+
<id name="Key" field="var1.PropKey" />
16+
<payload name="Val" />
17+
</frame>
18+
19+
<message name="Prop1" id="var1.PropKey.K1">
20+
<int name="Val" type="uint16" />
21+
</message>
22+
23+
<message name="Prop2" id="var1.PropKey.K2">
24+
<float name="Val" type="float" defaultValue="nan" />
25+
</message>
26+
27+
<message name="Prop3" id="var1.PropKey.K3">
28+
<string name="Val">
29+
<lengthPrefix>
30+
<int name="Length" type="uint8" />
31+
</lengthPrefix>
32+
</string>
33+
</message>
34+
</ns>
35+
36+
<ns name="var2">
37+
<fields>
38+
<enum name="PropKey" type="uint8" semanticType="messageId">
39+
<validValue name="K4" val="10" />
40+
<validValue name="K5" val="15" />
41+
<validValue name="K6" val="25" />
42+
<validValue name="K7" val="30" />
43+
</enum>
44+
</fields>
45+
46+
<interface name="Interface" />
47+
48+
<frame name="TlvProp">
49+
<id name="Key" field="var2.PropKey" />
50+
<size name="Length">
51+
<int name="LengthField" type="uint8"/>
52+
</size>
53+
<payload name="Val" />
54+
</frame>
55+
56+
<interface name="Message" />
57+
58+
<message name="Prop4" id="var2.PropKey.K4">
59+
<int name="Val" type="uint32" />
60+
</message>
61+
62+
<message name="Prop5" id="var2.PropKey.K5">
63+
<float name="Val" type="double" defaultValue="inf" />
64+
</message>
65+
66+
<message name="Prop6" id="var2.PropKey.K6">
67+
<string name="Val" />
68+
</message>
69+
70+
<message name="Prop7" id="var2.PropKey.K7">
71+
<int name="Val" type="uint64" availableLengthLimit="true" />
72+
</message>
73+
</ns>
74+
75+
<ns name="prot">
76+
<fields>
77+
<string name="Msg1Name" defaultValue="Message 1" />
78+
<string name="Msg2Name" defaultValue="Message 2" />
79+
80+
<enum name="MsgId" type="uint8" semanticType="messageId">
81+
<validValue name="M1" val="1" displayName="^prot.Msg1Name" />
82+
<validValue name="M2" val="2" displayName="^prot.Msg2Name" />
83+
</enum>
84+
</fields>
85+
86+
<interface name="Message" />
87+
88+
<frame name="Frame">
89+
<size name="Size">
90+
<int name="SizeField" type="uint16" />
91+
</size>
92+
<id name="ID" field="prot.MsgId" />
93+
<payload name="Data" />
94+
</frame>
95+
96+
<message name="Msg1" id="prot.MsgId.M1" displayName="^prot.Msg1Name">
97+
<int name="Count" type="uint8" />
98+
<data name="KeyValueProps" />
99+
</message>
100+
101+
<message name="Msg2" id="prot.MsgId.M2" displayName="^prot.Msg2Name">
102+
<data name="TlvProps" />
103+
</message>
104+
</ns>
105+
</schema>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Generated by commsdsl2comms v7.1.0
2+
3+
/// @file
4+
/// @brief Contains protocol version definition.
5+
6+
#pragma once
7+
8+
#include "comms/version.h"
9+
10+
/// @brief Version of the protocol specification.
11+
#define HOWTO11_SPEC_VERSION (0U)
12+
13+
namespace howto11
14+
{
15+
16+
/// @brief Version of the protocol specification.
17+
inline constexpr unsigned specVersion()
18+
{
19+
return HOWTO11_SPEC_VERSION;
20+
}
21+
22+
} // namespace howto11
23+
24+
// Generated compile time check for minimal supported version of the COMMS library
25+
static_assert(COMMS_MAKE_VERSION(5, 4, 0) <= comms::version(),
26+
"The version of COMMS library is too old");
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Generated by commsdsl2comms v7.1.0
2+
3+
/// @file
4+
/// @brief Contains definition of base class of all the fields.
5+
6+
#pragma once
7+
8+
#include "comms/Field.h"
9+
#include "comms/options.h"
10+
#include "howto11/Version.h"
11+
12+
namespace howto11
13+
{
14+
15+
namespace field
16+
{
17+
18+
/// @brief Common base class for all the fields.
19+
/// @tparam TOpt Extra options.
20+
template <typename... TOpt>
21+
using FieldBase =
22+
comms::Field<
23+
TOpt...,
24+
comms::option::def::BigEndian
25+
>;
26+
27+
} // namespace field
28+
29+
} // namespace howto11
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Generated by commsdsl2comms v7.1.0
2+
3+
/// @file
4+
/// @brief Contains definition of protocol all messages dynamic memory allocation message factory options.
5+
6+
#pragma once
7+
8+
#include "howto11/options/DefaultOptions.h"
9+
#include "howto11/prot/factory/AllMessagesDynMemMsgFactory.h"
10+
#include "howto11/var1/factory/AllMessagesDynMemMsgFactory.h"
11+
#include "howto11/var2/factory/AllMessagesDynMemMsgFactory.h"
12+
13+
namespace howto11
14+
{
15+
16+
namespace options
17+
{
18+
19+
/// @brief Provided all messages dynamic memory allocation message factory options of the protocol.
20+
/// @details Must be used as the outermost wrapper of the protocol options.
21+
template <typename TBase = howto11::options::DefaultOptions>
22+
struct AllMessagesDynMemMsgFactoryDefaultOptionsT : public TBase
23+
{
24+
/// @brief Alias to actual message factory class.
25+
/// @details Exposes the same template parameters as @b comms::MsgFactory.
26+
template <typename TInterface, typename TAllMessages, typename... TOptions>
27+
using prot_MsgFactory =
28+
howto11::prot::factory::AllMessagesDynMemMsgFactory<TInterface, AllMessagesDynMemMsgFactoryDefaultOptionsT<TBase> >;
29+
30+
/// @brief Alias to actual message factory class.
31+
/// @details Exposes the same template parameters as @b comms::MsgFactory.
32+
template <typename TInterface, typename TAllMessages, typename... TOptions>
33+
using var1_MsgFactory =
34+
howto11::var1::factory::AllMessagesDynMemMsgFactory<TInterface, AllMessagesDynMemMsgFactoryDefaultOptionsT<TBase> >;
35+
36+
/// @brief Alias to actual message factory class.
37+
/// @details Exposes the same template parameters as @b comms::MsgFactory.
38+
template <typename TInterface, typename TAllMessages, typename... TOptions>
39+
using var2_MsgFactory =
40+
howto11::var2::factory::AllMessagesDynMemMsgFactory<TInterface, AllMessagesDynMemMsgFactoryDefaultOptionsT<TBase> >;
41+
42+
/// @brief Extra options for namespace.
43+
struct prot: public TBase::prot
44+
{
45+
/// @brief Extra options for frames.
46+
struct frame : public TBase::prot::frame
47+
{
48+
/// @brief Extra options for layers of
49+
/// @ref howto11::prot::frame::Frame frame.
50+
struct FrameLayers : public TBase::prot::frame::FrameLayers
51+
{
52+
/// @brief Extra options for @ref
53+
/// howto11::prot::frame::FrameLayers::ID
54+
/// layer.
55+
using ID =
56+
std::tuple<
57+
comms::option::app::MsgFactoryTempl<prot_MsgFactory>,
58+
typename TBase::prot::frame::FrameLayers::ID
59+
>;
60+
}; // struct FrameLayers
61+
}; // struct frame
62+
}; // struct prot
63+
64+
/// @brief Extra options for namespace.
65+
struct var1: public TBase::var1
66+
{
67+
/// @brief Extra options for frames.
68+
struct frame : public TBase::var1::frame
69+
{
70+
/// @brief Extra options for layers of
71+
/// @ref howto11::var1::frame::KeyValueProp frame.
72+
struct KeyValuePropLayers : public TBase::var1::frame::KeyValuePropLayers
73+
{
74+
/// @brief Extra options for @ref
75+
/// howto11::var1::frame::KeyValuePropLayers::Key
76+
/// layer.
77+
using Key =
78+
std::tuple<
79+
comms::option::app::MsgFactoryTempl<var1_MsgFactory>,
80+
typename TBase::var1::frame::KeyValuePropLayers::Key
81+
>;
82+
}; // struct KeyValuePropLayers
83+
}; // struct frame
84+
}; // struct var1
85+
86+
/// @brief Extra options for namespace.
87+
struct var2: public TBase::var2
88+
{
89+
/// @brief Extra options for frames.
90+
struct frame : public TBase::var2::frame
91+
{
92+
/// @brief Extra options for layers of
93+
/// @ref howto11::var2::frame::TlvProp frame.
94+
struct TlvPropLayers : public TBase::var2::frame::TlvPropLayers
95+
{
96+
/// @brief Extra options for @ref
97+
/// howto11::var2::frame::TlvPropLayers::Key
98+
/// layer.
99+
using Key =
100+
std::tuple<
101+
comms::option::app::MsgFactoryTempl<var2_MsgFactory>,
102+
typename TBase::var2::frame::TlvPropLayers::Key
103+
>;
104+
}; // struct TlvPropLayers
105+
}; // struct frame
106+
}; // struct var2
107+
};
108+
109+
/// @brief Alias to @ref AllMessagesDynMemMsgFactoryDefaultOptionsT with default template parameter.
110+
using AllMessagesDynMemMsgFactoryDefaultOptions = AllMessagesDynMemMsgFactoryDefaultOptionsT<>;
111+
112+
} // namespace options
113+
114+
} // namespace howto11

0 commit comments

Comments
 (0)