MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/driver/BinaryCrcCheck.hh
2024-06-07 11:12:56 +03:00

57 lines
1.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* BinaryCrcCheck.hh
*
* Created on: 21 мая 2023 г.
* Author: titov
*/
#ifndef UMLIBRARY_DRIVER_BINARYCRCCHECK_HH_
#define UMLIBRARY_DRIVER_BINARYCRCCHECK_HH_
#include "../communication/IBinaryDataSubscriber.hh"
#include "../communication/format/BinaryHelpers.hh"
#include "../common/ICrcUnit.hpp"
#include <memory_resource>
#include <vector>
#include <mutex>
namespace driver {
//!Модуль проверки контрольной суммы бинарных данных.
class BinaryCrcCheck : public communication::IBinaryDataSubscriber {
public:
BinaryCrcCheck( common::crc::ICrcUnit::CrcCalcualtor calculator,
communication::IBinaryDataSubscriber & protected_data,
std::size_t crc_bit_address, std::size_t crc_bit_len,
std::size_t data_bit_address, std::size_t data_bit_len,
std::pmr::memory_resource * memory_resource );
void read( const void * data, std::size_t size );
const bool & error() const;
private:
std::vector< char, std::pmr::polymorphic_allocator<char> > buffer_data;
communication::IBinaryDataSubscriber & protected_data;
common::crc::ICrcUnit::CrcCalcualtor calculator;
communication::format::bits::Extractor extract_crc;
communication::format::bits::Extractor extract_data;
char * temp_data_buffer;
std::size_t data_octet_size;
std::size_t data_byte_size;
bool crc_mismatch;
};
}
#endif /* UMLIBRARY_DRIVER_BINARYCRCCHECK_HH_ */