/linux/module.h is not being included, or CONFIG_MODULES is not set

本文记录了在使用SRR跨平台编译过程中遇到的模块编译错误及警告信息,并推测这些问题可能是由于内核配置中未设置CONFIG_MODULES选项导致。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

BlueCat:bash-2.05a$ make mod
make SRRDEBUG=n FORCESYMBOLS=y SRCBASE=/BlueCat/usr/src INCLUDEDIR="-I/BlueCat/
usr/src/linux/include -I/BlueCat/usr/src/linux/include/asm-i386/mach-default" VE
RSION=\"1.4.34\" RECALC_TSK=0 SRRTHREAD="y" ROOTDIR=/BlueCat/cogent/srr-1.4.34 P
ATHS="-I/BlueCat/cogent/srr-1.4.34/mod -I/BlueCat/cogent/srr-1.4.34/inc" -C /Blu
eCat/usr/src/linux SUBDIRS=/BlueCat/cogent/srr-1.4.34/mod modules
make[1]: Entering directory `/BlueCat/usr/src/linux.x86'
CC [M] /BlueCat/cogent/srr-1.4.34/mod/srr_tt.o
CC [M] /BlueCat/cogent/srr-1.4.34/mod/srr_util.o
CC [M] /BlueCat/cogent/srr-1.4.34/mod/srr_mod.o
CC [M] /BlueCat/cogent/srr-1.4.34/mod/srr_time.o
CC [M] /BlueCat/cogent/srr-1.4.34/mod/srr_bytecode.o
CC [M] /BlueCat/cogent/srr-1.4.34/mod/srr_sys.o
LD [M] /BlueCat/cogent/srr-1.4.34/mod/srripc.o
Building modules, stage 2.
MODPOST
Warning: could not find versions for .tmp_versions/srripc.mod
*** Warning: "disable_irq" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!

*** Warning: "__request_region" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undef
ined!
*** Warning: "__kmalloc" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "del_timer" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "iomem_resource" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefin
ed!
*** Warning: "release_resource" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undef
ined!
*** Warning: "malloc_sizes" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined
!
*** Warning: "remove_wait_queue" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] unde
fined!
*** Warning: "__page_cache_release" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] u
ndefined!
*** Warning: "schedule_work" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefine
d!
*** Warning: "sprintf" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "jiffies" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "default_wake_function" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko]
undefined!
*** Warning: "misc_register" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefine
d!
*** Warning: "ioport_resource" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefi
ned!
*** Warning: "printk" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "copy_to_user" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined
!
*** Warning: "__down_failed_interruptible" [/BlueCat/cogent/srr-1.4.34/mod/srrip
c.ko] undefined!
*** Warning: "mod_timer" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "flush_signals" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefine
d!
*** Warning: "kmem_cache_alloc" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undef
ined!
*** Warning: "get_user_pages" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefin
ed!
*** Warning: "request_irq" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!

*** Warning: "schedule" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "recalc_sigpending" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] unde
fined!
*** Warning: "__wake_up" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "do_gettimeofday" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefi
ned!
*** Warning: "add_wait_queue" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefin
ed!
*** Warning: "enable_irq" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "kfree" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "kill_proc" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
*** Warning: "flush_scheduled_work" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] u
ndefined!
*** Warning: "__up_wakeup" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!

*** Warning: "find_task_by_pid" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undef
ined!
*** Warning: "__down_failed" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefine
d!
*** Warning: "copy_from_user" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefin
ed!
*** Warning: "misc_deregister" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefi
ned!
*** Warning: "free_irq" [/BlueCat/cogent/srr-1.4.34/mod/srripc.ko] undefined!
CC /BlueCat/cogent/srr-1.4.34/mod/srripc.mod.o
/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.c:9: variable `__this_module' has init
ializer but incomplete type
/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.c:10: unknown field `name' specified i
n initializer
/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.c:10: warning: excess elements in stru
ct initializer
/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.c:10: warning: (near initialization fo
r `__this_module')
/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.c:11: unknown field `init' specified i
n initializer
/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.c:11: warning: excess elements in stru
ct initializer
/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.c:11: warning: (near initialization fo
r `__this_module')
/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.c:9: storage size of `__this_module' i
sn't known
make[2]: *** [/BlueCat/cogent/srr-1.4.34/mod/srripc.mod.o] Error 1
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/BlueCat/usr/src/linux.x86'
make: *** [mod] Error 2

BlueCat:bash-2.05a$

Hi Mark,

It looks like include/linux/module.h is not being included, or CONFIG_MODULES is not set in the kernel config options. My vote is that CONFIG_MODULES is not set. Check .config in the root of your kernel source tree. There should be a section:
#
# Loadable module support
#
CONFIG_MODULES=y

I didn't know you could cross-compile SRR under Cygwin. That's pretty neat.

Andrew

这是slp_model.h中部分代码: #define ALARM_PLAN_STR_MAX_LEN 16 typedef struct _MSG_ALARM_CHN1_PLAN { SWITCH enabled; char alarm_plan_1[5][ALARM_PLAN_STR_MAX_LEN + 1]; /* 0000-0000,000格式 */ S32 alarm_plan_num; }MSG_ALARM_CHN1_PLAN, *PTR_MSG_ALARM_PLAN; 这是msg_alarm.c中部分代码: LOCAL void msg_alarm_plan_data_model() { /*************************************************************************************/ /********* Desc of /msg_alarm_plan/chn1_msg_alarm_plan *******************************/ /*************************************************************************************/ DS_ARR_DESC(alarm_plan, OPT_TYPE_STRING, MSG_ALARM_CHN1_PLAN, alarm_plan_1); DS_OPT_DESC chn1_msg_alarm_plan_options[] = { DS_SWITCH_OPT(MSG_ALARM_CHN1_PLAN, enabled, OPT_FLAG_NORM), DS_ARR_OPT(MSG_ALARM_CHN1_PLAN, alarm_plan_1, OPT_FLAG_NORM, &alarm_plan), DS_S32_OPT(MSG_ALARM_CHN1_PLAN, alarm_plan_num, OPT_FLAG_NORM), }; DS_SEG_DESC chn1_msg_alarm_plan_segments[] = { DS_STRUCT_SEG("chn1_msg_alarm_plan", SEG_LIM_RW, SEG_GROUP_ROOT, MSG_ALARM_CHN1_PLAN, chn1_msg_alarm_plan_options), }; DS_SECT_DESC chn1_msg_alarm_plan_sections[] = { DS_STRUCT_SECT("chn1_msg_alarm_plan", chn1_msg_alarm_plan_segments), }; /*************************************************************************************/ /********* Desc of /msg_alarm_plan/arming_schedule_sound***************************************/ /*************************************************************************************/ DS_OPT_DESC arming_schedule_info_options[] = { DS_STR_OPT(ARMING_SCHEDULE, monday, OPT_FLAG_NORM), DS_STR_OPT(ARMING_SCHEDULE, tuesday, OPT_FLAG_NORM), DS_STR_OPT(ARMING_SCHEDULE, wednesday, OPT_FLAG_NORM), DS_STR_OPT(ARMING_SCHEDULE, thursday, OPT_FLAG_NORM), DS_STR_OPT(ARMING_SCHEDULE, friday, OPT_FLAG_NORM), DS_STR_OPT(ARMING_SCHEDULE, saturday, OPT_FLAG_NORM), DS_STR_OPT(ARMING_SCHEDULE, sunday, OPT_FLAG_NORM), }; DS_SEG_DESC sound_arming_schedule_info_segments[] = { DS_STRUCT_SEG("arming_schedule_sound", SEG_LIM_RW, SEG_GROUP_ROOT, ARMING_SCHEDULE, arming_schedule_info_options), }; DS_SECT_DESC sound_arming_schedule_sections[] = { DS_STRUCT_SECT("arming_schedule_sound", sound_arming_schedule_info_segments), }; /*************************************************************************************/ /********* Desc of /msg_alarm_plan/arming_schedule_light***************************************/ /*************************************************************************************/ DS_SEG_DESC light_arming_schedule_info_segments[] = { DS_STRUCT_SEG("arming_schedule_light", SEG_LIM_RW, SEG_GROUP_ROOT, ARMING_SCHEDULE, arming_schedule_info_options), }; DS_SECT_DESC light_arming_schedule_sections[] = { DS_STRUCT_SECT("arming_schedule_light", light_arming_schedule_info_segments), }; DS_TBL_DESC msg_alarm_plan_tables[] = { DS_STRUCT_TBL("plan", TBL_ATTR_CFG, chn1_msg_alarm_plan_sections), DS_STRUCT_TBL("plan", TBL_ATTR_CFG, sound_arming_schedule_sections), DS_STRUCT_TBL("plan", TBL_ATTR_CFG, light_arming_schedule_sections), }; DS_DAT_MON_DESC msg_alarm_plan_data_monitor[] = { DS_DAT_MON(MSG_ALARM_CHN1_PLAN_PATH, DATA_ATTRI_CHECK), DS_DAT_MON(MSG_ALARM_PLAN_ARMING_SCHEDULE_SOUND_PATH, DATA_ATTRI_CHECK), DS_DAT_MON(MSG_ALARM_PLAN_ARMING_SCHEDULE_LIGHT_PATH, DATA_ATTRI_CHECK), }; DS_MOD_DESC msg_alarm_plan_module = DS_STRUCT_MOD("msg_alarm_plan", msg_alarm_plan_init, msg_alarm_plan_check, NULL, msg_alarm_plan_start, NULL, msg_alarm_plan_tables, msg_alarm_plan_data_monitor); MODULE *module_node = ds_register_module("msg_alarm_plan", &msg_alarm_plan_module); CAP_ASSERT(NULL != module_node); } CAP_INIT(msg_alarm_plan_data_model); 这是alarm_plan_ds.c中的代码: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <unistd.h> #include "slp_model.h" #include "libds.h" #include "msg_alarm.h" #include "detection_utils.h" #define MSG_ALARM_PLAN_MODULE_NAME "msg_alarm_plan" #define MSG_ALARM_PLAN_TABLE_NAME "plan" #define MSG_ALARM_PLAN_SECTION_NAME "chn1_msg_alarm_plan" /* 存放从ds中读取的数据 */ LOCAL MSG_ALARM_CHN1_PLAN g_msg_alarm_plan = {FALSE, NULL, 0}; /* ds get回调函数 */ /* 从ds共享内存中读取,然后填入json字符串 */ S32 ds_cb_get_alarm_plan(struct _DS_HANDLE_CONTEXT *context, JSON_OBJPTR reply_obj) { S32 i = 0; if (NULL == context || NULL == reply_obj) { MSG_ALARM_ERROR("ds_cb_get_alarm_plan: ptr is null"); return ERROR; } /* 从内存中读取并存入g_msg_alarm_plan结构体中 */ if (0 == ds_read(MSG_ALARM_CHN1_PLAN_PATH, &g_msg_alarm_plan, sizeof(MSG_ALARM_CHN1_PLAN))) { MSG_ALARM_ERROR("read from ds shm fail."); return ERROR; } /* 将enabled配置写入json */ jso_add_string(reply_obj, "enabled", g_msg_alarm_plan.enabled ? "on" : "off"); /* 将alarm_plan_num配置写入json */ jso_add_int(reply_obj, "alarm_plan_num", g_msg_alarm_plan.alarm_plan_num); JSON_OBJPTR alarm_plan_array = jso_new_array(); if(NULL == alarm_plan_array) { MSG_ALARM_ERROR("create new array object fail."); return ERROR; } /* 将alarm_plan_1数组配置写入json */ for (i = 0; i < g_msg_alarm_plan.alarm_plan_num; i++) { jso_array_add(alarm_plan_array, jso_new_string(g_msg_alarm_plan.alarm_plan_1[i])); } jso_obj_add(reply_obj, "alarm_plan_1", alarm_plan_array); /* 调试:打印json字符串 */ MSG_ALARM_DEBUG(" JSON %s",json_object_to_json_string(reply_obj)); return OK; } /* ds set回调函数 */ /* 解析json字符串,然后填入ds共享内存 */ S32 ds_cb_set_alarm_plan(struct _DS_HANDLE_CONTEXT *context, U8 method, const char* section_name, JSON_OBJPTR req_obj, BOOL is_table) { S32 i = 0; S32 ret = OK; const char *json_value_str = NULL; if (NULL == context || NULL == section_name || NULL == req_obj) { MSG_ALARM_ERROR("ptr is null"); return ERROR; } /* 从json中获取enable配置值 */ json_value_str = jso_obj_get_string_origin(req_obj, "enabled"); if (NULL == json_value_str) { MSG_ALARM_ERROR("jso_obj_get_string_origin key-enable return NULL"); return ERROR; } g_msg_alarm_plan.enabled = 0; if (0 == strcmp(json_value_str, "on")) { g_msg_alarm_plan.enabled = 1; } /* 从json中获取alarm_plan_num配置值 */ if (!jso_obj_get_int(req_obj, "alarm_plan_num", &g_msg_alarm_plan.alarm_plan_num)) { MSG_ALARM_ERROR("jso_obj_get_int key-alarm_plan_num return -1"); return ERROR; } /* 如果传入太多,只取前最大plan个数 */ if (g_msg_alarm_plan.alarm_plan_num > ALARM_PLAN_SIZE) { MSG_ALARM_ERROR("set too many plans!"); g_msg_alarm_plan.alarm_plan_num = ALARM_PLAN_SIZE; } JSON_OBJPTR alarm_plan_array = jso_obj_get(req_obj, "alarm_plan_1"); JSON_OBJPTR alarm_plan_term = jso_new_string(""); if (!jso_is_array(alarm_plan_array)) { MSG_ALARM_ERROR("key-alarm_plan_1 get non-array"); return ERROR; } /* 从json中获取alarm_plan_ch1配置值 */ for (i = 0; i < g_msg_alarm_plan.alarm_plan_num; i++) { alarm_plan_term = jso_array_get_idx(req_obj, i); if (!jso_is_string(alarm_plan_term)) { MSG_ALARM_ERROR("key-alarm_plan_1[] get non-string"); return ERROR; } jso_to_string(alarm_plan_term, g_msg_alarm_plan.alarm_plan_1[i], ALARM_PLAN_STR_MAX_LEN); } if (0 == ds_write(MSG_ALARM_CHN1_PLAN_PATH, &g_msg_alarm_plan, sizeof(MSG_ALARM_CHN1_PLAN))) { MSG_ALARM_ERROR("ds_write %s error", MSG_ALARM_CHN1_PLAN_PATH); return ERROR; } ret = ds_save_usr_cfg(); MSG_ALARM_DEBUG("ds_save_usr_cfg() ret[%d]", ret); /* 由于ds暂不支持listConfig的reload,所以这里手动调用 */ if (OK == ret) { alarm_plan_reload(); } return OK; } /* ds del回调函数 */ /* 解析json字符串,然后删除ds共享内存结构体中对应的plan */ S32 ds_cb_del_alarm_plan(struct _DS_HANDLE_CONTEXT *context, U8 method, const char* section_name, JSON_OBJPTR req_obj, BOOL is_table) { S32 i = 0; S32 ret = OK; const char *json_value_str = NULL; if (NULL == context || NULL == section_name || NULL == req_obj) { MSG_ALARM_ERROR("ptr is null"); return ERROR; } /* 从内存中读取并存入g_msg_alarm_plan结构体中 */ if (0 == ds_read(MSG_ALARM_CHN1_PLAN_PATH, &g_msg_alarm_plan, sizeof(MSG_ALARM_CHN1_PLAN))) { MSG_ALARM_ERROR("read from ds shm fail."); return ERROR; } JSON_OBJPTR alarm_plan_array = jso_obj_get(req_obj, "alarm_plan_1"); JSON_OBJPTR alarm_plan_term = jso_new_string(""); if (!jso_is_array(alarm_plan_array)) { MSG_ALARM_ERROR("key-alarm_plan_1 get non-array"); return ERROR; } /* 删的数量过多,清空plan数组 */ if (0 > (g_msg_alarm_plan.alarm_plan_num - jso_array_length(alarm_plan_array))) { for (i = 0; i < g_msg_alarm_plan.alarm_plan_num; i++ ) { memset(g_msg_alarm_plan.alarm_plan_1[i], 0, ALARM_PLAN_STR_MAX_LEN); } MSG_ALARM_ERROR("delete too many plans."); return ERROR; } /* 从json中获取enable配置值 */ json_value_str = jso_obj_get_string_origin(req_obj, "enabled"); if (NULL == json_value_str) { MSG_ALARM_ERROR("jso_obj_get_string_origin key-enable return NULL"); return ERROR; } if (!strcmp(json_value_str, "on")) { g_msg_alarm_plan.enabled = 1; } else if (!strcmp(json_value_str, "off")) { g_msg_alarm_plan.enabled = 0; } else { MSG_ALARM_ERROR("set wrong key-enable param"); return ERROR; } /* 从json中获取要删除的plan项并删除,并更新alarm_plan_num的值 */ for (i = 0; i < jso_array_length(alarm_plan_array); i++) { alarm_plan_term = jso_array_get_idx(req_obj, i); if (!jso_is_string(alarm_plan_term)) { MSG_ALARM_ERROR("key-alarm_plan_1[] get non-string"); return ERROR; } jso_to_string(alarm_plan_term, json_value_str, ALARM_PLAN_STR_MAX_LEN); for (int j = 0; j < g_msg_alarm_plan.alarm_plan_num; j++) { if (!strncmp(json_value_str, g_msg_alarm_plan.alarm_plan_1[j], strlen(json_value_str))) { strncpy(g_msg_alarm_plan.alarm_plan_1[j], g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1], strlen(g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1])); memset(g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1], 0, ALARM_PLAN_STR_MAX_LEN); g_msg_alarm_plan.alarm_plan_num--; break; } } } if (0 == ds_write(MSG_ALARM_CHN1_PLAN_PATH, &g_msg_alarm_plan, sizeof(MSG_ALARM_CHN1_PLAN))) { MSG_ALARM_ERROR("ds_write %s error", MSG_ALARM_CHN1_PLAN_PATH); return ERROR; } ret = ds_save_usr_cfg(); MSG_ALARM_DEBUG("ds_save_usr_cfg() ret[%d]", ret); /* 由于ds暂不支持listConfig的reload,所以这里手动调用 */ if (OK == ret) { msg_alarm_plan_reload(); } return OK; } /* 注册ds get/set 回调函数 */ S32 registe_ds_cb() { S32 ret = OK; if (ERROR == ds_register_get_json(MSG_ALARM_PLAN_MODULE_NAME, MSG_ALARM_PLAN_TABLE_NAME, MSG_ALARM_PLAN_SECTION_NAME, ds_cb_get_alarm_plan)) { MSG_ALARM_ERROR("ds_register_get_json return error"); ret = ERROR; } if (ERROR == ds_register_set_json(MSG_ALARM_PLAN_MODULE_NAME, MSG_ALARM_PLAN_TABLE_NAME, MSG_ALARM_PLAN_SECTION_NAME, ds_cb_set_alarm_plan)) { MSG_ALARM_ERROR("ds_register_set_json return error"); ret = ERROR; } if (ERROR == ds_register_del_json(MSG_ALARM_PLAN_MODULE_NAME, MSG_ALARM_PLAN_TABLE_NAME, ds_cb_del_alarm_plan)) { MSG_ALARM_ERROR("ds_register_del_json return error"); ret = ERROR; } return ret; } /* 获取报警排程 */ PTR_MSG_ALARM_PLAN get_alarm_plan_cfg() { return &g_msg_alarm_plan; } /* 初始化 */ S32 alarm_plan_init() { S32 ret = OK; /* 注册ds set/get/del回调函数 */ ret = registe_ds_cb(); if (ERROR == ret) { MSG_ALARM_ERROR("registe_ds_cb error"); return ret; } /* 初始化ds侦测报警排程结构体 */ g_msg_alarm_plan.enabled = FALSE; g_msg_alarm_plan.alarm_plan_num = 0; for(int i = 0; i < ALARM_PLAN_SIZE; i++) { memset(g_msg_alarm_plan.alarm_plan_1[i], 0, ALARM_PLAN_STR_MAX_LEN); } return ret; } 发生以下错误:make "make -C modules/msg_alarm MODULE_NAME=msg_alarm" make[5]: Entering directory '/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap/modules/msg_alarm' arm-AX620E-linux-uclibcgnueabihf-gcc -Os -pipe -D__LINUX_ARM_ARCH__=7 -march=armv7-a -mfloat-abi=hard -Wformat=0 -g -Wno-stringop-truncation -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-sizeof-pointer-div -Wno-restrict -Wno-stringop-overflow -Wno-format-truncation -Wno-format-overflow -Wno-error -g -DMCU_DIGITAL_LIGHT_SENSOR -DMCU_DIGITAL_PIR_SENSOR -DCLOUD_IOT_SUPPORT -DTAPO_USR_DEF_AUDIO_ALARM -DAUDIO_SAMPLE_RATE=16000 -DTAPO_AUDIO_ALARM_SETTINGS -DOPTIONAL_ALARM_AUDIO -DTELEMETRY_SUPPORT -DIR_LED_USE_MCU_ADC -DTP_TAPO_BATTERY_CAM -DTAPO_CARE_SUPPORT -DCONFIG_TARGET_AX620Q -DCONFIG_OPT300X_I2C_ALIAS=\"/dev/i2c-0\" -DSET_FRAME_SUPPORT -DBATTERY_OPERATING_MODE_SUPPORT -DBATTERY_STATISTIC_SUPPORT -DFREQ_WAKE_ABNORMAL_POWER_SUPPORT -DHUB_MANAGE_SUPPORT -DAUDIO_G711_16K_SUPPORT -DNET_STATUS_CHANGE_BITRATE -DNET_STATUS_CHANGE_BITRATE_REALTIME -DBAT_CAPACITY_CURVE_OPTIMIZATION -DPIR_SENSITIVITY_DEF_TABLE=100,91,80,69,48,36,30,28,24,20 -DMCU_CONTROL_MOTOR -DIRCUT_SWITCH_BY_MCU_MSG -DMCU_UART_ALIAS=\"/dev/ttyS3\" -DMCU_UPGRADE_CLEAN_UART -DMAX_BAT_MODEL=2 -DLOWER_IR_BEFORE_POWER_OFF -DJPEG_STREAM_ENABLE -DPTZ_SUPPORT -DGET_SNAPSHOT_ACCURATE -DSNAPSHOT_JPEG_HEIGHT=360 -DWLAN_SUPPORT -DLINUX_VERSION=4.19.125 -DTP_TAPO_RESET_WIFI_SUPPORT -I/home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include -I/home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/include -I/home/xyc/NVMP/nvmp/../sdk/soc/AX620Q/uclibc-toolchain/arm-AX620E-linux-uclibcgnueabihf/arm-AX620E-linux-uclibcgnueabihf/libc/usr/include -Wall -Werror -ffunction-sections -fdata-sections -DMODULE_LIST="\"general_plan mcu_proxy osd image dn_switch cover video battery_manage msg_alarm hsr md_alarm ptd_alarm vd_alarm speaker sd_card record_plan alarm_clock audio_library detection_region ptz light_control\"" -DTSS_MODULE_LIST="\"\"" -I/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap -c -o alarm_plan_ds.o alarm_plan_ds.c alarm_plan_ds.c:17:54: error: initialization of 'char' from 'void *' makes integer from pointer without a cast [-Werror=int-conversion] LOCAL MSG_ALARM_CHN1_PLAN g_msg_alarm_plan = {FALSE, NULL, 0}; ^~~~ alarm_plan_ds.c:17:54: note: (near initialization for 'g_msg_alarm_plan.alarm_plan_1[0]') alarm_plan_ds.c:17:46: error: missing braces around initializer [-Werror=missing-braces] LOCAL MSG_ALARM_CHN1_PLAN g_msg_alarm_plan = {FALSE, NULL, 0}; ^ In file included from alarm_plan_ds.c:9: alarm_plan_ds.c: In function 'ds_cb_get_alarm_plan': msg_alarm.h:59:36: error: implicit declaration of function 'CAP_ERROR'; did you mean 'MC_ERROR'? [-Werror=implicit-function-declaration] #define MSG_ALARM_ERROR(fmt, ...) CAP_ERROR("[MSG_ALARM]" fmt , ##__VA_ARGS__) ^~~~~~~~~ alarm_plan_ds.c:27:3: note: in expansion of macro 'MSG_ALARM_ERROR' MSG_ALARM_ERROR("ds_cb_get_alarm_plan: ptr is null"); ^~~~~~~~~~~~~~~ alarm_plan_ds.c:54:85: error: passing argument 1 of 'jso_new_string' makes pointer from integer without a cast [-Werror=int-conversion] jso_array_add(alarm_plan_array, jso_new_string(g_msg_alarm_plan.alarm_plan_1[i])); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/json/json.h:26, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/libds.h:7, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/slp_model.h:7, from alarm_plan_ds.c:7: /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/json/json_api.h:35:41: note: expected 'char *' but argument is of type 'char' extern JSON_OBJPTR jso_new_string(char *str); ~~~~~~^~~ In file included from alarm_plan_ds.c:9: msg_alarm.h:57:36: error: implicit declaration of function 'CAP_DEBUG'; did you mean 'MC_DEBUG'? [-Werror=implicit-function-declaration] #define MSG_ALARM_DEBUG(fmt, ...) CAP_DEBUG("[MSG_ALARM]" fmt, ##__VA_ARGS__) ^~~~~~~~~ alarm_plan_ds.c:59:2: note: in expansion of macro 'MSG_ALARM_DEBUG' MSG_ALARM_DEBUG(" JSON %s",json_object_to_json_string(reply_obj)); ^~~~~~~~~~~~~~~ alarm_plan_ds.c: In function 'ds_cb_set_alarm_plan': alarm_plan_ds.c:100:43: error: 'ALARM_PLAN_SIZE' undeclared (first use in this function); did you mean 'ALARM_STATE_IDLE'? if (g_msg_alarm_plan.alarm_plan_num > ALARM_PLAN_SIZE) ^~~~~~~~~~~~~~~ ALARM_STATE_IDLE alarm_plan_ds.c:100:43: note: each undeclared identifier is reported only once for each function it appears in alarm_plan_ds.c:124:69: error: passing argument 2 of 'jso_to_string' makes pointer from integer without a cast [-Werror=int-conversion] jso_to_string(alarm_plan_term, g_msg_alarm_plan.alarm_plan_1[i], ALARM_PLAN_STR_MAX_LEN); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/json/json.h:26, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/libds.h:7, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/slp_model.h:7, from alarm_plan_ds.c:7: /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/json/json_api.h:40:49: note: expected 'char *' but argument is of type 'char' extern int jso_to_string(JSON_OBJPTR obj, char *str_buf, int len); ~~~~~~^~~~~~~ alarm_plan_ds.c:139:3: error: implicit declaration of function 'alarm_plan_reload' [-Werror=implicit-function-declaration] alarm_plan_reload(); ^~~~~~~~~~~~~~~~~ alarm_plan_ds.c: In function 'ds_cb_del_alarm_plan': alarm_plan_ds.c:180:49: error: passing argument 1 of 'memset' makes pointer from integer without a cast [-Werror=int-conversion] memset(g_msg_alarm_plan.alarm_plan_1[i], 0, ALARM_PLAN_STR_MAX_LEN); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from alarm_plan_ds.c:3: /home/xyc/NVMP/sdk/soc/AX620Q/uclibc-toolchain/arm-AX620E-linux-uclibcgnueabihf/arm-AX620E-linux-uclibcgnueabihf/sysroot/usr/include/string.h:58:14: note: expected 'void *' but argument is of type 'char' extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); ^~~~~~ alarm_plan_ds.c:218:40: error: passing argument 2 of 'jso_to_string' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] jso_to_string(alarm_plan_term, json_value_str, ALARM_PLAN_STR_MAX_LEN); ^~~~~~~~~~~~~~ In file included from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/json/json.h:26, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/libds.h:7, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/slp_model.h:7, from alarm_plan_ds.c:7: /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/json/json_api.h:40:49: note: expected 'char *' but argument is of type 'const char *' extern int jso_to_string(JSON_OBJPTR obj, char *str_buf, int len); ~~~~~~^~~~~~~ alarm_plan_ds.c:221:71: error: passing argument 2 of 'strncmp' makes pointer from integer without a cast [-Werror=int-conversion] if (!strncmp(json_value_str, g_msg_alarm_plan.alarm_plan_1[j], strlen(json_value_str))) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from alarm_plan_ds.c:3: /home/xyc/NVMP/sdk/soc/AX620Q/uclibc-toolchain/arm-AX620E-linux-uclibcgnueabihf/arm-AX620E-linux-uclibcgnueabihf/sysroot/usr/include/string.h:101:51: note: expected 'const char *' but argument is of type 'char' extern int strncmp (const char *__s1, const char *__s2, size_t __n) ~~~~~~~~~~~~^~~~ alarm_plan_ds.c:224:61: error: passing argument 1 of 'strlen' makes pointer from integer without a cast [-Werror=int-conversion] strlen(g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1])); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from alarm_plan_ds.c:3: /home/xyc/NVMP/sdk/soc/AX620Q/uclibc-toolchain/arm-AX620E-linux-uclibcgnueabihf/arm-AX620E-linux-uclibcgnueabihf/sysroot/usr/include/string.h:247:35: note: expected 'const char *' but argument is of type 'char' extern size_t strlen (const char *__s) ~~~~~~~~~~~~^~~ alarm_plan_ds.c:223:54: error: passing argument 1 of 'strncpy' makes pointer from integer without a cast [-Werror=int-conversion] strncpy(g_msg_alarm_plan.alarm_plan_1[j], g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1], ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from alarm_plan_ds.c:3: /home/xyc/NVMP/sdk/soc/AX620Q/uclibc-toolchain/arm-AX620E-linux-uclibcgnueabihf/arm-AX620E-linux-uclibcgnueabihf/sysroot/usr/include/string.h:86:14: note: expected 'char * restrict' but argument is of type 'char' extern char *strncpy (char *__restrict __dest, ^~~~~~~ alarm_plan_ds.c:223:88: error: passing argument 2 of 'strncpy' makes pointer from integer without a cast [-Werror=int-conversion] strncpy(g_msg_alarm_plan.alarm_plan_1[j], g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1], ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from alarm_plan_ds.c:3: /home/xyc/NVMP/sdk/soc/AX620Q/uclibc-toolchain/arm-AX620E-linux-uclibcgnueabihf/arm-AX620E-linux-uclibcgnueabihf/sysroot/usr/include/string.h:86:14: note: expected 'const char * restrict' but argument is of type 'char' extern char *strncpy (char *__restrict __dest, ^~~~~~~ alarm_plan_ds.c:225:53: error: passing argument 1 of 'memset' makes pointer from integer without a cast [-Werror=int-conversion] memset(g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1], 0, ALARM_PLAN_STR_MAX_LEN); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from alarm_plan_ds.c:3: /home/xyc/NVMP/sdk/soc/AX620Q/uclibc-toolchain/arm-AX620E-linux-uclibcgnueabihf/arm-AX620E-linux-uclibcgnueabihf/sysroot/usr/include/string.h:58:14: note: expected 'void *' but argument is of type 'char' extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); ^~~~~~ alarm_plan_ds.c:244:3: error: implicit declaration of function 'msg_alarm_plan_reload'; did you mean 'msg_alarm_type_filter'? [-Werror=implicit-function-declaration] msg_alarm_plan_reload(); ^~~~~~~~~~~~~~~~~~~~~ msg_alarm_type_filter alarm_plan_ds.c: In function 'registe_ds_cb': alarm_plan_ds.c:268:94: error: passing argument 3 of 'ds_register_del_json' from incompatible pointer type [-Werror=incompatible-pointer-types] if (ERROR == ds_register_del_json(MSG_ALARM_PLAN_MODULE_NAME, MSG_ALARM_PLAN_TABLE_NAME, ds_cb_del_alarm_plan)) ^~~~~~~~~~~~~~~~~~~~ In file included from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/libds.h:12, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/slp_model.h:7, from alarm_plan_ds.c:7: /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/ds_model.h:252:87: note: expected 'DEL_JSON' {aka 'int (*)(struct _DS_HANDLE_CONTEXT *, struct json_object *, enum _BOOL)'} but argument is of type 'S32 (*)(struct _DS_HANDLE_CONTEXT *, U8, const char *, struct json_object *, BOOL)' {aka 'int (*)(struct _DS_HANDLE_CONTEXT *, unsigned char, const char *, struct json_object *, enum _BOOL)'} STATUS ds_register_del_json(const char *module_name, const char *table_name, DEL_JSON del_json); ~~~~~~~~~^~~~~~~~ alarm_plan_ds.c: In function 'alarm_plan_init': alarm_plan_ds.c:299:24: error: 'ALARM_PLAN_SIZE' undeclared (first use in this function); did you mean 'ALARM_STATE_IDLE'? for(int i = 0; i < ALARM_PLAN_SIZE; i++) ^~~~~~~~~~~~~~~ ALARM_STATE_IDLE alarm_plan_ds.c:301:45: error: passing argument 1 of 'memset' makes pointer from integer without a cast [-Werror=int-conversion] memset(g_msg_alarm_plan.alarm_plan_1[i], 0, ALARM_PLAN_STR_MAX_LEN); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from alarm_plan_ds.c:3: /home/xyc/NVMP/sdk/soc/AX620Q/uclibc-toolchain/arm-AX620E-linux-uclibcgnueabihf/arm-AX620E-linux-uclibcgnueabihf/sysroot/usr/include/string.h:58:14: note: expected 'void *' but argument is of type 'char' extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); ^~~~~~ cc1: all warnings being treated as errors <builtin>: recipe for target 'alarm_plan_ds.o' failed make[5]: *** [alarm_plan_ds.o] Error 1 make[5]: Leaving directory '/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap/modules/msg_alarm' Makefile:32: recipe for target 'build_modules' failed make[4]: *** [build_modules] Error 2 make[4]: Leaving directory '/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap' Makefile:758: recipe for target '/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap/.built' failed make[3]: *** [/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap/.built] Error 2 make[3]: Leaving directory '/home/xyc/NVMP/nvmp/tp_package/cap' package/Makefile:105: recipe for target 'package/tp_package/cap/compile' failed make[2]: *** [package/tp_package/cap/compile] Error 2 make[2]: Leaving directory '/home/xyc/NVMP/nvmp' package/Makefile:101: recipe for target '/home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/stamp/.package_compile' failed make[1]: *** [/home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/xyc/NVMP/nvmp' /home/xyc/NVMP/nvmp/include/toplevel.mk:210: recipe for target 'world' failed make: *** [world] Error 2
08-19
alarm_plan_ds.c: In function 'ds_cb_del_alarm_plan': alarm_plan_ds.c:226:40: error: passing argument 2 of 'jso_to_string' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] jso_to_string(alarm_plan_term, json_value_str, ALARM_PLAN_STR_MAX_LEN); ^~~~~~~~~~~~~~ In file included from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/json/json.h:26, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/libds.h:7, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/slp_model.h:7, from alarm_plan_ds.c:7: /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/json/json_api.h:40:49: note: expected 'char *' but argument is of type 'const char *' extern int jso_to_string(JSON_OBJPTR obj, char *str_buf, int len); ~~~~~~^~~~~~~ alarm_plan_ds.c: In function 'registe_ds_cb': alarm_plan_ds.c:276:94: error: passing argument 3 of 'ds_register_del_json' from incompatible pointer type [-Werror=incompatible-pointer-types] if (ERROR == ds_register_del_json(MSG_ALARM_PLAN_MODULE_NAME, MSG_ALARM_PLAN_TABLE_NAME, ds_cb_del_alarm_plan)) ^~~~~~~~~~~~~~~~~~~~ In file included from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/libds.h:12, from /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/slp_model.h:7, from alarm_plan_ds.c:7: /home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/usr/include/ds_model.h:252:87: note: expected 'DEL_JSON' {aka 'int (*)(struct _DS_HANDLE_CONTEXT *, struct json_object *, enum _BOOL)'} but argument is of type 'S32 (*)(struct _DS_HANDLE_CONTEXT *, U8, const char *, struct json_object *, BOOL)' {aka 'int (*)(struct _DS_HANDLE_CONTEXT *, unsigned char, const char *, struct json_object *, enum _BOOL)'} STATUS ds_register_del_json(const char *module_name, const char *table_name, DEL_JSON del_json); ~~~~~~~~~^~~~~~~~ cc1: all warnings being treated as errors <builtin>: recipe for target 'alarm_plan_ds.o' failed make[5]: *** [alarm_plan_ds.o] Error 1 make[5]: Leaving directory '/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap/modules/msg_alarm' Makefile:32: recipe for target 'build_modules' failed make[4]: *** [build_modules] Error 2 make[4]: Leaving directory '/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap' Makefile:758: recipe for target '/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap/.built' failed make[3]: *** [/home/xyc/NVMP/nvmp/build_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/cap/.built] Error 2 make[3]: Leaving directory '/home/xyc/NVMP/nvmp/tp_package/cap' package/Makefile:105: recipe for target 'package/tp_package/cap/compile' failed make[2]: *** [package/tp_package/cap/compile] Error 2 make[2]: Leaving directory '/home/xyc/NVMP/nvmp' package/Makefile:101: recipe for target '/home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/stamp/.package_compile' failed make[1]: *** [/home/xyc/NVMP/nvmp/staging_dir/target-arm-AX620E-linux-uclibcgnueabihf-c668bv1/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/xyc/NVMP/nvmp' /home/xyc/NVMP/nvmp/include/toplevel.mk:210: recipe for target 'world' failed 对于现在这些错误,修改以下代码: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <unistd.h> #include "slp_model.h" #include "libds.h" #include "msg_alarm.h" #include "detection_utils.h" #include "cap_common.h" #define MSG_ALARM_PLAN_MODULE_NAME "msg_alarm_plan" #define MSG_ALARM_PLAN_TABLE_NAME "plan" #define MSG_ALARM_PLAN_SECTION_NAME "chn1_msg_alarm_plan" void alarm_plan_reload(void); void msg_alarm_plan_reload(void); /* 存放从ds中读取的数据 */ LOCAL MSG_ALARM_CHN1_PLAN g_msg_alarm_plan = { .enabled = FALSE, .alarm_plan_1 = {{0}}, .alarm_plan_num = 0 }; /* ds get回调函数 */ /* 从ds共享内存中读取,然后填入json字符串 */ S32 ds_cb_get_alarm_plan(struct _DS_HANDLE_CONTEXT *context, JSON_OBJPTR reply_obj) { S32 i = 0; if (NULL == context || NULL == reply_obj) { MSG_ALARM_ERROR("ds_cb_get_alarm_plan: ptr is null"); return ERROR; } /* 从内存中读取并存入g_msg_alarm_plan结构体中 */ if (0 == ds_read(MSG_ALARM_CHN1_PLAN_PATH, &g_msg_alarm_plan, sizeof(MSG_ALARM_CHN1_PLAN))) { MSG_ALARM_ERROR("read from ds shm fail."); return ERROR; } /* 将enabled配置写入json */ jso_add_string(reply_obj, "enabled", g_msg_alarm_plan.enabled ? "on" : "off"); /* 将alarm_plan_num配置写入json */ jso_add_int(reply_obj, "alarm_plan_num", g_msg_alarm_plan.alarm_plan_num); JSON_OBJPTR alarm_plan_array = jso_new_array(); if(NULL == alarm_plan_array) { MSG_ALARM_ERROR("create new array object fail."); return ERROR; } /* 将alarm_plan_1数组配置写入json */ for (i = 0; i < g_msg_alarm_plan.alarm_plan_num; i++) { jso_array_add(alarm_plan_array, jso_new_string(g_msg_alarm_plan.alarm_plan_1[i])); } jso_obj_add(reply_obj, "alarm_plan_1", alarm_plan_array); /* 调试:打印json字符串 */ MSG_ALARM_DEBUG(" JSON %s",json_object_to_json_string(reply_obj)); return OK; } /* ds set回调函数 */ /* 解析json字符串,然后填入ds共享内存 */ S32 ds_cb_set_alarm_plan(struct _DS_HANDLE_CONTEXT *context, U8 method, const char* section_name, JSON_OBJPTR req_obj, BOOL is_table) { S32 i = 0; S32 ret = OK; const char *json_value_str = NULL; if (NULL == context || NULL == section_name || NULL == req_obj) { MSG_ALARM_ERROR("ptr is null"); return ERROR; } /* 从json中获取enable配置值 */ json_value_str = jso_obj_get_string_origin(req_obj, "enabled"); if (NULL == json_value_str) { MSG_ALARM_ERROR("jso_obj_get_string_origin key-enable return NULL"); return ERROR; } g_msg_alarm_plan.enabled = 0; if (0 == strcmp(json_value_str, "on")) { g_msg_alarm_plan.enabled = 1; } /* 从json中获取alarm_plan_num配置值 */ if (!jso_obj_get_int(req_obj, "alarm_plan_num", &g_msg_alarm_plan.alarm_plan_num)) { MSG_ALARM_ERROR("jso_obj_get_int key-alarm_plan_num return -1"); return ERROR; } /* 如果传入太多,只取前最大plan个数 */ if (g_msg_alarm_plan.alarm_plan_num > ALARM_PLAN_SIZE) { MSG_ALARM_ERROR("set too many plans!"); g_msg_alarm_plan.alarm_plan_num = ALARM_PLAN_SIZE; } JSON_OBJPTR alarm_plan_array = jso_obj_get(req_obj, "alarm_plan_1"); JSON_OBJPTR alarm_plan_term = jso_new_string(""); if (!jso_is_array(alarm_plan_array)) { MSG_ALARM_ERROR("key-alarm_plan_1 get non-array"); return ERROR; } /* 从json中获取alarm_plan_ch1配置值 */ for (i = 0; i < g_msg_alarm_plan.alarm_plan_num; i++) { alarm_plan_term = jso_array_get_idx(req_obj, i); if (!jso_is_string(alarm_plan_term)) { MSG_ALARM_ERROR("key-alarm_plan_1[] get non-string"); return ERROR; } jso_to_string(alarm_plan_term, g_msg_alarm_plan.alarm_plan_1[i], ALARM_PLAN_STR_MAX_LEN); } if (0 == ds_write(MSG_ALARM_CHN1_PLAN_PATH, &g_msg_alarm_plan, sizeof(MSG_ALARM_CHN1_PLAN))) { MSG_ALARM_ERROR("ds_write %s error", MSG_ALARM_CHN1_PLAN_PATH); return ERROR; } ret = ds_save_usr_cfg(); MSG_ALARM_DEBUG("ds_save_usr_cfg() ret[%d]", ret); /* 由于ds暂不支持listConfig的reload,所以这里手动调用 */ if (OK == ret) { alarm_plan_reload(); } return OK; } /* ds del回调函数 */ /* 解析json字符串,然后删除ds共享内存结构体中对应的plan */ S32 ds_cb_del_alarm_plan(struct _DS_HANDLE_CONTEXT *context, U8 method, const char* section_name, JSON_OBJPTR req_obj, BOOL is_table) { S32 i = 0; S32 ret = OK; const char *json_value_str = NULL; if (NULL == context || NULL == section_name || NULL == req_obj) { MSG_ALARM_ERROR("ptr is null"); return ERROR; } /* 从内存中读取并存入g_msg_alarm_plan结构体中 */ if (0 == ds_read(MSG_ALARM_CHN1_PLAN_PATH, &g_msg_alarm_plan, sizeof(MSG_ALARM_CHN1_PLAN))) { MSG_ALARM_ERROR("read from ds shm fail."); return ERROR; } JSON_OBJPTR alarm_plan_array = jso_obj_get(req_obj, "alarm_plan_1"); JSON_OBJPTR alarm_plan_term = jso_new_string(""); if (!jso_is_array(alarm_plan_array)) { MSG_ALARM_ERROR("key-alarm_plan_1 get non-array"); return ERROR; } /* 删的数量过多,清空plan数组 */ if (0 > (g_msg_alarm_plan.alarm_plan_num - jso_array_length(alarm_plan_array))) { for (i = 0; i < g_msg_alarm_plan.alarm_plan_num; i++ ) { memset(g_msg_alarm_plan.alarm_plan_1[i], 0, ALARM_PLAN_STR_MAX_LEN); } MSG_ALARM_ERROR("delete too many plans."); return ERROR; } /* 从json中获取enable配置值 */ json_value_str = jso_obj_get_string_origin(req_obj, "enabled"); if (NULL == json_value_str) { MSG_ALARM_ERROR("jso_obj_get_string_origin key-enable return NULL"); return ERROR; } if (!strcmp(json_value_str, "on")) { g_msg_alarm_plan.enabled = 1; } else if (!strcmp(json_value_str, "off")) { g_msg_alarm_plan.enabled = 0; } else { MSG_ALARM_ERROR("set wrong key-enable param"); return ERROR; } /* 从json中获取要删除的plan项并删除,并更新alarm_plan_num的值 */ for (i = 0; i < jso_array_length(alarm_plan_array); i++) { alarm_plan_term = jso_array_get_idx(req_obj, i); if (!jso_is_string(alarm_plan_term)) { MSG_ALARM_ERROR("key-alarm_plan_1[] get non-string"); return ERROR; } jso_to_string(alarm_plan_term, json_value_str, ALARM_PLAN_STR_MAX_LEN); for (int j = 0; j < g_msg_alarm_plan.alarm_plan_num; j++) { if (!strncmp(json_value_str, g_msg_alarm_plan.alarm_plan_1[j], strlen(json_value_str))) { strncpy(g_msg_alarm_plan.alarm_plan_1[j], g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1], strlen(g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1])); memset(g_msg_alarm_plan.alarm_plan_1[g_msg_alarm_plan.alarm_plan_num - 1], 0, ALARM_PLAN_STR_MAX_LEN); g_msg_alarm_plan.alarm_plan_num--; break; } } } if (0 == ds_write(MSG_ALARM_CHN1_PLAN_PATH, &g_msg_alarm_plan, sizeof(MSG_ALARM_CHN1_PLAN))) { MSG_ALARM_ERROR("ds_write %s error", MSG_ALARM_CHN1_PLAN_PATH); return ERROR; } ret = ds_save_usr_cfg(); MSG_ALARM_DEBUG("ds_save_usr_cfg() ret[%d]", ret); /* 由于ds暂不支持listConfig的reload,所以这里手动调用 */ if (OK == ret) { msg_alarm_plan_reload(); } return OK; } /* 注册ds get/set 回调函数 */ S32 registe_ds_cb() { S32 ret = OK; if (ERROR == ds_register_get_json(MSG_ALARM_PLAN_MODULE_NAME, MSG_ALARM_PLAN_TABLE_NAME, MSG_ALARM_PLAN_SECTION_NAME, ds_cb_get_alarm_plan)) { MSG_ALARM_ERROR("ds_register_get_json return error"); ret = ERROR; } if (ERROR == ds_register_set_json(MSG_ALARM_PLAN_MODULE_NAME, MSG_ALARM_PLAN_TABLE_NAME, MSG_ALARM_PLAN_SECTION_NAME, ds_cb_set_alarm_plan)) { MSG_ALARM_ERROR("ds_register_set_json return error"); ret = ERROR; } if (ERROR == ds_register_del_json(MSG_ALARM_PLAN_MODULE_NAME, MSG_ALARM_PLAN_TABLE_NAME, ds_cb_del_alarm_plan)) { MSG_ALARM_ERROR("ds_register_del_json return error"); ret = ERROR; } return ret; } /* 获取报警排程 */ PTR_MSG_ALARM_PLAN get_alarm_plan_cfg() { return &g_msg_alarm_plan; } /* 初始化 */ S32 alarm_plan_init() { S32 ret = OK; /* 注册ds set/get/del回调函数 */ ret = registe_ds_cb(); if (ERROR == ret) { MSG_ALARM_ERROR("registe_ds_cb error"); return ret; } /* 初始化ds侦测报警排程结构体 */ g_msg_alarm_plan.enabled = FALSE; g_msg_alarm_plan.alarm_plan_num = 0; for(int i = 0; i < ALARM_PLAN_SIZE; i++) { memset(g_msg_alarm_plan.alarm_plan_1[i], 0, ALARM_PLAN_STR_MAX_LEN); } return ret; }
最新发布
08-19
-- ROMFS: Adding boards/px4/fmu-v5/extras/px4_io-v2_default.bin -> /etc/extras/px4_io-v2_default.bin -- Configuring done -- Generating done -- Build files have been written to: /home/me/下载/px4-autopilot-1.15.4/build/px4_fmu-v5_default [1/1299] Generating git version header FAILED: src/lib/version/build_git_version.h cd /home/me/下载/px4-autopilot-1.15.4 && /usr/bin/python3 /home/me/下载/px4-autopilot-1.15.4/src/lib/version/px_update_git_header.py /home/me/下载/px4-autopilot-1.15.4/build/px4_fmu-v5_default/src/lib/version/build_git_version.h --validate Error: the git tag 'c49f4c2142' does not match the expected format. The expected format is 'v<PX4 version>[-<custom version>]' <PX4 version>: v<major>.<minor>.<patch>[-rc<rc>|-beta<beta>|-alpha<alpha>|-dev] <custom version>: <major>.<minor>.<patch>[-rc<rc>|-beta<beta>|-alpha<alpha>|-dev] Examples: v1.9.0-rc3 (preferred) v1.9.0-beta1 v1.9.0-1.0.0 v1.9.0-1.0.0-alpha2 See also https://docs.px4.io/main/en/dev_setup/building_px4.html#building-for-nuttx [2/1299] Generating ../../../platforms/nuttx/NuttX/nuttx/.config ninja: build stopped: subcommand failed. make: *** [Makefile:227:px4_fmu-v5_default] 错误 1如何修改代码避免此错误############################################################################ # # Copyright (c) 2017 - 2024 PX4 Development Team. 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. # ############################################################################ #============================================================================= # CMAKE CODING STANDARD FOR PX4 # # Structure # --------------------------------------------------------------------------- # # * Common functions should be included in px_base.cmake. # # * OS/ board specific fucntions should be include in # px_impl_${PX4_PLATFORM}.cmake # # Formatting # --------------------------------------------------------------------------- # # * Use hard indents to match the px4 source code. # # * All function and script arguments are upper case. # # * All local variables are lower case. # # * All cmake functions are lowercase. # # * For else, endif, endfunction, etc, never put the name of the statement # # Functions/Macros # --------------------------------------------------------------------------- # # * Use px4_parse_function_args to parse functions and check for required # arguments. Unless there is only one argument in the function and it is clear. # # * Never use macros. They allow overwriting global variables and this # makes variable declarations hard to locate. # # * If a target from add_custom_* is set in a function, explicitly pass it # as an output argument so that the target name is clear to the user. # # * Avoid use of global variables in functions. Functions in a nested # scope may use global variables, but this makes it difficult to # reuse functions. # # Included CMake Files # --------------------------------------------------------------------------- # # * All variables in config files must have the prefix "config_". # # * Never set global variables in an included cmake file, # you may only define functions. This excludes config and Toolchain files. # This makes it clear to the user when variables are being set or targets # are being created. # # * Setting a global variable in a CMakeLists.txt file is ok, because # each CMakeLists.txt file has scope in the current directory and all # subdirectories, so it is not truly global. # # * All toolchain files should be included in the cmake # directory and named Toolchain-"name".cmake. # # Misc # --------------------------------------------------------------------------- # # * If referencing a string variable, don't put it in quotes. # Don't do "${PX4_PLATFORM}" STREQUAL "posix", # instead type ${PX4_PLATFORM} STREQUAL "posix". This will throw an # error when ${PX4_PLATFORM} is not defined instead of silently # evaluating to false. # #============================================================================= cmake_minimum_required(VERSION 3.9 FATAL_ERROR) set(PX4_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE FILEPATH "PX4 source directory" FORCE) set(PX4_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE FILEPATH "PX4 binary directory" FORCE) list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake) include(px4_parse_function_args) #============================================================================= # git # include(px4_git) execute_process( COMMAND git describe --exclude ext/* --always --tags OUTPUT_VARIABLE PX4_GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY ${PX4_SOURCE_DIR} ) set(PX4_GIT_TAG "v1.15.4") # git describe to X.Y.Z version string(REPLACE "." ";" VERSION_LIST ${PX4_GIT_TAG}) # major version list(GET VERSION_LIST 0 PX4_VERSION_MAJOR) string(REPLACE "v" "" PX4_VERSION_MAJOR ${PX4_VERSION_MAJOR}) # minor version list(GET VERSION_LIST 1 PX4_VERSION_MINOR) # patch version list(GET VERSION_LIST 2 PX4_VERSION_PATCH) string(REPLACE "-" ";" PX4_VERSION_PATCH ${PX4_VERSION_PATCH}) list(GET PX4_VERSION_PATCH 0 PX4_VERSION_PATCH) # # Capture only the hash part after 'g' string(REGEX MATCH "g([a-f0-9]+)$" GIT_HASH "${PX4_GIT_TAG}") set(PX4_GIT_HASH ${CMAKE_MATCH_1}) define_property(GLOBAL PROPERTY PX4_MODULE_LIBRARIES BRIEF_DOCS "PX4 module libs" FULL_DOCS "List of all PX4 module libraries" ) define_property(GLOBAL PROPERTY PX4_KERNEL_MODULE_LIBRARIES BRIEF_DOCS "PX4 kernel side module libs" FULL_DOCS "List of all PX4 kernel module libraries" ) define_property(GLOBAL PROPERTY PX4_MODULE_PATHS BRIEF_DOCS "PX4 module paths" FULL_DOCS "List of paths to all PX4 modules" ) define_property(GLOBAL PROPERTY PX4_SRC_FILES BRIEF_DOCS "src files from all PX4 modules & libs" FULL_DOCS "SRC files from px4_add_{module,library}" ) #============================================================================= # configuration # include(px4_add_module) set(config_module_list) set(config_kernel_list) # Find Python find_package(PythonInterp 3) # We have a custom error message to tell users how to install python3. if(NOT PYTHONINTERP_FOUND) message(FATAL_ERROR "Python 3 not found. Please install Python 3:\n" " Ubuntu: sudo apt install python3 python3-dev python3-pip\n" " macOS: brew install python") endif() option(PYTHON_COVERAGE "Python code coverage" OFF) if(PYTHON_COVERAGE) message(STATUS "python coverage enabled") set(PYTHON_EXECUTABLE coverage run -p) endif() include(px4_config) include(kconfig) message(STATUS "PX4 config: ${PX4_CONFIG}") message(STATUS "PX4 platform: ${PX4_PLATFORM}") if($ENV{CLION_IDE}) # CLion automatically executes some compiler commands after configuring the # project. This would fail on NuttX, as visibility.h tries to (indirectly) # include nuttx/config.h, which at that point does not exist yet add_definitions(-DPX4_DISABLE_GCC_POISON) endif() if(${PX4_PLATFORM} STREQUAL "posix") if(ENABLE_LOCKSTEP_SCHEDULER) add_definitions(-DENABLE_LOCKSTEP_SCHEDULER) message(STATUS "PX4 lockstep: enabled") else() message(STATUS "PX4 lockstep: disabled") endif() endif() # external modules set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location") if(NOT EXTERNAL_MODULES_LOCATION STREQUAL "") get_filename_component(EXTERNAL_MODULES_LOCATION "${EXTERNAL_MODULES_LOCATION}" ABSOLUTE) endif() set_property(GLOBAL PROPERTY PX4_MODULE_CONFIG_FILES) include(platforms/${PX4_PLATFORM}/cmake/px4_impl_os.cmake) list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake) if(EXISTS "${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake/init.cmake") include(init) endif() #============================================================================= # project definition # project(px4 CXX C ASM) # CMake build type (Debug Release RelWithDebInfo MinSizeRel Coverage) if(NOT CMAKE_BUILD_TYPE) if(${PX4_PLATFORM} STREQUAL "nuttx") set(PX4_BUILD_TYPE "MinSizeRel") else() set(PX4_BUILD_TYPE "RelWithDebInfo") endif() set(CMAKE_BUILD_TYPE ${PX4_BUILD_TYPE} CACHE STRING "Build type" FORCE) endif() if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "Coverage")) set(MAX_CUSTOM_OPT_LEVEL -O0) elseif(CMAKE_BUILD_TYPE MATCHES "Sanitizer") set(MAX_CUSTOM_OPT_LEVEL -O1) elseif(CMAKE_BUILD_TYPE MATCHES "Release") set(MAX_CUSTOM_OPT_LEVEL -O3) else() if(px4_constrained_flash_build) set(MAX_CUSTOM_OPT_LEVEL -Os) else() set(MAX_CUSTOM_OPT_LEVEL -O2) endif() endif() set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Coverage;AddressSanitizer;UndefinedBehaviorSanitizer") message(STATUS "cmake build type: ${CMAKE_BUILD_TYPE}") # Check if LTO option and check if toolchain supports it if(LTO) include(CheckIPOSupported) check_ipo_supported() message(AUTHOR_WARNING "LTO enabled: LTO is highly experimental and should not be used in production") set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) endif() set(package-contact "px4users@googlegroups.com") set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PX4_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PX4_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PX4_BINARY_DIR}) #============================================================================= # gold linker - use if available (posix only for now) if(${PX4_PLATFORM} STREQUAL "posix") include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(USE_LD_GOLD "Use GNU gold linker" ON "NOT WIN32;NOT APPLE" OFF ) if(USE_LD_GOLD) execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) if("${LD_VERSION}" MATCHES "GNU gold") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold") else() set(USE_LD_GOLD OFF) endif() endif() endif() #============================================================================= # Setup install paths if(${PX4_PLATFORM} STREQUAL "posix") # This makes it possible to dynamically load code which depends on symbols # inside the px4 executable. set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_ENABLE_EXPORTS ON) if(CMAKE_BUILD_TYPE MATCHES "Coverage") include(coverage) endif() include(sanitizers) # Define GNU standard installation directories include(GNUInstallDirs) if (NOT CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install path prefix" FORCE) endif() endif() include(ccache) #============================================================================= # get chip and chip manufacturer # px4_os_determine_build_chip() if(NOT PX4_CHIP_MANUFACTURER) message(FATAL_ERROR "px4_os_determine_build_chip() needs to set PX4_CHIP_MANUFACTURER") endif() if(NOT PX4_CHIP) message(FATAL_ERROR "px4_os_determine_build_chip() needs to set PX4_CHIP") endif() #============================================================================= # build flags # include(px4_add_common_flags) px4_add_common_flags() px4_os_add_flags() #============================================================================= # board cmake init (optional) # if(EXISTS ${PX4_BOARD_DIR}/cmake/init.cmake) include(${PX4_BOARD_DIR}/cmake/init.cmake) endif() #============================================================================= # message, and airframe generation # include(px4_metadata) add_subdirectory(msg EXCLUDE_FROM_ALL) px4_generate_airframes_xml(BOARD ${PX4_BOARD}) #============================================================================= # external projects # set(ep_base ${PX4_BINARY_DIR}/external) set_property(DIRECTORY PROPERTY EP_BASE ${ep_base}) # add external project install folders to build # add the directories so cmake won't warn execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${ep_base}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${ep_base}/Install) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${ep_base}/Install/lib) link_directories(${ep_base}/Install/lib) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${ep_base}/Install/include) include_directories(${ep_base}/Install/include) #============================================================================= # external modules # set(external_module_paths) if (NOT EXTERNAL_MODULES_LOCATION STREQUAL "") message(STATUS "External modules: ${EXTERNAL_MODULES_LOCATION}") add_subdirectory("${EXTERNAL_MODULES_LOCATION}/src" external_modules) foreach(external_module ${config_module_list_external}) add_subdirectory(${EXTERNAL_MODULES_LOCATION}/src/${external_module} external_modules/${external_module}) list(APPEND external_module_paths ${EXTERNAL_MODULES_LOCATION}/src/${external_module}) endforeach() endif() #============================================================================= # Testing - Automatic unit and integration testing with CTest # # optionally enable cmake testing (supported only on posix) option(CMAKE_TESTING "Configure test targets" OFF) if(${PX4_CONFIG} STREQUAL "px4_sitl_test") set(CMAKE_TESTING ON) endif() if(CMAKE_TESTING) include(CTest) # sets BUILD_TESTING variable endif() # enable test filtering to run only specific tests with the ctest -R regex functionality set(TESTFILTER "" CACHE STRING "Filter string for ctest to selectively only run specific tests (ctest -R)") # if testing is enabled download and configure gtest list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake/gtest/) include(px4_add_gtest) if(BUILD_TESTING) include(gtest) add_custom_target(test_results COMMAND GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} --output-on-failure -T Test -R ${TESTFILTER} USES_TERMINAL DEPENDS px4 examples__dyn_hello USES_TERMINAL COMMENT "Running tests" WORKING_DIRECTORY ${PX4_BINARY_DIR}) set_target_properties(test_results PROPERTIES EXCLUDE_FROM_ALL TRUE) endif() #============================================================================= # subdirectories # add_library(parameters_interface INTERFACE) add_library(kernel_parameters_interface INTERFACE) add_library(events_interface INTERFACE) add_library(kernel_events_interface INTERFACE) include(px4_add_library) add_subdirectory(src/lib EXCLUDE_FROM_ALL) add_subdirectory(platforms/${PX4_PLATFORM}/src/px4) add_subdirectory(platforms EXCLUDE_FROM_ALL) if(EXISTS "${PX4_BOARD_DIR}/CMakeLists.txt") add_subdirectory(${PX4_BOARD_DIR}) endif() foreach(module ${config_module_list}) add_subdirectory(src/${module}) endforeach() # add events lib after modules and libs as it needs to know all source files (PX4_SRC_FILES) add_subdirectory(src/lib/events EXCLUDE_FROM_ALL) # metadata needs PX4_MODULE_CONFIG_FILES add_subdirectory(src/lib/metadata EXCLUDE_FROM_ALL) # must be the last module before firmware add_subdirectory(src/lib/parameters EXCLUDE_FROM_ALL) if(${PX4_PLATFORM} STREQUAL "nuttx" AND NOT CONFIG_BUILD_FLAT) target_link_libraries(parameters_interface INTERFACE usr_parameters) target_link_libraries(kernel_parameters_interface INTERFACE parameters) target_link_libraries(events_interface INTERFACE usr_events) target_link_libraries(kernel_events_interface INTERFACE events) else() target_link_libraries(parameters_interface INTERFACE parameters) target_link_libraries(events_interface INTERFACE events) endif() # firmware added last to generate the builtin for included modules add_subdirectory(platforms/${PX4_PLATFORM}) #============================================================================= # uORB graph generation: add a custom target 'uorb_graph' # set(uorb_graph_config ${PX4_BOARD}) set(graph_module_list "") foreach(module ${config_module_list}) set(graph_module_list "${graph_module_list}" "--src-path" "src/${module}") endforeach() add_custom_command(OUTPUT ${uorb_graph_config} COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/uorb_graph/create.py ${graph_module_list} --src-path src/lib --merge-depends --exclude-path src/examples --exclude-path src/lib/parameters # FIXME: enable & fix --file ${PX4_SOURCE_DIR}/Tools/uorb_graph/graph_${uorb_graph_config} WORKING_DIRECTORY ${PX4_SOURCE_DIR} COMMENT "Generating uORB graph" ) add_custom_target(uorb_graph DEPENDS ${uorb_graph_config}) include(bloaty) include(doxygen) include(metadata) include(package) # install python requirements using configured python add_custom_target(install_python_requirements COMMAND ${PYTHON_EXECUTABLE} -m pip install --break-system-packages --requirement ${PX4_SOURCE_DIR}/Tools/setup/requirements.txt DEPENDS ${PX4_SOURCE_DIR}/Tools/setup/requirements.txt USES_TERMINAL ) if(EXISTS "${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake/finalize.cmake") include(finalize) endif()
08-15
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/paddlehub/module/module.py", line 393, in __new__ module = cls.init_with_name( ^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/paddlehub/module/module.py", line 516, in init_with_name return user_module_cls(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/a123/.paddlehub/modules/pyramidbox_lite_server_mask/module.py", line 40, in __init__ self.face_detector = hub.Module(name='pyramidbox_lite_server') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/paddlehub/module/module.py", line 393, in __new__ module = cls.init_with_name( ^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/paddlehub/module/module.py", line 516, in init_with_name return user_module_cls(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/a123/.paddlehub/modules/pyramidbox_lite_server/module.py", line 31, in __init__ self._set_config() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/paddlehub/compat/paddle_utils.py", line 221, in runner return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/a123/.paddlehub/modules/pyramidbox_lite_server/module.py", line 43, in _set_config self.cpu_predictor = create_predictor(cpu_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: (NotFound) Operator (density_prior_box) is not registered. [Hint: op_info_ptr should not be null.] (at /Users/paddle/xly/workspace/7b5bf7ed-f223-4c37-9311-a1c9d604457b/Paddle/paddle/fluid/framework/op_info.h:152)
05-13
### 解决 PaddleHub 在 Mac 上运行口罩检测系统时出现的 `density_prior_box` 运算符未注册错误 #### 1. 错误原因分析 `RuntimeError: Operator (density_prior_box) is not registered` 的根本原因是当前安装的 PaddlePaddle 版本不支持 `density_prior_box` 操作符,或者所使用的模型与 PaddlePaddle 的版本不兼容。这种问题通常发生在低版本的 PaddlePaddle 中,因为某些新特性或操作符是在较新的版本中引入的[^5]。 #### 2. 升级 PaddlePaddle 到最新稳定版 确保安装的是最新的 PaddlePaddle 版本,特别是 GPU 或 CPU 支持的对应版本。可以尝试升级到更高版本以解决问题: ```bash pip uninstall paddlepaddle pip install paddlepaddle==latest_version_number ``` 替换 `latest_version_number` 为官方文档中标明的支持 `density_prior_box` 的最低版本号。例如,如果需要支持该运算符,则应至少更新至 2.4.0 及以上版本[^6]。 #### 3. 更新 PaddleHub 和相关依赖项 除了 PaddlePaddle 外,还需要同步更新 PaddleHub 至最新版本,以便匹配模型和框架间的接口变化: ```bash pip install --upgrade paddlehub ``` 此步骤有助于修复因 API 不一致引发的问题,并获取针对此类错误的新补丁[^7]。 #### 4. 使用替代模型规避问题 如果升级仍未能解决问题,考虑更换成其他无需依赖 `density_prior_box` 的模型。例如,选择轻量化的 MobileNetV3 结构的目标检测模型代替原有的金字塔结构模型: ```python model = hub.Module(name="yolov3_mobilenet_v3") ``` Yolo 系列模型具有良好的泛化能力和较快的速度表现,适合大多数实时性需求较高的场景应用[^8]。 #### 5. 手动编译源码重新构建环境(高级方法) 对于开发者而言,也可以通过克隆官方仓库并手动修改 C++ 层面实现来自定义添加缺失的操作符支持。但这要求熟悉底层开发流程且耗时较长,仅适用于特殊定制场合[^9]。 --- ### 注意事项 - **确认硬件适配性**:即使解决了软件层面冲突,还需注意实际运行设备是否满足性能指标要求。比如 MacBook Air M1 芯片相较于 Intel i7 更擅长处理神经网络任务。 - **备份现有配置**:在执行任何大规模改动之前记得做好项目副本保留工作以防万一恢复原始状态变得困难重重。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值