Skip to content

Commit

Permalink
require MODULE_NAME
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Nov 10, 2018
1 parent 8d15da3 commit 246b879
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 12 deletions.
3 changes: 3 additions & 0 deletions cmake/common/px4_base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ function(px4_add_module)
if(INCLUDES)
target_include_directories(${MODULE}_original PRIVATE ${INCLUDES})
endif()
target_compile_definitions(${MODULE}_original PRIVATE PX4_MAIN=${MAIN}_app_main)
target_compile_definitions(${MODULE}_original PRIVATE MODULE_NAME="${MAIN}_original")

# unity build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp
COMMAND cat ${SRCS} > ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp
DEPENDS ${MODULE}_original ${DEPENDS} ${SRCS}
Expand Down
2 changes: 1 addition & 1 deletion platforms/nuttx/src/px4_layer/px4_nuttx_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace px4

void init(int argc, char *argv[], const char *process_name)
{
PX4_WARN("process: %s", process_name);
printf("process: %s\n", process_name);
}

uint64_t get_time_micros()
Expand Down
1 change: 1 addition & 0 deletions platforms/posix/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#include "px4_daemon/server.h"
#include "px4_daemon/pxh.h"

#define MODULE_NAME "px4"

static const char *LOCK_FILE_PATH = "/tmp/px4_lock";

Expand Down
1 change: 1 addition & 0 deletions platforms/posix/src/px4_layer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ add_library(px4_layer
drv_hrt.c
${SHMEM_SRCS}
)
target_compile_definitions(px4_layer PRIVATE MODULE_NAME="px4")
target_link_libraries(px4_layer PRIVATE work_queue)
target_link_libraries(px4_layer PRIVATE px4_daemon)

Expand Down
4 changes: 2 additions & 2 deletions src/drivers/samv7/drv_hrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ hrt_tim_init(void)
ret = sam_tc_clockselect(frequency, &cmr, &actual);

if (ret < 0) {
PX4_PANIC("ERROR: Failed no divisor can be found (%d),for timer channel %d\n", ret, HRT_TIMER_CHANNEL);
printf("ERROR: Failed no divisor can be found (%d),for timer channel %d\n", ret, HRT_TIMER_CHANNEL);
return;
}

Expand Down Expand Up @@ -386,7 +386,7 @@ hrt_tim_init(void)
hrt_tch = sam_tc_allocate(HRT_TIMER_CHANNEL, cmr);

if (!hrt_tch) {
PX4_PANIC("ERROR: Failed to allocate timer channel %d\n", HRT_TIMER_CHANNEL);
printf("ERROR: Failed to allocate timer channel %d\n", HRT_TIMER_CHANNEL);
return;
}

Expand Down
6 changes: 2 additions & 4 deletions src/lib/mixer/mixer_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@
* Programmable multi-channel mixer library.
*/

#include <px4_config.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <systemlib/err.h>

#include "mixer_load.h"

Expand All @@ -54,7 +52,7 @@ int load_mixer_file(const char *fname, char *buf, unsigned maxlen)
fp = fopen(fname, "r");

if (fp == NULL) {
warnx("file not found");
printf("file not found\n");
return -1;
}

Expand Down Expand Up @@ -100,7 +98,7 @@ int load_mixer_file(const char *fname, char *buf, unsigned maxlen)

/* if the line is too long to fit in the buffer, bail */
if ((strlen(line) + strlen(buf) + 1) >= maxlen) {
warnx("line too long");
printf("line too long\n");
fclose(fp);
return -1;
}
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/apps.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include <cstdlib>

#define MODULE_NAME "px4"

extern "C" {

${builtin_apps_decl_string}
Expand Down
1 change: 1 addition & 0 deletions src/platforms/common/work_queue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ if (NOT "${OS}" MATCHES "nuttx")
work_queue.c
work_thread.c
)
target_compile_definitions(work_queue PRIVATE MODULE_NAME="work_queue")
add_dependencies(work_queue prebuild_targets)

endif()
5 changes: 0 additions & 5 deletions src/platforms/px4_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ __END_DECLS
#define __px4__log_printcond(cond, ...) if (cond) printf(__VA_ARGS__)
#define __px4__log_printline(level, ...) printf(__VA_ARGS__)


#ifndef MODULE_NAME
#define MODULE_NAME "Unknown"
#endif

#define __px4__log_timestamp_fmt "%-10" PRIu64 " "
#define __px4__log_timestamp_arg ,hrt_absolute_time()
#define __px4__log_level_fmt "%-5s "
Expand Down

0 comments on commit 246b879

Please sign in to comment.