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).
84 lines
2.0 KiB
C++
84 lines
2.0 KiB
C++
#ifndef SERIALIZATION_HPP_U2YGHSPB
|
|
#define SERIALIZATION_HPP_U2YGHSPB
|
|
|
|
#include <vanetza/common/archives.hpp>
|
|
#include <vanetza/common/byte_order.hpp>
|
|
#include <boost/units/quantity.hpp>
|
|
#include <type_traits>
|
|
|
|
namespace vanetza
|
|
{
|
|
|
|
template<typename T, ByteOrder ORDER>
|
|
void serialize(OutputArchive& ar, EndianType<T, ORDER> value)
|
|
{
|
|
typedef typename decltype(value)::network_type network_type;
|
|
T tmp = static_cast<network_type>(value).get();
|
|
ar << tmp;
|
|
}
|
|
|
|
template<typename T, ByteOrder ORDER>
|
|
void deserialize(InputArchive& ar, EndianType<T, ORDER>& value)
|
|
{
|
|
T tmp;
|
|
ar >> tmp;
|
|
value = network_cast<T>(tmp);
|
|
}
|
|
|
|
template<typename T>
|
|
typename std::enable_if<std::is_integral<T>::value>::type
|
|
serialize(OutputArchive& ar, T value)
|
|
{
|
|
auto tmp = hton(value);
|
|
ar << tmp;
|
|
}
|
|
|
|
template<typename T>
|
|
typename std::enable_if<std::is_integral<T>::value>::type
|
|
deserialize(InputArchive& ar, T& value)
|
|
{
|
|
T tmp;
|
|
ar >> tmp;
|
|
value = ntoh(tmp);
|
|
}
|
|
|
|
template<typename U, typename T>
|
|
void serialize(OutputArchive& ar, boost::units::quantity<U, T> q)
|
|
{
|
|
static_assert(std::is_integral<T>::value,
|
|
"Only integral based quantities are supported");
|
|
auto tmp = hton(q.value());
|
|
ar << tmp;
|
|
}
|
|
|
|
template<typename U, typename T>
|
|
void deserialize(InputArchive& ar, boost::units::quantity<U, T>& q)
|
|
{
|
|
static_assert(std::is_integral<T>::value,
|
|
"Only integral based quantities are supported");
|
|
T tmp;
|
|
ar >> tmp;
|
|
q = boost::units::quantity<U, T>::from_value(ntoh(tmp));
|
|
}
|
|
|
|
template<class T>
|
|
typename std::enable_if<std::is_enum<T>::value>::type
|
|
serialize(OutputArchive& ar, const T& t)
|
|
{
|
|
serialize(ar, host_cast(static_cast<typename std::underlying_type<T>::type const>(t)));
|
|
}
|
|
|
|
template<class T>
|
|
typename std::enable_if<std::is_enum<T>::value>::type
|
|
deserialize(InputArchive& ar, T& t)
|
|
{
|
|
typename std::underlying_type<T>::type tmp;
|
|
deserialize(ar, tmp);
|
|
t = static_cast<T>(tmp);
|
|
}
|
|
|
|
} // namespace vanetza
|
|
|
|
#endif /* SERIALIZATION_HPP_U2YGHSPB */
|
|
|