qurt: update for functional logger

This commit is contained in:
Zachary Lowell 2022-10-25 20:07:15 -05:00 committed by GitHub
parent bcae7e550b
commit 740d2fccb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 8 deletions

View File

@ -0,0 +1,55 @@
/****************************************************************************
*
* Copyright (C) 2022 ModalAI, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#pragma once
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
__BEGIN_DECLS
//Defining hap_debug
void HAP_debug(const char *msg, int level, const char *filename, int line);
static __inline void qurt_log(int level, const char *file, int line,
const char *format, ...)
{
char buf[256];
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
HAP_debug(buf, level, file, line);
}
__END_DECLS

View File

@ -38,8 +38,7 @@
#include <qurt_thread.h>
#include <pthread.h>
// TODO: Move this out of here once we have px4-log functionality
extern "C" void HAP_debug(const char *msg, int level, const char *filename, int line);
#include <px4_platform_common/log.h>
// Definition of test to run when in muorb test mode
static MUORBTestType test_to_run;
@ -48,7 +47,7 @@ fc_func_ptrs muorb_func_ptrs;
static void *test_runner(void *test)
{
HAP_debug("test_runner called", 1, muorb_test_topic_name, 0);
PX4_INFO("test_runner called");
switch (*((MUORBTestType *) test)) {
case ADVERTISE_TEST_TYPE:
@ -84,7 +83,7 @@ int px4muorb_orb_initialize(fc_func_ptrs *func_ptrs, int32_t clock_offset_us)
// so they must be saved off here
if (func_ptrs != nullptr) { muorb_func_ptrs = *func_ptrs; }
HAP_debug("px4muorb_orb_initialize called", 1, "init", 0);
PX4_INFO("px4muorb_orb_initialize called");
return 0;
}
@ -107,7 +106,7 @@ int px4muorb_topic_advertised(const char *topic_name)
{
if (IS_MUORB_TEST(topic_name)) { run_test(ADVERTISE_TEST_TYPE); }
HAP_debug("px4muorb_topic_advertised called", 1, topic_name, 0);
PX4_INFO("px4muorb_topic_advertised called");
return 0;
}
@ -116,7 +115,7 @@ int px4muorb_add_subscriber(const char *topic_name)
{
if (IS_MUORB_TEST(topic_name)) { run_test(SUBSCRIBE_TEST_TYPE); }
HAP_debug("px4muorb_add_subscriber called", 1, topic_name, 0);
PX4_INFO("px4muorb_add_subscriber called");
return 0;
}
@ -125,7 +124,7 @@ int px4muorb_remove_subscriber(const char *topic_name)
{
if (IS_MUORB_TEST(topic_name)) { run_test(UNSUBSCRIBE_TEST_TYPE); }
HAP_debug("px4muorb_remove_subscriber called", 1, topic_name, 0);
PX4_INFO("px4muorb_remove_subscriber called");
return 0;
}
@ -152,7 +151,7 @@ int px4muorb_send_topic_data(const char *topic_name, const uint8_t *data,
if (test_passed) { run_test(TOPIC_TEST_TYPE); }
}
HAP_debug("px4muorb_send_topic_data called", 1, topic_name, 0);
PX4_INFO("px4muorb_send_topic_data called");
return 0;
}