Close socket by default when destroying object
[apps/agl-service-can-low-level.git] / CAN-binder / low-can-binding / utils / socketcan-bcm.cpp
index 38f4852..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,6 +92,10 @@ namespace utils
                cm = ::can_message_t::convert_from_frame(msg.frames ,
                                nbytes-sizeof(struct bcm_msg_head),
                                timestamp);
+               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;
        }