我在 8 月 23 日更新了这篇文章以反映有效的解决方案。
我正在使用 sourceforge 上的 c BACnet Stack。 http://sourceforge.net/projects/bacnet/
我正在尝试修改库中包含的演示服务器。服务器几乎完全按照我的意愿执行,除了我需要将它连接到我编写的其他一些 c 程序。
我现在的问题是我不知道如何将我自己的 c 程序添加到演示服务器中。演示中有几个嵌套的 Makefile。我尝试将我的文件添加到这些 Makefile 中,但编译器 (gcc) 不喜欢它。
最新的错误是:No rule to make target ../../demo/object/test.o', needed by
bacserv'。停止。
我不是交流专家。我已经在业余时间使用它大约一年了。我了解 Makefile 的基础知识,但这个演示中的 Makefile 显然超出了我的范围。
有没有熟悉这个库的人可以给我一点帮助?
有没有比 sourceforge 网站上更好的文档?
在此示例中,我只是尝试将 test.c 添加到 ai.c。
/demo/server/Makefile
OBJECT_SRC = \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/av.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/bo.c \
$(BACNET_OBJECT)/bv.c \
$(BACNET_OBJECT)/csv.c \
$(BACNET_OBJECT)/lc.c \
$(BACNET_OBJECT)/lsp.c \
$(BACNET_OBJECT)/ms-input.c \
$(BACNET_OBJECT)/mso.c \
$(BACNET_OBJECT)/msv.c \
$(BACNET_OBJECT)/nc.c \
$(BACNET_OBJECT)/trendlog.c \
$(BACNET_OBJECT)/test.c \ <-- New entry
$(BACNET_OBJECT)/bacfile.c
/lib/Makefile
CORE_SRC = \
$(BACNET_CORE)/apdu.c \
$(BACNET_CORE)/npdu.c \
$(BACNET_CORE)/bacdcode.c \
$(BACNET_CORE)/bacint.c \
$(BACNET_CORE)/bacreal.c \
$(BACNET_CORE)/bacstr.c \
$(BACNET_CORE)/bacapp.c \
$(BACNET_CORE)/bacprop.c \
$(BACNET_CORE)/bactext.c \
$(BACNET_CORE)/datetime.c \
$(BACNET_CORE)/indtext.c \
$(BACNET_CORE)/key.c \
$(BACNET_CORE)/keylist.c \
$(BACNET_CORE)/proplist.c \
$(BACNET_CORE)/debug.c \
$(BACNET_CORE)/bigend.c \
$(BACNET_CORE)/arf.c \
$(BACNET_CORE)/awf.c \
$(BACNET_CORE)/cov.c \
$(BACNET_CORE)/dcc.c \
$(BACNET_CORE)/iam.c \
$(BACNET_CORE)/ihave.c \
$(BACNET_CORE)/rd.c \
$(BACNET_CORE)/rp.c \
$(BACNET_CORE)/rpm.c \
$(BACNET_CORE)/timesync.c \
$(BACNET_CORE)/whohas.c \
$(BACNET_CORE)/whois.c \
$(BACNET_CORE)/wp.c \
$(BACNET_CORE)/wpm.c \
$(BACNET_CORE)/abort.c \
$(BACNET_CORE)/reject.c \
$(BACNET_CORE)/bacerror.c \
$(BACNET_CORE)/ptransfer.c \
$(BACNET_CORE)/memcopy.c \
$(BACNET_CORE)/filename.c \
$(BACNET_CORE)/tsm.c \
$(BACNET_CORE)/bacaddr.c \
$(BACNET_CORE)/address.c \
$(BACNET_CORE)/bacdevobjpropref.c \
$(BACNET_CORE)/bacpropstates.c \
$(BACNET_CORE)/alarm_ack.c \
$(BACNET_CORE)/event.c \
$(BACNET_CORE)/getevent.c \
$(BACNET_CORE)/get_alarm_sum.c \
$(BACNET_CORE)/readrange.c \
$(BACNET_CORE)/timestamp.c \
$(BACNET_CORE)/test.c \ <-- Do not include test.c in this Makefile at all
$(BACNET_CORE)/version.c
新文件位置:
test.c is located in /src <-- Should be located in /demo/object
test.h is located in /include <-- This works ok here
测试.h
#ifndef _TEST_INCLUDE_
#define _TEST_INCLUDE_
void printit();
#endif
测试.c
#include <stdio.h> <-- Needed to add #include <stdio.h>
#include "test.h"
void printit (){
printf("it....");
}
/demo/object/ai.c
...
#include "handlers.h"
#include "timestamp.h"
#include "test.h"
#include "ai.h"
...
void Analog_Input_Init(
void)
{
unsigned i;
#if defined(INTRINSIC_REPORTING)
unsigned j;
#endif
printit(); //*****************************************************************
for (i = 0; i < MAX_ANALOG_INPUTS; i++) {
printf("Initializing AI:%u\n",i);
AI_Descr[i].Present_Value = 0.0f;
AI_Descr[i].Out_Of_Service = false;
AI_Descr[i].Units = UNITS_PERCENT;
AI_Descr[i].Reliability = RELIABILITY_NO_FAULT_DETECTED;
#if defined(INTRINSIC_REPORTING)
AI_Descr[i].Event_State = EVENT_STATE_NORMAL;
/* notification class not connected */
AI_Descr[i].Notification_Class = BACNET_MAX_INSTANCE;
/* initialize Event time stamps using wildcards
and set Acked_transitions */
for (j = 0; j < MAX_BACNET_EVENT_TRANSITION; j++) {
datetime_wildcard_set(&AI_Descr[i].Event_Time_Stamps[j]);
AI_Descr[i].Acked_Transitions[j].bIsAcked = true;
}
/* Set handler for GetEventInformation function */
handler_get_event_information_set(OBJECT_ANALOG_INPUT,
Analog_Input_Event_Information);
/* Set handler for AcknowledgeAlarm function */
handler_alarm_ack_set(OBJECT_ANALOG_INPUT, Analog_Input_Alarm_Ack);
/* Set handler for GetAlarmSummary Service */
handler_get_alarm_summary_set(OBJECT_ANALOG_INPUT,
Analog_Input_Alarm_Summary);
#endif
}
}