| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896 | /* * CLI_Commands.c * *  Created on: 28.11.2017 *      Author: balbekova *//* FreeRTOS includes. */#include "FreeRTOS.h"#include "task.h"/* Standard includes. */#include <stdint.h>#ifdef PRINTF_STDLIB#include <stdio.h>#endif#ifdef PRINTF_CUSTOM#include "tinystdio.h"#endif#include <string.h>#include <stdlib.h>/* FreeRTOS+CLI includes. */#include "FreeRTOS_CLI.h"#include "snmp_api.h"#include "trap_api.h"#include "sntp_api.h"#include "lwip/ip_addr.h"#include "settings_api.h"#include "log.h"#include "megatec.h"#include "web_params_api.h"#include "hal.h"#include "parameters.h"#include "CLI_Commands.h"#include "CLI_Parameters.h"#include "cli.h"#include "netconf.h"#include "control_symbol.h"#include "syslog.h"const int8_t *const pcInvalidCommand = ( int8_t * )    "Неправильно введены параметры команды.  Введите \"help\" для просмотра списка поддерживаемых команд.\r\n\r\n";const int8_t *const pcPermissionDenied = ( int8_t * ) "Отказ в доступе!\r\n\r\n";const int8_t *const pcSystymeDenied = ( int8_t * )    "Ручной ввод времени не доступен!\r\n\r\n";const char *info_args_list[] = {    "name",    "address",    "owner",    "comments",};const char *ups_args_list[] = {    "battest",    "shutdown",};const char *systime_args_list[] = {    "date",    "time",};const char *network_args_list[] = {    "info",    "dhcp",    "ip",    "gw",    "mask",};const char *snmp_args_list[] = {    "info",    "server",    "community",};const char *akb_args_list[] = {    "info",    "voltcellmin",    "voltcellmax",#if HARDWARE_BT6709 || HARDWARE_BT6709_MTS || HARDWARE_BT6710    "capacity",    "voltakb",    "lifetime",    "dataset",    "upspower",#else if HARDWARE_BT6711 || HARDWARE_BT6711_V1    "capacity",    "voltakb",    "upspower",#endif};const char *type_alarm_args_list[] = {    "info",    "temp",#ifndef HARDWARE_BT6710    "load",#endif    "vout",#ifdef TEMP_CABINET_MONITOR    "temp_cabinet"#endif#ifdef VAC_IN_MONITOR    "vacin",#endif};const char *alarm_args_list[] = {    "low",    "high",    "hist",};const char *notification_args_list[] = {    "info",    "set",};const char *whitelist_args_list[] = {    "info",    "range",    "reset",};const char *ntp_args_list[] = {    "ENA",    "DIS",    "info",    "set",};const char *config_args_list[] = {    "info",    "load",};const char *netconfig_args_list[] = {    "apply",    "confirm",};const char *history_args_list[] = {    "EVENTS",    "UPS",};const char *sensor_args_list[] = {    "info",    "setup",};const char *user_args_list[] = {    "passwd",};/**  * @brief  Общая структура настроек  */extern SETTINGS_t sSettings;/* * Implements the controller's information command. */static portBASE_TYPE prvTaskInfoCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );/* * Implements the reboot command. */static portBASE_TYPE prvTaskRebootCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );/* * Implements the systime command. */static portBASE_TYPE prvTaskSystimeCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );/* * Implements the ntp command. */static portBASE_TYPE prvTaskNTPCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );/* * Implements the network command. */static portBASE_TYPE prvTaskNetworkCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );/* * Implements the snmp command. */static portBASE_TYPE prvTaskSNMPCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );/* * Implements the AKB command. */static portBASE_TYPE prvTaskAKBCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );/* * Implements the alarm command. */static portBASE_TYPE prvTaskAlarmCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );#ifdef NOTIFICATION_CONTROL_ENABLE/* * Implements the notification command. */static portBASE_TYPE prvTaskNotificationCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );#endif#ifdef WHITELIST_ENABLE/* * Implements the whitelist command. */static portBASE_TYPE prvTaskWhiteListCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );#endif/* * Implements the change password command. */static portBASE_TYPE prvTaskUserCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );/* * Implements the config command. */static portBASE_TYPE prvTaskConfigCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );/* * Implements the netconfig command. */static portBASE_TYPE prvTaskNetConfigCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );/* * Implements the history command. */static portBASE_TYPE prvTaskHistoryCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );/* * Implements the sensor info command. */static portBASE_TYPE prvTaskSensorCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );/* * Implements the firmware download http command. */static portBASE_TYPE prvTaskUploadCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString );/* * Implements the ups command. */static portBASE_TYPE prvTaskUPSCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );/* * Implements the гзs serial command. */static portBASE_TYPE prvSetUPSserialCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );/* Structure that defines the "info" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvInfoCommandDefinition = {    ( const int8_t *const ) "info",  /* The command string to type. */    ( const int8_t *const ) "\tinfo: вывод информации о контроллере\r\n"							"\tinfo name <name>: установка поля \"название устройства\"\r\n"							"\tinfo address <adrr>: установка поля \"адрес расположения контролируемого объекта\"\r\n"							"\tinfo owner <owner>: установка поля \"организация (собственник)\"\r\n"							"\tinfo comments <comment>: установка поля \"комментарии\"\r\n",							prvTaskInfoCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};/* Structure that defines the "reboot" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvRebootCommandDefinition = {    ( const int8_t *const ) "reboot",  /* The command string to type. */    ( const int8_t *const ) "\treboot: перезагрузка Контроллера\r\n",    prvTaskRebootCommand, /* The function to run. */    0 /* No parameters are expected. */};/* Structure that defines the "systime" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvSystimeCommandDefinition = {    ( const int8_t *const ) "systime",  /* The command string to type. */    ( const int8_t *const ) "\tsystime: вывод системного времени\r\n"							"\tsystime date <YYYY-MM-DD>: установка даты\r\n"							"\tsystime time <HH:MM>: установка времени\r\n",    prvTaskSystimeCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};/* Structure that defines the "ntp" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvNTPCommandDefinition = {    ( const int8_t *const ) "ntp",  /* The command string to type. */    ( const int8_t *const ) "\tntp ENA|DIS: разрешение/запрет синхронизации времени\r\n"							"\tntp set IP <A.B.C.D>: установка сервера NTP\r\n"							"\tntp info: вывод информации о сервере NTP\r\n"							"\tntp set gmt <SIGN><NUM>: установка часового пояса\r\n",    prvTaskNTPCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};/* Structure that defines the "network" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvNetworkCommandDefinition = {    ( const int8_t *const ) "network",  /* The command string to type. */    ( const int8_t *const ) "\tnetwork info вывод информации о текущих сетевых настройках:\r\n"							"\tnetwork dhcp ENA|DIS: разрешение/запрет получения IP по DHCP\r\n"							"\tnetwork ip <A.B.C.D>: установка статического IP\r\n"							"\tnetwork gw <A.B.C.D>: установка шлюза\r\n"							"\tnetwork mask <A.B.C.D>: установка маски подсети\r\n",    prvTaskNetworkCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};/* Structure that defines the "snmp" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvSNMPCommandDefinition = {    ( const int8_t *const ) "snmp",  /* The command string to type. */    ( const int8_t *const ) "\tsnmp info: вывод информации о текущих SNMP настройках\r\n"							"\tsnmp server <NUM> <A.B.C.D>: установка сервера SNMP\r\n"							"\tsnmp community read <read>: установка Read community\r\n"							"\tsnmp community write <write>: установка Write community\r\n",    prvTaskSNMPCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};/* Structure that defines the "akb" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvAKBCommandDefinition = {    ( const int8_t *const ) "akb",  /* The command string to type. */    ( const int8_t *const ) "\takb info: вывод информации о параметрах АКБ\r\n"							"\takb voltcellmin <value>: ввод минимального напряжения на ячейки АКБ (В)\r\n"							"\takb voltcellmax <value>: ввод максимального напряжения на ячейки АКБ (В)\r\n"#if HARDWARE_BT6709 || HARDWARE_BT6709_MTS || HARDWARE_BT6710							"\takb capacity <value>: ввод ёмкости АКБ (Ач)\r\n"							"\takb voltakb <value>:  ввод номинального напряжения АКБ (В)\r\n"							"\takb lifetime <value>: ввод срока службы АКБ (лет)\r\n"							"\takb dataset <YYYY-MM-DD>: ввод даты установки АКБ\r\n"							"\takb upspower <value>: ввод полной мощности ИБП (ВА)\r\n"#else if HARDWARE_BT6711 || HARDWARE_BT6711_V1							"\takb capacity <value>: ввод ёмкости АКБ (Ач)\r\n"							"\takb voltakb <value>:  ввод номинального напряжения АКБ (В)\r\n"							"\takb upspower <value>: ввод полной мощности ИБП (ВА)\r\n"#endif								,    prvTaskAKBCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};/* Structure that defines the "alarm" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvAlarmCommandDefinition = {    ( const int8_t *const ) "alarm",  /* The command string to type. */    ( const int8_t *const ) "\talarm info: вывод информации о параметрах АКБ\r\n"							"\talarm temp low <value>: ввод нижней границы аварии по температуре (С)\r\n"							"\talarm temp high <value>: ввод верxней границы аварии по температуре (С)\r\n"							"\talarm temp hist <value>: ввод гистерезиса аварии по температуре (С)\r\n"#ifndef HARDWARE_BT6710							"\talarm load high <value>: ввод верхней границы аварии по нагрузке (%)\r\n"							"\talarm load hist <value>: ввод гистерезиса аварии по нагрузке (%)\r\n"#endif							"\talarm vout low <value>: ввод нижней границы аварии по вых. напряжению (В)\r\n"							"\talarm vout high <value>: ввод верxней границы аварии по вых. напряжению (В)\r\n"							"\talarm vout hist <value>: ввод гистерезиса аварии по вых. напряжению (В)\r\n"#ifdef TEMP_CABINET_MONITOR                            "\talarm temp_cabinet low <value>: ввод нижней границы аварии по температуре в шкафу (С)\r\n"							"\talarm temp_cabinet high <value>: ввод верxней границы аварии по температуре в шкафу (С)\r\n"							"\talarm temp_cabinet hist <value>: ввод гистерезиса аварии по температуре в шкафу (С)\r\n"#endif#ifdef VAC_IN_MONITOR							"\talarm vacin low <value>: ввод нижней границы аварии по вх. напряжению (В)\r\n"							"\talarm vacin high <value>: ввод верxней границы аварии по вх. напряжению (В)\r\n"							"\talarm vacin hist <value>: ввод гистерезиса аварии по вх. напряжению (В)\r\n"#endif    ,prvTaskAlarmCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};#ifdef NOTIFICATION_CONTROL_ENABLE/* Structure that defines the "notification" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvNotificationCommandDefinition = {    ( const int8_t *const ) "notification",  /* The command string to type. */    ( const int8_t *const ) "\tnotification info: вывод списка уведомлений\r\n"    						"\tnotification set <NUM> ENA|DIS: вкл/выкл уведомления\r\n",    prvTaskNotificationCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};#endif#ifdef  WHITELIST_ENABLE/* Structure that defines the "whitelist" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvWhiteListCommandDefinition = {    ( const int8_t *const ) "whitelist",  /* The command string to type. */    ( const int8_t *const ) "\twhitelist info: вывод информации о текущем белом списке IP адресов контроллера\r\n"    						"\twhitelist range <NUM> <A.B.C.D/E>: установка диапазона IP адресов\r\n"                            "\twhitelist reset <NUM>: сброс диапазона IP адресов\r\n",    prvTaskWhiteListCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};#endif/* Structure that defines the "user" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvUserCommandDefinition = {    ( const int8_t *const ) "user",  /* The command string to type. */    ( const int8_t *const ) "\tuser passwd <name>: установка пароля для пользователя <name>\r\n",    prvTaskUserCommand, /* The function to run. */    2 /* Two parameters are expected, which can take any value. */};/* Structure that defines the "config" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvConfigCommandDefinition = {    ( const int8_t *const ) "config",  /* The command string to type. */    ( const int8_t *const ) "\tconfig info: вывод информации о состоянии конфигураций\r\n"    						"\tconfig load default: загрузка конфигурации по умолчанию\r\n",    prvTaskConfigCommand, /* The function to run. */    -1 /* Two parameters are expected, which can take any value. */};/* Structure that defines the "config" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvNetConfigCommandDefinition = {    ( const int8_t *const ) "netconfig",  /* The command string to type. */    ( const int8_t *const ) "\tnetconfig apply: применение конфигурации сетевых настроек\r\n"    						"\tnetconfig confirm: подтверждение конфигурации сетевых настроек\r\n",    prvTaskNetConfigCommand, /* The function to run. */    1 /* Two parameters are expected, which can take any value. */};/* Structure that defines the "history" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvHistoryCommandDefinition = {    ( const int8_t *const ) "history",  /* The command string to type. */    ( const int8_t *const ) "\thistory show EVENTS|UPS <num_page>:	вывод журнала\r\n",    prvTaskHistoryCommand, /* The function to run. */    3 /* Two parameters are expected, which can take any value. */};/* Structure that defines the "sensor info" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvSensorCommandDefinition = {    ( const int8_t *const ) "sensor",  /* The command string to type. */    ( const int8_t *const ) "\tsensor info: вывод параметров системы (выход из режима Ctrl+C далее Enter)\r\n"#ifdef DINS_ENABLE							"\tsensor 	setup DI <num> <state>: установка нормального состояния сухого контакта:\r\n"							"\t\t\t\t0 - разомкнутое состояние\r\n"							"\t\t\t\t1 - замкнутое состояние\r\n"#ifdef HARDWARE_BT6710                            "\tsensor 	setup DIname <num> <name>: установка названия сухого контакта\r\n"#endif                        #endif#if defined(DALLAS_SENSOR_ENABLE) || defined(AM2301_SENSOR_ENABLE)                            "\tsensor 	setup TS <num> <function>: установка назначения датчика температуры:\r\n"							"\t\t\t\t0 - нет\r\n"							"\t\t\t\t1 - Шкаф\r\n"                            "\t\t\t\t2 - АКБ\r\n"#endif#ifdef DOUTS_ENABLE							"\tsensor 	setup DO <num> <issue>: установка источника срабатывания реле:\r\n"							"\t\t\t\t1 - Наличие сети\r\n"							"\t\t\t\t2 - Наличие выходного напряжения\r\n"							"\t\t\t\t3 - Разряд АКБ\r\n"							"\t\t\t\t4 - Отключение АКБ\r\n"							"\t\t\t\t5 - SNMP SET\r\n"#endif    ,    prvTaskSensorCommand, /* The function to run. */    -1 /* No parameters are expected. */};/* Structure that defines the "firmware dowmload http" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvUploadCommandDefinition = {    ( const int8_t *const ) "firmware download http",  /* The command string to type. */    ( const int8_t *const ) "\tfirmware download http: переход в режим обновления через Web-сервер\r\n",    prvTaskUploadCommand, /* The function to run. */    2 /* No parameters are expected. */};/* Structure that defines the "ups" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvUPSCommandDefinition = {    ( const int8_t *const ) "ups",  /* The command string to type. */    ( const int8_t *const ) "\tups battest <num>: управление процедурой тестирования АКБ:\r\n"							"\t\t\t\t0 - Остановить тестирование\r\n"							"\t\t\t\t1-99 - Запустить тест на x минут\r\n"							"\t\t\t\t100 - Тестирование в течение 10 секунд\r\n"							"\t\t\t\t999 - Тестирование до разряда\r\n"							"\tups shutdown <num>: управление отключением нагрузки ИБП:\r\n"							"\t\t\t\t0 - Остановить процедуру отключения нагрузки\r\n"							"\t\t\t\tn - Отключить нагрузку через n минут\r\n"							"\t\t\t\tn: 0.2, 0.3, ..., 1, 2, ..., 10\r\n",    prvTaskUPSCommand, /* The function to run. */    2 /* Two parameters are expected, which can take any value. */};#ifdef FTP_ENABLE#include "ftp.h"#define FTP_ARGS_LIST \X(info) \X(server_ip) \X(server_port) \X(remote_path) \X(user) \X(pass) \X(run) \typedef enum {#define X(name) ARG_FTP_##name,FTP_ARGS_LIST#undef XARG_FTP_ALL,} ftp_args_t;const char *ftp_args_list[] = {#define X(name) #name,FTP_ARGS_LIST#undef X};static portBASE_TYPE prvTaskFTPCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );static const CLI_Command_Definition_t prvFTPCommandDefinition = {    (const int8_t *const)"ftp",  /* The command string to type. */    (const int8_t *const)"\tftp info: вывод информации о настройках обновления по ftp\r\n"                         "\tftp server_ip <ip address>: задать адрес FTP-сервера\r\n"                         "\tftp server_port <port>: задать порт FTP-сервера\r\n"                         "\tftp remote_path <file path>: задать путь к файлу обновления ПО\r\n"                         "\tftp user <username>: задать имя пользователя для аутентификации на FTP-сервере\r\n"                         "\tftp pass <password>: задать пароль для аутентификации на FTP-сервере\r\n"                         "\tftp run: запустить процесс обновления через FTP\r\n",    prvTaskFTPCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};#endif#ifdef SYSLOG_ENABLEconst char *syslog_args_list[] = {    "info",    "ENA",    "DIS",    "server_ip",    "server_port",};typedef enum{    ARG_SYSLOG_INFO = 0,	ARG_SYSLOG_ENABLE,	ARG_SYSLOG_DISABLE,	ARG_SYSLOG_IP,    ARG_SYSLOG_PORT,	ARG_SYSLOG_ALL}syslog_args_t;static portBASE_TYPE prvTaskSysLogCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );static const CLI_Command_Definition_t prvSysLogCommandDefinition = {    (const int8_t *const)"syslog",  /* The command string to type. */    (const int8_t *const)"\tsyslog info: вывод информации о настройках Syslog\r\n"                         "\tsyslog ENA|DIS: вкл./выкл. Syslog\r\n"                         "\tsyslog server_ip <ip address>: установка ip-адреса Syslog-сервера\r\n"                         "\tsyslog server_port <port>: установка порта Syslog-сервера\r\n",    prvTaskSysLogCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};#endif#ifdef RADIUS_SERVER_ENABLEconst char *radius_args_list[] = {    "info",    "ENA",    "DIS",    "server_ip",    "server_port",    "secret",};typedef enum{    ARG_RADIUS_INFO = 0,	ARG_RADIUS_ENABLE,	ARG_RADIUS_DISABLE,	ARG_RADIUS_IP,    ARG_RADIUS_PORT,    ARG_RADIUS_SECRET,	ARG_RADIUS_ALL}radius_args_t;static portBASE_TYPE prvTaskRADIUSCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );static const CLI_Command_Definition_t prvRADIUSCommandDefinition = {    (const int8_t *const)"radius",  /* The command string to type. */    (const int8_t *const)"\tradius info: вывод информации о настройках RADIUS\r\n"                         "\tradius ENA|DIS: вкл./выкл. авторизации через RADIUS\r\n"                         "\tradius server_ip <ip address>: установка ip-адреса RADIUS-сервера\r\n"                         "\tradius server_port <port>: установка порта RADIUS-сервера\r\n"                         "\tradius secret <secret>: установка пароля RADIUS-сервера\r\n",    prvTaskRADIUSCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};#endif#ifdef PORTGW_ENABLEconst char *pgw_args_list[] = {    "info",    "ENA",    "DIS",    "port",    "boardrate",    "parity",    "datalen",    "stopbit"};typedef enum{    ARG_PGW_INFO = 0,	ARG_PGW_ENABLE,	ARG_PGW_DISABLE,    ARG_PGW_PORT,    ARG_PGW_RATE,    ARG_PGW_PARITY,    ARG_PGW_DATALEN,    ARG_PGW_STOPBIT,	ARG_PGW_ALL}pgw_args_t;static portBASE_TYPE prvTaskPGWCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );static const CLI_Command_Definition_t prvPGWCommandDefinition = {    (const int8_t *const)"pgw",  /* The command string to type. */    (const int8_t *const)"\tpgw info: вывод информации о настройках прозрачного канала\r\n"                         "\tpgw ENA|DIS: вкл./выкл. прозрачного канала\r\n"                         "\tpgw port <port>: установка сетевого парта\r\n"                         "\tpgw boardrate <boardrate>: установка скорости (бит/с) порта RS-485\r\n"                         "\tpgw parity <parity>: установка четности порта RS-485:\r\n"                         "\t\t\t\t0 - нет\r\n"                         "\t\t\t\t1 - нечетный\r\n"                         "\t\t\t\t2 - четный\r\n"                         "\tpgw datalen <datalen>: установка битов данных порта RS-485\r\n"                         "\tpgw stopbit <stopbit>: установка стоповых бит порта RS-485\r\n",    prvTaskPGWCommand, /* The function to run. */    -1 /* The user can enter any number of commands. */};#endifstatic const CLI_Command_Definition_t prvSetUPSserialCommandDefinition ={	( const int8_t * const ) "setupsid", /* The command string to type. */	( const int8_t * const ) "",//\tsetupsid <password> <SN>: установка серийного номера ИБП\r\n	prvSetUPSserialCommand, /* The function to run. */	2 /* Two parameters are expected, which can take any value. */};/* Structure that defines the "quit" command line command.   Thisgenerates a table that shows how much run time each task has */static const CLI_Command_Definition_t prvQuitCommandDefinition = {    ( const int8_t *const ) "quit",  /* The command string to type. */    ( const int8_t *const ) "\tquit: завершение сессии\r\n",    NULL, /* The function to run. */    -1 /* The user can enter any number of commands. */};/*-----------------------------------------------------------*/void vRegisterCLICommands( void ){    /* Register all the command line commands defined immediately above. */    FreeRTOS_CLIRegisterCommand( &prvInfoCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvRebootCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvSystimeCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvNTPCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvNetworkCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvSNMPCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvAKBCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvAlarmCommandDefinition );#ifdef NOTIFICATION_CONTROL_ENABLE    FreeRTOS_CLIRegisterCommand( &prvNotificationCommandDefinition );#endif#ifdef WHITELIST_ENABLE    FreeRTOS_CLIRegisterCommand( &prvWhiteListCommandDefinition );#endif    FreeRTOS_CLIRegisterCommand( &prvUserCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvConfigCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvNetConfigCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvHistoryCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvSensorCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvUploadCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvUPSCommandDefinition );#ifdef FTP_ENABLE    FreeRTOS_CLIRegisterCommand( &prvFTPCommandDefinition );#endif#ifdef SYSLOG_ENABLE    FreeRTOS_CLIRegisterCommand( &prvSysLogCommandDefinition );#endif#ifdef RADIUS_SERVER_ENABLE    FreeRTOS_CLIRegisterCommand( &prvRADIUSCommandDefinition );#endif#ifdef PORTGW_ENABLE    FreeRTOS_CLIRegisterCommand( &prvPGWCommandDefinition );#endif    FreeRTOS_CLIRegisterCommand( &prvSetUPSserialCommandDefinition );    FreeRTOS_CLIRegisterCommand( &prvQuitCommandDefinition );}/*-----------------------------------------------------------*/static portBASE_TYPE prvTaskInfoCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    uint8_t len;    int8_t num_arg = 0;    uint8_t i;    static uint8_t page = 0;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    num_arg = prvGetNumberOfParameters(pcCommandString);    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    if (num_arg == 0) {        const int8_t *const pcInfoTableHeader = ( int8_t * )            "\r\n**************Информация о Контроллере**************\r\n";        const int8_t *const pcUPSInfoTableHeader = ( int8_t * )            "\r\n*****************Информация об ИБП******************\r\n";        if (!page) {            /* Return the next command help string, before moving the pointer on to            the next command in the list. */            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInfoTableHeader, strlen( ( char * ) pcInfoTableHeader ) );            GetWorkTimeStr(str, &len);            strcat(( char * ) pcWriteBuffer, "Время работы:\t\t\t");            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nМодель:\t\t\t\t");            GetModelStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nДата производства:\t\t");            GetProductionDataStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nВерсия ПО:\t\t\t");            GetVersionStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nMAC адрес:\t\t\t");            GetMacStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nСерийный номер:\t\t\t");            GetSerialNumberStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nНазвание устройства:\t\t");            GetNameDeviceStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nВладелец:\t\t\t");            GetOwnerStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nМестоположение:\t\t\t");            GetLocationStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nКомментарии:\t\t\t");            GetCommentsStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            page = 1;            xReturn = pdTRUE;        } else {            strncat( ( char * ) pcWriteBuffer, ( const char * ) pcUPSInfoTableHeader, strlen( ( char * ) pcUPSInfoTableHeader ) );            strcat(( char * ) pcWriteBuffer, "\r\nКомпания:\t\t\tАО\"НПК РоТеК\"");            strcat(( char * ) pcWriteBuffer, "\r\nМодель:\t\t\t\t");            GetUPSModelStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nСерийный номер:\t\t\t");            GetUPSSerialStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\nВерсия ПО:\t\t\t");            GetUPSVersionStr(str, &len);            strncat(( char * ) pcWriteBuffer, str, len);            strcat(( char * ) pcWriteBuffer, "\r\n");            page = 0;            /* There are no more commands in the list, so there will be no more            strings to return after this one and pdFALSE should be returned. */            xReturn = pdFALSE;        }    } else if (num_arg == 1) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        xReturn = pdFALSE;    } else {        /* Obtain the parameter string. */        pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter            (                pcCommandString,        /* The command string itself. */                xParameterNumber,       /* Return the next parameter. */                &xParameterStringLength /* Store the parameter string length. */            );        for (i = 0; i < INFO_ALL_ARGS; i ++) {            if ( strncmp( ( const char * ) pcParameterString, info_args_list[i], strlen(info_args_list[i]) ) == 0                 && xParameterStringLength == strlen(info_args_list[i])) {                break;            }        }        xParameterNumber ++;        //  xParameterNumber ++;        /* Obtain the parameter string. */        pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter            (                pcCommandString,        /* The command string itself. */                xParameterNumber,       /* Return the next parameter. */                &xParameterStringLength /* Store the parameter string length. */            );        memset(str, 0, sizeof(str));        xParameterStringLength = strlen(( const char * ) pcParameterString);        if (xParameterStringLength > (int32_t)sizeof(str)) {            xParameterStringLength = sizeof(str) - 1;        }        strncat(str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));        if (control_string_en_digit(str, strlen(str))) {            switch (i) {                case INFO_DEV_NAME:                    if (cli_state->user_id == ADMIN) {                        str[19] = 0;                        SetNameDeviceStr(str);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );                    }                    break;                case INFO_ADDRESS:                    if (cli_state->user_id == ADMIN) {                        str[109] = 0;                        SetLocation(str);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );                    }                    break;                case INFO_OWNER:                    if (cli_state->user_id == ADMIN) {                        str[49] = 0;                        SetOwner(str);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );                    }                    break;                case INFO_COMMENTS:                    if (cli_state->user_id == ADMIN) {                        str[109] = 0;                        SetComment(str);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );                    }                    break;                default:                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    break;            }            if (i >= INFO_DEV_NAME && i <= INFO_COMMENTS) {                cli_save_config(cli_state);            }        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }        xReturn = pdFALSE;    }    return xReturn;}static portBASE_TYPE prvTaskRebootCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    static bool start_reboot = true;    const int8_t *const pcRebootHeader = ( int8_t * )        "Контроллер будет перезагружен через 1 секунду\r\n";    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    if (cli_state->user_id != ADMIN) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    if (start_reboot) {        start_reboot = false;        strcpy( ( char * ) pcWriteBuffer, ( char * ) pcRebootHeader );        return pdTRUE;    } else {        Reboot(CLI_ACT);        return pdFALSE;    }}static portBASE_TYPE prvTaskSystimeCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    uint8_t len;    uint8_t i;    uint8_t fail = 0;    uint16_t temp = 0;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        const int8_t *const pcInfoTableHeader = ( int8_t * )            "\r\n******Системное время Контроллера******\r\n";        /* Return the next command help string, before moving the pointer on to        the next command in the list. */        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInfoTableHeader, strlen( ( char * ) pcInfoTableHeader ) );        GetDateStr(str, &len);        strcat(( char * ) pcWriteBuffer, "Дата:\t\t\t");        strncat(( char * ) pcWriteBuffer, str, len);        strcat(( char * ) pcWriteBuffer, "\r\nВремя:\t\t\t");        GetTimeStr(str, &len);        strncat(( char * ) pcWriteBuffer, str, len);        strcat(( char * ) pcWriteBuffer, "\r\n");        /* There are no more commands in the list, so there will be no more        strings to return after this one and pdFALSE should be returned. */        xReturn = pdFALSE;    } else {        if (cli_state->user_id != ADMIN) {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );            return pdFALSE;        }        for (i = 0; i < ARG_SYSTIME_ALL; i ++) {            if ( strncmp( ( const char * ) pcParameterString, systime_args_list[i], strlen(systime_args_list[i]) ) == 0                 && xParameterStringLength == strlen(systime_args_list[i])) {                break;            }        }        if (i != ARG_SYSTIME_ALL) {            if (sSettings.sSNTP.sntpEnable) {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcSystymeDenied, strlen( ( char * ) pcSystymeDenied ) );                return pdFALSE;            }        }        xParameterNumber ++;        /* Obtain the parameter string. */        pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter            (                pcCommandString,        /* The command string itself. */                xParameterNumber,       /* Return the next parameter. */                &xParameterStringLength /* Store the parameter string length. */            );        if (pcParameterString == NULL) {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            return pdFALSE;        }        memset(str, 0, sizeof(str));        xParameterStringLength = strlen(( const char * ) pcParameterString);        if (xParameterStringLength > (int32_t)sizeof(str)) {            xParameterStringLength = sizeof(str) - 1;        }        strncat(str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));        switch (i) {            case ARG_SYSTIME_DATA:                if (xParameterStringLength == 10) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (j != 4 && j != 7) {                            if (str[j] > 0x39 || str[j] < 0x30) {                                fail = 1;                            }                        } else if (j == 4 || j == 7) {                            if (str[j] != '-') {                                fail = 1;                            }                        }                    }                    if (!fail) {                        temp = 1000 * (str[0] - 0x30) + 100 * (str[1] - 0x30) + 10 * (str[2] - 0x30) + str[3] - 0x30;                        if (temp > 2099 || temp < 2000) {                            fail = 1;                        }                        temp = 0;                        temp = 10 * (str[5] - 0x30) + (str[6] - 0x30);                        if (temp > 12) {                            fail = 1;                        }                        temp = 0;                        temp = 10 * (str[8] - 0x30) + (str[9] - 0x30);                        if (temp > 31) {                            fail = 1;                        }                    }                } else {                    fail = 1;                }                if (!fail) {                    SetDateStr(str);                    cli_save_config(cli_state);                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            case ARG_SYSTIME_TIME:                if (xParameterStringLength == 5) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (j != 2) {                            if (str[j] > 0x39 || str[j] < 0x30) {                                fail = 1;                            }                        } else if (j == 2) {                            if (str[j]  != ':') {                                fail = 1;                            }                        }                    }                    if (!fail) {                        temp = 10 * (str[0] - 0x30) + (str[1] - 0x30);                        if (temp > 23) {                            fail = 1;                        }                        temp = 0;                        temp = 10 * (str[3] - 0x30) + (str[4] - 0x30);                        if (temp > 59) {                            fail = 1;                        }                    }                } else {                    fail = 1;                }                if (!fail) {                    SetTimeStr(str);                    cli_save_config(cli_state);                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }        xReturn = pdFALSE;    }    return xReturn;}/* * Implements the ntp command. */static portBASE_TYPE prvTaskNTPCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    char str_temp[110];    uint8_t len;    uint8_t i;    bool enable_old_sntp;    const int8_t *const pcInfoTableHeader = ( int8_t * )        "\r\n************NTP настройки Контроллера************\r\n";    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_NTP_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, ntp_args_list[i], strlen(ntp_args_list[i]) ) == 0             && xParameterStringLength == strlen(ntp_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_NTP_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    xParameterNumber ++;    if (pcParameterString == NULL) {        switch (i) {            case ARG_NTP_ENABLE:                enable_old_sntp = sSettings.sSNTP.sntpEnable;                SetSntpStateStr("1");                if (sSettings.sSNTP.sntpEnable != enable_old_sntp) {                    cli_save_config(cli_state);                }                break;            case ARG_NTP_DISABLE:                enable_old_sntp = sSettings.sSNTP.sntpEnable;                SetSntpStateStr("0");                if (sSettings.sSNTP.sntpEnable != enable_old_sntp) {                    cli_save_config(cli_state);                }                break;            case ARG_NTP_INFO:                /* Return the next command help string, before moving the pointer on to                the next command in the list. */                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInfoTableHeader, strlen( ( char * ) pcInfoTableHeader ) );                GetSntpStateStrRU(str, &len);                strcat(( char * ) pcWriteBuffer, "Режим установки времени:\t");                strncat(( char * ) pcWriteBuffer, str, len);                strcat(( char * ) pcWriteBuffer, "\r\nIP адрес NTP сервера:\t\t");                GetSntpServerIpStr(str, &len);                strncat(( char * ) pcWriteBuffer, str, len);                strcat(( char * ) pcWriteBuffer, "\r\nЧасовой пояс:\t\t\t");                GetSntpTimeZoneStr(str, &len);                strncat(( char * ) pcWriteBuffer, str, len);                strcat(( char * ) pcWriteBuffer, "\r\nПоследняя дата синхронизации:\t");                GetSntpLastDataStr(str, &len);                strncat(( char * ) pcWriteBuffer, str, len);                strcat(( char * ) pcWriteBuffer, "\r\n");                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }        return pdFALSE;    }    if (i == ARG_NTP_SET) {        memset(str, 0, sizeof(str));        if (xParameterStringLength > (int32_t)sizeof(str)) {            xParameterStringLength = sizeof(str) - 1;        }        strncat(str, ( const char * ) pcParameterString, xParameterStringLength);        pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter            (                pcCommandString,        /* The command string itself. */                xParameterNumber,       /* Return the next parameter. */                &xParameterStringLength /* Store the parameter string length. */            );        if (pcParameterString != NULL) {            memset(str_temp, 0, sizeof(str_temp));            if (xParameterStringLength > (int32_t)sizeof(str_temp)) {                xParameterStringLength = sizeof(str_temp) - 1;            }            strncat(str_temp, ( const char * ) pcParameterString, xParameterStringLength);            if (strncmp(str, "IP", 2) == 0) {                if (xParameterStringLength <= 15) {                    if (ipaddr_addr(str_temp) != IPADDR_NONE) {                        if (strncmp(str_temp, sSettings.sSNTP.ip, strlen(str_temp)) != 0 || strlen(sSettings.sSNTP.ip) != strlen(str_temp)) {                            SetSntpServerIpStr(str_temp);                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else if (strncmp(str, "gmt", 3) == 0) {                if (xParameterStringLength > 1 && xParameterStringLength < 5) {                    bool fail = false;                    if (str_temp[0] != '-' && str_temp[0] != '+') {                        fail = true;                    }                    if (!isdigit_int(str_temp[1]) && (!isdigit_int(str_temp[2]) && str_temp[2] != '.') && (!isdigit_int(str_temp[3]) &&                            str_temp[3] != '.')) {                        fail = true;                    }                    if (xParameterStringLength == 5) {                        if (!isdigit_int(str_temp[4])) {                            fail = true;                        }                    }                    if (!fail) {                        float value = atof(str_temp);                        if (value >= -12.0 && value <= 12.0) {                            SetSntpTimeZoneStr(str_temp);                            cli_save_config(cli_state);                        } else {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }    } else {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );    }    xReturn = pdFALSE;    return xReturn;}/* * Implements the network command. */static portBASE_TYPE prvTaskNetworkCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    uint8_t i;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_NETWORK_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, network_args_list[i], strlen(network_args_list[i]) ) == 0             && xParameterStringLength == strlen(network_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_NETWORK_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    if (i != ARG_NETWORK_ALL && i != ARG_NETWORK_DHCP && i != ARG_NETWORK_INFO) {        if (sSettings.sWebTempParams.dhcpEnable) {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );            return pdFALSE;        }    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        if (i == ARG_NETWORK_INFO) {            net_config_param(pcWriteBuffer);        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }        return pdFALSE;    }    memset(str, 0, sizeof(str));    xParameterStringLength = strlen(( const char * ) pcParameterString);    if (xParameterStringLength > (int32_t)sizeof(str)) {        xParameterStringLength = sizeof(str) - 1;    }    strncat(str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));    switch (i) {        case ARG_NETWORK_DHCP:            if (strncmp(str, "ENA", 3) == 0) {                SetUDPDhcpStateStr("True");                strcpy( ( char * ) pcWriteBuffer,                    "\t\tСохраните конфигурацию сетевых настроек\r\n" );            } else if (strncmp(str, "DIS", 3) == 0) {                SetUDPDhcpStateStr("False");                strcpy( ( char * ) pcWriteBuffer,                    "\t\tСохраните конфигурацию сетевых настроек\r\n" );            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        case ARG_NETWORK_IP:            if (xParameterStringLength <= 15) {                if (ipaddr_addr(str) != IPADDR_NONE) {                    SetIPStr(str);                    strcpy( ( char * ) pcWriteBuffer,                        "\t\tСохраните конфигурацию сетевых настроек\r\n" );                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        case ARG_NETWORK_GW:            if (xParameterStringLength <= 15) {                if (ipaddr_addr(str) != IPADDR_NONE) {                    SetGatewayStr(str);                    strcpy( ( char * ) pcWriteBuffer,                        "\t\tСохраните конфигурацию сетевых настроек\r\n" );                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        case ARG_NETWORK_MASK:            if (xParameterStringLength <= 15) {                uint32_t mask = ipaddr_addr(str);                if (mask != IPADDR_NONE) {                    if(ip4_addr_netmask_valid(mask)) {                        SetMaskStr(str);                        strcpy( ( char * ) pcWriteBuffer,                        "\t\tСохраните конфигурацию сетевых настроек\r\n" );                    }  else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                 } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            break;    }    xReturn = pdFALSE;    return xReturn;}/* * Implements the snmp command. */static portBASE_TYPE prvTaskSNMPCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[20];    char temp_str[20];    uint8_t i;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_SNMP_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, snmp_args_list[i], strlen(snmp_args_list[i]) ) == 0             && xParameterStringLength == strlen(snmp_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_SNMP_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    xParameterNumber ++;    if (pcParameterString == NULL) {        if (i == ARG_SNMP_INFO) {            snmp_config_param(pcWriteBuffer);        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }        return pdFALSE;    }    memset(str, 0, sizeof(str));    if (xParameterStringLength > (int32_t)sizeof(str)) {        xParameterStringLength = sizeof(str) - 1;    }    strncat(str, ( const char * ) pcParameterString, xParameterStringLength);    switch (i) {        case ARG_SNMP_SERVER:            if (xParameterStringLength == 1 && isdigit_int(str[0])) {                int32_t temp = atoi(str);                if (temp > 0 && temp < 6) {                    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter                        (                            pcCommandString,        /* The command string itself. */                            xParameterNumber,       /* Return the next parameter. */                            &xParameterStringLength /* Store the parameter string length. */                        );                    if (pcParameterString != NULL) {                        memset(str, 0, sizeof(str));                        xParameterStringLength = strlen(( const char * ) pcParameterString);                        if (xParameterStringLength > (int32_t)sizeof(str)) {                            xParameterStringLength = sizeof(str) - 1;                        }                        strncat(str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));                        if (xParameterStringLength <= 15) {                            if (ipaddr_addr(str) != IPADDR_NONE) {                                switch (temp) {                                    case 1:                                        SetManagerIp(str);                                        break;                                    case 2:                                        SetManagerIp2(str);                                        break;                                    case 3:                                        SetManagerIp3(str);                                        break;                                    case 4:                                        SetManagerIp4(str);                                        break;                                    case 5:                                        SetManagerIp5(str);                                        break;                                }                                if (temp > 0 && temp < 6) {                                    cli_save_config(cli_state);                                }                            } else {                                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            }                        } else {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        case ARG_SNMP_COMMUNITY:            pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter                (                    pcCommandString,        /* The command string itself. */                    xParameterNumber,       /* Return the next parameter. */                    &xParameterStringLength /* Store the parameter string length. */                );            if (pcParameterString != NULL) {                memset(temp_str, 0, sizeof(temp_str));                xParameterStringLength = strlen(( const char * ) pcParameterString);                if (xParameterStringLength > (int32_t)sizeof(temp_str)) {                    xParameterStringLength = sizeof(temp_str) - 1;                }                strncat(temp_str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));                if (control_string_en_digit(temp_str, strlen(temp_str))) {                    if (strncmp(str, "read", 4) == 0) {                        SetReadCommunity(temp_str);                        cli_save_config(cli_state);                    } else if (strncmp(str, "write", 5) == 0) {                        SetWriteCommunity(temp_str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            break;    }    xReturn = pdFALSE;    return xReturn;}/* * Implements the akb command. */static portBASE_TYPE prvTaskAKBCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    uint8_t i;	uint8_t fail = 0;	uint16_t temp = 0;    float value = 0;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_AKB_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, akb_args_list[i], strlen(akb_args_list[i]) ) == 0             && xParameterStringLength == strlen(akb_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_AKB_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        if (i == ARG_AKB_INFO) {            akb_config_param(pcWriteBuffer);        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }        return pdFALSE;    }    memset(str, 0, sizeof(str));    xParameterStringLength = strlen(( const char * ) pcParameterString);    if (xParameterStringLength > (int32_t)sizeof(str)) {        xParameterStringLength = sizeof(str) - 2;    }    strncat(str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));#if HARDWARE_BT6709 || HARDWARE_BT6709_MTS || HARDWARE_BT6710	if (i != ARG_AKB_DATASET)#endif	{		for (uint8_t j = 0; j < xParameterStringLength; j ++) {			if (!isfloatdigit(str[j])) {				strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );				return pdFALSE;			}		}		value = atof(str);	}    switch (i) {        case ARG_AKB_VOLT_CELL_MIN:            if (value < sSettings.UPS_Setting.Ucellmax && value >= MIN_VOLT_CELL_RANGE) {                SetUPSVoltCellMinStr(str);                cli_save_config(cli_state);            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        case ARG_AKB_VOLT_CELL_MAX:            if (value > sSettings.UPS_Setting.Ucellmin && value <= MAX_VOLT_CELL_RANGE) {                SetUPSVoltCellMaxStr(str);                cli_save_config(cli_state);            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;#if HARDWARE_BT6709 || HARDWARE_BT6709_MTS || HARDWARE_BT6711 || HARDWARE_BT6711_V1 || HARDWARE_BT6710        case ARG_AKB_CAPACITY:            if (value >= CAPACITY_MIN_RANGE && value <= CAPACITY_MAX_RANGE && (value - (int32_t)value) == 0) {                SetCapacityNominalAKBStr(str);                cli_save_config(cli_state);            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        case ARG_AKB_VOLT:            if (value >= AKB_VOLTAGE_MIN_RANGE && value <= AKB_VOLTAGE_MAX_RANGE && ((int32_t)value % 12) == 0 && (value - (int32_t)value) == 0) {                SetVoltageAKBNominalStr(str);                cli_save_config(cli_state);            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;#if HARDWARE_BT6709 || HARDWARE_BT6709_MTS || HARDWARE_BT6710        case ARG_AKB_LIFETIME:            if (value >= LIFETIME_MIN_RANGE && value <= LIFETIME_MAX_RANGE  && (value - (int32_t)value) == 0) {                SetLifeTimeAKBStr(str);                cli_save_config(cli_state);            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;		case ARG_AKB_DATASET:                if (xParameterStringLength == 10) {                    if (strncmp( str, "0000-00-00", 10) == 0) {                        memset(str, 0, sizeof(str));                        SetDataSetAKBStr(str);                        SETTINGS_Save();                        xReturn = pdFALSE;                        return xReturn;                    }                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (j != 4 && j != 7) {                            if (str[j] > 0x39 || str[j] < 0x30) {                                fail = 1;                            }                        } else if (j == 4 || j == 7) {                            if (str[j] != '-') {                                fail = 1;                            }                        }                    }                    if (!fail) {                        temp = 1000 * (str[0] - 0x30) + 100 * (str[1] - 0x30) + 10 * (str[2] - 0x30) + str[3] - 0x30;                        if (temp > 2099 || temp < 2000) {                            fail = 1;                        }                        temp = 0;                        temp = 10 * (str[5] - 0x30) + (str[6] - 0x30);                        if (temp > 12) {                            fail = 1;                        }                        temp = 0;                        temp = 10 * (str[8] - 0x30) + (str[9] - 0x30);                        if (temp > 31) {                            fail = 1;                        }                    }                } else {                    fail = 1;                }                if (!fail) {                    SetDataSetAKBStr(str);                    cli_save_config(cli_state);                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }			break;#endif        case ARG_AKB_UPS_POWER:            if (value >= UPS_POWER_MIN_RANGE && value <= UPS_POWER_MAX_RANGE && ((int32_t)value % 50) == 0 && (value - (int32_t)value) == 0) {                SetUPSPowerStr(str);                cli_save_config(cli_state);            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;#endif        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            break;    }    xReturn = pdFALSE;    return xReturn;}/* * Implements the alarm command. */static portBASE_TYPE prvTaskAlarmCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    uint8_t i, j;    float value = 0;    uint8_t k;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_ALARM_TYPE_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, type_alarm_args_list[i], strlen(type_alarm_args_list[i]) ) == 0             && xParameterStringLength == strlen(type_alarm_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_ALARM_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        if (i == ARG_ALARM_INFO) {            alarm_config_param(pcWriteBuffer);        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }        return pdFALSE;    }    for (j = 0; j < ARG_ALARM_ALL; j ++) {        if ( strncmp( ( const char * ) pcParameterString, alarm_args_list[j], strlen(alarm_args_list[j]) ) == 0 ) {            break;        }    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    memset(str, 0, sizeof(str));    xParameterStringLength = strlen(( const char * ) pcParameterString);    if (xParameterStringLength > (int32_t)sizeof(str)) {        xParameterStringLength = sizeof(str) - 2;    }    strncat(str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));    switch (i) {        case ARG_ALARM_TEMP:            switch (j) {                case ARG_ALARM_LINE_LOW:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            if (k == 0 && str[k] == '-') {                                continue;                            } else {                                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                                return pdFALSE;                            }                        }                    }                    value = atof(str);                    if (value >= MIN_TEMP_MIN_RANGE && value <= MIN_TEMP_MAX_RANGE) {                        SetTemperatureAlarmLowRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIGH:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= MAX_TEMP_MIN_RANGE && value <= MAX_TEMP_MAX_RANGE) {                        SetTemperatureAlarmHighRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIST:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isfloatdigit(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= HIST_TEMP_MIN_RANGE && value <= HIST_TEMP_MAX_RANGE) {                        SetTemperatureAlarmHisteStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                default:                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    break;            }            break;#ifndef HARDWARE_BT6710        case ARG_ALARM_LOAD:            switch (j) {                case ARG_ALARM_LINE_LOW:                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    break;                case ARG_ALARM_LINE_HIGH:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= MAX_LOAD_MIN_RANGE && value <= MAX_LOAD_MAX_RANGE) {                        SetLoadAlarmHighRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIST:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isfloatdigit(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= HIST_LOAD_MIN_RANGE && value <= HIST_LOAD_MAX_RANGE) {                        SetLoadAlarmHistStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                default:                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    break;            }            break;#endif        case ARG_ALARM_VOUT:            switch (j) {                case ARG_ALARM_LINE_LOW:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= MIN_VAC_MIN_RANGE && value <= MIN_VAC_MAX_RANGE) {                        SetVACAlarmLowRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIGH:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= MAX_VAC_MIN_RANGE && value <= MAX_VAC_MAX_RANGE) {                        SetVACAlarmHighRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIST:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= HIST_VAC_MIN_RANGE && value <= HIST_VAC_MAX_RANGE) {                        SetVACAlarmHisteStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                default:                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    break;            }            break;#ifdef TEMP_CABINET_MONITOR        case ARG_TEMP_CABINAT:            switch (j) {                case ARG_ALARM_LINE_LOW:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            if (k == 0 && str[k] == '-') {                                continue;                            } else {                                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                                return pdFALSE;                            }                        }                    }                    value = atof(str);                    if (value >= MIN_TEMP_MIN_RANGE && value <= MIN_TEMP_MAX_RANGE) {                        SetTemperatureCabinetAlarmLowRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIGH:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= MAX_TEMP_MIN_RANGE && value <= MAX_TEMP_MAX_RANGE) {                        SetTemperatureCabinetAlarmHighRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIST:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isfloatdigit(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= HIST_TEMP_MIN_RANGE && value <= HIST_TEMP_MAX_RANGE) {                        SetTemperatureCabinetAlarmHisteStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                default:                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    break;            }            break;#endif#ifdef VAC_IN_MONITOR        case ARG_ALARM_VACIN:            switch (j) {                case ARG_ALARM_LINE_LOW:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= MIN_VAC_MIN_RANGE && value <= MIN_VAC_MAX_RANGE) {                        SetVACInputAlarmLowRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIGH:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= MAX_VAC_MIN_RANGE && value <= MAX_VAC_MAX_RANGE) {                        SetVACInputAlarmHighRangeStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                case ARG_ALARM_LINE_HIST:                    for (k = 0; k < xParameterStringLength; k ++) {                        if (!isdigit_int(str[k])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    value = atof(str);                    if (value >= HIST_VAC_MIN_RANGE && value <= HIST_VAC_MAX_RANGE) {                        SetVACinputAlarmHisteStr(str);                        cli_save_config(cli_state);                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                    break;                default:                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    break;            }            break;#endif        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            break;    }    xReturn = pdFALSE;    return xReturn;}#ifdef NOTIFICATION_CONTROL_ENABLE/* * Implements the notification command. */static portBASE_TYPE prvTaskNotificationCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[20];    char temp_str[20];    uint8_t i;    char *beginValue;    uint8_t len;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_NOTIFICATION_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, notification_args_list[i], strlen(notification_args_list[i]) ) == 0             && xParameterStringLength == strlen(notification_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_NOTIFICATION_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    xParameterNumber ++;    if (pcParameterString == NULL) {        if (i == ARG_NOTIFICATION_INFO) {            notification_param(pcWriteBuffer);        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }        return pdFALSE;    }    memset(str, 0, sizeof(str));    if (xParameterStringLength > (int32_t)sizeof(str)) {        xParameterStringLength = sizeof(str) - 1;    }    strncat(str, ( const char * ) pcParameterString, xParameterStringLength);    switch (i) {        case ARG_NOTIFICATION_SET:            if (xParameterStringLength >= 1) {                for(uint32_t k = 0; k < xParameterStringLength; k ++) {                    if (!isdigit_int(str[k])) {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                         return pdFALSE;                    }                }                int32_t temp = atoi(str);                uint8_t value_notification = 0;                if (temp > 0 && temp < ALL_TRAPS) {                    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter                        (                            pcCommandString,        /* The command string itself. */                            xParameterNumber,       /* Return the next parameter. */                            &xParameterStringLength /* Store the parameter string length. */                        );                    if (pcParameterString != NULL && xParameterStringLength == 3) {                        if (strncmp(pcParameterString, "ENA", 3) == 0) {                            value_notification = 1;                            SetNotificationFlagsStr(&value_notification, (uint8_t)temp);                            SETTINGS_Save();                        } else if (strncmp(pcParameterString, "DIS", 3) == 0) {                            SetNotificationFlagsStr(&value_notification, (uint8_t)temp);                            SETTINGS_Save();                        } else {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            break;    }    xReturn = pdFALSE;    return xReturn;}#endif#ifdef WHITELIST_ENABLE/* * Implements the whitelist command. */static portBASE_TYPE prvTaskWhiteListCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[20];    char temp_str[20];    uint8_t i;    char *beginValue;    uint8_t len;    int32_t temp;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_WHITELIST_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, whitelist_args_list[i], strlen(whitelist_args_list[i]) ) == 0             && xParameterStringLength == strlen(whitelist_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_WHITELIST_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    xParameterNumber ++;    if (pcParameterString == NULL) {        if (i == ARG_WHITELIST_INFO) {            whitelist_config_param(pcWriteBuffer);        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }        return pdFALSE;    }    memset(str, 0, sizeof(str));    if (xParameterStringLength > (int32_t)sizeof(str)) {        xParameterStringLength = sizeof(str) - 1;    }    strncat(str, ( const char * ) pcParameterString, xParameterStringLength);    switch (i) {        case ARG_WHITELIST_RANGE:            if (xParameterStringLength == 1 && isdigit_int(str[0])) {                temp = atoi(str);                if (temp > 0 && temp < 6) {                    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter                        (                            pcCommandString,        /* The command string itself. */                            xParameterNumber,       /* Return the next parameter. */                            &xParameterStringLength /* Store the parameter string length. */                        );                    if (pcParameterString != NULL) {                        memset(str, 0, sizeof(str));                        xParameterStringLength = strlen(( const char * ) pcParameterString);                        if (xParameterStringLength > (int32_t)sizeof(str)) {                            xParameterStringLength = sizeof(str) - 1;                        }                        strncat(str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));                        if (xParameterStringLength <= 19) {                            beginValue = strpbrk(str, "/");                            if (beginValue == NULL) {                                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                                return pdFALSE;                            }                            int32_t mask = atoi(&beginValue[1]);                            len = beginValue - str;                            memset(temp_str, 0, sizeof(temp_str));                            strncpy(temp_str, str, len);                            for (uint8_t j = (len + 1); j < xParameterStringLength; j++) {                                if (!isdigit_int(str[j])) {                                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                                    return pdFALSE;                                }                            }                            if (ipaddr_addr(temp_str) != IPADDR_NONE && (mask <= 32 && mask >= 0)) {                                SetWhiteListSTR(str, (temp - 1));                                strcpy( ( char * ) pcWriteBuffer,                                    "\t\tСохраните конфигурацию сетевых настроек\r\n" );                            } else {                                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            }                        } else {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        case ARG_WHITELIST_RESET:            if (xParameterStringLength == 1 && isdigit_int(str[0])) {                temp = atoi(str);                if (temp > 0 && temp < 6) {                    memset(str, 0, sizeof(str));                    SetWhiteListSTR(str, (temp - 1));                    strcpy( ( char * ) pcWriteBuffer,                        "\t\tСохраните конфигурацию сетевых настроек\r\n" );                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            break;    }    xReturn = pdFALSE;    return xReturn;}#endif/* * Implements the change password command. */static portBASE_TYPE prvTaskUserCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    uint8_t i;    char temp_str[MAX_WEB_LOGIN_LEN];    char WebLogin[MAX_WEB_LOGIN_LEN];    uint8_t valueLen, user_id;    const int8_t *const pcChangePWDHeader = ( int8_t * ) "\r\nВведите новый пароль:";    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    if (cli_state->user_id != ADMIN) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_USER_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, user_args_list[i], strlen(user_args_list[i]) ) == 0 ) {            break;        }    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (i == ARG_USER_PWD) {        memset(temp_str, 0, sizeof(temp_str));        xParameterStringLength = strlen(( const char * ) pcParameterString);        if (xParameterStringLength > (int32_t)sizeof(temp_str)) {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        } else {            strncat(temp_str, ( const char * ) pcParameterString, strlen(( const char * ) pcParameterString));            for (user_id = 0; user_id < MAX_WEB_USERS; user_id++) {                GetUserLogin(user_id, WebLogin, &valueLen);                /* Check login and password */                if (strncmp(WebLogin, temp_str, MAX_WEB_LOGIN_LEN) == 0) {                    /* Login and pass are valid */                    cli_state->id_change_pwd = user_id;                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcChangePWDHeader, strlen( ( char * ) pcChangePWDHeader ) );                    cli_state->input_state = CLI_CHANGE_PWD;                    break;                }            }            if (cli_state->input_state != CLI_CHANGE_PWD) {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }        }    } else {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );    }    xReturn = pdFALSE;    return xReturn;}/* * Implements the config command. */static portBASE_TYPE prvTaskConfigCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    uint8_t i;    static uint8_t config_menu = 0;    const int8_t *const pcInfoTableHeader = ( int8_t * )        "\r\n*********Конфигурация Контроллера*********\r\n";    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_CONFIG_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, config_args_list[i], strlen(config_args_list[i]) ) == 0             && xParameterStringLength == strlen(config_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_CONFIG_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        switch (i) {            case ARG_CONFIG_INFO:                switch (config_menu) {                    case PARAM_CONFIG_SNMP:                        /* Return the next command help string, before moving the pointer on to                        the next command in the list. */                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInfoTableHeader, strlen( ( char * ) pcInfoTableHeader ) );                        snmp_config_param(pcWriteBuffer);                        break;#ifdef DINS_ENABLE || DOUTS_ENABLE || DALLAS_SENSOR_ENABLE || AM2301_SENSOR_ENABLE                    case PARAM_CONFIG_INOUTS:                        inouts_config_param(pcWriteBuffer);                        break;#endif#ifdef SYSLOG_ENABLE	                case PARAM_CONFIG_SYSLOG:                        syslog_config_param(pcWriteBuffer);                        break;#endif#ifdef RADIUS_SERVER_ENABLE	                case PARAM_CONFIG_RADIUS:                        radius_config_param(pcWriteBuffer);                        break;#endif                    case PARAM_CONFIG_AKB:                        akb_config_param(pcWriteBuffer);                        break;                    case PARAM_CONFIG_ALARM:                        alarm_config_param(pcWriteBuffer);                        break;#ifdef WHITELIST_ENABLE                    case PARAM_CONFIG_WHITELIST:                        whitelist_config_param(pcWriteBuffer);                        break;#endif                    case PARAM_CONFIG_NET:                        net_config_param(pcWriteBuffer);                        break; #ifdef PORTGW_ENABLE                    case PARAM_CONFIG_PGW:                        pgw_config_param(pcWriteBuffer);                        break;#endif                    case PARAM_CONFIG_TIME:                        time_config_param(pcWriteBuffer);                        break;                }                config_menu ++;                if (config_menu == PARAM_CONFIG_ALL) {                    config_menu = 0;                    return pdFALSE;                } else {                    return pdTRUE;                }                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }        return pdFALSE;    }    if (i == ARG_CONFIG_LOAD) {        memset(str, 0, sizeof(str));        xParameterStringLength = strlen(( const char * ) pcParameterString);        if (xParameterStringLength > (int32_t)sizeof(str)) {            xParameterStringLength = sizeof(str) - 1;        }        strncat(str, ( const char * ) pcParameterString, xParameterStringLength);        if (xParameterStringLength < 13) {            if (strncmp(str, "default", 7) == 0) {                SNMP_SendUserTrap(DEVICE_RESTORED);                log_event_data(LOG_SYSTEM_DEFCONFIG, "Администратор");                vTaskDelay(500);                SETTINGS_SetPartDefault();                cli_save_config(cli_state);                syslog_str(SYSLOG_INFORMATIONAL, "Сброс настроек (Администратор)");                strcpy( ( char * ) pcWriteBuffer,                    "\t\tНастройки сброшены к настройкам по умолчанию!\r\n");            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }    } else {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );    }    xReturn = pdFALSE;    return xReturn;}/* * Implements the config command. */static portBASE_TYPE prvTaskNetConfigCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    int8_t *pcParameterString;    portBASE_TYPE xParameterNumber = 1;    signed portBASE_TYPE xParameterStringLength;    uint8_t i;    static start = 0;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    for (i = 0; i < ARG_NETCONFIG_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, netconfig_args_list[i], strlen(netconfig_args_list[i]) ) == 0             && xParameterStringLength == strlen(netconfig_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    switch (i) {        case ARG_NETCONFIG_APPLY:            if (!start) {                /* Если параметры WEB изменились выставляем флаг, сохраняем настройки и перезагружаемся */                if (GetStateWebReinit() == true) {                    start = 1;                    SetWebReinitFlag(true);                    cli_save_config(cli_state);                    strcpy( ( char * ) pcWriteBuffer,                        "\t\tНастройки сохранены! Контроллер будет перезагружен\r\n\tПосле перезагрузки подтвердите изменения сетевых настроек\r\n");                    return pdTRUE;                }            } else {                start = 0;                vTaskDelay(1010);                Reboot(CLI_ACT);            }            break;        case ARG_NETCONFIG_CONFIRM:            SetWebReinitFlag(false);            SetConfirmWebParamsFlag();            strcpy( ( char * ) pcWriteBuffer, "\t\tСетевые настройки подтверждены!\r\n");            break;        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            break;    }    return pdFALSE;}/* * Implements the history command. */static portBASE_TYPE prvTaskHistoryCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    uint8_t i;    static int16_t num_page = 0;    static int16_t num_page_temp = 1;    static bool start = true;    const int8_t *const pcUPShistoryTableHeader = ( int8_t * )        "\r\n***********Журнал событий ИБП***********\r\n";    const int8_t *const pcControllerHistoryTableHeader = ( int8_t * )        "\r\n***********Журнал событий Контроллера***********\r\n";    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    if ( strncmp( ( const char * ) pcParameterString, "show", xParameterStringLength ) != 0 ) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    for (i = 0; i < ARG_HISTORY_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, history_args_list[i], strlen(history_args_list[i]) ) == 0             && xParameterStringLength == strlen(history_args_list[i])) {            break;        }    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    memset(str, 0, sizeof(str));    if (xParameterStringLength > 5) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    strncat(str, ( const char * ) pcParameterString, xParameterStringLength);    if (num_page == 0) {        num_page = atoi(str);        if (num_page <= 0) {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            return pdFALSE;        }    }    switch (i) {        case ARG_HISTORY_EVENTS:            if (start) {                start = false;                /* Return the next command help string, before moving the pointer on to                the next command in the list. */                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcControllerHistoryTableHeader,                    strlen( ( char * ) pcControllerHistoryTableHeader ) );                memset(str, 0, sizeof(str));                strcat(( char * ) pcWriteBuffer, "\r\n");                sprintf(str, "Количество страниц журнала: %d\r\n", History_GetPageCount());                strncat(( char * ) pcWriteBuffer, str, strlen(str));                strcat(( char * ) pcWriteBuffer, "\r\n");                if (num_page > History_GetPageCount()) {                    num_page = History_GetPageCount();                }            }            History_GetPage_tabs(( char * ) pcWriteBuffer, num_page_temp);            num_page --;            num_page_temp ++;            if (num_page == 0) {                num_page = 0;                num_page_temp = 1;                start = true;                xReturn = pdFALSE;            } else {                xReturn = pdTRUE;            }            break;        case ARG_HISTORY_UPS:            if (start) {                start = false;                /* Return the next command help string, before moving the pointer on to                the next command in the list. */                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcUPShistoryTableHeader,                    strlen( ( char * ) pcUPShistoryTableHeader ) );                memset(str, 0, sizeof(str));                sprintf(str, "Количество страниц журнала: %d\r\n", LOG_GetPageCount());                strncat(( char * ) pcWriteBuffer, str, strlen(str));                if (num_page > LOG_GetPageCount()) {                    num_page = LOG_GetPageCount();                }            }            LOG_GetPage_tabs(( char * ) pcWriteBuffer, num_page_temp);            num_page --;            num_page_temp ++;            if (num_page == 0) {                num_page = 0;                num_page_temp = 1;                start = true;                xReturn = pdFALSE;            } else {                xReturn = pdTRUE;            }            break;        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            xReturn = pdFALSE;            break;    }    return xReturn;}/* * Implements the sensor info command. */static portBASE_TYPE prvTaskSensorCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    uint8_t i;    char str[10];    char temp_str[10];    int32_t val = 0, val2 = 0;    uint8_t fail = 0;    static uint8_t config_menu = 0;    uint8_t MAX_CONFIG_PARAM = 0;#ifdef DINS_ENABLE || DOUTS_ENABLE || DALLAS_SENSOR_ENABLE || AM2301_SENSOR_ENABLE    MAX_CONFIG_PARAM = 3;#else    MAX_CONFIG_PARAM = 2;#endif    const int8_t *const pcSensorTableHeader = ( int8_t * )        "\r\n*********Параметры Контроллера*********\r\n";    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_SENSOR_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, sensor_args_list[i], strlen(sensor_args_list[i]) ) == 0             && xParameterStringLength == strlen(sensor_args_list[i])) {            break;        }    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        if (i == ARG_SENSOR_INFO) {            switch (config_menu) {                case 0:                    /* Return the next command help string, before moving the pointer on to                    the next command in the list. */                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcSensorTableHeader, strlen( ( char * ) pcSensorTableHeader ) );                    ups_sensor_param(pcWriteBuffer);                    break;                case 1:                    ups_sensor_akb_param(pcWriteBuffer);                    break;#ifdef DINS_ENABLE || DOUTS_ENABLE || DALLAS_SENSOR_ENABLE || AM2301_SENSOR_ENABLE                case 2:                    inouts_sensor_param(pcWriteBuffer);                    break;#endif            }            config_menu ++;            if (config_menu == MAX_CONFIG_PARAM) {                config_menu = 0;                return pdFALSE;            } else {                return pdTRUE;            }        } else {            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        }    } else {        switch (i) {#ifdef DINS_ENABLE || DOUTS_ENABLE || DALLAS_SENSOR_ENABLE || AM2301_SENSOR_ENABLE            case ARG_SENSOR_SETUP:                if (cli_state->user_id != ADMIN) {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );                    return pdFALSE;                }                memset(str, 0, sizeof(str));                if (xParameterStringLength > (int32_t)sizeof(str)) {                    xParameterStringLength = sizeof(str) - 1;                }                strncat(str, ( const char * ) pcParameterString, xParameterStringLength);                if (xParameterStringLength < 7) {                    xParameterNumber ++;                    /* Obtain the parameter string. */                    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter                        (                            pcCommandString,        /* The command string itself. */                            xParameterNumber,       /* Return the next parameter. */                            &xParameterStringLength /* Store the parameter string length. */                        );                    memset(temp_str, 0, sizeof(str));                    if (xParameterStringLength > 1) {                        fail = 1;                        break;                    }                    strncat(temp_str, ( const char * ) pcParameterString, xParameterStringLength);                    if (!isdigit_int(temp_str[0])) {                        fail = 1;                        break;                    }                    val = atoi(temp_str);                    xParameterNumber ++;                    /* Obtain the parameter string. */                    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter                        (                            pcCommandString,        /* The command string itself. */                            xParameterNumber,       /* Return the next parameter. */                            &xParameterStringLength /* Store the parameter string length. */                        );                    memset(temp_str, 0, sizeof(str));                                        fail = 1;#ifdef DINS_ENABLE                    if (strncmp(str, "DI", 2) == 0 && strlen(str) == 2) {                        if (xParameterStringLength > 1) {                            break;                        }                        strncat(temp_str, ( const char * ) pcParameterString, xParameterStringLength);                        if (!isdigit_int(temp_str[0])) {                            break;                        }                        if (val < 1 || val > INPUTS_TOTAL_COUNT) {                            break;                        }                        val2 = atoi(temp_str);                        if (val2 < 0 || val2 > 1) {                            break;                        }                        SetDINTypeActStr(temp_str, (val - 1));                        cli_save_config(cli_state);                        fail = 0;                    }#ifdef HARDWARE_BT6710                    else if (strncmp(str, "DIname", 6) == 0) {                        if (val < 1 || val > INPUTS_TOTAL_COUNT) {                            break;                        }                        if (xParameterStringLength > 21) {                            fail = 1;                            break;                        }                        strncat(temp_str, ( const char * ) pcParameterString, xParameterStringLength);                         if (!control_string_en_digit(temp_str, strlen(temp_str))) {                             break;                         }                        SetDINNameStr(temp_str, (val - 1));                        cli_save_config(cli_state);                        fail = 0;                    }#endif                   #endif#if defined(DALLAS_SENSOR_ENABLE) || defined(AM2301_SENSOR_ENABLE)                    if (strncmp(str, "TS", 2) == 0) {                        if (xParameterStringLength > 1) {                            break;                        }                        strncat(temp_str, ( const char * ) pcParameterString, xParameterStringLength);                        if (!isdigit_int(temp_str[0])) {                            break;                        }                        if (val < 1 || val > MAX_T_SENSORS) {                            break;                        }                        val2 = atoi(temp_str);                        if (val2 < TS_NONE || val2 > TS_AKB) {                            break;                        }                        SetTSlocationStr(temp_str, (val - 1));                        cli_save_config(cli_state);                        fail = 0;                    }#endif#ifdef DOUTS_ENABLE                     if (strncmp(str, "DO", 2) == 0) {                        if (xParameterStringLength > 1) {                            break;                        }                        strncat(temp_str, ( const char * ) pcParameterString, xParameterStringLength);                        if (!isdigit_int(temp_str[0])) {                            break;                        }                        if (val < 1 || val > 3) {                            break;                        }                        val2 = atoi(temp_str);                        if (val2 < 1 || val2 > 5) {                            break;                        }                        SetROTypeActStr(temp_str, (val - 1));                        cli_save_config(cli_state);                        fail = 0;                    }              #endif                 }                break;#endif            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }    }    if (fail) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );    }    xReturn = pdFALSE;    return xReturn;}/* * Implements the firmware download http command. */static portBASE_TYPE prvTaskUploadCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen,    const int8_t *pcCommandString ){    static bool start_update = true;    const int8_t *const pcUploadHeader = ( int8_t * )        "Контроллер переводится в режим загрузчика\r\n";    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    if (cli_state->user_id != ADMIN) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    if (start_update) {        start_update = false;        strcpy( ( char * ) pcWriteBuffer, ( char * ) pcUploadHeader );        return pdTRUE;    } else {        HTTP_StartResetTask(true);        return pdFALSE;    }}/* * Implements the ups command. */static portBASE_TYPE prvTaskUPSCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    int32_t val = 0;    float val_float = 0;    int8_t res = 0;    uint8_t i;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    if (cli_state->user_id != ADMIN) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    for (i = 0; i < ARG_UPS_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, ups_args_list[i], strlen(ups_args_list[i]) ) == 0             && xParameterStringLength == strlen(ups_args_list[i])) {            break;        }    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    memset(str, 0, sizeof(str));    if (xParameterStringLength > 3) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    strncat(str, ( const char * ) pcParameterString, xParameterStringLength);    switch (i) {        case ARG_UPS_BATTEST:            for (uint8_t j = 0; j < xParameterStringLength; j++) {                if (!isdigit_int(str[j])) {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    return pdFALSE;                }            }            val = atoi(str);            if (val == 0) {                res = ups_metac_service_pdu(ups_cancel_test);                set_act_source(CLI_ACT);                if (res == 1) {                    log_event_data(LOG_TEST_UPS, "Администратор (Останов)");                    strcpy( ( char * ) pcWriteBuffer, "\t\tКоманда \"Останов теста\" принята ИБП!\r\n");                } else {                    strcpy( ( char * ) pcWriteBuffer, "\t\tКоманда \"Останов теста\" отклонена ИБП!\r\n");                }            } else if (val > 0 && val < 100) {                TimeParam = val;                res = ups_metac_service_pdu(ups_test_time);                if (res == 1) {                    strcpy( ( char * ) pcWriteBuffer, "\t\tКоманда \"Запуск теста\" принята ИБП!\r\n");                } else {                    strcpy( ( char * ) pcWriteBuffer, "\t\tКоманда \"Запуск теста\" отклонена ИБП!\r\n");                }            } else if (val == 100) {                res = ups_metac_service_pdu(ups_test_10sec);                if (res == 1) {                    strcpy( ( char * ) pcWriteBuffer, "\t\tКоманда \"Запуск теста\" принята ИБП!\r\n");                } else {                    strcpy( ( char * ) pcWriteBuffer, "\t\tКоманда \"Запуск теста\" отклонена ИБП!\r\n");                }            } else if (val == 999) {                res = ups_metac_service_pdu(ups_test_low_bat);                if (res == 1) {                    strcpy( ( char * ) pcWriteBuffer, "\t\tКоманда \"Запуск теста\" принята ИБП!\r\n");                } else {                    strcpy( ( char * ) pcWriteBuffer, "\t\tКоманда \"Запуск теста\" отклонена ИБП!\r\n");                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        case ARG_UPS_SHUTDOWN:            for (uint8_t j = 0; j < xParameterStringLength; j++) {                if (!isfloatdigit(str[j])) {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    return pdFALSE;                }            }            val_float = atof(str);            if (val_float == 0) {                res = ups_metac_service_pdu(ups_cancel_shut_down);                if (res == 1) {                    log_event_data(LOG_SHUTDOWN_UPS, "Администратор (Останов)");                    strcpy( ( char * ) pcWriteBuffer, "\t\t\tВыключение нагрузки ИБП отменено!\r\n");                } else {                    strcpy( ( char * ) pcWriteBuffer,                        "\t\tВыключение нагрузки ИБП не удалось отменить!\r\n");                }            } else if (val_float > 0 && val_float <= 10) {                TimeParamFloat = val_float;                res = ups_metac_service_pdu(ups_shutdown);                if (res == 1) {                    log_event_data(LOG_SHUTDOWN_UPS, "Администратор");                    strcpy( ( char * ) pcWriteBuffer, "\t\tОтключение нагрузки ИБП!\r\n");                } else {                    strcpy( ( char * ) pcWriteBuffer, "\t\tОтключение нагрузки ИБП не удалось!\r\n");                }            } else {                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            }            break;        default:            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );            break;    }    xReturn = pdFALSE;    return xReturn;}#ifdef SYSLOG_ENABLEstatic portBASE_TYPE  prvTaskSysLogCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    char str_temp[110];    uint8_t len;    uint8_t i;    bool enable_old_syslog;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_SYSLOG_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, syslog_args_list[i], strlen(syslog_args_list[i]) ) == 0             && xParameterStringLength == strlen(syslog_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_SYSLOG_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        switch (i) {            case ARG_SYSLOG_INFO:                /* Return the next command help string, before moving the pointer on to                the next command in the list. */                syslog_config_param(pcWriteBuffer);                break;            case ARG_SYSLOG_ENABLE:                enable_old_syslog = sSettings.sSyslog.enabled;                SetSyslogEnable("on");                if (sSettings.sSyslog.enabled != enable_old_syslog) {                    cli_save_config(cli_state);                }                break;            case ARG_SYSLOG_DISABLE:                enable_old_syslog = sSettings.sSyslog.enabled;                SetSyslogEnable("off");                if (sSettings.sSyslog.enabled != enable_old_syslog) {                    cli_save_config(cli_state);                }                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }    } else {        memset(str_temp, 0, sizeof(str_temp));        if (xParameterStringLength > (int32_t)sizeof(str_temp)) {            xParameterStringLength = sizeof(str_temp) - 1;        }        strncat(str_temp, ( const char * ) pcParameterString, xParameterStringLength);        switch (i) {            case ARG_SYSLOG_IP:                if (xParameterStringLength <= 15) {                    if (ipaddr_addr(str_temp) != IPADDR_NONE) {                        GetSyslogServer(str, &len);                        if (strncmp(str_temp, str, strlen(str_temp)) != 0 || strlen(str_temp) != strlen(str)) {                            SetSyslogServer(str_temp);                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            case ARG_SYSLOG_PORT:                if (xParameterStringLength <= 5) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (!isdigit_int(str_temp[j])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    int temp = atoi(str_temp);                    if (temp > 0 && temp < 65535) {                        GetSyslogPort(str, &len);                        if (strncmp(str_temp, str, strlen(str_temp)) != 0) {                            SetSyslogPort(str_temp);                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }         }    xReturn = pdFALSE;    return xReturn;    }#endif#ifdef RADIUS_SERVER_ENABLEstatic portBASE_TYPE  prvTaskRADIUSCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    char str_temp[110];    uint8_t len;    uint8_t i;    bool enable_old_radius;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_RADIUS_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, radius_args_list[i], strlen(radius_args_list[i]) ) == 0             && xParameterStringLength == strlen(radius_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_RADIUS_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        switch (i) {            case ARG_RADIUS_INFO:                /* Return the next command help string, before moving the pointer on to                the next command in the list. */                radius_config_param(pcWriteBuffer);                break;            case ARG_RADIUS_ENABLE:                enable_old_radius = sSettings.sRADIUS.RDSEnable;                SetRDSEnableStateStr("on");                if (sSettings.sRADIUS.RDSEnable != enable_old_radius) {                    cli_save_config(cli_state);                }                break;            case ARG_RADIUS_DISABLE:                enable_old_radius = sSettings.sRADIUS.RDSEnable;                SetRDSEnableStateStr("off");                if (sSettings.sRADIUS.RDSEnable != enable_old_radius) {                    cli_save_config(cli_state);                }                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }    } else {        memset(str_temp, 0, sizeof(str_temp));        if (xParameterStringLength > (int32_t)sizeof(str_temp)) {            xParameterStringLength = sizeof(str_temp) - 1;        }        strncat(str_temp, ( const char * ) pcParameterString, xParameterStringLength);        switch (i) {            case ARG_RADIUS_IP:                if (xParameterStringLength <= 15) {                    if (ipaddr_addr(str_temp) != IPADDR_NONE) {                        GetRDSIpStr(str, &len);                        if (strncmp(str_temp, str, strlen(str_temp)) != 0 || strlen(str_temp) != strlen(str)) {                            SetRDSIpStr(str_temp);                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            case ARG_RADIUS_PORT:                if (xParameterStringLength <= 5) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (!isdigit_int(str_temp[j])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    int temp = atoi(str_temp);                    if (temp > 0 && temp < 65535) {                        GetRDSPortStr(str, &len);                        if (strncmp(str_temp, str, strlen(str_temp)) != 0) {                            SetRDSPortStr(str_temp);                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            case ARG_RADIUS_SECRET:                if (xParameterStringLength <= 17) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if ( str_temp[j] < 33 || str_temp[j] > 127 ) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    GetRDSPasswordkStr(str, &len);                    if (strncmp(str_temp, str, strlen(str_temp)) != 0 || strlen(str_temp) != strlen(str)) {                        SetRDSPasswordkStr(str_temp);                        cli_save_config(cli_state);                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }         }    xReturn = pdFALSE;    return xReturn;    }#endif#ifdef PORTGW_ENABLEstatic portBASE_TYPE  prvTaskPGWCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){    int8_t *pcParameterString;    signed portBASE_TYPE xParameterStringLength, xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    char str_temp[110];    uint8_t len;    uint8_t i;    bool enable_old_pgw;    ( void ) pcCommandString;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );        return pdFALSE;    }    for (i = 0; i < ARG_PGW_ALL; i ++) {        if ( strncmp( ( const char * ) pcParameterString, pgw_args_list[i], strlen(pgw_args_list[i]) ) == 0             && xParameterStringLength == strlen(pgw_args_list[i])) {            break;        }    }    if (cli_state->user_id != ADMIN && i != ARG_PGW_INFO) {        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );        return pdFALSE;    }    xParameterNumber ++;    /* Obtain the parameter string. */    pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    if (pcParameterString == NULL) {        switch (i) {            case ARG_PGW_INFO:                /* Return the next command help string, before moving the pointer on to                the next command in the list. */                pgw_config_param(pcWriteBuffer);                break;            case ARG_PGW_ENABLE:                enable_old_pgw = sSettings.sPortGw.enabled;                SetPortGwEnabledStr("on");                if (sSettings.sPortGw.enabled != enable_old_pgw) {                    cli_save_config(cli_state);                }                break;            case ARG_PGW_DISABLE:                enable_old_pgw = sSettings.sPortGw.enabled;                SetPortGwEnabledStr("off");                if (sSettings.sPortGw.enabled != enable_old_pgw) {                    cli_save_config(cli_state);                }                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }    } else {        memset(str_temp, 0, sizeof(str_temp));        if (xParameterStringLength > (int32_t)sizeof(str_temp)) {            xParameterStringLength = sizeof(str_temp) - 1;        }        strncat(str_temp, ( const char * ) pcParameterString, xParameterStringLength);        switch (i) {            case ARG_PGW_PORT:                if (xParameterStringLength <= 5) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (!isdigit_int(str_temp[j])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    int temp = atoi(str_temp);                    if (temp > 0 && temp < 65535) {                        GetPortGwPortnumStr(str, &len);                        if (strncmp(str_temp, str, strlen(str_temp)) != 0) {                            SetPortGwPortnumStr(str_temp);                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            case ARG_PGW_RATE:                if (xParameterStringLength <= 6) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (!isdigit_int(str_temp[j])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    int temp_rate = atoi(str_temp);                    if (temp_rate == 1200 || temp_rate == 2400 || temp_rate == 4800 || temp_rate == 9600                        || temp_rate == 19200 || temp_rate == 38400 || temp_rate == 57600 || temp_rate == 115200) {                        GetPortGwBaudStr(str, &len);                        if (strncmp(str_temp, str, strlen(str_temp)) != 0 || strlen(str_temp) != strlen(str)) {                            SetPortGwBaudStr(str_temp);                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            case ARG_PGW_PARITY:                if (xParameterStringLength == 1) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (!isdigit_int(str_temp[j])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    int temp_parity = atoi(str_temp);                    if (temp_parity >= GW_NO_PAR && temp_parity < MAX_PARITY_TYPES) {                        uint32_t parity;                        GetPortGwParityInt(&parity);                        if ((int)parity != temp_parity) {                            SetPortGwParityInt(temp_parity);                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            case ARG_PGW_DATALEN:            case ARG_PGW_STOPBIT:                if (xParameterStringLength == 1) {                    for (uint8_t j = 0; j < xParameterStringLength; j++) {                        if (!isdigit_int(str_temp[j])) {                            strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                            return pdFALSE;                        }                    }                    char limit1, limit2;                    if (i == ARG_PGW_DATALEN) {                        GetPortGwDatabitsStr(str, &len);                        limit1 = 0x37;                        limit2 = 0x38;                    } else {                        GetPortGwStopbitsStr(str, &len);                        limit1 = 0x31;                        limit2 = 0x32;                    }                    if (str_temp[0] == limit1 || str_temp[0] == limit2) {                                                if (str[0] != str_temp[0]) {                            if (i == ARG_PGW_DATALEN) {                                SetPortGwDatabitsStr(str_temp);                            } else {                                SetPortGwStopbitsStr(str_temp);                            }                            cli_save_config(cli_state);                        }                    } else {                        strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                    }                } else {                    strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                }                break;            default:                strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );                break;        }         }    xReturn = pdFALSE;    return xReturn;    }#endif#ifdef FTP_ENABLE#pragma GCC diagnostic error "-Wall"#pragma GCC diagnostic error "-Wextra"static portBASE_TYPE prvTaskFTPCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString){    int8_t *pcParameterString;    unsigned portBASE_TYPE xParameterStringLength;    signed portBASE_TYPE xReturn;    portBASE_TYPE xParameterNumber = 1;    char str[110];    uint8_t i;    ( void ) xWriteBufferLen;    configASSERT( pcWriteBuffer );    memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);    if (cli_state->user_id != ADMIN && i != ARG_FTP_info) {        strncpy((char *)pcWriteBuffer, (const char *)pcPermissionDenied, strlen((char *)pcPermissionDenied));        return pdFALSE;    }    /* Obtain the subcommand */    pcParameterString = (int8_t *)FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    for (i = 0; i < ARG_FTP_ALL; i++) {        if (strncmp((const char *)pcParameterString, ftp_args_list[i], strlen(ftp_args_list[i])) == 0            && xParameterStringLength == strlen(ftp_args_list[i])) {            break;        }    }    xParameterNumber++;    /* Obtain the subcommand parameter */    pcParameterString = (int8_t *)FreeRTOS_CLIGetParameter        (            pcCommandString,        /* The command string itself. */            xParameterNumber,       /* Return the next parameter. */            &xParameterStringLength /* Store the parameter string length. */        );    memset(str, 0, sizeof(str));    strncat(str, (const char *) pcParameterString, xParameterStringLength);    switch (i) {        case ARG_FTP_info:            ;            snprintf((char *)pcWriteBuffer, configCOMMAND_INT_MAX_OUTPUT_SIZE, "\r\n"                     "*******************Настройки FTP********************\r\n"                     "Адрес сервера: \t\t%s\r\n"                     "Порт: \t\t\t%u\r\n"                     "Путь к файлу: \t\t%s\r\n"                     "Имя пользователя: \t%s\r\n"                     "Пароль: \t\t%s\r\n",                     ipaddr_ntoa(&sSettings.sFTPUpdate.server_ip),                     sSettings.sFTPUpdate.server_port,                     sSettings.sFTPUpdate.remote_path,                     sSettings.sFTPUpdate.user,                     sSettings.sFTPUpdate.pass);            break;        case ARG_FTP_server_ip:            ;            ip_addr_t server_ip_old = sSettings.sFTPUpdate.server_ip;            if (!ipaddr_aton(str, &sSettings.sFTPUpdate.server_ip)) {                strcpy((char *)pcWriteBuffer, (const char *)pcInvalidCommand);                return pdFALSE;            }            if (!ip_addr_cmp(&sSettings.sFTPUpdate.server_ip, &server_ip_old)) {                cli_save_config(cli_state);            }            break;        case ARG_FTP_server_port:            ;            u16_t server_port_old = sSettings.sFTPUpdate.server_port;            int temp = atoi(str);            if (temp < 1 || temp > 65535) {                strcpy((char *)pcWriteBuffer, (const char *)pcInvalidCommand);                return pdFALSE;            } else {                sSettings.sFTPUpdate.server_port = temp;                if (sSettings.sFTPUpdate.server_port != server_port_old) {                    cli_save_config(cli_state);                }            }            break;        case ARG_FTP_remote_path: {            if (xParameterStringLength < 1 || xParameterStringLength >= sizeof(sSettings.sFTPUpdate.remote_path)) {                strcpy((char *)pcWriteBuffer, (const char *)pcInvalidCommand);                return pdFALSE;            } else {                strcpy(&sSettings.sFTPUpdate.remote_path, str);                cli_save_config(cli_state);            }            break; }        case ARG_FTP_user: {            if (xParameterStringLength < 1 || xParameterStringLength >= sizeof(sSettings.sFTPUpdate.user)) {                strcpy((char *)pcWriteBuffer, (const char *)pcInvalidCommand);                return pdFALSE;            } else {                strcpy(&sSettings.sFTPUpdate.user, str);                cli_save_config(cli_state);            }            break; }        case ARG_FTP_pass: {            if (xParameterStringLength < 1 || xParameterStringLength >= sizeof(sSettings.sFTPUpdate.pass)) {                strcpy((char *)pcWriteBuffer, (const char *)pcInvalidCommand);                return pdFALSE;            } else {                strcpy(&sSettings.sFTPUpdate.pass, str);                cli_save_config(cli_state);            }            break; }        case ARG_FTP_run: {            static bool ran = false;            if (ran) {                vTaskDelay(500 / portTICK_PERIOD_MS);                char *status = get_ftp_progress();                unsigned statuslen = strlen(status);                sprintf((char *)pcWriteBuffer, "Статус обновления по FTP: %s%%\r\n", status);                // stop polling when we get an error message or 100%                bool resume = statuslen < 3;                if (!resume) {                    ran = false;                }                return resume;            } else {                // run!                ftpcfg.settings = &sSettings.sFTPUpdate;                start_ftp_client(&ftpcfg);                strcpy((char *)pcWriteBuffer, "Начато обновление ПО по FTP\r\n");                ran = true;                // tell the caller to poll us for more data                return pdTRUE;            }            break; }        default:            strcpy((char *)pcWriteBuffer, (const char *)pcInvalidCommand);            break;    }    xReturn = pdFALSE;    return xReturn;}#endif // FTP_ENABLE/* * Implements the ups serial command. */static portBASE_TYPE prvSetUPSserialCommand(cli_state_t *cli_state,  int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString ){	int8_t *pcParameterString;	signed portBASE_TYPE xParameterStringLength;	portBASE_TYPE xParameterNumber = 1;	char str[10];	( void ) pcCommandString;	( void ) xWriteBufferLen;	configASSERT( pcWriteBuffer );	memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);	/* Obtain the parameter string. */	pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter															(																pcCommandString,		/* The command string itself. */																xParameterNumber,		/* Return the next parameter. */																&xParameterStringLength	/* Store the parameter string length. */															);	if(pcParameterString == NULL){		strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );		return pdFALSE;	}	if( strncmp( ( const char * ) pcParameterString, "SvUsn", xParameterStringLength ) != 0 ){		strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );			return pdFALSE;	}	xParameterNumber ++;	/* Obtain the parameter string. */	pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter															(																pcCommandString,		/* The command string itself. */																xParameterNumber,		/* Return the next parameter. */																&xParameterStringLength	/* Store the parameter string length. */															);	memset(str, 0, sizeof(str));	if(xParameterStringLength != 8){		strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );		return pdFALSE;	}	strncat(str, ( const char * ) pcParameterString, xParameterStringLength);	for(uint8_t j = 0; j < xParameterStringLength; j++){		if(!isdigit_int(str[j])){			strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );			return pdFALSE;		}	}	SetUPSSerialStr(str);    cli_save_config(cli_state);	return pdFALSE;}/*-----------------------------------------------------------*/
 |