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 /// @class can_message_t
25 /// @brief A compact representation of a single CAN message, meant to be used in in/out
26 /// buffers. It is a wrapper of a can_frame struct with some sugar around it for binding purposes.
27 class can_message_t : public message_t {
29 uint8_t maxdlen_; ///< maxdlen_ - Max data length deduce from number of bytes read from the socket.*/
30 uint32_t id_; ///< id_ - The ID of the message. */
31 bool rtr_flag_; ///< rtr_flag_ - Telling if the frame has RTR flag positionned. Then frame hasn't data field*/
32 uint8_t flags_; ///< flags_ - flags of a CAN FD frame. Needed if we catch FD frames.*/
33 struct bcm_msg bcm_msg_;
37 can_message_t(uint8_t maxdlen, uint32_t id, uint8_t length, message_format_t format, bool rtr_flag_, uint8_t flags, std::vector<uint8_t>& data, uint64_t timestamp);
39 uint32_t get_id() const;
41 static std::shared_ptr<can_message_t> convert_from_frame(const canfd_frame& frame, size_t nbytes, uint64_t timestamp);
42 bool is_correct_to_send();
44 struct bcm_msg get_bcm_msg();
45 void set_bcm_msg(struct bcm_msg bcm_msg);
47 std::string get_debug_message();