Init
This commit is contained in:
commit
71c65f5b2a
|
|
@ -0,0 +1,46 @@
|
||||||
|
//
|
||||||
|
// Created by zemon on 24.11.22.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef UVEOS_ON_NATION_FLIPSETTING_H
|
||||||
|
#define UVEOS_ON_NATION_FLIPSETTING_H
|
||||||
|
|
||||||
|
#include "CliCmd.h"
|
||||||
|
#include "CarFlipDetection.h"
|
||||||
|
#include "ComIntCmd/Vars.h"
|
||||||
|
#include "Accel_QMA6100P.h"
|
||||||
|
#include "CarCrashDetection.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tVariablesTable *externTable;
|
||||||
|
tCarFlipDetection *flipDetect;
|
||||||
|
tAccelCoor *accelCoor;
|
||||||
|
tCarCrashDetection *carCrashDetection;
|
||||||
|
float isDetectValue;
|
||||||
|
|
||||||
|
float val_x;
|
||||||
|
float val_y;
|
||||||
|
float val_z;
|
||||||
|
|
||||||
|
int32_t valGraviti_x;
|
||||||
|
int32_t valGraviti_y;
|
||||||
|
int32_t valGraviti_z;
|
||||||
|
|
||||||
|
float asi15This;
|
||||||
|
float asi15Limit;
|
||||||
|
float angleCos;
|
||||||
|
} tFlipSetting;
|
||||||
|
|
||||||
|
void CliCmd_FlipSettingInit(
|
||||||
|
tFlipSetting *tFlipSet,
|
||||||
|
tCarFlipDetection *tFlipBase,
|
||||||
|
tVariablesTable *externTable,
|
||||||
|
tAccelCoor *tAccelCoor,
|
||||||
|
tCarCrashDetection *carCrashDetection
|
||||||
|
);
|
||||||
|
|
||||||
|
uint8_t CliCmd_FlipSetting(tFlipSetting *tFlipSet, tCliCmd *cli);
|
||||||
|
|
||||||
|
void CliCmd_flipModedHelp(void *env, tCliCmd *cli);
|
||||||
|
|
||||||
|
#endif //UVEOS_ON_NATION_FLIPSETTING_H
|
||||||
|
|
@ -0,0 +1,224 @@
|
||||||
|
////
|
||||||
|
//// Created by zemon on 18.11.22.
|
||||||
|
////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#include "CliCmd/FlipSetting.h"
|
||||||
|
#include "SystemDelayInterface.h"
|
||||||
|
#include "XfcProtProcessorUtilDefines.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "stream.h"
|
||||||
|
|
||||||
|
void CliCmd_flipModedHelp(void *env, tCliCmd *cli) {
|
||||||
|
CliCmd_PrintLnStatic(cli, " access sub commands:");
|
||||||
|
CliCmd_PrintLnStatic(cli, " command [ exit ] - exit as this sub mode");
|
||||||
|
CliCmd_PrintLnStatic(cli, " command [ help ] - help this as sub mode");
|
||||||
|
CliCmd_PrintLnStatic(cli, " command [ stop] - stop listing data acsel");
|
||||||
|
CliCmd_PrintLnStatic(cli, " command [ rec_angle ] - record this params");
|
||||||
|
CliCmd_PrintLnStatic(cli, " command [ rec_vector ] - record this params");
|
||||||
|
CliCmd_PrintLnStatic(cli, " press ENTER key to continue");
|
||||||
|
CliCmd_PrintLnStatic(cli, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
char sps[] = " ";
|
||||||
|
char ln[] = "\n";
|
||||||
|
void printSps(tCliCmd *cli) {
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) sps, sizeof(sps) - 1, SystemWaitForever);
|
||||||
|
}
|
||||||
|
void printLn(tCliCmd *cli) {
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) ln, sizeof(ln) - 1, SystemWaitForever);
|
||||||
|
}
|
||||||
|
void updateData(tFlipSetting *env) {
|
||||||
|
env->val_x = env->flipDetect->current.value.x;
|
||||||
|
env->val_y = env->flipDetect->current.value.y;
|
||||||
|
env->val_z = env->flipDetect->current.value.z;
|
||||||
|
|
||||||
|
env->valGraviti_x = env->accelCoor->x;
|
||||||
|
env->valGraviti_y = env->accelCoor->y;
|
||||||
|
env->valGraviti_z = env->accelCoor->z;
|
||||||
|
|
||||||
|
if(env->isDetectValue != env->carCrashDetection->asi15.isDetectValue) {
|
||||||
|
env->isDetectValue = env->carCrashDetection->asi15.isDetectValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
env->asi15This = env->carCrashDetection->asi15This;
|
||||||
|
env->asi15Limit = *env->carCrashDetection->asi15.threshold;
|
||||||
|
env->angleCos = env->flipDetect->current.angleCos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void printData(tFlipSetting *tFlipSet, tCliCmd *cli, uint32_t timeout) {
|
||||||
|
|
||||||
|
uint32_t endMs = SystemGetMs() + timeout;
|
||||||
|
|
||||||
|
updateData(tFlipSet);
|
||||||
|
|
||||||
|
printLn(cli);
|
||||||
|
CliCmd_PrintLnStatic(cli, "==================================================================");
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "| Cos=", sizeof("| Cos="), SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "%f", *(float *) &tFlipSet->angleCos);
|
||||||
|
printSps(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "X=", 2, SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "%f", *(float *) &tFlipSet->val_x);
|
||||||
|
printSps(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "Y=", 2, SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "%f", *(float *) &tFlipSet->val_y);
|
||||||
|
printSps(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "Z=", 2, SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "%f |", *(float *) &tFlipSet->val_z);
|
||||||
|
printSps(cli);
|
||||||
|
printLn(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "| ACCELERATOR_X", sizeof("| ACCELERATOR_X"), SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "(MicroG)=%d", *(int32_t *) &tFlipSet->valGraviti_x);
|
||||||
|
debug_printf(cli->serialCommandPort, " (MiliG)=%d |" , *(int32_t *) &tFlipSet->valGraviti_x/1000);
|
||||||
|
printSps(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "| ACCELERATOR_Y", sizeof("| ACCELERATOR_Y"), SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "(MicroG)=%d", *(int32_t *) &tFlipSet->valGraviti_y);
|
||||||
|
debug_printf(cli->serialCommandPort, " (MiliG)=%d |" , *(int32_t *) &tFlipSet->valGraviti_y/1000);
|
||||||
|
printSps(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "| ACCELERATOR_Z", sizeof("| ACCELERATOR_Z"), SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "(MicroG)=%d", *(int32_t *) &tFlipSet->valGraviti_z);
|
||||||
|
debug_printf(cli->serialCommandPort, " (MiliG)=%d |" , *(int32_t *) &tFlipSet->valGraviti_z/1000);
|
||||||
|
printSps(cli);
|
||||||
|
printLn(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "| THIS_ASI15", sizeof("| THIS_ASI15"), SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "=%f |", *(float *) &tFlipSet->asi15This);
|
||||||
|
printSps(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "| ASI_TRESHOLD", sizeof("| ASI_TRESHOLD"), SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "=%f |", *(float *) &tFlipSet->asi15Limit);
|
||||||
|
printSps(cli);
|
||||||
|
SerialPortTransmit(cli->serialCommandPort, (uint8_t *) "| ACTIVATION_VALUE_ASI15", sizeof("| ACTIVATION_VALUE_ASI15"), SystemWaitForever);
|
||||||
|
debug_printf(cli->serialCommandPort, "=%f |", *(float *) &tFlipSet->isDetectValue);
|
||||||
|
|
||||||
|
printLn(cli);
|
||||||
|
CliCmd_PrintLnStatic(cli, "==================================================================");
|
||||||
|
printLn(cli);
|
||||||
|
|
||||||
|
while (endMs > SystemGetMs()) {
|
||||||
|
SystemDelayMs(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t recordVarData(tFlipSetting *tFlipSet, tCliCmd *cli, uint8_t stat) {
|
||||||
|
char *nameFiled;
|
||||||
|
tVariableDescriptor *descriptor;
|
||||||
|
|
||||||
|
if (VariablesTable_RequireChange(tFlipSet->externTable, 10)) {
|
||||||
|
if (stat == 0) {
|
||||||
|
|
||||||
|
nameFiled = "FLIP_DETECT_TRESHOLD_ANGLE_COS";
|
||||||
|
descriptor = VariablesTable_GetByName(tFlipSet->externTable, nameFiled, strlen(nameFiled));
|
||||||
|
memcpy(descriptor->addr, &tFlipSet->angleCos, sizeof(tFlipSet->angleCos));
|
||||||
|
|
||||||
|
VariablesTable_VariableChanged(tFlipSet->externTable, descriptor);
|
||||||
|
VariablesTable_ReleaseChange(tFlipSet->externTable);
|
||||||
|
|
||||||
|
CliCmd_PrintLnStatic(cli, " record angle is success");
|
||||||
|
//осовбождаем доступ к измененению настроек
|
||||||
|
VariablesTable_ReleaseChange(tFlipSet->externTable);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
nameFiled = "FLIP_DETECT_GRAVITY_X";
|
||||||
|
descriptor = VariablesTable_GetByName(tFlipSet->externTable, nameFiled, strlen(nameFiled));
|
||||||
|
memcpy(descriptor->addr, &tFlipSet->val_x, sizeof(tFlipSet->val_x));
|
||||||
|
|
||||||
|
nameFiled = "FLIP_DETECT_GRAVITY_Y";
|
||||||
|
descriptor = VariablesTable_GetByName(tFlipSet->externTable, nameFiled, strlen(nameFiled));
|
||||||
|
memcpy(descriptor->addr, &tFlipSet->val_y, sizeof(tFlipSet->val_y));
|
||||||
|
|
||||||
|
nameFiled = "FLIP_DETECT_GRAVITY_Z";
|
||||||
|
descriptor = VariablesTable_GetByName(tFlipSet->externTable, nameFiled, strlen(nameFiled));
|
||||||
|
memcpy(descriptor->addr, &tFlipSet->val_z, sizeof(tFlipSet->val_z));
|
||||||
|
|
||||||
|
VariablesTable_VariableChanged(tFlipSet->externTable, descriptor);
|
||||||
|
VariablesTable_ReleaseChange(tFlipSet->externTable);
|
||||||
|
|
||||||
|
//осовбождаем доступ к измененению настроек
|
||||||
|
VariablesTable_ReleaseChange(tFlipSet->externTable);
|
||||||
|
CliCmd_PrintLnStatic(cli, " record vector is success");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//осовбождаем доступ к измененению настроек
|
||||||
|
VariablesTable_ReleaseChange(tFlipSet->externTable);
|
||||||
|
CliCmd_PrintLnStatic(cli, "Variable is busy");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void getNewData(tFlipSetting *tFlipSet, tCliCmd *cli) {
|
||||||
|
CliCmd_PrintLnStatic(cli, "=================== THIS DATA ===================");
|
||||||
|
printData(tFlipSet, cli, 1);
|
||||||
|
CliCmd_PrintLnStatic(cli, "=================================================");
|
||||||
|
CliCmd_PrintLnStatic(cli, " [ rec_vector ] - record this vector data");
|
||||||
|
CliCmd_PrintLnStatic(cli, " [ rec_angle ] - record this angle data");
|
||||||
|
CliCmd_PrintLnStatic(cli, " [ ENTER_PRESS_KEY ] - update this data");
|
||||||
|
CliCmd_PrintLnStatic(cli, " [ exit ] - exiting as sub mode record/ and continue listing info");
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopListing(tFlipSetting *tFlipSet, tCliCmd *cli) {
|
||||||
|
|
||||||
|
getNewData(tFlipSet, cli);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
CliCmd_WaitLine(cli);
|
||||||
|
if (CliCmd_RxStartsWithStatic(cli, "rec_angle")) {
|
||||||
|
recordVarData(tFlipSet, cli, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CliCmd_RxStartsWithStatic(cli, "rec_vector")) {
|
||||||
|
recordVarData(tFlipSet, cli, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CliCmd_RxStartsWithStatic(cli, "")) {
|
||||||
|
printData(tFlipSet, cli, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CliCmd_RxStartsWithStatic(cli, "exit")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CliCmd_FlipSettingInit(
|
||||||
|
tFlipSetting *tFlipSet,
|
||||||
|
tCarFlipDetection *tFlipBase,
|
||||||
|
tVariablesTable *externTable,
|
||||||
|
tAccelCoor *accelCoor,
|
||||||
|
tCarCrashDetection *carCrashDetection
|
||||||
|
) {
|
||||||
|
tFlipSet->carCrashDetection = carCrashDetection;
|
||||||
|
tFlipSet->accelCoor = accelCoor;
|
||||||
|
tFlipSet->flipDetect = tFlipBase;
|
||||||
|
tFlipSet->externTable = externTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CliCmd_FlipSetting(tFlipSetting *tFlipSet, tCliCmd *cli) {
|
||||||
|
CliCmd_PrintLnStatic(cli, "THIS MODE FLIPPING SETTINGS");
|
||||||
|
while (1) {
|
||||||
|
|
||||||
|
CliCmd_WaitLineDelay(cli, 1500);
|
||||||
|
if (CliCmd_RxStartsWithStatic(cli, "exit")) {
|
||||||
|
CliCmd_PrintLnStatic(cli, "EXIT IN BASE MODE...");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CliCmd_RxStartsWithStatic(cli, "help")) {
|
||||||
|
CliCmd_flipModedHelp(NULL, cli);
|
||||||
|
CliCmd_WaitLine(cli);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CliCmd_RxStartsWithStatic(cli, "stop")) {
|
||||||
|
stopListing(tFlipSet, cli);
|
||||||
|
}
|
||||||
|
|
||||||
|
printData(tFlipSet, cli, 1);
|
||||||
|
SystemDelayMs(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"dep": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"provider": "Smart_Components_Aurus",
|
||||||
|
"repo": "CmsisCore5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"provider": "Smart_Components_Aurus",
|
||||||
|
"repo": "CliCmd"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cmake": {
|
||||||
|
"inc_dirs": [
|
||||||
|
"Inc"
|
||||||
|
],
|
||||||
|
"srcs": [
|
||||||
|
"Src/**.c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
1.Ввести в консоль комманду set_flip, в ответ должно быть:
|
||||||
|
THIS MODE FLIPPING SETTINGS
|
||||||
|
angleCos=NaN X=0.070200 Y=-0.081900 Z=0.945750
|
||||||
|
angleCos=NaN X=0.072150 Y=-0.081900 Z=0.943800
|
||||||
|
angleCos=NaN X=0.070200 Y=-0.083850 Z=0.945750
|
||||||
|
angleCos=NaN X=0.066300 Y=-0.079950 Z=0.947700
|
||||||
|
angleCos=NaN X=0.072150 Y=-0.081900 Z=0.945750
|
||||||
|
|
||||||
|
|
||||||
|
2.Установить устройство в нормальное положение
|
||||||
|
|
||||||
|
3.Ввести комманду stop - ответ примерно такого вида:
|
||||||
|
|
||||||
|
=================== THIS DATA ===================
|
||||||
|
angleCos=NaN X=0.066300 Y=-0.076050 Z=0.941850
|
||||||
|
=================================================
|
||||||
|
[ rec_vector ] - record this vector data
|
||||||
|
[ rec_angle ] - record this angle data
|
||||||
|
[ ENTER_PRESS_KEY ] - update this data
|
||||||
|
[ exit ] - exiting as sub mode record/ and continue listing info
|
||||||
|
|
||||||
|
4.Ввести комманду rec_vector
|
||||||
|
~ответ:
|
||||||
|
record vector is success
|
||||||
|
angleCos=NaN X=0.072150 Y=-0.083850 Z=0.943800
|
||||||
|
angleCos=0.999943 X=0.074100 Y=-0.081900 Z=0.937950
|
||||||
|
angleCos=0.999945 X=0.072150 Y=-0.083850 Z=0.939900
|
||||||
|
angleCos=0.999969 X=0.074100 Y=-0.076050 Z=0.945750
|
||||||
|
|
||||||
|
5.Установите устройство в критический угол (после которого происходит опрокидывание)
|
||||||
|
|
||||||
|
6.Вбейте комманду stop
|
||||||
|
~ответ:
|
||||||
|
=================== THIS DATA ===================
|
||||||
|
angleCos=0.239791 X=-0.871650 Y=-0.070200 Z=0.276900
|
||||||
|
=================================================
|
||||||
|
[ rec_vector ] - record this vector data
|
||||||
|
[ rec_angle ] - record this angle data
|
||||||
|
[ ENTER_PRESS_KEY ] - update this data
|
||||||
|
[ exit ] - exiting as sub mode record/ and continue listing info
|
||||||
|
|
||||||
|
7.Вбейте комманду rec_angle
|
||||||
|
record angle is success
|
||||||
|
angleCos=0.999369 X=0.072150 Y=-0.109200 Z=0.939900
|
||||||
|
angleCos=0.999282 X=0.074100 Y=-0.111150 Z=0.939900
|
||||||
|
angleCos=0.999392 X=0.078000 Y=-0.107250 Z=0.941850
|
||||||
|
|
||||||
|
На данном этапе установлен нормальный вектор, и угол сробатывания
|
||||||
|
НО ОНИ НЕ СОХРАНЕНЫ В ПЗУ.
|
||||||
|
|
||||||
|
Для сохранения в ПЗУ, необходимо изменить настройку (фактически любую) на вкладке "Натройки"
|
||||||
|
В частности можно включить срабатывание при перевороте задав значение параметра FLIP_DETECT_ENABLE в 1
|
||||||
Loading…
Reference in New Issue