obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#ifndef BIT_NUMBER_HPP_H3ODBQR7
|
|
#define BIT_NUMBER_HPP_H3ODBQR7
|
|
|
|
#include <boost/operators.hpp>
|
|
#include <cstddef>
|
|
#include <type_traits>
|
|
|
|
namespace vanetza {
|
|
|
|
/**
|
|
* BitNumber restricts the value range by the given width
|
|
*
|
|
* \tparam T underlying integral type
|
|
* \tparam WIDTH number of bits used to represent a number
|
|
*/
|
|
template<typename T, std::size_t WIDTH>
|
|
class BitNumber : public boost::totally_ordered<BitNumber<T, WIDTH>>
|
|
{
|
|
static_assert(std::is_integral<T>::value == true,
|
|
"only integral types are supported");
|
|
static_assert(sizeof(T) * 8 > WIDTH,
|
|
"width has to be less than size of underlying type");
|
|
|
|
public:
|
|
static constexpr T mask = (1 << WIDTH) - 1; /**< excessive bits are masked */
|
|
static constexpr std::size_t bits = WIDTH; /**< number of bits used */
|
|
typedef T value_type; /**< underlying (integral) value type */
|
|
|
|
BitNumber() : mValue(0) {}
|
|
BitNumber(T value) : mValue(value & mask) {}
|
|
BitNumber& operator=(T value) { mValue = value & mask; return *this; }
|
|
T raw() const { return mValue; }
|
|
|
|
bool operator<(BitNumber other) const { return mValue < other.mValue; }
|
|
bool operator==(BitNumber other) const { return mValue == other.mValue; }
|
|
|
|
private:
|
|
T mValue;
|
|
};
|
|
|
|
} // namespace vanetza
|
|
|
|
#endif /* BIT_NUMBER_HPP_H3ODBQR7 */
|
|
|