fix logger (lost first two chars) and setting meterbus uart (8bit data plus parity, so 9bit incl. parity)
This commit is contained in:
@ -30,11 +30,11 @@ static void handleRequestEngine(void *handle) {
|
||||
|
||||
switch (localMbusCommHandle->state) {
|
||||
case IDLE:
|
||||
logMsg("mc state IDLE\n");
|
||||
logMsg("hre state IDLE");
|
||||
break;
|
||||
|
||||
case SEND:
|
||||
logMsg("mc state SEND\n");
|
||||
logMsg("hre state SEND");
|
||||
localMbusCommHandle->sendBuf[0] = 0x10;
|
||||
localMbusCommHandle->sendBuf[1] = localMbusCommHandle->cmd;
|
||||
localMbusCommHandle->sendBuf[2] = localMbusCommHandle->addr;
|
||||
@ -44,26 +44,28 @@ static void handleRequestEngine(void *handle) {
|
||||
// no break !!
|
||||
|
||||
case SEND_CONT:
|
||||
logMsg("mc state SEND_CONT\n");
|
||||
logMsg("hre state SEND_CONT");
|
||||
led(RED, OFF);
|
||||
if (! loopActive) {
|
||||
logMsg("hre enabling loop, try %d", localMbusCommHandle->retryCnt);
|
||||
localMbusCommHandle->retryCnt++;
|
||||
loopEnable();
|
||||
schAdd(handleRequestEngine, handle, 10, 0); // give 10ms to settled the loop
|
||||
} else {
|
||||
// write(fd, sendBuf, 5);
|
||||
localMbusCommHandle->retryCnt = 0;
|
||||
HAL_UART_Transmit_IT(&mbusUart, localMbusCommHandle->sendBuf, 5);
|
||||
localMbusCommHandle->state = SENDING;
|
||||
schAdd(handleRequestEngine, handle, 1, 0); // ask me again in 1ms in the next state ...
|
||||
schAdd(handleRequestEngine, handle, 5, 0); // ask me again in 1ms in the next state ...
|
||||
}
|
||||
break;
|
||||
|
||||
case SENDING:
|
||||
logMsg("mc state SENDING\n");
|
||||
logMsg("hre state SENDING");
|
||||
if (HAL_UART_GetState(&mbusUart) == HAL_UART_STATE_READY) { // ... whether I'm done
|
||||
localMbusCommHandle->state = IDLE;
|
||||
} else {
|
||||
schAdd(handleRequestEngine, handle, 1, 0); // not yet done, ask me again in 1ms
|
||||
schAdd(handleRequestEngine, handle, 5, 0); // not yet done, ask me again in 1ms
|
||||
}
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user