Hoymiles Lib: Move semaphore handing into parser base class

This commit is contained in:
Thomas Basler
2023-09-07 22:07:10 +02:00
parent 9ac6dd6e8d
commit 0260af9ada
14 changed files with 35 additions and 119 deletions

View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2022 Thomas Basler and others
* Copyright (C) 2022 - 2023 Thomas Basler and others
*/
#include "DevInfoParser.h"
#include "../Hoymiles.h"
@@ -46,16 +46,9 @@ const devInfo_t devInfo[] = {
{ { 0x10, 0x33, 0x31, ALL }, 2250, "HMT-2250" } // 01
};
#define HOY_SEMAPHORE_TAKE() \
do { \
} while (xSemaphoreTake(_xSemaphore, portMAX_DELAY) != pdPASS)
#define HOY_SEMAPHORE_GIVE() xSemaphoreGive(_xSemaphore)
DevInfoParser::DevInfoParser()
: Parser()
{
_xSemaphore = xSemaphoreCreateMutex();
HOY_SEMAPHORE_GIVE(); // release before first use
clearBufferSimple();
clearBufferAll();
}
@@ -92,16 +85,6 @@ void DevInfoParser::appendFragmentSimple(uint8_t offset, uint8_t* payload, uint8
_devInfoSimpleLength += len;
}
void DevInfoParser::beginAppendFragment()
{
HOY_SEMAPHORE_TAKE();
}
void DevInfoParser::endAppendFragment()
{
HOY_SEMAPHORE_GIVE();
}
uint32_t DevInfoParser::getLastUpdateAll()
{
return _lastUpdateAll;