Изменения на новый
This commit is contained in:
parent
6f8d09077b
commit
2e75434ea3
|
|
@ -8,6 +8,7 @@
|
||||||
#include <SystemMutexInterface.h>
|
#include <SystemMutexInterface.h>
|
||||||
#include "SerialPort.h"
|
#include "SerialPort.h"
|
||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
AT_BUSY = -3,
|
AT_BUSY = -3,
|
||||||
|
|
@ -42,7 +43,8 @@ typedef struct {
|
||||||
uint32_t stdRxTimeout;
|
uint32_t stdRxTimeout;
|
||||||
|
|
||||||
tAtCmdUrcProcessor urcProcessor;
|
tAtCmdUrcProcessor urcProcessor;
|
||||||
tSystemMutexInterface *access;
|
osMutexId_t access;
|
||||||
|
uint8_t test;
|
||||||
} tAtCmd;
|
} tAtCmd;
|
||||||
|
|
||||||
#endif //GSMAT_GSMATCOMMANDRESULT_H
|
#endif //GSMAT_GSMATCOMMANDRESULT_H
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ void AtCmdInit(
|
||||||
env->stdRxTimeout = stdRxTimeout;
|
env->stdRxTimeout = stdRxTimeout;
|
||||||
env->stdTxTimeout = stdTxTimeout;
|
env->stdTxTimeout = stdTxTimeout;
|
||||||
env->urcProcessor.process = NULL;
|
env->urcProcessor.process = NULL;
|
||||||
|
env->access= osMutexNew(NULL);
|
||||||
|
env->test = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtCommandResult AtCmd(tAtCmd *env) {
|
AtCommandResult AtCmd(tAtCmd *env) {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ AtCommandResult AtCmdReceiveChar(tAtCmd *env, uint16_t timeout) {
|
||||||
|
|
||||||
AtCommandResult AtCmdReceiveNextLine(tAtCmd *env, uint16_t timeout) {
|
AtCommandResult AtCmdReceiveNextLine(tAtCmd *env, uint16_t timeout) {
|
||||||
uint32_t endMs = SystemGetMs() + timeout;
|
uint32_t endMs = SystemGetMs() + timeout;
|
||||||
|
uint8_t attemptsNotEndOfLine = 3;
|
||||||
|
|
||||||
while (endMs > SystemGetMs()) {
|
while (endMs > SystemGetMs()) {
|
||||||
AtCmdRxClear(env);
|
AtCmdRxClear(env);
|
||||||
|
|
@ -48,6 +49,30 @@ AtCommandResult AtCmdReceiveNextLine(tAtCmd *env, uint16_t timeout) {
|
||||||
continue;
|
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') {
|
if (env->rxBuffer.data[env->rxBuffer.len - 1] != '\n') {
|
||||||
return AT_ERROR;
|
return AT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue