20 #include <boost/crc.hpp> 27 namespace data_conversion_layer
35 std::ostringstream os;
37 const uint32_t reserved{ 0 };
39 boost::crc_32_type crc;
40 crc.process_bytes(&reserved,
sizeof(reserved));
41 crc.process_bytes(&op_code,
sizeof(op_code));
42 crc.process_bytes(&res_code,
sizeof(res_code));
49 const std::string data_str(os.str());
51 "Message data of start reply has not the expected size");
57 return serialize(static_cast<uint32_t>(reply.
type()), static_cast<uint32_t>(reply.
result()));
62 std::istringstream is(std::string(data.data(),
Message::SIZE));
74 boost::crc_32_type crc_checked;
75 crc_checked.process_bytes(&reserved,
sizeof(reserved));
76 crc_checked.process_bytes(&opcode,
sizeof(opcode));
77 crc_checked.process_bytes(&res_code,
sizeof(res_code));
79 if (crc != crc_checked.checksum())
void read(std::istream &is, T &data)
static constexpr OperationResult convertToOperationResult(const uint32_t &value)
static constexpr Type convertToReplyType(const uint32_t &value)
CRCMismatch(const std::string &msg="CRC did not match!")
void write(std::ostringstream &os, const T &data)
RawData serialize(const Message &reply)
std::vector< char > RawData
Message deserialize(const data_conversion_layer::RawData &data)
static constexpr std::size_t SIZE
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
constexpr OperationResult result() const
constexpr Type type() const
Exception thrown if an incorrect CRC is detected during deserialization of a data_conversion_layer::s...
Higher level data type representing a reply message from the scanner.