diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-07-20 10:14:56 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-07-20 13:23:15 +0000 |
commit | 944295b5af95fdcb1a33e2028ef709e7bf60cb6e (patch) | |
tree | b22ddde59ab0f0fd3fabdb87413105b9571cdf9b /low-can-binding/binding | |
parent | 5d58986bc8389a44741486c5856f39f51a4c6e39 (diff) |
Fix: align bindingv2 struct with dab appfw version
DAB Fixes follows appfw API break.
Following functions now return 0 on success and negative value
on failure :
o afb_req_subcall
o afb_req_subcall_sync
o afb_service_call
o afb_service_call_sync
Verbosity macros used in v2 bindings now needs to be prefixed
with AFB_ (ERROR -> AFB_ERROR)
New field for afb_verb_v2 and afb_binding_v2 structures
Fix: uninitialized variables.
Change-Id: Ia728b9ac4576b9b44c8c7c054820b7c64a314942
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/binding')
-rw-r--r-- | low-can-binding/binding/low-can-cb.cpp | 18 | ||||
-rw-r--r-- | low-can-binding/binding/low-can-hat.cpp | 9 |
2 files changed, 14 insertions, 13 deletions
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp index 824aa81..e2ddf07 100644 --- a/low-can-binding/binding/low-can-cb.cpp +++ b/low-can-binding/binding/low-can-cb.cpp @@ -105,7 +105,7 @@ static int make_subscription_unsubscription(struct afb_req request, std::shared_ /* Make the subscription or unsubscription to the event */ if (((subscribe ? afb_req_subscribe : afb_req_unsubscribe)(request, s[can_subscription->get_index()]->get_event())) < 0) { - ERROR("Operation goes wrong for signal: %s", can_subscription->get_name().c_str()); + AFB_ERROR("Operation goes wrong for signal: %s", can_subscription->get_name().c_str()); return -1; } return 0; @@ -118,7 +118,7 @@ static int create_event_handle(std::shared_ptr<low_can_subscription_t>& can_subs s[sub_index] = can_subscription; if (!afb_event_is_valid(s[sub_index]->get_event())) { - ERROR("Can't create an event for %s, something goes wrong.", can_subscription->get_name().c_str()); + AFB_ERROR("Can't create an event for %s, something goes wrong.", can_subscription->get_name().c_str()); return -1; } return 0; @@ -136,7 +136,7 @@ static int subscribe_unsubscribe_signal(struct afb_req request, bool subscribe, { if (!afb_event_is_valid(s[sub_index]->get_event()) && !subscribe) { - NOTICE("Event isn't valid, no need to unsubscribed."); + AFB_NOTICE("Event isn't valid, no need to unsubscribed."); ret = -1; } ret = 0; @@ -192,22 +192,22 @@ static int subscribe_unsubscribe_diagnostic_messages(struct afb_req request, boo diag_m.add_recurring_request(diag_req, sig->get_name().c_str(), false, sig->get_decoder(), sig->get_callback(), event_filter.frequency); if(can_subscription->create_rx_filter(sig) < 0) {return -1;} - DEBUG("Signal: %s subscribed", sig->get_name().c_str()); + AFB_DEBUG("Signal: %s subscribed", sig->get_name().c_str()); if(it == s.end() && add_to_event_loop(can_subscription) < 0) { diag_m.cleanup_request( diag_m.find_recurring_request(*diag_req), true); - WARNING("signal: %s isn't supported. Canceling operation.", sig->get_name().c_str()); + AFB_WARNING("signal: %s isn't supported. Canceling operation.", sig->get_name().c_str()); return -1; } } else { if(sig->get_supported()) - {DEBUG("%s cancelled due to unsubscribe", sig->get_name().c_str());} + {AFB_DEBUG("%s cancelled due to unsubscribe", sig->get_name().c_str());} else { - WARNING("signal: %s isn't supported. Canceling operation.", sig->get_name().c_str()); + AFB_WARNING("signal: %s isn't supported. Canceling operation.", sig->get_name().c_str()); return -1; } } @@ -246,7 +246,7 @@ static int subscribe_unsubscribe_can_signals(struct afb_req request, bool subscr {return -1;} rets++; - DEBUG("signal: %s subscribed", sig->get_name().c_str()); + AFB_DEBUG("signal: %s subscribed", sig->get_name().c_str()); } return rets; } @@ -308,7 +308,7 @@ static int one_subscribe_unsubscribe(struct afb_req request, bool subscribe, con openxc_DynamicField search_key = build_DynamicField(tag); sf = utils::signals_manager_t::instance().find_signals(search_key); if (sf.can_signals.empty() && sf.diagnostic_messages.empty()) - NOTICE("No signal(s) found for %s.", tag.c_str()); + AFB_NOTICE("No signal(s) found for %s.", tag.c_str()); else ret = subscribe_unsubscribe_signals(request, subscribe, sf, event_filter); diff --git a/low-can-binding/binding/low-can-hat.cpp b/low-can-binding/binding/low-can-hat.cpp index 7113b69..6709089 100644 --- a/low-can-binding/binding/low-can-hat.cpp +++ b/low-can-binding/binding/low-can-hat.cpp @@ -34,14 +34,15 @@ extern "C" static const struct afb_verb_v2 verbs[]= { - { .verb= "subscribe", .callback= subscribe, .auth= NULL, .session= AFB_SESSION_NONE}, - { .verb= "unsubscribe", .callback= unsubscribe, .auth= NULL, .session= AFB_SESSION_NONE}, - { .verb= NULL, .callback= NULL, .auth= NULL, .session= 0} + { .verb= "subscribe", .callback= subscribe, .auth= NULL, .info="Let subscribe to signals", .session= AFB_SESSION_NONE}, + { .verb= "unsubscribe", .callback= unsubscribe, .auth= NULL, .info="Let unsubscribe signals", .session= AFB_SESSION_NONE}, + { .verb= NULL, .callback= NULL, .auth= NULL, .info=NULL, .session= 0} }; const struct afb_binding_v2 afbBindingV2 { .api = "low-can", .specification = NULL, + .info = "API to Low level CAN service, read and decode the bus", .verbs = verbs, .preinit = NULL, .init = initv2, @@ -67,7 +68,7 @@ extern "C" if(application_t::instance().get_diagnostic_manager().initialize()) return 0; - ERROR("There was something wrong with CAN device Initialization."); + AFB_ERROR("There was something wrong with CAN device Initialization."); return 1; } }; |