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 struct bcm_msg bcm_msg_;
42 can_message_t( uint32_t maxdlen,
47 std::vector<uint8_t>& data,
50 uint32_t get_id() const;
51 void set_id(const canid_t id);
52 bool is_correct_to_send();
54 static std::shared_ptr<can_message_t> convert_from_frame(const canfd_frame& frame, size_t nbytes, uint64_t timestamp);
55 struct canfd_frame convert_to_canfd_frame();
56 struct std::vector<canfd_frame> convert_to_canfd_frame_vector();
57 struct bcm_msg& get_bcm_msg();
58 void set_bcm_msg(struct bcm_msg bcm_msg);
60 struct can_frame convert_to_can_frame();
62 std::string get_debug_message();