message(STATUS "Creation of ${PROJECT_NAME} binding for AFB-DAEMON")
###########################################################################
-add_library(${PROJECT_NAME}-binding MODULE ${PROJECT_NAME}-binding.cpp can-signals.cpp can-utils.cpp obd2.cpp)
+add_library(${PROJECT_NAME}-binding MODULE ${PROJECT_NAME}-binding.cpp can-signals.cpp can-utils.cpp can_reader.cpp can_decode_message.cpp can_event_push.cpp openxc-utils.cpp timer.cpp)
+#add_library(${PROJECT_NAME}-binding MODULE ${PROJECT_NAME}-binding.cpp can-signals.cpp can-utils.cpp obd2.cpp)
set_target_properties(${PROJECT_NAME}-binding PROPERTIES
PREFIX ""
break;
}
return signals;
-}
-
- struct CanMessageDefinition* message;
- const char* genericName;
- uint8_t bitPosition;
- uint8_t bitSize;
- float factor;
- float offset;
- float minValue;
- float maxValue;
- FrequencyClock frequencyClock;
- bool sendSame;
- bool forceSendChanged;
- const CanSignalState* states;
- uint8_t stateCount;
- bool writable;
- SignalDecoder decoder;
- SignalEncoder encoder;
- bool received;
- float lastValue;
\ No newline at end of file
+}
\ No newline at end of file
#include <afb/afb-event-itf.h>
}
-#define MESSAGE_SET_ID 0
-
-/** Can signal event map making access to afb_event
- * external to openxc existing structure.
- */
-static std::map<std::string, struct afb_event> subscribed_signals;
-static std::map<std::string, struct afb_event>::iterator subscribed_signals_i;
-
/**
* @brief Dumb SIGNALS array. It is composed by CanMessageSet
* SIGNALS[MESSAGE_SET_ID][CanSignal]
*/
std::vector<std::vector<CanSignal>> SIGNALS {
- { // message set: example
- }
+ {}// message set: example
};
/** Public: Return the currently active CAN configuration. */
*/
void can_bus_dev_t::start_reading()
{
- th_reading_ = std::thread(can_reader, *this);
- is_running_ = true;
+ th_reading_ = std::thread(can_reader, std::ref(*this));
+ is_running_ = true; is_running_ = true;
}
/*
*/
void can_bus_t::start_threads()
{
- th_decoding_ = std::thread(can_decode_message, *this);
- th_pushing_ = std::thread(can_event_push, *this);
+ th_decoding_ = std::thread(can_decode_message, std::ref(*this));
+ th_pushing_ = std::thread(can_event_push, std::ref(*this));
}
/**
* limitations under the License.
*/
-#include "low-can-binding.hpp"
+#include "can_decode_message.hpp"
void can_decode_message(can_bus_t &can_bus)
{
- can_message_t can_message;
- std:vector <CanSignal> signals;
- std:vector <CanSignal>::iterator signals_i;
+ can_message_t can_message(interface) ;
+ std::vector <CanSignal> signals;
+ std::vector <CanSignal>::iterator signals_i;
openxc_VehicleMessage vehicle_message;
openxc_DynamicField search_key, ret;
bool send = true;
if(can_message = can_bus.next_can_message(interface))
{
/* First we have to found which CanSignal is */
- search_key = build_DynamicField(openxc_DynamicField_Type::openxc_DynamicField_Type_NUM, (double)can_message.get_id())
+ search_key = build_DynamicField((double)can_message.get_id())
signals = find_can_signals(search_key);
/* Decoding the message ! Don't kill the messenger ! */
* limitations under the License.
*/
-#include "low-can-binding.hpp"
+#include "can_event_push.hpp"
void can_event_push(can_bus_t& can_bus)
{
* limitations under the License.
*/
-#include "low-can-binding.hpp"
+#include "can_reader.hpp"
void can_reader(can_bus_dev_t &can_bus)
{
#include <linux/can/raw.h>
#include <systemd/sd-event.h>
-#include "obd2.hpp"
#include "timer.hpp"
#include "openxc.pb.h"
#include "can-utils.hpp"
#include "can-decoder.hpp"
#include "openxc-utils.hpp"
+#define MESSAGE_SET_ID 0
+
/*
* Interface between the daemon and the binding
*/
* @return Exit code, zero if success.
*/
int afbBindingV1ServiceInit(struct afb_service service);
-};
\ No newline at end of file
+};
+
+/** Can signal event map making access to afb_event
+ * external to openxc existing structure.
+ */
+static std::map<std::string, struct afb_event> subscribed_signals;
+static std::map<std::string, struct afb_event>::iterator subscribed_signals_i;
* limitations under the License.
*/
+#include "obd2.hpp"
-void shims_logger(afb_binding_interface *itf)
+void shims_logger(const char* m, const struct afb_binding_interface *interface)
{
- //DEBUG(itf, "dd");
+ DEBUG(interface, "%s", m);
}
void shims_timer()
/*
* Will scan for supported Obd2 pids
*/
-obd2_handler_t::obd2_handler_t(afb_binding_interface *itf, can_bus_t cb)
+obd2_handler_t::obd2_handler_t(const struct afb_binding_interface *interface, can_bus_t can_bus)
+ : can_bus_{can_bus}
{
- can_bus_t can_bus = cb;
- DiagnosticShims shims = diagnostic_init_shims(shims_logger, can_bus.send_can_message, NULL);
+ can_bus_t can_bus_ = can_bus;
+ DiagnosticShims shims_ = diagnostic_init_shims(shims_logger, can_bus.send_can_message, NULL);
- int n_pids, i;
+ int n_pids_, i_;
- n_pids = size(Obd2Pid);
- for(i=0; i<=n_pids; i++)
+ n_pids_ = size(Obd2Pid);
+ for(i_=0; i_<=n_pids_; i_++)
{
}
}
* limitations under the License.
*/
+ #pragma once
+
#include <vector>
#include "uds/uds.h"
+#include "can-utils.hpp"
+
extern "C"
{
#include <afb/afb-binding.h>