123456789101112131415161718192021222324252627282930 |
- // // ******************************************************************
- // // /\ /| @File DataCheckHelper.cpp
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-05-16
- // // / \\ @Modified 2024-05-16
- // // *(__\_\
- // // ******************************************************************
- #include "DataCheckHelper.h"
- namespace Protocol
- {
- bool DataCheckHelper::CheckDataByOddEven(uint8_t data, int32_t dataBitCount,
- const OddEvenCheck checkType)
- {
- if (checkType == OddEvenCheck::None) return true;
- bool temp = false;
- while (dataBitCount > 0)
- {
- temp ^= ((data & 0b01) == 1);
- data >>= 1;
- dataBitCount--;
- }
- if (checkType == OddEvenCheck::Odd) temp = !temp;
- return temp;
- }
- }
|