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.
18 #include "./message.hpp"
22 #include "../../binding/low-can-hat.hpp"
25 * @brief Construct a new message t::message t object
28 message_t::message_t()
37 * @brief Construct a new message t::message t object
39 * @param maxdlen The maxdlen of a message
40 * @param length The length of the message
41 * @param format The format of the message
42 * @param data The data vector of the message
43 * @param timestamp The timestamp of the message
45 message_t::message_t(uint32_t maxdlen,
48 std::vector<uint8_t>& data,
54 timestamp_{timestamp},
59 * @brief Return the sub_id of the message
61 * @return int The sub_id of the message
63 int message_t::get_sub_id() const
69 /// @brief Retrieve data_ member value.
71 /// @return pointer to the first element
72 /// of class member data_
74 const uint8_t* message_t::get_data() const
80 /// @brief Retrieve data_ member whole vector
82 /// @return the vector as is
84 const std::vector<uint8_t> message_t::get_data_vector() const
90 /// @brief Retrieve length_ member value.
92 /// @return length_ class member
94 uint32_t message_t::get_length() const
100 * @brief Set data vector of the message
102 * @param data A vector of data
104 void message_t::set_data(std::vector<uint8_t> data)
110 * @brief Set sub_id of the message
112 * @param sub_id The sub_id to set
114 void message_t::set_sub_id(int sub_id)
120 * @brief Return the timestamp of the message
122 * @return uint64_t The timestamp
124 uint64_t message_t::get_timestamp() const
129 uint32_t message_t::get_flags()
134 void message_t::set_flags(uint32_t flags)
136 flags_ = flags_ | flags;
139 void message_t::erase_flags()
144 uint32_t message_t::get_maxdlen()
149 void message_t::set_maxdlen(uint32_t maxdlen)
154 void message_t::set_length(uint32_t length)
159 void message_t::frame_swap()
162 uint8_t *temp = (uint8_t*)alloca(length_);
164 for(i = 0; i < length_; i++)
165 temp[i] = data_[length_ - i - 1];
167 memcpy(data_.data(), temp, length_);