summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
3331cf9)
Change-Id: I0bcccb15200064bd7d83edbf06c1e7202069189a
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
# -D_FORTIFY_SOURCE=2
# CACHE STRING "Compilation flags for RELEASE build type.")
# -D_FORTIFY_SOURCE=2
# CACHE STRING "Compilation flags for RELEASE build type.")
-add_definitions(-DAFB_BINDING_VERSION=2)
+add_definitions(-DAFB_BINDING_VERSION=3)
# Optional location for config.xml.in
# -----------------------------------
# Optional location for config.xml.in
# -----------------------------------
</feature>
<feature name="urn:AGL:widget:provided-api">
</feature>
<feature name="urn:AGL:widget:provided-api">
- <param name="low-can" value="ws" />
+ <param name="@API_NAME@" value="ws" />
- <feature name="urn:AGL:widget:required-binding">
- <param name="lib/afb-low-can.so" value="local" />
+ <feature name="urn:AGL:widget:required-api">
+ <param name="@WIDGET_ENTRY_POINT@" value="local" />
# Binder exposes a unique public entry point
SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
PREFIX "afb-"
# Binder exposes a unique public entry point
SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
PREFIX "afb-"
LINK_FLAGS ${BINDINGS_LINK_FLAG}
OUTPUT_NAME ${TARGET_NAME}
)
LINK_FLAGS ${BINDINGS_LINK_FLAG}
OUTPUT_NAME ${TARGET_NAME}
)
"postfix": "",
"start": null ,
"onevent": null,
"postfix": "",
"start": null ,
"onevent": null,
+ "init": "init_binding",
"scope": "",
"private": false
}
"scope": "",
"private": false
}
///
///*******************************************************************************/
///
///*******************************************************************************/
-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());
((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());
}
static int create_event_handle(std::shared_ptr<low_can_subscription_t>& can_subscription,
}
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()));
{
int sub_index = can_subscription->get_index();
can_subscription->set_event(afb_daemon_make_event(can_subscription->get_name().c_str()));
/// @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.
/// @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();
{
int ret = -1;
int sub_index = can_subscription->get_index();
else
{
/* Event doesn't exist , so let's create it */
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);
}
s[sub_index] = can_subscription;
ret = create_event_handle(can_subscription, s);
}
can_subscription.get()));
}
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();
{
int rets = 0;
application_t& app = application_t::instance();
-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)
{
int rets = 0;
for(const auto& sig: can_signals)
///
/// @return Number of correctly subscribed signal
///
///
/// @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();
{
int rets = 0;
utils::signals_manager_t& sm = utils::signals_manager_t::instance();
-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;
{
int ret = 0;
struct event_filter_t event_filter;
-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;
{
int rc = 0, rc2=0;
json_object *x = nullptr, *event = nullptr;
-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;
{
int rc = 0;
struct json_object *args, *x;
afb_req_fail(request, "error", NULL);
}
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);
}
{
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);
}
{
do_subscribe_unsubscribe(request, true);
}
-void unsubscribe(struct afb_req request)
+void unsubscribe(afb_req_t request)
{
do_subscribe_unsubscribe(request, false);
}
{
do_subscribe_unsubscribe(request, false);
}
-void write(struct afb_req request)
+void write(afb_req_t request)
{
int rc = 0;
struct json_object* args = nullptr,
{
int rc = 0;
struct json_object* args = nullptr,
-void get(struct afb_req request)
+void get(afb_req_t request)
{
int rc = 0;
struct json_object* args = nullptr,
{
int rc = 0;
struct json_object* args = nullptr,
-void list(struct afb_req request)
+void list(afb_req_t request)
{
int rc = 0;
json_object *ans = nullptr;
{
int rc = 0;
json_object *ans = nullptr;
/// @param[in] service Structure which represent the Application Framework Binder.
///
/// @return Exit code, zero if success.
/// @param[in] service Structure which represent the Application Framework Binder.
///
/// @return Exit code, zero if success.
+int init_binding(afb_api_t api)
{
uint32_t ret = 1;
can_bus_t& can_bus_manager = application_t::instance().get_can_bus_manager();
{
uint32_t ret = 1;
can_bus_t& can_bus_manager = application_t::instance().get_can_bus_manager();
if(sf.can_signals.empty() && sf.diagnostic_messages.size() == 1)
{
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();
struct event_filter_t event_filter;
event_filter.frequency = sf.diagnostic_messages.front()->get_frequency();
class low_can_subscription_t;
class low_can_subscription_t;
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);
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);
float get_max() const;
utils::socketcan_bcm_t& get_socket();
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);
void set_frequency(float freq);
void set_min(float min);
void set_max(float max);
#include "application.hpp"
#include "canutil/write.h"
#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()
-void low_can_subscription_t::set_event(struct afb_event event)
+void low_can_subscription_t::set_event(afb_event_t event)
class low_can_subscription_t : public low_can_socket_t
{
private:
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;
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);
std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages;
};
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.
/// 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.
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)
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));