63 lines
1.8 KiB
C
63 lines
1.8 KiB
C
//
|
|
// Created by zemon on 25.12.24.
|
|
//
|
|
|
|
#include <stdint-gcc.h>
|
|
#include <string.h>
|
|
#include "XfcArray.h"
|
|
#include "XfcProtProcessorUtilDefines.h"
|
|
#include "DeviceTesting_Env.h"
|
|
#include "ComIntTest.h"
|
|
|
|
uint8_t XfcProtMethod_TestSet(tXfcArray *request, tXfcArray *response, tXfcTest *env){
|
|
uint8_t result = XfcProtMethod_TestRun(request, response, env);
|
|
env->run = true;
|
|
return result;
|
|
}
|
|
|
|
|
|
uint16_t XfcArrayGetBytesFrontToSendTest(tXfcTest *env, tXfcTestType codecType, tXfcArray *array, uint8_t length) {
|
|
|
|
uint16_t available = XfcArrayGetDataSize(array);
|
|
uint16_t toGet = available > length ? length : available;
|
|
|
|
if (codecType == RUN) {
|
|
if(*env->factoryMode == true) {
|
|
env->run = *(uint32_t *) (array->data + array->begin);
|
|
}
|
|
}
|
|
|
|
array->begin += toGet;
|
|
return toGet;
|
|
}
|
|
|
|
uint8_t XfcProtMethod_TestRun(tXfcArray *request, tXfcArray *response, tXfcTest *env) {
|
|
|
|
// Запись избранных параметров
|
|
uint16_t paramCount = 0;
|
|
uint8_t paramValueID_len = 0;
|
|
uint8_t paramValueID_text[64];
|
|
|
|
XFC_CMD_RX_GET_RAW(paramCount);
|
|
|
|
if (!paramCount) {
|
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_OK;
|
|
}
|
|
|
|
for (uint16_t count = 0; count < paramCount; ++count) {
|
|
|
|
// Получение текстового id параметра
|
|
XFC_CMD_RX_GET_RAW(paramValueID_len);
|
|
XFC_CMD_RX_GET_ARR(paramValueID_text, paramValueID_len);
|
|
uint8_t dataLen;
|
|
XFC_CMD_RX_GET_RAW(dataLen);
|
|
|
|
if (memcmp(paramValueID_text, "RUN", sizeof("RUN") - 1) == 0) {
|
|
uint16_t countLen = XfcArrayGetBytesFrontToSendTest(env, RUN, request, dataLen);
|
|
if (countLen != dataLen) {
|
|
return XFC_TRANSPORT_PROTOCOL_REQUEST_UNEXPECTEDLY_SHORT;
|
|
}
|
|
}
|
|
}
|
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_OK;
|
|
} |