Use UDS PID has key to record subscriptions
authorRomain Forlot <romain.forlot@iot.bzh>
Thu, 1 Jun 2017 11:48:19 +0000 (13:48 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 1 Jun 2017 16:40:13 +0000 (18:40 +0200)
can_signal_t use socket number but has for OBD2 diagnostic request
there is only 1 socket to listen all response then we use PID has key
to find the subscription later on the processing.

Change-Id: I5f0554e1a4ac43e1046d9b7b7f9bb00d3a753562
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
CAN-binder/low-can-binding/binding/low-can-cb.cpp
CAN-binder/low-can-binding/utils/socketcan-bcm.cpp

index 6504acf..245a9ce 100644 (file)
@@ -61,7 +61,9 @@ low_can_subscription_t::low_can_subscription_t(struct event_filter_t event_filte
 
 low_can_subscription_t::low_can_subscription_t(struct event_filter_t event_filter, std::shared_ptr<diagnostic_message_t> diagnostic_message)
        : diagnostic_message_{diagnostic_message}, event_filter_{event_filter}
-{}
+{
+       index_ = diagnostic_message->get_pid();
+}
 
 low_can_subscription_t::low_can_subscription_t( low_can_subscription_t&& s)
        : index_{s.index_},
index 1009a42..cd84a85 100644 (file)
@@ -21,6 +21,8 @@
 #include <sys/ioctl.h>
 #include <fcntl.h>
 
+#include "../binding/application.hpp"
+
 namespace utils
 {
        /// @brief Connect the socket.
@@ -90,7 +92,10 @@ namespace utils
                cm = ::can_message_t::convert_from_frame(msg.frames ,
                                nbytes-sizeof(struct bcm_msg_head),
                                timestamp);
-               cm.set_sub_id((int)s.socket());
+               if(application_t::instance().get_diagnostic_manager().is_diagnostic_response(cm))
+                       {cm.set_sub_id(msg.frames.data[2]);}
+               else
+                       {cm.set_sub_id((int)s.socket());}
 
                return s;
        }