aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/can/message
diff options
context:
space:
mode:
Diffstat (limited to 'low-can-binding/can/message')
-rw-r--r--low-can-binding/can/message/can-message.hpp9
-rw-r--r--low-can-binding/can/message/j1939-message.cpp63
-rw-r--r--low-can-binding/can/message/j1939-message.hpp5
-rw-r--r--low-can-binding/can/message/message.hpp8
4 files changed, 66 insertions, 19 deletions
diff --git a/low-can-binding/can/message/can-message.hpp b/low-can-binding/can/message/can-message.hpp
index 7625cc17..0f8bc9b5 100644
--- a/low-can-binding/can/message/can-message.hpp
+++ b/low-can-binding/can/message/can-message.hpp
@@ -18,7 +18,14 @@
#pragma once
#include "./message.hpp"
-
+struct bcm_msg
+{
+ struct bcm_msg_head msg_head;
+ union {
+ struct canfd_frame fd_frames[MAX_BCM_CAN_FRAMES];
+ struct can_frame frames[MAX_BCM_CAN_FRAMES];
+ };
+};
/// @class can_message_t
///
diff --git a/low-can-binding/can/message/j1939-message.cpp b/low-can-binding/can/message/j1939-message.cpp
index 08fc1302..0d2320dc 100644
--- a/low-can-binding/can/message/j1939-message.cpp
+++ b/low-can-binding/can/message/j1939-message.cpp
@@ -184,16 +184,63 @@ uint32_t j1939_message_t::get_id() const
return get_pgn();
}
-
-struct bcm_msg j1939_message_t::get_bcm_msg()
+/**
+ * @brief Return the sockname of the message
+ *
+ * @return struct sockaddr_can The sockname of the message
+ */
+struct sockaddr_can j1939_message_t::get_sockname()
{
- AFB_WARNING("Not implemented");
- struct bcm_msg bcm_msg;
- ::memset(&bcm_msg, 0, sizeof(struct bcm_msg));
- return bcm_msg;
+ return sockname_;
}
-void j1939_message_t::set_bcm_msg(struct bcm_msg bcm_msg)
+/**
+ * @brief Allows to set a sockname at a message to send it after
+ *
+ * @param sockname The sockname of the message
+ */
+void j1939_message_t::set_sockname(struct sockaddr_can sockname)
{
- AFB_WARNING("Not implemented");
+ sockname_ = sockname;
}
+
+/**
+ * @brief Allows to generate a sockname for the message
+ *
+ * @param pgn The pgn for the sockname
+ * @param name The name for the sockname
+ * @param addr The address for the sockname
+ */
+void j1939_message_t::set_sockname(pgn_t pgn, name_t name, uint8_t addr)
+{
+ memset(&sockname_, 0, sizeof(sockname_));
+ sockname_.can_family = AF_CAN;
+ sockname_.can_ifindex = 0;
+
+ if(addr <= 0 || addr >= UINT8_MAX )
+ {
+ sockname_.can_addr.j1939.addr = J1939_NO_ADDR;
+ }
+ else
+ {
+ sockname_.can_addr.j1939.addr = addr;
+ }
+
+ if(name <= 0 || name >= UINT64_MAX )
+ {
+ sockname_.can_addr.j1939.name = J1939_NO_NAME;
+ }
+ else
+ {
+ sockname_.can_addr.j1939.name = name;
+ }
+
+ if(pgn <= 0 || pgn > J1939_PGN_MAX)
+ {
+ sockname_.can_addr.j1939.pgn = J1939_NO_PGN;
+ }
+ else
+ {
+ sockname_.can_addr.j1939.pgn = pgn;
+ }
+} \ No newline at end of file
diff --git a/low-can-binding/can/message/j1939-message.hpp b/low-can-binding/can/message/j1939-message.hpp
index aad62a1f..929c8232 100644
--- a/low-can-binding/can/message/j1939-message.hpp
+++ b/low-can-binding/can/message/j1939-message.hpp
@@ -75,6 +75,7 @@ class j1939_message_t : public message_t
bool is_set();
std::string get_debug_message();
uint32_t get_id() const;
- struct bcm_msg get_bcm_msg();
- void set_bcm_msg(struct bcm_msg bcm_msg);
+ struct sockaddr_can get_sockname();
+ void set_sockname(struct sockaddr_can sockname);
+ void set_sockname(pgn_t pgn, name_t name, uint8_t addr);
};
diff --git a/low-can-binding/can/message/message.hpp b/low-can-binding/can/message/message.hpp
index 5be1ff18..48f4d98b 100644
--- a/low-can-binding/can/message/message.hpp
+++ b/low-can-binding/can/message/message.hpp
@@ -30,14 +30,6 @@
#define MAX_BCM_CAN_FRAMES 257
-struct bcm_msg
-{
- struct bcm_msg_head msg_head;
- union {
- struct canfd_frame fd_frames[MAX_BCM_CAN_FRAMES];
- struct can_frame frames[MAX_BCM_CAN_FRAMES];
- };
-};
/**
* @enum message_format_t