uorb: use single byte for internal types in o_fields metadata

Reduces flash usage by ~9KB.
This commit is contained in:
Beat Küng
2021-10-20 08:10:05 +02:00
parent 9aaf6e3f3e
commit 4c73ac3805
8 changed files with 131 additions and 36 deletions
+32
View File
@@ -172,3 +172,35 @@ int orb_get_interval(int handle, unsigned *interval)
{
return uORB::Manager::get_instance()->orb_get_interval(handle, interval);
}
const char *orb_get_c_type(unsigned char short_type)
{
// this matches with the uorb o_fields generator
switch (short_type) {
case 0x82: return "int8_t";
case 0x83: return "int16_t";
case 0x84: return "int32_t";
case 0x85: return "int64_t";
case 0x86: return "uint8_t";
case 0x87: return "uint16_t";
case 0x88: return "uint32_t";
case 0x89: return "uint64_t";
case 0x8a: return "float";
case 0x8b: return "double";
case 0x8c: return "bool";
case 0x8d: return "char";
}
return nullptr;
}
+7 -3
View File
@@ -31,8 +31,7 @@
*
****************************************************************************/
#ifndef _UORB_UORB_H
#define _UORB_UORB_H
#pragma once
/**
* @file uORB.h
@@ -235,6 +234,12 @@ extern int orb_set_interval(int handle, unsigned interval) __EXPORT;
*/
extern int orb_get_interval(int handle, unsigned *interval) __EXPORT;
/**
* Returns the C type string from a short type in o_fields metadata, or nullptr
* if not a short type
*/
const char *orb_get_c_type(unsigned char short_type);
__END_DECLS
/* Diverse uORB header defines */ //XXX: move to better location
@@ -245,4 +250,3 @@ typedef uint8_t hil_state_t;
typedef uint8_t navigation_state_t;
typedef uint8_t switch_pos_t;
#endif /* _UORB_UORB_H */