Init
This commit is contained in:
commit
a88fc5c3f8
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// Created by zemon on 17.11.22.
|
||||
//
|
||||
|
||||
#ifndef UVEOS_ON_NATION_CLIMSDTABLE_H
|
||||
#define UVEOS_ON_NATION_CLIMSDTABLE_H
|
||||
|
||||
#include "CliCmd.h"
|
||||
#include "EraGlonassMsdTable.h"
|
||||
#include "EraGlonassUveos_Dumper.h"
|
||||
|
||||
typedef struct {
|
||||
tEraGlonassMsdTable *msdTable;
|
||||
tEraGlonassUveosDumperInterface *dumperInterface;
|
||||
} tCliCmdMsdTable;
|
||||
|
||||
|
||||
void CliCmdMsdTable_Init(tCliCmdMsdTable *env, tEraGlonassMsdTable *msdTable, tEraGlonassUveosDumperInterface *dumperInterface);
|
||||
|
||||
int32_t CliCmdMsdTable_Process(tCliCmdMsdTable *env, tCliCmd *cliCmd);
|
||||
|
||||
void CliCmdMsdTable_Help(tCliCmd *cli);
|
||||
|
||||
#endif //UVEOS_ON_NATION_CLIMSDTABLE_H
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
//
|
||||
// Created by zemon on 18.11.22.
|
||||
//
|
||||
|
||||
|
||||
#include <sys/select.h>
|
||||
#include <time.h>
|
||||
#include "CliCmd/MsdTable.h"
|
||||
#include "SystemDelayInterface.h"
|
||||
#include "AsciiStringAssmeblingUtils.h"
|
||||
#include "stream.h"
|
||||
|
||||
void CliCmdMsdTable_Init(tCliCmdMsdTable *env, tEraGlonassMsdTable *msdTable, tEraGlonassUveosDumperInterface *dumperInterface) {
|
||||
env->msdTable = msdTable;
|
||||
env->dumperInterface = dumperInterface;
|
||||
}
|
||||
|
||||
void CliCmdMsdTable_Help(tCliCmd *cli) {
|
||||
CliCmd_PrintLnStatic(cli, " access sub commands:");
|
||||
CliCmd_PrintLnStatic(cli, " command [ exit ] exit as this sub mode");
|
||||
CliCmd_PrintLnStatic(cli, " command [ ls ] exit as this sub mode");
|
||||
CliCmd_PrintLnStatic(cli, " command [ clear ]- listing all access variable and values");
|
||||
CliCmd_PrintLnStatic(cli, " syntaxis: [ command ]");
|
||||
CliCmd_PrintLnStatic(cli, "");
|
||||
}
|
||||
|
||||
void PrintTime(time_t rawtime, tSerialPortIO *serialPort) {
|
||||
struct tm ts;
|
||||
char buf[80];
|
||||
ts = *localtime(&rawtime);
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", &ts);
|
||||
debug_printf(serialPort, "%s\n", buf );
|
||||
}
|
||||
|
||||
void CliCmdMsdTable_List(tCliCmdMsdTable *env, tCliCmd *cliCmd) {
|
||||
bool emerg = false;
|
||||
for (uint32_t id = 0; id < EraGlonassMsdTable_GetSize(); ++id) {
|
||||
if (env->msdTable->items[id].msd.MSD_Data.msgId != 0) {
|
||||
emerg = true;
|
||||
CliCmd_PrintLnStatic(cliCmd, "======================= EMERGENCY INFORMATION =======================");
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "VIN = ");
|
||||
for (uint16_t vinCharInd = 0; vinCharInd < 18; ++vinCharInd) {
|
||||
debug_printf(cliCmd->serialCommandPort, "%u", (uint16_t) env->msdTable->items[id].msd.MSD_Data.vin[vinCharInd]);
|
||||
}
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "LAST MSG ID = ");
|
||||
debug_printf(cliCmd->serialCommandPort, "%u", (uint16_t) env->msdTable->items[id].msd.MSD_Data.msgId );
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "DIRECTION = ");
|
||||
debug_printf(cliCmd->serialCommandPort, "%u", (uint8_t) env->msdTable->items[id].msd.MSD_Data.direction );
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "ASI 15 = ");
|
||||
debug_printf(cliCmd->serialCommandPort, "%u", (uint16_t) env->msdTable->items[id].msd.MSD_Data.additionalData.asi15 );
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "LATITUDE = ");
|
||||
debug_printf(cliCmd->serialCommandPort, "%u", (uint32_t) env->msdTable->items[id].msd.MSD_Data.pos.lat );
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "LONGITUDE = ");
|
||||
debug_printf(cliCmd->serialCommandPort, "%u", (uint32_t) env->msdTable->items[id].msd.MSD_Data.pos.lon );
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "ATTEMPS LEFT = ");
|
||||
debug_printf(cliCmd->serialCommandPort, "%u", (uint32_t) env->msdTable->items[id].attemptsLeft );
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "TIME STAMP = ");
|
||||
PrintTime((uint32_t) env->msdTable->items[id].msd.MSD_Data.timestamp, cliCmd->serialCommandPort);
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
|
||||
//--------------------------------------------- MND BILD ----------------------------------------------
|
||||
tEraGlonassMsd *msd = &env->msdTable->items[id].msd;
|
||||
struct {
|
||||
uint8_t data[ERA_GLONASS_MSD_ENCODED_BUFFER_LENGTH];
|
||||
uint32_t len;
|
||||
}msdEncoded;
|
||||
|
||||
msdEncoded.len = EraGlonassMsdEncode(msd, MSD_V_2, msdEncoded.data);
|
||||
|
||||
char asciiMsd[msdEncoded.len * 2];
|
||||
size_t asciiMsdLen = 0;
|
||||
vAsciiStringAddBytesAsHex(asciiMsd, &asciiMsdLen, msdEncoded.data, msdEncoded.len);
|
||||
|
||||
CliCmd_PrintStatic(cliCmd, "MND INFO = ");
|
||||
CliCmd_Print(cliCmd,asciiMsd,asciiMsdLen);
|
||||
CliCmd_PrintLnStatic(cliCmd, "");
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
CliCmd_PrintLnStatic(cliCmd, "=====================================================================");
|
||||
}
|
||||
}
|
||||
|
||||
if(emerg == false) {
|
||||
CliCmd_PrintLnStatic(cliCmd, "======================== INFORMATION IS NONE ========================");
|
||||
}
|
||||
}
|
||||
|
||||
void CliCmdMsdTable_Clear(tCliCmdMsdTable *env, tCliCmd *cliCmd) {
|
||||
EraGlonassMsdTable_Init(env->msdTable);
|
||||
EraGlonassUveosDumper_ForceDump(env->dumperInterface);
|
||||
CliCmd_PrintLnStatic(cliCmd, "================== EMERGENCY INFORMATION IS CLEAR ===================");
|
||||
}
|
||||
|
||||
uint32_t CliCmdMsdTable_ProcessSub(tCliCmdMsdTable *env, tCliCmd *cliCmd) {
|
||||
|
||||
if (CliCmd_RxStartsWithStatic(cliCmd, "ls")) {
|
||||
CliCmdMsdTable_List(env, cliCmd);
|
||||
return 0;
|
||||
} else if (CliCmd_RxStartsWithStatic(cliCmd, "clear")) {
|
||||
CliCmdMsdTable_Clear(env, cliCmd);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t CliCmdMsdTable_Process(tCliCmdMsdTable *env, tCliCmd *cliCmd) {
|
||||
CliCmd_PrintStatic(cliCmd, "SWITCH TO MST TABLE MODE");
|
||||
CliCmdMsdTable_Help(cliCmd);
|
||||
CliCmd_RxSkipSpace(cliCmd);
|
||||
|
||||
if (CliCmd_RxLineLength(cliCmd) != 0) {
|
||||
for (;;) {
|
||||
CliCmd_WaitLine(cliCmd);
|
||||
|
||||
if (CliCmd_RxStartsWithStatic(cliCmd, "exit")) {
|
||||
CliCmd_PrintStatic(cliCmd, "SWITCH TO BASE MODE");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CliCmd_RxStartsWithStatic(cliCmd, "help")) {
|
||||
CliCmdMsdTable_Help(cliCmd);
|
||||
}
|
||||
|
||||
uint32_t result = CliCmdMsdTable_ProcessSub(env, cliCmd);
|
||||
if (!result) {
|
||||
//CliCmdMsdTable_Help(cliCmd);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return CliCmdMsdTable_ProcessSub(env, cliCmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"dep": [
|
||||
{
|
||||
"type": "git",
|
||||
"provider": "NAVIGATOR_UVEOS_NATION_TELIT",
|
||||
"repo": "EraGlonassMsdTable"
|
||||
},
|
||||
{
|
||||
"type": "git",
|
||||
"provider": "NAVIGATOR_UVEOS_NATION_TELIT",
|
||||
"repo": "CliCmd"
|
||||
}
|
||||
],
|
||||
"cmake": {
|
||||
"inc_dirs": [
|
||||
"Inc"
|
||||
],
|
||||
"srcs": [
|
||||
"Src/**.c"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue