Commit 1d7f7d8e authored by Micha Mueller's avatar Micha Mueller
Browse files

Extend Makefile to compile BACnet plugin. Some bugfixes to BACnet files....

Extend Makefile to compile BACnet plugin. Some bugfixes to BACnet files. However, there are still some compiler errors left to resolve
parent e3f9034d
......@@ -10,7 +10,7 @@ CXXFLAGS = -std=c++11 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -O2 -g -Wall -Wno-
PLUGINFLAGS = -fPIC -c $(CXXFLAGS)
LIBS = -L../deps/mosquitto_build/lib -L$(DCDBDEPLOYPATH)/lib/ -ldl -lmosquitto -lboost_system -lboost_thread -lboost_log_setup -lboost_log -lpthread -rdynamic
OBJS = dcdbpusher.o Configuration.o Sensor.o MQTTPusher.o
PLUGINS = libdcdbplugin_pdu.so.1.0 libdcdbplugin_perfevent.so.1.0 libdcdbplugin_sysfs.so.1.0 libdcdbplugin_ipmi.so.1.0
PLUGINS = libdcdbplugin_pdu.so.1.0 libdcdbplugin_perfevent.so.1.0 libdcdbplugin_sysfs.so.1.0 libdcdbplugin_ipmi.so.1.0 libdcdbplugin_bacnet.so.1.0
$(TARGET): $(PLUGINS) $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
......@@ -48,3 +48,9 @@ libdcdbplugin_pdu.so.1.0:
$(CXX) $(PLUGINFLAGS) sensors/pdu/PDUUnit.cpp
$(CXX) $(PLUGINFLAGS) sensors/pdu/PDUConfigurator.cpp
$(CXX) -shared -Wl,-soname,libdcdbplugin_pdu.so.1 -o libdcdbplugin_pdu.so.1.0 PDUSensor.o PDUUnit.o PDUConfigurator.o -L$(DCDBDEPLOYPATH)/lib/ -lcrypto -lssl
libdcdbplugin_bacnet.so.1.0:
$(CXX) $(PLUGINFLAGS) sensors/bacnet/BACnetSensor.cpp
$(CXX) $(PLUGINFLAGS) sensors/bacnet/BACnetClient.cpp
$(CXX) $(PLUGINFLAGS) sensors/bacnet/BACnetConfigurator.cpp
$(CXX) -shared -Wl,-soname,libdcdbplugin_bacnet.so.1 -o libdcdbplugin_bacnet.so.1.0 BACnetSensor.o BACnetClient.o BACnetConfigurator.o -lbacnet
......@@ -18,6 +18,8 @@
#include "bacnetTEMP/rp.h"
#include "bacnetTEMP/tsm.h"
#include <functional>
BACnetClient::BACnetClient() {
_strand = NULL;
_invokeId = 0;
......@@ -51,14 +53,17 @@ void BACnetClient::init(std::string interface, unsigned port, unsigned timeout,
//Device_Init(NULL); // Initializes Device Object; TODO do we need this?
using namespace std::placeholders; // for _1, _2, ...
/* set the handler for all the services we don't implement
It is required to send the proper reject message... */
apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service);
//TODO make it accept the method. but i would like to avoid just making it static...
apdu_set_unrecognized_service_handler_handler(std::bind(&BACnetClient::unrecognizedServiceHandler, this, _1, _2, _3, _4));
//NOTE: no handler for read property set even though it is required. We are no real BACnet device
/* we only need to handle the data coming back from confirmed (read property) requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY, readPropertyAckHandler); //TODO implement read_property_ack_handler
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY, readPropertyAckHandler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY, errorHandler);
......@@ -103,9 +108,9 @@ uint64_t BACnetClient::readProperty(uint32_t deviceObjInstance, uint32_t objInst
}
/* encode the NPDU portion of the packet */
datalink_get_my_address(&my_address);
datalink_get_my_address(&myAddr);
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
pdu_lenSent = npdu_encode_pdu(&_handlerTransmitBuffer[0], &_targetAddress, &my_address, &npdu_data);
pdu_lenSent = npdu_encode_pdu(&_handlerTransmitBuffer[0], &_targetAddress, &myAddr, &npdu_data);
/* encode the APDU portion of the packet */
data.object_type = objType;
......@@ -122,7 +127,9 @@ uint64_t BACnetClient::readProperty(uint32_t deviceObjInstance, uint32_t objInst
tsm_set_confirmed_unsegmented_transaction(_invokeId, &_targetAddress, &npdu_data, &_handlerTransmitBuffer[0], (uint16_t) pdu_lenSent);
bytes_sent = datalink_send_pdu(&_targetAddress, &npdu_data, &_handlerTransmitBuffer[0], pdu_lenSent);
if (bytes_sent <= 0) {
throw std::runtime_error("Failed to Send ReadProperty Request (%s)", strerror(errno));
std::string errorMsg = strerror(errno);
std::string str = "Failed to send ReadProperty Request ";
throw std::runtime_error(str + errorMsg);
}
} else {
tsm_free_invoke_id(_invokeId);
......@@ -140,7 +147,7 @@ uint64_t BACnetClient::readProperty(uint32_t deviceObjInstance, uint32_t objInst
#ifdef DEBUG
LOG(debug) << "BACnet: Protocol Version = " << (unsigned) RecBuf[0];
#else
#endif
apdu_offset = npdu_decode(&RecBuf[0], &destRec, &src, &npdu_dataRec);
if (npdu_data.network_layer_message) {
......
......@@ -11,6 +11,7 @@
#include "../../Sensor.h" //only for logging
//TODO where to put bacnet?
#include "bacnetTEMP/apdu.h"
#include "bacnetTEMP/bacenum.h"
#include "bacnetTEMP/datalink.h"
#include <boost/asio.hpp>
......
......@@ -11,7 +11,7 @@
#include "../../Sensor.h"
#include "BACnetClient.h"
#include "bacenum.h"
#include "bacnetTEMP/bacenum.h"
class BACnetSensor: public Sensor {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment