message: More explicit define about CAN protocols. 19/23219/6
authorRomain Forlot <romain.forlot@iot.bzh>
Wed, 20 Nov 2019 12:02:24 +0000 (13:02 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 9 Jan 2020 14:55:03 +0000 (15:55 +0100)
Change a bit CAN binding define about used protocol. There was a mistake
about BCM define which isn't a protocol at all but a maner to filter
and retrieve CAN message through SocketCAN. Also FD_FRAME was using the
same name than SocketCAN which isn't a good idea, better to distinguis both
of them.

Bug-AGL: SPEC-2988

Change-Id: I255fa03029c7d5f90a33448e5e7692d8c249279b
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
low-can-binding/binding/low-can-cb.cpp
low-can-binding/binding/low-can-subscription.cpp
low-can-binding/can/message-definition.cpp
low-can-binding/can/message/message.hpp

index 0445de3..14e1f87 100644 (file)
@@ -526,7 +526,7 @@ static int send_message(message_t *message, const std::string& bus_name, uint32_
        cd[bus_name]->set_signal(signal);
 
 
-       if(flags&BCM_PROTOCOL)
+       if(flags&CAN_PROTOCOL)
                return low_can_subscription_t::tx_send(*cd[bus_name], message, bus_name);
 #ifdef USE_FEATURE_ISOTP
        else if(flags&ISOTP_PROTOCOL)
@@ -552,12 +552,12 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess
        if( !sf.signals.empty() )
        {
                AFB_DEBUG("ID WRITE RAW : %d", sf.signals.front()->get_message()->get_id());
-               if(flags & BCM_PROTOCOL)
+               if(flags & CAN_PROTOCOL)
                {
                        if(sf.signals.front()->get_message()->is_fd())
                        {
                                AFB_DEBUG("CANFD_MAX_DLEN");
-                               message->set_flags(CAN_FD_FRAME);
+                               message->set_flags(CAN_PROTOCOL_WITH_FD_FRAME);
                                message->set_maxdlen(CANFD_MAX_DLEN);
                        }
                        else
@@ -591,7 +591,7 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess
                }
                else
                {
-                       if(flags&BCM_PROTOCOL)
+                       if(flags&CAN_PROTOCOL)
                                afb_req_fail(request, "Invalid", "Frame BCM");
                        else if(flags&J1939_PROTOCOL)
                                afb_req_fail(request, "Invalid", "Frame J1939");
@@ -631,7 +631,7 @@ static void write_frame(afb_req_t request, const std::string& bus_name, json_obj
                                  "can_data", &can_data))
        {
                message = new can_message_t(0, id, length, false, 0, data, 0);
-               write_raw_frame(request, bus_name, message, can_data, BCM_PROTOCOL, event_filter);
+               write_raw_frame(request, bus_name, message, can_data, CAN_PROTOCOL, event_filter);
        }
 #ifdef USE_FEATURE_J1939
        else if(!wrap_json_unpack(json_value, "{si, si, so !}",
@@ -688,7 +688,7 @@ static void write_signal(afb_req_t request, const std::string& name, json_object
        else if(sig->get_message()->is_isotp())
                flags = ISOTP_PROTOCOL;
        else
-               flags = BCM_PROTOCOL;
+               flags = CAN_PROTOCOL;
 
 //     cfd = encoder_t::build_frame(sig, value);
        message_t *message = encoder_t::build_message(sig, value, false, false);
index c3a0b3f..05367b7 100644 (file)
@@ -364,7 +364,7 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co
        int ret = -1;
        if(! subscription.socket_)
        {
-               if(flags & BCM_PROTOCOL)
+               if(flags & CAN_PROTOCOL)
                {
                        subscription.socket_ = std::make_shared<utils::socketcan_bcm_t>();
                        if( subscription.signal_ )
@@ -666,7 +666,7 @@ int low_can_subscription_t::create_rx_filter(std::shared_ptr<diagnostic_message_
 int low_can_subscription_t::create_rx_filter_bcm(low_can_subscription_t &subscription, struct bcm_msg& bcm_msg)
 {
        // Make sure that socket is opened.
-       if(subscription.open_socket(subscription, "", BCM_PROTOCOL) < 0)
+       if(subscription.open_socket(subscription, "", CAN_PROTOCOL) < 0)
                return -1;
 
        // If it's not an OBD2 CAN ID then just add a simple RX_SETUP job
@@ -709,7 +709,7 @@ int low_can_subscription_t::tx_send(low_can_subscription_t &subscription, messag
 
        std::vector<canfd_frame> cfd_vect = cm->convert_to_canfd_frame_vector();
 
-       if(subscription.open_socket(subscription, bus_name, BCM_PROTOCOL) < 0)
+       if(subscription.open_socket(subscription, bus_name, CAN_PROTOCOL) < 0)
                return -1;
 
        struct bcm_msg &bcm_cm = cm->get_bcm_msg();
index 8060982..6354127 100644 (file)
@@ -79,12 +79,12 @@ uint32_t message_definition_t::get_id() const
 
 bool message_definition_t::is_fd() const
 {
-       return (flags_&FD_FRAME);
+       return (flags_ & CAN_PROTOCOL_WITH_FD_FRAME);
 }
 
 bool message_definition_t::is_j1939() const
 {
-       return (flags_&J1939_PROTOCOL);
+       return (flags_ & J1939_PROTOCOL);
 }
 
 bool message_definition_t::is_isotp() const
index 7f13ac4..af34615 100644 (file)
  */
 
 #define INVALID_FLAG 0x0001
-#define BCM_PROTOCOL 0x0002
+#define CAN_PROTOCOL 0x0002
 #define J1939_PROTOCOL 0x0004
 #define J1939_ADDR_CLAIM_PROTOCOL 0x0008
 #define ISOTP_PROTOCOL 0x0010
 #define ISOTP_SEND 0x0020
 #define ISOTP_RECEIVE 0x0040
-#define FD_FRAME 0x0080
+#define CAN_PROTOCOL_WITH_FD_FRAME 0x0080
 
 /// @class message_t
 ///