270 lines
7.7 KiB
C
270 lines
7.7 KiB
C
//
|
||
// Created by xemon on 18.11.22.
|
||
//
|
||
|
||
#ifndef UVEOS_ON_NATION_DEVICETESTING_ENV_H
|
||
#define UVEOS_ON_NATION_DEVICETESTING_ENV_H
|
||
|
||
#include "DeviceTestsTable.h"
|
||
#include "GpioPinInterface.h"
|
||
#include "AtCmdCommon.h"
|
||
#include "AudioCodec.h"
|
||
#include "LoggerInterface.h"
|
||
#include "AudioPlayerInterface.h"
|
||
#include "AudioRecorderInterface.h"
|
||
#include "UserButtonsInterface.h"
|
||
#include "UserIndication.h"
|
||
#include "EraGlonassMsd.h"
|
||
#include "EraGlonassUveos.h"
|
||
#include "Adc.h"
|
||
#include "SpiPortIO.h"
|
||
#include "AccelDataFlowInterface.h"
|
||
#include "Accel.h"
|
||
#include "SpiPortArtery.h"
|
||
#include "CmsisRtosThreadUtils.h"
|
||
#include "GsmWithGnss.h"
|
||
#include "AntTest.h"
|
||
#include "UserInputButtonWatcher.h"
|
||
#include "PowerManagment.h"
|
||
#include "Gpios.h"
|
||
#include "RoutineControl_31.h"
|
||
#include "Amplifier.h"
|
||
#include "AtGsmSimComA7600_SSL_LOAD_CA.h"
|
||
#include "ModemDataCollector.h"
|
||
|
||
|
||
#define DEVICE_TESTS_LIMIT (24)
|
||
|
||
typedef enum {
|
||
FULL_TESTS = 0,
|
||
SPEAK_MICR_TEST = 1,
|
||
GSM_TEST = 2,
|
||
ECALL_TEST = 3,
|
||
ECALL_NOT_REG_TEST = 4,
|
||
ECALL_TEST_AUTO = 5,
|
||
REG_TO_NETWORK = 6,
|
||
REG_BOARD_VOLTAGE_CALIBRATION = 7,
|
||
LEDS_TEST = 8,
|
||
INTERNAL_ONE_TEST = 9,
|
||
}eControlTransferSource;
|
||
|
||
typedef enum {
|
||
QUERY_INIT = 0,
|
||
QUERY_RUN = 1,
|
||
QUERY_STOP= 2,
|
||
QUERY_ERROR = 3,
|
||
QUERY_BUSY= 4,
|
||
QUERY_DONE= 5
|
||
} eState;
|
||
|
||
typedef enum {
|
||
COM_INIT= 0,
|
||
COM_RUN = 1,
|
||
COM_STOP= 2,
|
||
} eCommands;
|
||
|
||
typedef enum {
|
||
HINTS_MINIMAL = 0,
|
||
HINTS_NORMAL = 1,
|
||
HINTS_FULL = 2,
|
||
HINTS_NOT_ERA_EXIT = 3,
|
||
HINTS_NONE = 3
|
||
} eAudioHintsMode;
|
||
|
||
typedef enum {
|
||
SYSTEM_IS_BUSY = 0,
|
||
SYSTEM_IS_FREE = 1,
|
||
SYSTEM_IS_DONE = 2,
|
||
} eSystemExitStatus;
|
||
|
||
typedef struct {
|
||
eState state;
|
||
eCommands commands;
|
||
eControlTransferSource source;
|
||
} eQueryUDSState;
|
||
|
||
typedef struct {
|
||
eDeviceTestingCode *deviceTestingCodeCan;
|
||
tDeviceStorage *deviceStorage;
|
||
bool *fl_IsLoad;
|
||
} tCanTest;
|
||
|
||
typedef struct {
|
||
tDeviceModes *deviceModes;
|
||
tDeviceStorage *deviceStorage;
|
||
tIsFind checkCert;
|
||
tGsmWithGnss *gsmWithGnss;
|
||
tModemDataColl *modemDataCollector;
|
||
bool *telematicaIsActive;
|
||
bool *testTelematicaIsActive;
|
||
bool *fl_telematicaServerIsActive;
|
||
|
||
} tModemVersionRevisionTest;
|
||
|
||
typedef struct {
|
||
tMSD_DiagnosticResult tmsdDiagRes;
|
||
tTestDescriptor testsTableAlloc[DEVICE_TESTS_LIMIT];
|
||
tDeviceTestsTable testsTable;
|
||
tEraGlonassUveos *ErGlUv;
|
||
tLoggerInterface *logger;
|
||
tAudioPlayerInterface *audioPlayer;
|
||
tAudioRecorderInterface *audioRecorder;
|
||
tUserButtonsInterface *input;
|
||
tUserIndication *indication;
|
||
tGpioPin *pinIgnition;
|
||
tGpioPin *ringPin;
|
||
tAccelDataFlowInterface *accelDFI;
|
||
tUserInputButtonWatcher *UserInputButtonWatcher;
|
||
uint8_t indicationStatusRes;
|
||
uint8_t ignitionAddStatusRes;
|
||
uint8_t buttonAddStatusRes;
|
||
uint8_t ecallAddStatusRes;
|
||
tGsmWithGnss *gsmWithGnss;
|
||
tSpekTestPower *spekTestPower;
|
||
tBipPins *bipDiagnost;
|
||
tPowerManagement *powerManagement;
|
||
tDeviceStorage *deviceStorage;
|
||
tModemVersionRevisionTest modemVersionRevisionTest;
|
||
|
||
struct {
|
||
tTestDescriptor *can;
|
||
tTestDescriptor *ignition;
|
||
tTestDescriptor *gnssAnt;
|
||
tTestDescriptor *speakConnect;
|
||
tTestDescriptor *batteryConn;
|
||
tTestDescriptor *batteryCharge;
|
||
tTestDescriptor *firmware;
|
||
tTestDescriptor *gsm;
|
||
tTestDescriptor *audioCodec;
|
||
tTestDescriptor *accel;
|
||
tTestDescriptor *bipConnect;
|
||
|
||
tTestDescriptor *modemSoftRevision;
|
||
tTestDescriptor *modemSertRevision;
|
||
tTestDescriptor *modemAudiotRevision;
|
||
tTestDescriptor *modemAmplifare;
|
||
tTestDescriptor *modemSimEra;
|
||
tTestDescriptor *modemSimComers;
|
||
tTestDescriptor *vin;
|
||
tTestDescriptor *accel_calib;
|
||
tTestDescriptor *eol;
|
||
tTestDescriptor *tele;
|
||
|
||
} namedTests;
|
||
|
||
tStaticThreadBlock(2048) threadUserTest;
|
||
tCanTest canTest;
|
||
bool flagAutoTestSucsess;
|
||
uint8_t flagAcsessExitThread;
|
||
tAntTest antDiscript;
|
||
eControlTransferSource controlTransferSource;
|
||
bool fl_oneTestResult;
|
||
bool telematicaIsActive;
|
||
tAmplifier *amplifier;
|
||
tModemDataColl *modemDataColl;
|
||
tString32 *ccidEra;
|
||
tString32 *ccidComers;
|
||
eQueryUDSState *queryUDSState;
|
||
eAudioHintsMode audioHintsMode;
|
||
tVersionRevision *modemVersionRevision;
|
||
eSubSystems *subSystemsTmp;
|
||
osMutexId_t mux_testingMode;
|
||
tUserInputButtonEvent buttonEvent;
|
||
float *boardVoltCalbCof;
|
||
eSystemExitStatus systemExitStatus;
|
||
|
||
} tDeviceTesting;
|
||
|
||
bool DeviceTesting_Init(
|
||
tDeviceTesting *env,
|
||
|
||
tUserInputButtonWatcher *UserInputButtonWatcher,
|
||
tGpioPin *ignPin,
|
||
tAdcIO *gnssAntAdc,
|
||
tSpekTestPower *spekTestPower,
|
||
tBipPins *bipDiagnost,
|
||
tBatteryPower *batteryPower,
|
||
tAccel *accel,
|
||
|
||
tGsmWithGnss *gsmWithGnss,
|
||
tAudioCodec *audioCodec,
|
||
tLoggerInterface *logger,
|
||
tAtCmd *gsmAt,
|
||
|
||
tAudioPlayerInterface *audioPlayer,
|
||
tAudioRecorderInterface *audioRecorder,
|
||
|
||
tUserButtonsInterface *input,
|
||
tUserIndication *indication,
|
||
|
||
tEraGlonassUveos *ErGlUv,
|
||
bool *antMode,
|
||
tGpioPin *ring,
|
||
tPowerManagement *powerManagement,
|
||
|
||
tDeviceStorage *deviceStorage,
|
||
tDeviceModes *deviceModes,
|
||
tAmplifier *amplifier,
|
||
tModemDataColl *modemDataColl,
|
||
eQueryUDSState *queryUDSState,
|
||
float *boardVoltCalbCof,
|
||
bool *telematicaIsActive,
|
||
bool *fl_telematicaServerIsActive,
|
||
eDeviceTestingCode *deviceTestingCodeCan
|
||
);
|
||
|
||
//ограничение воспроизведения одного семпла в 60с, можно увеличить до длительности большего семпла
|
||
#define DEVTST_PLAY_SAMPLE(SAMPLE) \
|
||
AudioPlayer_PlayToWait(env->audioPlayer, SAMPLE, 6*1000);
|
||
|
||
///AudioPlayer_PlayStaticTone(env->audioPlayer,5);
|
||
|
||
//ограничение записи одного семпла в 60с, можно увеличить до длительности большего семпла
|
||
#define DEVTST_REC_SAMPLE(SAMPLE) \
|
||
SystemDelayMs(40);\
|
||
AudioRecord_RecStatic(env->audioRecorder, SAMPLE, 6*1000);
|
||
|
||
#define DEVTST_REC_TO_WAIT_SAMPLE(SAMPLE) \
|
||
AudioRecord_RecStaticToWaitEnd(env->audioRecorder, SAMPLE, 6*1000);
|
||
|
||
//#define DEVTST_GET_MAIN(NAME) DeviceTestsTable_GetModeTestStatic(&env->testsTable, DEVICE_TESTING_MODE_MAIN, NAME);
|
||
|
||
//Return IF Error (RIFE) - Выйти в случае ошибки
|
||
#define DEVICE_TESTING_RIFE(FUNC) {bool result = FUNC; if(!result){ return result;}}
|
||
|
||
//Битовые флаги режимов тестирования (константы с локальной видимостью)
|
||
static const uint16_t DEVICE_TESTING_MODE_IGNITION_WITHOUT_GSM = 0b1 << 0;
|
||
static const uint16_t DEVICE_TESTING_MODE_IGNITION_AFTER_GSM = 0b1 << 1;
|
||
static const uint16_t DEVICE_TESTING_MODE_ALWAYS = 0b1 << 2;
|
||
static const uint16_t DEVICE_TESTING_MODE_PERIODICAL = 0b1 << 3;
|
||
static const uint16_t DEVICE_TESTING_MODE_MAIN = 0b1 << 4;
|
||
static const uint16_t DEVICE_TESTING_MODE_ALL = 0xFFFF;
|
||
|
||
static const uint16_t DEVICE_TESTING_MODE_NOT_ALWAYS =
|
||
DEVICE_TESTING_MODE_ALL
|
||
& ~DEVICE_TESTING_MODE_ALWAYS
|
||
& ~DEVICE_TESTING_MODE_IGNITION_WITHOUT_GSM
|
||
& ~DEVICE_TESTING_MODE_IGNITION_AFTER_GSM;
|
||
|
||
|
||
|
||
bool DeviceTests_InitTestsTable(
|
||
tDeviceTesting *env,
|
||
tGpioPin *ignitionPin,
|
||
tSpekTestPower *spekTestPower,
|
||
tBipPins *bipTestDiagnost,
|
||
tBatteryPower *batteryPower,
|
||
tAtCmd *gsm,
|
||
tAudioCodec *audioCodec,
|
||
tAccel *accel,
|
||
tAntTest *antCheck,
|
||
tDeviceStorage *deviceStorage,
|
||
tModemVersionRevisionTest *modemVersionRevisionTest,
|
||
tAmplifier *amplifier,
|
||
tCanTest *canTest
|
||
);
|
||
|
||
|
||
|
||
#endif //UVEOS_ON_NATION_DEVICETESTING_ENV_H
|