aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-10-11 12:25:27 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-10-15 12:27:24 +0000
commit1b3655d85cfb9cc143c9e7f0d3506e6b004f835e (patch)
tree08ddc01f3692fce7972b6f3a436cd9b774eb958d /low-can-binding
parent3331cf98d09874f6d480e17538ebb6a53a4adf71 (diff)
Migration to binding v3
Change-Id: I0bcccb15200064bd7d83edbf06c1e7202069189a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding')
-rw-r--r--low-can-binding/CMakeLists.txt2
-rw-r--r--low-can-binding/binding/low-can-apidef.json2
-rw-r--r--low-can-binding/binding/low-can-cb.cpp83
-rw-r--r--low-can-binding/binding/low-can-hat.hpp1
-rw-r--r--low-can-binding/binding/low-can-socket.hpp2
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp4
-rw-r--r--low-can-binding/binding/low-can-subscription.hpp6
-rw-r--r--low-can-binding/utils/signals.hpp2
-rw-r--r--low-can-binding/utils/socketcan.hpp2
9 files changed, 50 insertions, 54 deletions
diff --git a/low-can-binding/CMakeLists.txt b/low-can-binding/CMakeLists.txt
index b2892cc1..acbf4f18 100644
--- a/low-can-binding/CMakeLists.txt
+++ b/low-can-binding/CMakeLists.txt
@@ -50,7 +50,7 @@ PROJECT_TARGET_ADD(low-can)
# Binder exposes a unique public entry point
SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
PREFIX "afb-"
- LABELS "BINDINGV2"
+ LABELS "BINDINGV3"
LINK_FLAGS ${BINDINGS_LINK_FLAG}
OUTPUT_NAME ${TARGET_NAME}
)
diff --git a/low-can-binding/binding/low-can-apidef.json b/low-can-binding/binding/low-can-apidef.json
index 854bdd4a..24eb23be 100644
--- a/low-can-binding/binding/low-can-apidef.json
+++ b/low-can-binding/binding/low-can-apidef.json
@@ -12,7 +12,7 @@
"postfix": "",
"start": null ,
"onevent": null,
- "init": "initv2",
+ "init": "init_binding",
"scope": "",
"private": false
}
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp
index 0f97404c..c5a0138e 100644
--- a/low-can-binding/binding/low-can-cb.cpp
+++ b/low-can-binding/binding/low-can-cb.cpp
@@ -109,13 +109,13 @@ int read_message(sd_event_source *event_source, int fd, uint32_t revents, void *
///
///*******************************************************************************/
-static int make_subscription_unsubscription(struct afb_req request,
- std::shared_ptr<low_can_subscription_t>& can_subscription,
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s,
- bool subscribe)
+static int make_subscription_unsubscription(afb_req_t request,
+ std::shared_ptr<low_can_subscription_t>& can_subscription,
+ std::map<int, std::shared_ptr<low_can_subscription_t> >& s,
+ bool subscribe)
{
- /* Make the subscription or unsubscription to the event (if request contents are not null) */
- if(request.itf && request.closure &&
+ /* Make the subscription or unsubscription to the event (if request is not null) */
+ if(request &&
((subscribe ? afb_req_subscribe : afb_req_unsubscribe)(request, s[can_subscription->get_index()]->get_event())) < 0)
{
AFB_ERROR("Operation goes wrong for signal: %s", can_subscription->get_name().c_str());
@@ -125,7 +125,7 @@ static int make_subscription_unsubscription(struct afb_req request,
}
static int create_event_handle(std::shared_ptr<low_can_subscription_t>& can_subscription,
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
+ std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
{
int sub_index = can_subscription->get_index();
can_subscription->set_event(afb_daemon_make_event(can_subscription->get_name().c_str()));
@@ -141,10 +141,10 @@ static int create_event_handle(std::shared_ptr<low_can_subscription_t>& can_subs
/// @brief This will determine if an event handle needs to be created and checks if
/// we got a valid afb_event to get subscribe or unsubscribe. After that launch the subscription or unsubscription
/// against the application framework using that event handle.
-static int subscribe_unsubscribe_signal(struct afb_req request,
- bool subscribe,
- std::shared_ptr<low_can_subscription_t>& can_subscription,
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
+static int subscribe_unsubscribe_signal(afb_req_t request,
+ bool subscribe,
+ std::shared_ptr<low_can_subscription_t>& can_subscription,
+ std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
{
int ret = -1;
int sub_index = can_subscription->get_index();
@@ -161,7 +161,6 @@ static int subscribe_unsubscribe_signal(struct afb_req request,
else
{
/* Event doesn't exist , so let's create it */
- can_subscription->set_event({nullptr, nullptr});
s[sub_index] = can_subscription;
ret = create_event_handle(can_subscription, s);
}
@@ -184,12 +183,12 @@ static int add_to_event_loop(std::shared_ptr<low_can_subscription_t>& can_subscr
can_subscription.get()));
}
-static int subscribe_unsubscribe_diagnostic_messages(struct afb_req request,
- bool subscribe,
- std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages,
- struct event_filter_t& event_filter,
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s,
- bool perm_rec_diag_req)
+static int subscribe_unsubscribe_diagnostic_messages(afb_req_t request,
+ bool subscribe,
+ std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages,
+ struct event_filter_t& event_filter,
+ std::map<int, std::shared_ptr<low_can_subscription_t> >& s,
+ bool perm_rec_diag_req)
{
int rets = 0;
application_t& app = application_t::instance();
@@ -245,11 +244,11 @@ static int subscribe_unsubscribe_diagnostic_messages(struct afb_req request,
return rets;
}
-static int subscribe_unsubscribe_can_signals(struct afb_req request,
- bool subscribe,
- std::vector<std::shared_ptr<can_signal_t> > can_signals,
- struct event_filter_t& event_filter,
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
+static int subscribe_unsubscribe_can_signals(afb_req_t request,
+ bool subscribe,
+ std::vector<std::shared_ptr<can_signal_t> > can_signals,
+ struct event_filter_t& event_filter,
+ std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
{
int rets = 0;
for(const auto& sig: can_signals)
@@ -287,10 +286,10 @@ static int subscribe_unsubscribe_can_signals(struct afb_req request,
///
/// @return Number of correctly subscribed signal
///
-static int subscribe_unsubscribe_signals(struct afb_req request,
- bool subscribe,
- const struct utils::signals_found& signals,
- struct event_filter_t& event_filter)
+static int subscribe_unsubscribe_signals(afb_req_t request,
+ bool subscribe,
+ const struct utils::signals_found& signals,
+ struct event_filter_t& event_filter)
{
int rets = 0;
utils::signals_manager_t& sm = utils::signals_manager_t::instance();
@@ -304,10 +303,10 @@ static int subscribe_unsubscribe_signals(struct afb_req request,
return rets;
}
-static int one_subscribe_unsubscribe(struct afb_req request,
- bool subscribe,
- const std::string& tag,
- json_object* args)
+static int one_subscribe_unsubscribe(afb_req_t request,
+ bool subscribe,
+ const std::string& tag,
+ json_object* args)
{
int ret = 0;
struct event_filter_t event_filter;
@@ -341,7 +340,7 @@ static int one_subscribe_unsubscribe(struct afb_req request,
return ret;
}
-static int process_one_subscribe_args(struct afb_req request, bool subscribe, json_object *args)
+static int process_one_subscribe_args(afb_req_t request, bool subscribe, json_object *args)
{
int rc = 0, rc2=0;
json_object *x = nullptr, *event = nullptr;
@@ -367,7 +366,7 @@ static int process_one_subscribe_args(struct afb_req request, bool subscribe, js
return rc;
}
-static void do_subscribe_unsubscribe(struct afb_req request, bool subscribe)
+static void do_subscribe_unsubscribe(afb_req_t request, bool subscribe)
{
int rc = 0;
struct json_object *args, *x;
@@ -392,18 +391,18 @@ static void do_subscribe_unsubscribe(struct afb_req request, bool subscribe)
afb_req_fail(request, "error", NULL);
}
-void auth(struct afb_req request)
+void auth(afb_req_t request)
{
afb_req_session_set_LOA(request, 1);
afb_req_success(request, NULL, NULL);
}
-void subscribe(struct afb_req request)
+void subscribe(afb_req_t request)
{
do_subscribe_unsubscribe(request, true);
}
-void unsubscribe(struct afb_req request)
+void unsubscribe(afb_req_t request)
{
do_subscribe_unsubscribe(request, false);
}
@@ -484,7 +483,7 @@ static int write_signal(const std::string& name, uint64_t value)
return rc;
}
-void write(struct afb_req request)
+void write(afb_req_t request)
{
int rc = 0;
struct json_object* args = nullptr,
@@ -561,7 +560,7 @@ static struct json_object *get_signals_value(const std::string& name)
return ans;
}
-void get(struct afb_req request)
+void get(afb_req_t request)
{
int rc = 0;
struct json_object* args = nullptr,
@@ -619,7 +618,7 @@ static struct json_object *list_can_message(const std::string& name)
return ans;
}
-void list(struct afb_req request)
+void list(afb_req_t request)
{
int rc = 0;
json_object *ans = nullptr;
@@ -652,7 +651,7 @@ void list(struct afb_req request)
/// @param[in] service Structure which represent the Application Framework Binder.
///
/// @return Exit code, zero if success.
-int initv2()
+int init_binding(afb_api_t api)
{
uint32_t ret = 1;
can_bus_t& can_bus_manager = application_t::instance().get_can_bus_manager();
@@ -672,9 +671,7 @@ int initv2()
if(sf.can_signals.empty() && sf.diagnostic_messages.size() == 1)
{
- struct afb_req request;
- request.itf = nullptr;
- request.closure = nullptr;
+ afb_req_t request = nullptr;
struct event_filter_t event_filter;
event_filter.frequency = sf.diagnostic_messages.front()->get_frequency();
diff --git a/low-can-binding/binding/low-can-hat.hpp b/low-can-binding/binding/low-can-hat.hpp
index 248b62ce..e21b9cd0 100644
--- a/low-can-binding/binding/low-can-hat.hpp
+++ b/low-can-binding/binding/low-can-hat.hpp
@@ -28,7 +28,6 @@
class low_can_subscription_t;
-int initv2();
void on_no_clients(std::shared_ptr<low_can_subscription_t> can_subscription, std::map<int, std::shared_ptr<low_can_subscription_t> >& s);
void on_no_clients(std::shared_ptr<low_can_subscription_t> can_subscription, uint32_t pid, std::map<int, std::shared_ptr<low_can_subscription_t> >& s);
int read_message(sd_event_source *s, int fd, uint32_t revents, void *userdata);
diff --git a/low-can-binding/binding/low-can-socket.hpp b/low-can-binding/binding/low-can-socket.hpp
index dee7bd13..00f6825a 100644
--- a/low-can-binding/binding/low-can-socket.hpp
+++ b/low-can-binding/binding/low-can-socket.hpp
@@ -76,7 +76,7 @@ public:
float get_max() const;
utils::socketcan_bcm_t& get_socket();
- void set_event(struct afb_event event);
+ void set_event(afb_event_t event);
void set_frequency(float freq);
void set_min(float min);
void set_max(float max);
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index 20287b88..3f844da3 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -20,12 +20,12 @@
#include "application.hpp"
#include "canutil/write.h"
-struct afb_event& low_can_subscription_t::get_event()
+afb_event_t low_can_subscription_t::get_event()
{
return event_;
}
-void low_can_subscription_t::set_event(struct afb_event event)
+void low_can_subscription_t::set_event(afb_event_t event)
{
event_ = event;
}
diff --git a/low-can-binding/binding/low-can-subscription.hpp b/low-can-binding/binding/low-can-subscription.hpp
index 2e656b9a..0807feef 100644
--- a/low-can-binding/binding/low-can-subscription.hpp
+++ b/low-can-binding/binding/low-can-subscription.hpp
@@ -33,11 +33,11 @@
class low_can_subscription_t : public low_can_socket_t
{
private:
- struct afb_event event_; ///< event_ - application framework event used to push on client
+ afb_event_t event_; ///< event_ - application framework event used to push on client
public:
using low_can_socket_t::low_can_socket_t;
- struct afb_event& get_event();
- void set_event(struct afb_event event);
+ afb_event_t get_event();
+ void set_event(afb_event_t event);
};
diff --git a/low-can-binding/utils/signals.hpp b/low-can-binding/utils/signals.hpp
index 65316a7d..10cb8ad0 100644
--- a/low-can-binding/utils/signals.hpp
+++ b/low-can-binding/utils/signals.hpp
@@ -36,7 +36,7 @@ namespace utils
std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages;
};
- /// @brief Signal manager singleton hold subscription object with attached afb_event and its mutex
+ /// @brief Signal manager singleton hold subscription object with attached afb_event_t and its mutex
/// to read and write it safely.
/// It can be used to browse CAN signals and Diagnostic messages vectors and find a particular signal to
/// subscribe to.
diff --git a/low-can-binding/utils/socketcan.hpp b/low-can-binding/utils/socketcan.hpp
index 40e165bd..a1fdcb58 100644
--- a/low-can-binding/utils/socketcan.hpp
+++ b/low-can-binding/utils/socketcan.hpp
@@ -65,7 +65,7 @@ namespace utils
socketcan_t& operator<<(socketcan_t& s, const T& obj)
{
if (::sendto(s.socket(), &obj, sizeof(obj), 0, (const struct sockaddr*)&s.get_tx_address(), sizeof(s.get_tx_address())) < 0)
- AFB_ERROR("Error sending : %i %s", errno, ::strerror(errno));
+ AFB_API_ERROR(afbBindingV3root, "Error sending : %i %s", errno, ::strerror(errno));
return s;
}
}