aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--can-utils.cpp25
-rw-r--r--can-utils.h4
-rw-r--r--can_decoder.cpp5
-rw-r--r--can_event_push.cpp11
-rw-r--r--can_reader.cpp14
m---------uds-c10
6 files changed, 32 insertions, 37 deletions
diff --git a/can-utils.cpp b/can-utils.cpp
index 1e215ba..53b4f46 100644
--- a/can-utils.cpp
+++ b/can-utils.cpp
@@ -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
diff --git a/can-utils.h b/can-utils.h
index d2020a5..4b5102c 100644
--- a/can-utils.h
+++ b/can-utils.h
@@ -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 */
diff --git a/can_decoder.cpp b/can_decoder.cpp
index ae1b693..74694c9 100644
--- a/can_decoder.cpp
+++ b/can_decoder.cpp
@@ -22,7 +22,10 @@
#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;
diff --git a/can_event_push.cpp b/can_event_push.cpp
index c8a3b6d..429abe4 100644
--- a/can_event_push.cpp
+++ b/can_event_push.cpp
@@ -22,14 +22,17 @@
#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();
}
}
}
diff --git a/can_reader.cpp b/can_reader.cpp
index 35ea79e..1e6429e 100644
--- a/can_reader.cpp
+++ b/can_reader.cpp
@@ -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
-Subproject e506334e270d77b20c0bc259ac6c7d8c9b702b7