commit 5e3a58147fdb1138b642d6e8bd0a6c083f8efcad Author: cfif Date: Mon Jun 2 13:26:40 2025 +0300 Init diff --git a/ComIntThisSubSystem.c b/ComIntThisSubSystem.c new file mode 100644 index 0000000..14762b1 --- /dev/null +++ b/ComIntThisSubSystem.c @@ -0,0 +1,15 @@ +// +// Created by zemon on 09.09.24. +// + +#include "XfcProtTable.h" +#include "ComIntThisSubSystem.h" +#include "SystemSelector.h" + +void XfcProtMethodsAdd_SybSystemInit(tXfcSybSystem *env, eSubSystems *subSystem){ + env->subSystem = subSystem; +} + +void XfcProtMethodsAdd_SybSystem(tXfcProtTable *protTab, tXfcSybSystem *XfcSybSystem){ + XfcProtTable_AddStatic(protTab, "GET_THIS_SUBSYSTEM", XfcProtMethod_ThisSubSystemGet, XfcSybSystem); +} \ No newline at end of file diff --git a/ComIntThisSubSystem.h b/ComIntThisSubSystem.h new file mode 100644 index 0000000..895f083 --- /dev/null +++ b/ComIntThisSubSystem.h @@ -0,0 +1,23 @@ +// +// Created by zemon on 09.09.24. +// + +#ifndef SMART_COMPONENTS_V2_COMINTTHISSUBSYSTEM_H +#define SMART_COMPONENTS_V2_COMINTTHISSUBSYSTEM_H + +#include "XfcArray.h" +#include "XfcProtTable.h" +#include "SystemSelector.h" + +typedef struct { + eSubSystems *subSystem; +} tXfcSybSystem; + +void XfcProtMethodsAdd_SybSystem(tXfcProtTable *protTab, tXfcSybSystem *XfcSybSystem); + +void XfcProtMethodsAdd_SybSystemInit(tXfcSybSystem *env, eSubSystems *subSystem); + +uint16_t XfcProtMethod_ThisSubSystemGet(tXfcArray *request, tXfcArray *response, tXfcSybSystem *XfcSybSystem); + + +#endif //SMART_COMPONENTS_V2_COMINTTHISSUBSYSTEM_H diff --git a/ComIntThisSubSystemGet.c b/ComIntThisSubSystemGet.c new file mode 100644 index 0000000..dd3c7b2 --- /dev/null +++ b/ComIntThisSubSystemGet.c @@ -0,0 +1,77 @@ +#include +#include "ComIntThisSubSystem.h" +#include "XfcArray.h" +#include "XfcProtProcessorUtilDefines.h" + +// +// Created by zemon on 09.09.24. +// +uint16_t XfcProtMethod_GetThisSystem(tXfcArray *request, tXfcArray *response, tXfcSybSystem *env, char *paramValueID_text, uint8_t paramValueID_len) { + // Текстовый вид ID + XFC_CMD_TX_ADD_RAW(paramValueID_len); + XFC_CMD_TX_ADD_ARR(paramValueID_text, paramValueID_len); + + if (memcmp(paramValueID_text, "SUBSYSTEM", sizeof("SUBSYSTEM") - 1) == 0) { + uint8_t len = 2; + // Размер данных + XFC_CMD_TX_ADD_RAW(len); + // Данные + uint16_t value = 0; + if(*env->subSystem == UVEOS){ + value = 1; + } + if(*env->subSystem == TELEMATICA){ + value = 2; + } + XFC_CMD_TX_ADD_ARR(&value, len); + + return true; + } + + return false; +} + +uint16_t XfcProtMethod_ThisSubSystemGet(tXfcArray *request, tXfcArray *response, tXfcSybSystem *env){ + + // Чтение всех параметров + if (XfcArrayGetDataSize(request) == 0) { + + uint16_t paramCount = 1; + // Количество параметров + XFC_CMD_TX_ADD_RAW(paramCount); + + uint8_t paramValueID_len; + char paramValueID_text[20]; + + paramValueID_len = sizeof("SUBSYSTEM") - 1; + paramValueID_text[0] = '\0'; + strcat(paramValueID_text, "SUBSYSTEM"); + if (!XfcProtMethod_GetThisSystem(request, response, env, paramValueID_text, paramValueID_len)) { + return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_EXECUTION_ERROR; + } + + return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_OK; + } + + // Чтение избранных параметров + uint16_t paramCount; + XFC_CMD_RX_GET_RAW(paramCount); + + // Количество параметров + XFC_CMD_TX_ADD_RAW(paramCount); + + for (uint16_t count = 0; count < paramCount; ++count) { + // Получение текстового id параметра + uint8_t paramValueID_len; + XFC_CMD_RX_GET_RAW(paramValueID_len); + char paramValueID_text[paramValueID_len]; + XFC_CMD_RX_GET_ARR(paramValueID_text, paramValueID_len); + + if(!XfcProtMethod_GetThisSystem(request, response, env, paramValueID_text, paramValueID_len)) { + return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_EXECUTION_ERROR; + } + + } + + 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