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.
20 #include <linux/can/j1939.h>
21 #include "message.hpp"
24 #define J1939_MAX_MULTIPACKETS 255
25 #define J1939_MAX_DLEN J1939_MAX_MULTIPACKETS * CAN_MAX_DLEN
28 class j1939_message_t : public message_t
33 * bit 0-20 : Identity Number
34 * bit 21-31 : Manufacturer Code
35 * bit 32-34 : ECU Instance
36 * bit 35-39 : Function Instance
37 * bit 40-47 : Function
39 * bit 49-55 : Vehicle System
40 * bit 56-59 : Vehicle System Instance
41 * bit 60-62 : Industry Group
42 * bit 63 : Arbitrary Address Capable
46 /* J1939 Parameter Group Number
48 * bit 0-7 : PDU Specific (PS)
49 * bit 8-15 : PDU Format (PF)
50 * bit 16 : Data Page (DP)
51 * bit 17 : Reserved (R)
52 * bit 19-31 : set to zero
63 * @brief The sockanme to send a message to
66 struct sockaddr_can sockname_;
70 j1939_message_t(uint32_t maxdlen, uint32_t length, message_format_t format, std::vector<uint8_t>& data, uint64_t timestamp, name_t name, pgn_t pgn, uint8_t addr);
71 uint64_t get_name() const;
72 uint32_t get_pgn() const;
73 uint8_t get_addr() const;
74 static std::shared_ptr<j1939_message_t> convert_from_addr(struct sockaddr_can& addr, uint8_t (&data)[128], size_t nbytes, uint64_t timestamp);
76 std::string get_debug_message();
77 uint32_t get_id() const;
78 struct sockaddr_can get_sockname();
79 void set_sockname(struct sockaddr_can sockname);
80 void set_sockname(pgn_t pgn, name_t name, uint8_t addr);