dataPack changes done

This commit is contained in:
2024-01-25 15:46:11 +03:00
parent 6691915aa0
commit 5bf3a26948

View File

@ -75,31 +75,12 @@ void IR_Decoder::writeToBuffer(bool bit) {
#endif #endif
/*
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const auto testval = bufferBitSizeMax; //const auto testval = bufferBitSizeMax;
if ((bufBitPos >= (8 * msgBytes) - syncBits) && !isMsgAvaliable) { if ((i_dataBuffer >= (8 * msgBytes)) && !isMsgAvaliable) {
switch ((rawBuffer[0] >> 5) & IR_MASK_MSG_TYPE) { switch ((dataBuffer[0] >> 5) & IR_MASK_MSG_TYPE) {
case IR_MSG_ACCEPT: case IR_MSG_ACCEPT:
if (bufBitPos >= ((msgBytes + addrBytes + crcBytes) * (8 + 3)) - syncBits) { if (i_dataBuffer >= ((msgBytes + addrBytes + crcBytes) * bitPerByte)) {
const uint8_t dataSize = msgBytes + addrBytes; const uint8_t dataSize = msgBytes + addrBytes;
isRawAvaliable = true; isRawAvaliable = true;
isMsgAvaliable = crcCheck(dataSize); isMsgAvaliable = crcCheck(dataSize);
@ -111,7 +92,7 @@ void IR_Decoder::writeToBuffer(bool bit) {
break; break;
case IR_MSG_REQUEST: case IR_MSG_REQUEST:
if (bufBitPos >= ((msgBytes + addrBytes + addrBytes + crcBytes) * (8 + 3)) - syncBits) { if (i_dataBuffer >= ((msgBytes + addrBytes + addrBytes + crcBytes) * bitPerByte)) {
const uint8_t dataSize = msgBytes + addrBytes + addrBytes; const uint8_t dataSize = msgBytes + addrBytes + addrBytes;
isRawAvaliable = true; isRawAvaliable = true;
isMsgAvaliable = (crcCheck(dataSize)); isMsgAvaliable = (crcCheck(dataSize));
@ -125,8 +106,9 @@ void IR_Decoder::writeToBuffer(bool bit) {
case IR_MSG_DATA_ACCEPT: case IR_MSG_DATA_ACCEPT:
case IR_MSG_DATA_NOACCEPT: case IR_MSG_DATA_NOACCEPT:
if (bufBitPos >= ((bitPerByte + syncBits) * ((rawBuffer[0] & IR_MASK_MSG_INFO) + crcBytes)) - syncBits) { if (i_dataBuffer >= ((dataBuffer[0] & IR_MASK_MSG_INFO) + crcBytes) * bitPerByte) {
const uint8_t dataSize = (rawBuffer[0] & IR_MASK_MSG_INFO); // Serial.println("OK");
const uint8_t dataSize = (dataBuffer[0] & IR_MASK_MSG_INFO);
isRawAvaliable = true; isRawAvaliable = true;
isMsgAvaliable = crcCheck(dataSize); isMsgAvaliable = crcCheck(dataSize);
if (isMsgAvaliable && checkAddr(3, 4)) { if (isMsgAvaliable && checkAddr(3, 4)) {
@ -144,7 +126,6 @@ void IR_Decoder::writeToBuffer(bool bit) {
} }
}/**/ }/**/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} }
// uint8_t* IR_Decoder::getDataBuffer(bool reset = false) { // uint8_t* IR_Decoder::getDataBuffer(bool reset = false) {
@ -186,12 +167,6 @@ void IR_Decoder::writeToBuffer(bool bit) {
bool IR_Decoder::crcCheck(uint8_t len) { bool IR_Decoder::crcCheck(uint8_t len) {
bool crcOK = false; bool crcOK = false;
// получить буффер, если нет
if (!isFilterBufferAvaliable) getDataBuffer();
if (dataBuffer == nullptr) {
return false;
}
crcValue = 0; crcValue = 0;
crcValue = (crc8(dataBuffer, 0, len, poly1) << 8) & ~((crc_t)0xFF); crcValue = (crc8(dataBuffer, 0, len, poly1) << 8) & ~((crc_t)0xFF);