mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 06:53:34 +08:00
uorb: use single byte for internal types in o_fields metadata
Reduces flash usage by ~9KB.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user