Изменения на новый

This commit is contained in:
cfif 2025-06-18 13:56:44 +03:00
parent 6f8d09077b
commit 2e75434ea3
3 changed files with 30 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include <SystemMutexInterface.h>
#include "SerialPort.h"
#include "stddef.h"
#include "cmsis_os2.h"
typedef enum {
AT_BUSY = -3,
@ -42,7 +43,8 @@ typedef struct {
uint32_t stdRxTimeout;
tAtCmdUrcProcessor urcProcessor;
tSystemMutexInterface *access;
osMutexId_t access;
uint8_t test;
} tAtCmd;
#endif //GSMAT_GSMATCOMMANDRESULT_H

View File

@ -29,6 +29,8 @@ void AtCmdInit(
env->stdRxTimeout = stdRxTimeout;
env->stdTxTimeout = stdTxTimeout;
env->urcProcessor.process = NULL;
env->access= osMutexNew(NULL);
env->test = 0;
}
AtCommandResult AtCmd(tAtCmd *env) {

View File

@ -33,6 +33,7 @@ AtCommandResult AtCmdReceiveChar(tAtCmd *env, uint16_t timeout) {
AtCommandResult AtCmdReceiveNextLine(tAtCmd *env, uint16_t timeout) {
uint32_t endMs = SystemGetMs() + timeout;
uint8_t attemptsNotEndOfLine = 3;
while (endMs > SystemGetMs()) {
AtCmdRxClear(env);
@ -48,6 +49,30 @@ AtCommandResult AtCmdReceiveNextLine(tAtCmd *env, uint16_t timeout) {
continue;
}
if (env->rxBuffer.data[env->rxBuffer.len - 1] != '\n') {
while (attemptsNotEndOfLine) {
uint16_t limit = 0;
if (env->rxBuffer.limit >= env->rxBuffer.len) {
limit = env->rxBuffer.limit - env->rxBuffer.len;
}
uint16_t len = SerialPortReceiveTo(
env->io, (uint8_t *) &env->rxBuffer.data[env->rxBuffer.len], limit, '\n', 5
);
env->rxBuffer.len += len;
if (env->rxBuffer.data[env->rxBuffer.len - 1] == '\n') {
break;
}
--attemptsNotEndOfLine;
}
}
if (env->rxBuffer.data[env->rxBuffer.len - 1] != '\n') {
return AT_ERROR;
}