summaryrefslogtreecommitdiffstats
path: root/low-can-binding/utils/socketcan-j1939/socketcan-j1939.hpp
diff options
context:
space:
mode:
authorArthur GUYADER <arthur.guyader@iot.bzh>2019-12-12 18:12:01 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 16:25:36 +0100
commit43cc23cd9d0986ae370f5839aa952c6e3eb196d0 (patch)
tree0e99d6a235d50731a0f55c15a722e51887b9555a /low-can-binding/utils/socketcan-j1939/socketcan-j1939.hpp
parentc57722b34d38c9843a728829204d2711aaadacbb (diff)
j1939: Follow updates of the kernel
This commit patch j1939 feature after the update of the kernel from linux-can-next to mainline. Now promisc option removes filter of the bind. The option is now a parameter in the event_filter. The feature recv_own isn't available, you can't receive on the same socket an emit frame from you. Not a big problem because receive and send method use two different sockets in the implementation. Change-Id: I5ac410177c1512090827870300b8aa1679477b84 Signed-off-by: Arthur GUYADER <arthur.guyader@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/utils/socketcan-j1939/socketcan-j1939.hpp')
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939.hpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/low-can-binding/utils/socketcan-j1939/socketcan-j1939.hpp b/low-can-binding/utils/socketcan-j1939/socketcan-j1939.hpp
index 1ae8d1c9..c68500fb 100644
--- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939.hpp
+++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939.hpp
@@ -29,6 +29,17 @@
#define J1939_NAME_ECU 0x1234
#endif
+#define J1939_CAN_ID CAN_EFF_FLAG
+#define J1939_CAN_MASK (CAN_EFF_FLAG | CAN_RTR_FLAG)
+
+
+// PDU 1 = NO BROADCAST
+// PDU 2 = BRODCAST
+static inline bool j1939_pgn_is_pdu1(pgn_t pgn)
+{
+ return (pgn & 0xff00) < 0xf000;
+}
+
namespace utils
{
@@ -54,6 +65,7 @@ namespace utils
virtual std::shared_ptr<message_t> read_message(int flag);
virtual int write_message(message_t& obj);
virtual int write_j1939_message(pgn_t pgn, std::vector<uint8_t> &data, uint32_t len_data);
+ void define_opt(bool broadcast = true, bool promisc = false);
protected:
struct ifreq ifr_;
@@ -61,7 +73,7 @@ namespace utils
static std::condition_variable signal_address_claiming_;
void define_tx_address(std::string device_name, name_t name, pgn_t pgn, uint8_t addr);
int add_filter(name_t name, pgn_t pgn, uint8_t addr, name_t name_mask, pgn_t pgn_mask, uint8_t addr_mask);
- void define_opt(bool promisc = true, bool recv_own_msgs = true, bool broadcast = true);
+
};
}