commit acac5e454ad0a0f044e737df87d8d09148b108d3 Author: cfif Date: Mon Jun 2 13:26:41 2025 +0300 Init diff --git a/ComIntTest.c b/ComIntTest.c new file mode 100644 index 0000000..1813260 --- /dev/null +++ b/ComIntTest.c @@ -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); +} diff --git a/ComIntTest.h b/ComIntTest.h new file mode 100644 index 0000000..554a08a --- /dev/null +++ b/ComIntTest.h @@ -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 diff --git a/ComIntTestRun.c b/ComIntTestRun.c new file mode 100644 index 0000000..7ea870b --- /dev/null +++ b/ComIntTestRun.c @@ -0,0 +1,63 @@ +// +// Created by zemon on 25.12.24. +// + +#include +#include +#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; +} \ No newline at end of file diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..0dd1901 --- /dev/null +++ b/modular.json @@ -0,0 +1,10 @@ +{ + "cmake": { + "inc_dirs": [ + "./" + ], + "srcs": [ + "./**.c" + ] + } +} \ No newline at end of file