This commit is contained in:
cfif 2024-12-04 13:10:49 +03:00
commit 670d3aa532
4 changed files with 251 additions and 0 deletions

25
Inc/CliCmd/NetGsmUpDown.h Normal file
View File

@ -0,0 +1,25 @@
//
// Created by zemon on 23.03.23.
//
#ifndef UVEOS_ON_NATION_NETGSMUPDOWN_H
#define UVEOS_ON_NATION_NETGSMUPDOWN_H
#include "CliCmd.h"
#include "PowerManagement.h"
#include "GsmWithGnss.h"
typedef struct {
tGsmWithGnss *gsmWithGnss;
tPowerManagement *power;
tEraGlonassUveos *uveos;
bool netState;
} tAddFunc;
void CliCmd_AddInfoInit(tAddFunc *addFunc, tGsmWithGnss *gsmWithGnss, tEraGlonassUveos *uveos, tPowerManagement *power);
uint8_t CliCmd_powerStateHelp(tCliCmd *cli);
uint8_t CliCmd_AddInfo(tAddFunc *addFunc, tCliCmd *cli);
#endif //UVEOS_ON_NATION_NETGSMUPDOWN_H

178
Src/CliCmd/NetGsmUpDown.c Normal file
View File

@ -0,0 +1,178 @@
//
// Created by zemon on 23.03.23.
//
#include <stdlib.h>
#include <math.h>
#include "CliCmd/NetGsmUpDown.h"
#include "SystemDelayInterface.h"
#include "PowerManagement.h"
#include "AsciiStringAssmeblingUtils.h"
#include "stream.h"
void CliCmd_AddInfoInit(tAddFunc *addFunc, tGsmWithGnss *gsmWithGnss, tEraGlonassUveos *uveos, tPowerManagement *power){
addFunc->gsmWithGnss = gsmWithGnss;
addFunc->power = power;
addFunc->uveos = uveos;
}
bool CliCmd_GetOffsetToDistance(tAddFunc *env, tCliCmd *cliCmd){
size_t str_len = 0;
char step[20];
EraGlonassUveosNavData movDinst;
while (1) {
CliCmd_WaitLineDelay(cliCmd, 1500);
if (CliCmd_RxStartsWithStatic(cliCmd, "exit")) {
CliCmd_PrintLnStatic(cliCmd, "EXIT IN BASE MODE...");
return 0;
}
if (CliCmd_RxStartsWithStatic(cliCmd, "exit")) {
CliCmd_PrintLnStatic(cliCmd, "EXIT IN BASE MODE...");
return 0;
}
if (env->uveos->doNothing.stopLimitTime < SystemGetMs()) {
NavDataProvider_GetNavData(env->uveos->navDataProvider, &env->uveos->doNothing.movePosition, false);
CliCmd_PrintStatic(cliCmd, "Установлена новая точка отсчёта движения ТС\r\n");
env->uveos->doNothing.stopLimitTime = SystemGetMs() + (40 * 1000);
}
if (env->uveos->doNothing.movePosition.valid > 0) {
NavDataProvider_GetNavData(env->uveos->navDataProvider, &movDinst, false);
uint32_t latDistance = abs(movDinst.latitude - env->uveos->doNothing.movePosition.latitude);
uint32_t lonDistance = abs(movDinst.longitude - env->uveos->doNothing.movePosition.longitude);
double x = latDistance * 0.1;
double y = lonDistance * 0.1;
double move = sqrt(x * x + y * y);
env->uveos->doNothing.movDist = (uint32_t) move;
vAsciiStringInit(step, &str_len, 5);
vAsciiStringAddDecimalInt64(step, &str_len, env->uveos->doNothing.movDist, 5);
CliCmd_PrintStatic(cliCmd, "Отклонение = ");
debug_printf(cliCmd->serialCommandPort, "%u", step);
CliCmd_PrintStatic(cliCmd, "\n");
} else {
CliCmd_PrintStatic(cliCmd, "Данные GNSS не валидны\r\n");
}
}
}
uint8_t CliCmd_AddInfo(tAddFunc *env, tCliCmd *cli) {
CliCmd_PrintLnStatic(cli, "THIS MODE IS MANAGE COMMUNICATION SUBSUSTEM STATUS");
CliCmd_powerStateHelp(cli);
while (1) {
CliCmd_WaitLineDelay(cli, 1500);
if (CliCmd_RxStartsWithStatic(cli, "exit")) {
CliCmd_PrintLnStatic(cli, "EXIT IN BASE MODE...");
return 0;
}
if (CliCmd_RxStartsWithStatic(cli, "breakTest")) {
env->uveos->doNothing.mode = UVEOS_DO_NOTHING_DISABLED;
}
if (CliCmd_RxStartsWithStatic(cli, "pulMsd")) {
env->gsmWithGnss->urc.msdPull = true;
}
if (CliCmd_RxStartsWithStatic(cli, "getOfset")) {
CliCmd_GetOffsetToDistance(env, cli);
}
if (CliCmd_RxStartsWithStatic(cli, "gsmUp")) {
GsmWithGnssInitGnss(env->gsmWithGnss);
if(GsmWithGnss_InvalidateNetworkEnable(env->gsmWithGnss, 0, true)){
CliCmd_PrintLnStatic(cli, "GSM network is up");
} else {
CliCmd_PrintLnStatic(cli, "GSM network upping is error");
}
}
if (CliCmd_RxStartsWithStatic(cli, "gsmDown")) {
GsmWithGnssInitGnss(env->gsmWithGnss);
if(GsmWithGnss_InvalidateNetworkEnable(env->gsmWithGnss, 0, false) == false){
CliCmd_PrintLnStatic(cli, "GSM network is down");
} else {
CliCmd_PrintLnStatic(cli, "GSM network down is error");
}
}
if (CliCmd_RxStartsWithStatic(cli, "audioUp")) {
Pwm_AudioEnable(env->power);
CliCmd_PrintLnStatic(cli, "audio subsystem is up");
}
if (CliCmd_RxStartsWithStatic(cli, "audioDown")) {
Pwm_AudioDisable(env->power);
CliCmd_PrintLnStatic(cli, "audio subsystem is down");
}
if (CliCmd_RxStartsWithStatic(cli, "bipUp")) {
Pwm_GsmAndBipStartUp(env->power);
CliCmd_PrintLnStatic(cli, "block user interface is up");
}
if (CliCmd_RxStartsWithStatic(cli, "bipDown")) {
Pwm_BipShutdown(env->power);
CliCmd_PrintLnStatic(cli, "block user interface is down");
}
if (CliCmd_RxStartsWithStatic(cli, "commIntDown")) {
CliCmd_PrintLnStatic(cli, "Command interface is down");
Pwm_Rs485Disable(env->power);
}
if (CliCmd_RxStartsWithStatic(cli, "charUp")) {
Pwm_ChargeEnable(env->power);
CliCmd_PrintLnStatic(cli, "Charge battary is up");
}
if (CliCmd_RxStartsWithStatic(cli, "charDown")) {
Pwm_ChargeDisable(env->power);
CliCmd_PrintLnStatic(cli, "Charge battary is down");
}
if (CliCmd_RxStartsWithStatic(cli, "netPowerUp")) {
Pwm_GsmAndGnssStartup(env->power);
CliCmd_PrintLnStatic(cli, "Enabled power network subsystem");
}
if (CliCmd_RxStartsWithStatic(cli, "netPowerDown")) {
Pwm_GsmAndGnssShutdown(env->power);
CliCmd_PrintLnStatic(cli, "Disabled power network subsystem");
}
if (CliCmd_RxStartsWithStatic(cli, "fullUp")) {
Pwm_PowerSavingDisable(env->power);
}
if (CliCmd_RxStartsWithStatic(cli, "fullDown")) {
Pwm_PowerSavingEnable(env->power);
CliCmd_PrintLnStatic(cli, "Command interface is upping, for is down ComInt enter command [ commIntDown ]");
}
if (CliCmd_RxStartsWithStatic(cli, "help")) {
CliCmd_powerStateHelp(cli);
CliCmd_WaitLine(cli);
}
if (CliCmd_RxStartsWithStatic(cli, "rmcStop")) {
GsmWithGnss_StopRMCThread(&env->gsmWithGnss->gsmAt);
CliCmd_PrintLnStatic(cli, "+++ is sending");
}
if (CliCmd_RxStartsWithStatic(cli, "rmcStart")) {
GsmWithGnss_ActivateRMCPort(&env->gsmWithGnss->gsmAt);
GsmWithGnss_StartRMCThread(&env->gsmWithGnss->gsmAt);
CliCmd_PrintLnStatic(cli, "rmc is sending");
}
SystemDelayMs(10);
}
}

View File

@ -0,0 +1,31 @@
//
// Created by zemon on 23.03.23.
//
#include "CliCmd/NetGsmUpDown.h"
uint8_t CliCmd_powerStateHelp(tCliCmd *cli) {
CliCmd_PrintLnStatic(cli, " access sub commands:");
CliCmd_PrintLnStatic(cli, " command [ rmcStop ] - stop RMC nav thread");
CliCmd_PrintLnStatic(cli, " command [ gsmUp ] - Enabled GSM network");
CliCmd_PrintLnStatic(cli, " command [ gsmDown ] - Disabled GSM network");
CliCmd_PrintLnStatic(cli, " command [ netPowerUp ] - Enabled power network subsystem");
CliCmd_PrintLnStatic(cli, " command [ netPowerDown ] - Disabled power network subsystem");
CliCmd_PrintLnStatic(cli, " command [ audioUp ] - Audio power is up");
CliCmd_PrintLnStatic(cli, " command [ audioDown ] - Audio power is down");
CliCmd_PrintLnStatic(cli, " command [ bipUp ] - block user interface is up");
CliCmd_PrintLnStatic(cli, " command [ bipDown ] - block user interface is down");
CliCmd_PrintLnStatic(cli, " command [ charUp ] - Charge battary is up");
CliCmd_PrintLnStatic(cli, " command [ charDown ] - Charge battary is down");
CliCmd_PrintLnStatic(cli, " command [ commIntDown ] - Command interface is down");
CliCmd_PrintLnStatic(cli, " command [ fullUp ] - Full peref devise is upiing");
CliCmd_PrintLnStatic(cli, " command [ fullDown ] - Full peref devise is down");
CliCmd_PrintLnStatic(cli, " command [ exit ] - exit as this sub mode");
CliCmd_PrintLnStatic(cli, " command [ pulMsd ] - set pul qwery of msd");
CliCmd_PrintLnStatic(cli, " command [ getOfset ] - get this offset to distance");
CliCmd_PrintLnStatic(cli, " command [ breakTest ] - direct exit is testing mode of distance");
CliCmd_PrintLnStatic(cli, " command [ rmcStop ]");
CliCmd_PrintLnStatic(cli, " command [ rmcStart ]");
CliCmd_PrintLnStatic(cli, "");
return 0;
}

17
modular.json Normal file
View File

@ -0,0 +1,17 @@
{
"dep": [
{
"type": "git",
"provider": "NAVIGATOR_UVEOS_NATION_TELIT",
"repo": "CliCmd"
}
],
"cmake": {
"inc_dirs": [
"Inc"
],
"srcs": [
"Src/**.c"
]
}
}