start refactoring
This commit is contained in:
parent
b8513b2112
commit
491a60f515
@ -33,6 +33,7 @@ typedef struct {
|
|||||||
|
|
||||||
// e_mbusCommRequestResult mbusCommRequest(t_mbusDevice *mbusDevice);
|
// e_mbusCommRequestResult mbusCommRequest(t_mbusDevice *mbusDevice);
|
||||||
void mbusCommInit();
|
void mbusCommInit();
|
||||||
|
void mbusCommExec();
|
||||||
void mbusCommEnable(bool enable);
|
void mbusCommEnable(bool enable);
|
||||||
void mbusCommTxCpltCallback(UART_HandleTypeDef *huart);
|
void mbusCommTxCpltCallback(UART_HandleTypeDef *huart);
|
||||||
void mbusCommRxCpltCallback(UART_HandleTypeDef *huart);
|
void mbusCommRxCpltCallback(UART_HandleTypeDef *huart);
|
||||||
|
@ -71,6 +71,8 @@ void my_loop() {
|
|||||||
#ifndef LOGGER_OUTPUT_BY_INTERRUPT
|
#ifndef LOGGER_OUTPUT_BY_INTERRUPT
|
||||||
logExec();
|
logExec();
|
||||||
#endif //LOGGER_OUTPUT_BY_INTERRUPT
|
#endif //LOGGER_OUTPUT_BY_INTERRUPT
|
||||||
|
|
||||||
|
mbusCommExec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SYSTICK_Callback() {
|
void SYSTICK_Callback() {
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include <mbusParserExt.h>
|
#include <mbusParserExt.h>
|
||||||
#include <mqttComm.h>
|
#include <mqttComm.h>
|
||||||
#include <oled.h>
|
#include <oled.h>
|
||||||
|
#include <ringbuffer.h>
|
||||||
|
|
||||||
|
|
||||||
#include <mbus/mbus-protocol.h>
|
#include <mbus/mbus-protocol.h>
|
||||||
|
|
||||||
@ -87,6 +89,7 @@ typedef struct {
|
|||||||
uint8_t receiveCnt;
|
uint8_t receiveCnt;
|
||||||
uint8_t receivedOctet;
|
uint8_t receivedOctet;
|
||||||
bool receiving;
|
bool receiving;
|
||||||
|
ringbuffer_t *receiveBuffer;
|
||||||
e_mbusCommResult result;
|
e_mbusCommResult result;
|
||||||
t_longframe frame;
|
t_longframe frame;
|
||||||
t_mbusDevice *device;
|
t_mbusDevice *device;
|
||||||
@ -247,10 +250,9 @@ static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
|
|||||||
static void handleRequestEngine(void *handle);
|
static void handleRequestEngine(void *handle);
|
||||||
static void timeoutHandler(void *handle) {
|
static void timeoutHandler(void *handle) {
|
||||||
t_mbusCommHandle *localMbusCommHandle = (t_mbusCommHandle*) handle;
|
t_mbusCommHandle *localMbusCommHandle = (t_mbusCommHandle*) handle;
|
||||||
// coloredMsg(LOG_RED, true, "mbc th [%d] timeout", localMbusCommHandle->requestId);
|
coloredMsg(LOG_RED, true, "mbc th [%d] timeout", localMbusCommHandle->requestId);
|
||||||
localMbusCommHandle->state = MBCS_TIMEOUT;
|
localMbusCommHandle->state = MBCS_TIMEOUT;
|
||||||
localMbusCommHandle->receiving = false;
|
localMbusCommHandle->receiving = false;
|
||||||
handleRequestEngine(handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void receiveNext(t_mbusCommHandle *localMbusCommHandle) {
|
static void receiveNext(t_mbusCommHandle *localMbusCommHandle) {
|
||||||
@ -278,8 +280,8 @@ void mbusCommErrorCallback(UART_HandleTypeDef *huart) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleRequestEngine(void *handle) {
|
void mbusCommExec() {
|
||||||
t_mbusCommHandle *localMbusCommHandle = (t_mbusCommHandle*) handle;
|
t_mbusCommHandle *localMbusCommHandle = &mbusCommHandle;
|
||||||
|
|
||||||
static uint8_t userdataIdx = 0;
|
static uint8_t userdataIdx = 0;
|
||||||
static uint8_t calculatedChksum = 0;
|
static uint8_t calculatedChksum = 0;
|
||||||
@ -702,5 +704,10 @@ static void mbusCommScheduler(void *handle) {
|
|||||||
|
|
||||||
void mbusCommInit() {
|
void mbusCommInit() {
|
||||||
coloredMsg(LOG_GREEN, true, "mbc mci initializing Meterbus communication");
|
coloredMsg(LOG_GREEN, true, "mbc mci initializing Meterbus communication");
|
||||||
|
ringbufferInit(&(mbusCommHandle.receiveBuffer), 256);
|
||||||
|
coloredMsg(LOG_GREEN, true, "mbc mci ringbuffer created");
|
||||||
|
HAL_StatusTypeDef recvRet = HAL_UART_Receive_IT(&mbusUart, &(mbusCommHandle.receivedOctet), 1);
|
||||||
|
coloredMsg(LOG_GREEN, true, "mbc mci enable receiver, retCode: 0x%02x", recvRet);
|
||||||
|
|
||||||
schAdd(mbusCommScheduler, NULL, 0, 1000);
|
schAdd(mbusCommScheduler, NULL, 0, 1000);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user