WIP logger serialization

This commit is contained in:
Daniel Agar
2016-05-14 11:27:07 +02:00
committed by Lorenz Meier
parent 8f5cb4084d
commit 69c1ce1714
23 changed files with 154 additions and 314 deletions
+12 -9
View File
@@ -46,12 +46,12 @@
// Hack until everything is using this header
#include <systemlib/visibility.h>
// Macro to define packed structures
#ifdef __GNUC__
#define ORBPACKED( __Declaration__ ) __Declaration__ __attribute__((aligned(4), packed))
#else
#define ORBPACKED( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
#endif
struct orb_output_buffer {
void *data;
size_t next;
};
typedef void (*func_ptr)(void *in, struct orb_output_buffer *out);
/**
* Object metadata.
@@ -59,6 +59,7 @@
struct orb_metadata {
const char *o_name; /**< unique object name */
const size_t o_size; /**< object size */
func_ptr serialize; /**< serialization function for this orb topic */
const char *o_fields; /**< semicolon separated list of fields */
};
@@ -118,13 +119,15 @@ enum ORB_PRIO {
*
* @param _name The name of the topic.
* @param _struct The structure the topic provides.
* @param _func The pointer to a function that packs topic
* @param _func The pointer to a function that serializes this topic
* @param _fields All fields in a semicolon separated list e.g: "float[3] position;bool armed"
*/
#define ORB_DEFINE(_name, _struct, _fields) \
#define ORB_DEFINE(_name, _struct, _func, _fields) \
const struct orb_metadata __orb_##_name = { \
#_name, \
sizeof(_struct), \
_fields \
_func, \
_fields \
}; struct hack
__BEGIN_DECLS
@@ -41,8 +41,8 @@ struct orb_test {
int val;
hrt_abstime time;
};
ORB_DEFINE(orb_test, struct orb_test, "ORB_TEST:int val;hrt_abstime time;");
ORB_DEFINE(orb_multitest, struct orb_test, "ORB_MULTITEST:int val;hrt_abstime time;");
ORB_DEFINE(orb_test, struct orb_test, nullptr, "ORB_TEST:int val;hrt_abstime time;");
ORB_DEFINE(orb_multitest, struct orb_test, nullptr, "ORB_MULTITEST:int val;hrt_abstime time;");
struct orb_test_medium {
@@ -50,8 +50,8 @@ struct orb_test_medium {
hrt_abstime time;
char junk[64];
};
ORB_DEFINE(orb_test_medium, struct orb_test_medium, "ORB_TEST_MEDIUM:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_medium_multi, struct orb_test_medium,
ORB_DEFINE(orb_test_medium, struct orb_test_medium, nullptr, "ORB_TEST_MEDIUM:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_medium_multi, struct orb_test_medium, nullptr,
"ORB_TEST_MEDIUM_MULTI:int val;hrt_abstime time;char[64] junk;");
@@ -60,7 +60,7 @@ struct orb_test_large {
hrt_abstime time;
char junk[512];
};
ORB_DEFINE(orb_test_large, struct orb_test_large, "ORB_TEST_LARGE:int val;hrt_abstime time;char[512] junk;");
ORB_DEFINE(orb_test_large, struct orb_test_large, nullptr, "ORB_TEST_LARGE:int val;hrt_abstime time;char[512] junk;");
namespace uORBTest