2 * Copyright (C) 2015, 2016 "IoT.bzh"
3 * Author "Romain Forlot" <romain.forlot@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 "./message.hpp"
23 struct bcm_msg_head msg_head;
25 struct canfd_frame fd_frames[MAX_BCM_CAN_FRAMES];
26 struct can_frame frames[MAX_BCM_CAN_FRAMES];
30 /// @class can_message_t
32 /// @brief A compact representation of a single CAN message, meant to be used in in/out
33 /// buffers. It is a wrapper of a can_frame struct with some sugar around it for binding purposes.
34 class can_message_t : public message_t {
36 uint32_t id_; ///< id_ - The ID of the message. */
37 bool rtr_flag_; ///< rtr_flag_ - Telling if the frame has RTR flag positionned. Then frame hasn't data field*/
38 uint32_t flags_; ///< flags_ - flags of a CAN FD frame. Needed if we catch FD frames.*/
39 struct bcm_msg bcm_msg_;
43 can_message_t(uint32_t maxdlen, uint32_t id, uint32_t length, message_format_t format, bool rtr_flag_, uint32_t flags, std::vector<uint8_t>& data, uint64_t timestamp);
45 uint32_t get_id() const;
47 static std::shared_ptr<can_message_t> convert_from_frame(const canfd_frame& frame, size_t nbytes, uint64_t timestamp);
48 struct canfd_frame convert_to_canfd_frame();
49 struct can_frame convert_to_can_frame();
51 bool is_correct_to_send();
53 struct bcm_msg get_bcm_msg();
54 void set_bcm_msg(struct bcm_msg bcm_msg);
56 std::string get_debug_message();