system/uorb: optimize stack used
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
9f6d322186
commit
6fceb913a2
@ -344,7 +344,7 @@ static int listener_generate_object_list(FAR struct list_node *objlist,
|
|||||||
while ((entry = readdir(dir)))
|
while ((entry = readdir(dir)))
|
||||||
{
|
{
|
||||||
struct orb_object object;
|
struct orb_object object;
|
||||||
char file_name[PATH_MAX];
|
char file_name[ORB_PATH_MAX];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* Get meta data and instance number through file name */
|
/* Get meta data and instance number through file name */
|
||||||
@ -354,7 +354,7 @@ static int listener_generate_object_list(FAR struct list_node *objlist,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
strlcpy(file_name, entry->d_name, PATH_MAX);
|
strlcpy(file_name, entry->d_name, ORB_PATH_MAX);
|
||||||
|
|
||||||
len = strlen(file_name) - 1;
|
len = strlen(file_name) - 1;
|
||||||
object.instance = file_name[len] - '0';
|
object.instance = file_name[len] - '0';
|
||||||
@ -424,8 +424,6 @@ static int listener_print(FAR const struct orb_metadata *meta, int fd)
|
|||||||
{
|
{
|
||||||
meta->o_cb(meta, buffer);
|
meta->o_cb(meta, buffer);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
uorbinfo_raw("Enable debug uorb to print message");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -113,7 +113,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
|
|||||||
FAR const struct orb_metadata *orb_get_meta(FAR const char *name)
|
FAR const struct orb_metadata *orb_get_meta(FAR const char *name)
|
||||||
{
|
{
|
||||||
struct sensor_state_s state;
|
struct sensor_state_s state;
|
||||||
char path[PATH_MAX];
|
char path[ORB_PATH_MAX];
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
int ret;
|
int ret;
|
||||||
int fd;
|
int fd;
|
||||||
@ -141,11 +141,11 @@ FAR const struct orb_metadata *orb_get_meta(FAR const char *name)
|
|||||||
|
|
||||||
/* Then open node to get meta */
|
/* Then open node to get meta */
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, ORB_SENSOR_PATH"%s", name);
|
snprintf(path, ORB_PATH_MAX, ORB_SENSOR_PATH"%s", name);
|
||||||
fd = open(path, O_RDONLY);
|
fd = open(path, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
snprintf(path, PATH_MAX, ORB_SENSOR_PATH"%s%d", name, 0);
|
snprintf(path, ORB_PATH_MAX, ORB_SENSOR_PATH"%s%d", name, 0);
|
||||||
fd = open(path, O_RDONLY);
|
fd = open(path, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -56,12 +56,13 @@
|
|||||||
static int orb_open(FAR const struct orb_metadata *meta, bool advertiser,
|
static int orb_open(FAR const struct orb_metadata *meta, bool advertiser,
|
||||||
int instance, unsigned int queue_size)
|
int instance, unsigned int queue_size)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[ORB_PATH_MAX];
|
||||||
bool first_open = false;
|
bool first_open = false;
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, ORB_SENSOR_PATH"%s%d", meta->o_name, instance);
|
snprintf(path, ORB_PATH_MAX, ORB_SENSOR_PATH"%s%d", meta->o_name,
|
||||||
|
instance);
|
||||||
|
|
||||||
/* Check existance before open */
|
/* Check existance before open */
|
||||||
|
|
||||||
@ -281,11 +282,12 @@ orb_abstime orb_absolute_time(void)
|
|||||||
int orb_exists(FAR const struct orb_metadata *meta, int instance)
|
int orb_exists(FAR const struct orb_metadata *meta, int instance)
|
||||||
{
|
{
|
||||||
struct sensor_state_s state;
|
struct sensor_state_s state;
|
||||||
char path[PATH_MAX];
|
char path[ORB_PATH_MAX];
|
||||||
int ret;
|
int ret;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, ORB_SENSOR_PATH"%s%d", meta->o_name, instance);
|
snprintf(path, ORB_PATH_MAX, ORB_SENSOR_PATH"%s%d", meta->o_name,
|
||||||
|
instance);
|
||||||
fd = open(path, 0);
|
fd = open(path, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -78,6 +78,7 @@ typedef uint64_t orb_abstime;
|
|||||||
|
|
||||||
#define ORB_SENSOR_PATH "/dev/sensor/"
|
#define ORB_SENSOR_PATH "/dev/sensor/"
|
||||||
#define ORB_USENSOR_PATH "/dev/usensor"
|
#define ORB_USENSOR_PATH "/dev/usensor"
|
||||||
|
#define ORB_PATH_MAX (NAME_MAX + 16)
|
||||||
|
|
||||||
#ifdef CONFIG_UORB_ALERT
|
#ifdef CONFIG_UORB_ALERT
|
||||||
# define uorbpanic(fmt, ...) _alert(fmt "\n", ##__VA_ARGS__)
|
# define uorbpanic(fmt, ...) _alert(fmt "\n", ##__VA_ARGS__)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user