Fix wrong arguments type
authorRomain Forlot <romain.forlot@iot.bzh>
Sat, 11 Feb 2017 18:58:04 +0000 (19:58 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Mon, 13 Feb 2017 23:31:56 +0000 (23:31 +0000)
Reader is almost finish i think now

Change-Id: Ib4c7c88b430ada2661e6ce2a67dde76d03dba2f1
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
can-utils.cpp
can-utils.h
can_decoder.cpp
can_event_push.cpp
can_reader.cpp
uds-c [deleted submodule]

index 1e215ba..53b4f46 100644 (file)
@@ -85,11 +85,10 @@ int CanBus_c::close()
 
 void CanBus_c::start_threads()
 {
-    std::queue <canfd_frame> canfd_frame_queue;
-    std::queue <openxc_can_message_type> can_message_queue;
+       std::queue <CanMessage_t> can_message_q;
 
-    th_reading = std::thread(can_reader, interface, socket, canfd_frame_queue);
-    th_decoding = std::thread(can_decoder, interface, canfd_frame_queue, can_message_queue);
+    th_reading = std::thread(can_reader, interface, socket, can_message_q);
+    th_decoding = std::thread(can_decoder, interface, can_message_q, can_message_queue);
     th_pushing = std::thread(can_event_push, interface, can_message_queue);
 }
 
@@ -147,6 +146,12 @@ void CanMessage_c::set_lenght(uint8_t new_length)
     lenght = new_lenght;
 }
 
+/*
+ * This is the prefered way to initialize a CanMessage object 
+ * from a read canfd_frame message.
+ * 
+ * params: canfd_frame pointer
+ */
 void CanMessage_c::convert_canfd_frame_to_CanMessage(canfd_frame *frame)
 {
     
@@ -159,9 +164,11 @@ void CanMessage_c::convert_canfd_frame_to_CanMessage(canfd_frame *frame)
         case (canfd_frame->can_id & CAN_EFF_FLAG):
                    id = canfd_frame->can_id & CAN_EFF_MASK;
                format = EXTENDED;
-        default:
-                   format = STANDARD;
-                   id = canfd_frame->can_id & CAN_SFF_MASK;
+                       break;
+               default:
+                       format = STANDARD;
+                       id = canfd_frame->can_id & CAN_SFF_MASK;
+                       break;
 
        if (sizeof(canfd_frame->data) <= sizeof(data))
        {
@@ -169,7 +176,5 @@ void CanMessage_c::convert_canfd_frame_to_CanMessage(canfd_frame *frame)
                        can_message->data.bytes[i] = canfd_frame->data[i];
                return 0;
        } else if (sizeof(canfd_frame->data) >= CAN_MAX_DLEN)
-       {
-               ERROR(interface, "parse_can_frame: can_frame data too long to be stored into openxc_CanMessage data field");
-    }
+               ERROR(interface, "CanMessage_c: canfd_frame data too long to be stored into CanMessage object");
 }
\ No newline at end of file
index d2020a5..4b5102c 100644 (file)
@@ -82,7 +82,9 @@ typedef openxc_DynamicField (*SignalDecoder)(struct CanSignal* signal,
 typedef uint64_t (*SignalEncoder)(struct CanSignal* signal,
         openxc_DynamicField* value, bool* send);
 
-/* CanBus represent a can device definition gotten from configuraiton file */
+/* 
+ * CanBus represent a can device definition gotten from configuraiton file 
+ */
 class CanBus_c {
        private:
                /* Got from conf file */
index ae1b693..74694c9 100644 (file)
 
 #include <afb/afb-binding.h>
 
-void decode_can_message(afb_binding_interface *interface, std::queue <canfd_frame>& canfd_frame_queue, std::queue <openxc_can_message_type>& can_message_queue)
+#include "can-utils.h"
+#include "openxc.pb.h"
+
+void decode_can_message(afb_binding_interface *interface, std::queue <CanMessage_t>& can_message_q, std::queue <openxc_VehicleMessage>& VehicleMessage_q)
 {
     canfd_frame canfd_frame;
 
index c8a3b6d..429abe4 100644 (file)
 
 #include <afb/afb-binding.h>
 
-void can_event_push(afb_binding_interface *interface, std::queue <openxc_can_message_type>& can_message_queue)
+#include "can-utils.h"
+#include "openxc.pb.h"
+
+void can_event_push(afb_binding_interface *interface, std::queue <openxc_VehicleMessage>& vehicle_message_q)
 {
     while(true)
     {
-        if(! can_message_queue.empty())
+        if(! vehicle_message_q.empty())
         {
-            can_message = can_message_queue.front();
-            can_message_queue.pop();
+            vehicle_message = vehicle_message_q.front();
+            vehicle_message_q.pop();
         }
     }
 }
index 35ea79e..1e6429e 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <afb/afb-binding.h>
 
+#include "can-utils.h"
+
 void can_reader(afb_binding_interface *interface, int socket, std::queue <CanMessage_t>& can_message_q)
 {
     ssize_t nbytes;
@@ -56,19 +58,9 @@ void can_reader(afb_binding_interface *interface, int socket, std::queue <CanMes
                 return -2;
         }
 
-        /* 
-         * TODO: thread handle
-        if (parse_can_frame(can_message, &canfd_frame, maxdlen))
-        {
-            ERROR(interface, "read_can: Can't parse the can frame. ID: %i, DLC: %i, DATA: %s", 
-            canfd_frame.can_id, canfd_frame.len, canfd_frame.data);
-            return -4;
-        }
-        */
-
         can_message.convert_canfd_frame_to_CanMessage(canfd_frame);
 
 
         can_message_q.push(can_message);
     }
-}
+}
\ No newline at end of file
diff --git a/uds-c b/uds-c
deleted file mode 160000 (submodule)
index e506334..0000000
--- a/uds-c
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit e506334e270d77b20c0bc259ac6c7d8c9b702b7a