2 * Copyright (C) 2018, 2019 "IoT.bzh"
3 * Author "Arthur Guyader" <arthur.guyader@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include <linux/can.h>
20 #include <linux/can/j1939.h>
21 #include "./message.hpp"
23 #define J1939_MAX_MULTIPACKETS 255
24 #define J1939_MAX_DLEN J1939_MAX_MULTIPACKETS * CAN_MAX_DLEN
26 class j1939_message_t : public message_t
31 * bit 0-20 : Identity Number
32 * bit 21-31 : Manufacturer Code
33 * bit 32-34 : ECU Instance
34 * bit 35-39 : Function Instance
35 * bit 40-47 : Function
37 * bit 49-55 : Vehicle System
38 * bit 56-59 : Vehicle System Instance
39 * bit 60-62 : Industry Group
40 * bit 63 : Arbitrary Address Capable
44 /* J1939 Parameter Group Number
46 * bit 0-7 : PDU Specific (PS)
47 * bit 8-15 : PDU Format (PF)
48 * bit 16 : Data Page (DP)
49 * bit 17 : Reserved (R)
50 * bit 19-31 : set to zero
61 j1939_message_t(uint8_t length, message_format_t format, std::vector<uint8_t>& data, uint64_t timestamp, name_t name, pgn_t pgn, uint8_t addr);
62 uint64_t get_name() const;
63 uint32_t get_pgn() const;
64 uint8_t get_addr() const;
65 static std::shared_ptr<j1939_message_t> convert_from_addr(struct sockaddr_can& addr, uint8_t (&data)[128], size_t nbytes, uint64_t timestamp);
67 std::string get_debug_message();
68 uint32_t get_id() const;
69 struct bcm_msg get_bcm_msg();
70 void set_bcm_msg(struct bcm_msg bcm_msg);