obu-firmware builds against the vanetza-idf C-ITS library, which until now came from the colleague's microbu-esp32c5 tree beside the repository and was not tracked here, so a clone of this repository could not build the firmware it ships. The library alone is now part of obu-firmware, as obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from there by default; -DVANETZA_IDF_DIR still points the build elsewhere. The rest of the colleague's tree (their own VAM firmware, PKI tooling, station-link Python tools, the V2X2MAP bridge) stays out of this repository and gitignored; nothing is pushed to their repository. NOTES.md, docs/06, TODO.md and the pcap verifier's usage line point at the new location.
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 */
|
|
|