forked from Archive/PX4-Autopilot
qurt: update for functional logger
This commit is contained in:
parent
bcae7e550b
commit
740d2fccb1
|
@ -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
|
|
@ -38,8 +38,7 @@
|
||||||
#include <qurt_thread.h>
|
#include <qurt_thread.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
// TODO: Move this out of here once we have px4-log functionality
|
#include <px4_platform_common/log.h>
|
||||||
extern "C" void HAP_debug(const char *msg, int level, const char *filename, int line);
|
|
||||||
|
|
||||||
// Definition of test to run when in muorb test mode
|
// Definition of test to run when in muorb test mode
|
||||||
static MUORBTestType test_to_run;
|
static MUORBTestType test_to_run;
|
||||||
|
@ -48,7 +47,7 @@ fc_func_ptrs muorb_func_ptrs;
|
||||||
|
|
||||||
static void *test_runner(void *test)
|
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)) {
|
switch (*((MUORBTestType *) test)) {
|
||||||
case ADVERTISE_TEST_TYPE:
|
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
|
// so they must be saved off here
|
||||||
if (func_ptrs != nullptr) { muorb_func_ptrs = *func_ptrs; }
|
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;
|
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); }
|
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;
|
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); }
|
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;
|
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); }
|
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;
|
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); }
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue