Code Review
/
apps
/
low-level-can-service.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Cleaning old can_bus_dev_t now implemented
[apps/low-level-can-service.git]
/
src
/
low-can-binding.cpp
diff --git
a/src/low-can-binding.cpp
b/src/low-can-binding.cpp
index
13452a4
..
46dcbf2
100644
(file)
--- a/
src/low-can-binding.cpp
+++ b/
src/low-can-binding.cpp
@@
-22,12
+22,12
@@
#include <mutex>
#include <vector>
#include <thread>
#include <mutex>
#include <vector>
#include <thread>
-#include <fcntl.h>
#include <linux/can.h>
#include <json-c/json.h>
#include <systemd/sd-event.h>
#include "openxc.pb.h"
#include <linux/can.h>
#include <json-c/json.h>
#include <systemd/sd-event.h>
#include "openxc.pb.h"
+#include "configuration.hpp"
#include "can/can-bus.hpp"
#include "can/can-signals.hpp"
#include "can/can-message.hpp"
#include "can/can-bus.hpp"
#include "can/can-signals.hpp"
#include "can/can-message.hpp"
@@
-40,12
+40,9
@@
extern "C"
#include <afb/afb-service-itf.h>
};
#include <afb/afb-service-itf.h>
};
-/*
- * Interface between the daemon and the binding
- */
+// Interface between the daemon and the binding
const struct afb_binding_interface *binder_interface;
const struct afb_binding_interface *binder_interface;
-
-can_bus_t *can_bus_handler;
+configuration_t *config;
/********************************************************************************
*
/********************************************************************************
*
@@
-82,7
+79,7
@@
static int subscribe_unsubscribe_signal(struct afb_req request, bool subscribe,
std::lock_guard<std::mutex> subscribed_signals_lock(get_subscribed_signals_mutex());
std::map<std::string, struct afb_event>& s = get_subscribed_signals();
std::lock_guard<std::mutex> subscribed_signals_lock(get_subscribed_signals_mutex());
std::map<std::string, struct afb_event>& s = get_subscribed_signals();
- if (s.find(sig) != s.end() && !afb_event_is_valid(s[s
td::string(sig)
]))
+ if (s.find(sig) != s.end() && !afb_event_is_valid(s[s
ig
]))
{
if(!subscribe)
{
{
if(!subscribe)
{
@@
-90,12
+87,14
@@
static int subscribe_unsubscribe_signal(struct afb_req request, bool subscribe,
ret = -1;
}
else
ret = -1;
}
else
+ {
/* Event it isn't valid annymore, recreate it */
ret = create_event_handle(sig, s);
/* Event it isn't valid annymore, recreate it */
ret = create_event_handle(sig, s);
+ }
}
else
{
}
else
{
- /* Event don't exist , so let's create it */
+ /* Event do
es
n't exist , so let's create it */
struct afb_event empty_event = {nullptr, nullptr};
subscribed_signals[sig] = empty_event;
ret = create_event_handle(sig, s);
struct afb_event empty_event = {nullptr, nullptr};
subscribed_signals[sig] = empty_event;
ret = create_event_handle(sig, s);
@@
-222,18
+221,17
@@
extern "C"
*/
int afbBindingV1ServiceInit(struct afb_service service)
{
*/
int afbBindingV1ServiceInit(struct afb_service service)
{
- int fd_conf;
- fd_conf = afb_daemon_rootdir_open_locale(binder_interface->daemon, "can_buses.json", O_RDONLY, NULL);
+ config = new configuration_t();
- /* Initialize the CAN bus handler */
- can_bus_handler = new can_bus_t(fd_conf);
+ can_bus_t& can_bus_manager = config->get_can_bus_manager();
/* Open CAN socket */
/* Open CAN socket */
- if(can_bus_
handler->
init_can_dev() == 0)
+ if(can_bus_
manager.
init_can_dev() == 0)
{
{
- can_bus_
handler->
start_threads();
+ can_bus_
manager.
start_threads();
return 0;
}
return 0;
}
+
ERROR(binder_interface, "There was something wrong with CAN device Initialization. Check your config file maybe");
return 1;
}
ERROR(binder_interface, "There was something wrong with CAN device Initialization. Check your config file maybe");
return 1;
}