This commit is contained in:
cfif 2025-06-02 13:26:41 +03:00
commit acac5e454a
4 changed files with 113 additions and 0 deletions

16
ComIntTest.c Normal file
View File

@ -0,0 +1,16 @@
//
// Created by zemon on 24.07.24.
//
#include "ComIntCodec.h"
#include "XfcProtTable.h"
#include "DeviceTesting.h"
#include "ComIntTest.h"
void XfcProtMethodsAdd_TestInit(tXfcTest *env, tDeviceTesting *testing, bool *factoryMode){
env->testing = testing;
env->factoryMode = factoryMode;
}
void XfcProtMethodsAdd_Test(tXfcProtTable *protTab, tXfcTest *testing) {
XfcProtTable_AddStatic(protTab, "RUN_TEST", XfcProtMethod_TestSet, testing);
}

24
ComIntTest.h Normal file
View File

@ -0,0 +1,24 @@
//
// Created by zemon on 25.12.24.
//
#ifndef SMART_COMPONENTS_V2_COMINTTEST_H
#define SMART_COMPONENTS_V2_COMINTTEST_H
#include "XfcProtProcessorUtilDefines.h"
#include "DeviceTesting.h"
typedef enum {
RUN,
} tXfcTestType;
typedef struct {
tDeviceTesting *testing;
bool *factoryMode;
bool run;
} tXfcTest;
void XfcProtMethodsAdd_Test(tXfcProtTable *protTab, tXfcTest *XfcTest);
void XfcProtMethodsAdd_TestInit(tXfcTest *env, tDeviceTesting *testing, bool *factoryMode);
uint8_t XfcProtMethod_TestRun(tXfcArray *request, tXfcArray *response, tXfcTest *env);
uint8_t XfcProtMethod_TestSet(tXfcArray *request, tXfcArray *response, tXfcTest *env);
#endif //SMART_COMPONENTS_V2_COMINTTEST_H

63
ComIntTestRun.c Normal file
View File

@ -0,0 +1,63 @@
//
// 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;
}

10
modular.json Normal file
View File

@ -0,0 +1,10 @@
{
"cmake": {
"inc_dirs": [
"./"
],
"srcs": [
"./**.c"
]
}
}