x10 tester - · pdf filex10_tester.can page 3 of 128. 151 byte hastosendwritecolumnconfig = 0;...

of 128 /128
1 variables 2 { 3 //Vers. 9.4 4 message DTOOL_to_USM msgTesterToEcu; 5 message USM_to_DTOOL msgEcuToTester; 6 7 8 /////////////////////////////////////////////////////////////// / ////////////////// 9 ///////////////////////////////////////////////////////////////////// / //////////// 10 const long VARS_SIZE = 300; // Maximum number of variables 11 const long MAX_VAR_LENGTH = 100; // Maximum length of a variable name 12 const long MAX_VAR_SIZE = 100; // Maximum number of varibles read with an identifier 13 const BYTE SEP = ';'; // Separator used in config files (0x3B) 14 15 16 17 // EMC32 18 const long NCycles= 500; 19 const long NCyclesCalib=50; 20 const long NSTEPS =8; 21 long arrayError[VARS_SIZE][2]; //Capture flag up or down. 22 long eflag[VARS_SIZE]; 23 long errorCounter=0; 24 long startaux=0; 25 long indexDelay=0; 26 long indexStop=0; 27 long CANSTATEflag[2]; 28 long NewStep[VARS_SIZE]; 29 long senueloA=0; 30 long senueloB=0; 31 long senueloC=0; 32 int controlSimulador=0; 33 WORD DID_LIST_ID[VARS_SIZE][100]; // List of ID readed with the identifier 34 35 36 //mstimer tEMC32; 37 message m mEMC; 38 mstimer DelayCalibration; 39 mstimer DelayCycling; 40 mstimer DelayStop; 41 mstimer tflagA, tflagB, tflagC; 42 mstimer FailureCAN; 43 44 struct ErrorImmClass 45 { 46 double maxVal; 47 double minVal; 48 double Value; 49 double Frequenz; 50 double ImmunityField; 51 double Threshold; X10_Tester.can Page 1 of 128

Author: vuquynh

Post on 15-Mar-2018

290 views

Category:

Documents


3 download

Embed Size (px)

TRANSCRIPT

  • 1variables

    2{

    3//Vers. 9.4

    4message DTOOL_to_USM msgTesterToEcu;

    5message USM_to_DTOOL msgEcuToTester;

    678

    //////////////////////////////////////////////////////////////////////////////////

    9//////////////////////////////////////////////////////////////////////

    ////////////

    10const long VARS_SIZE = 300; // Maximum number of variables

    11const long MAX_VAR_LENGTH = 100; // Maximum length of a

    variable name

    12const long MAX_VAR_SIZE = 100; // Maximum number of

    varibles read with an identifier

    13const BYTE SEP = ';'; // Separator used in

    config files (0x3B)

    14151617

    // EMC32

    18const long NCycles= 500;

    19const long NCyclesCalib=50;

    20const long NSTEPS =8;

    21long arrayError[VARS_SIZE][2]; //Capture flag up or down.

    22long eflag[VARS_SIZE];

    23long errorCounter=0;

    24long startaux=0;

    25long indexDelay=0;

    26long indexStop=0;

    27long CANSTATEflag[2];

    28long NewStep[VARS_SIZE];

    29long senueloA=0;

    30long senueloB=0;

    31long senueloC=0;

    32int controlSimulador=0;

    33WORD DID_LIST_ID[VARS_SIZE][100]; // List of ID readed with the

    identifier

    343536

    //mstimer tEMC32;

    37message m mEMC;

    38mstimer DelayCalibration;

    39mstimer DelayCycling;

    40mstimer DelayStop;

    41mstimer tflagA, tflagB, tflagC;

    42mstimer FailureCAN;

    4344

    struct ErrorImmClass

    45{

    46double maxVal;

    47double minVal;

    48double Value;

    49double Frequenz;

    50double ImmunityField;

    51double Threshold;

    X10_Tester.can

    Page 1 of 128

  • 52long State;

    53long Ciclat;

    54long Varid;

    55int Error;

    56char Names[MAX_VAR_LENGTH];

    575859

    };

    60struct ErrorImmClass ErrorImm[NCycles][NSTEPS][VARS_SIZE];

    61struct ErrorImmClass ErrorCalib[NCyclesCalib][NSTEPS][VARS_SIZE];

    6263

    // Read from configuration file

    64WORD VARID[VARS_SIZE]; // Identifier of each variable (

    relation out/diag)

    65WORD TYPES[VARS_SIZE]; // 0: DI, 1: AI, 2: DO, 3: PO, 4: AD,

    5: DD, 6: ROUT

    66WORD INVERT[VARS_SIZE]; // 1: Variable is inverted (only for

    1 bit variables)

    67char NAMES[VARS_SIZE][MAX_VAR_LENGTH]; // Name of the variable

    68WORD DID[VARS_SIZE]; // DID for read/write the variable

    69WORD NBYTES[VARS_SIZE]; // Number of bytes of data in CAN MSG

    70WORD OFFSET[VARS_SIZE]; // Offset in CAN MSG

    71WORD NBITS[VARS_SIZE]; // Number of bits of the variable in

    CAN MSG

    72BYTE VARIANT_L0[VARS_SIZE]; // 0: Yes, 1: No, 2: Mounted

    7374

    // Internally used

    75long VALUES[VARS_SIZE]; // Value of the variable

    76WORD tmp[VARS_SIZE]; // Used to detect changes

    in output variables

    77WORD CHANGE[VARS_SIZE]; // Programmed change of an output, 1:

    active

    78long NVARS = 0; // Number of variables

    7980

    // Generated from the configuration

    81WORD DID_LIST[VARS_SIZE]; // List of different DIDs

    82BYTE DID_LIST_NUM_INPUTS[VARS_SIZE]; // Number of input vars for

    this DID

    83BYTE DID_LIST_NUM_OUTPUTS[VARS_SIZE]; // Number of output vars for

    this DID

    84BYTE DID_LIST_NUM_DIAGS[VARS_SIZE]; // Number of diag vars for this

    DID

    85BYTE DID_LIST_NUM[VARS_SIZE]; // Number of vars for this DID

    86WORD DID_LIST_NUMBER[VARS_SIZE][100]; // List of variables readed

    with the identifier

    87long NDID = 0; // Number of differente DIDs

    88//////////////////////////////////////////////////////////////////////

    ////////////

    89//////////////////////////////////////////////////////////////////////

    ////////////

    9091

    // All the times in milliseconds

    92const int USER_SCAN_RATE=50;

    93const int DELAY_SESSION=100;

    94const int DELAY_SECURITY_ACCESS=500;

    95const int DELAY_INPUT_READING=200;

    96const int PERIOD_WATCHDOG=1000;

    X10_Tester.can

    Page 2 of 128

  • 97const int PERIOD_TESTER_PRESENT=2500;

    98const int PERIOD_SCHEDULER=1;

    99100

    char ActiveSessionStr[4][100] = {"No Session", "Default Session", "Extended Session", "Extended Session (Secured)"};

    101BYTE ActiveSession = 0;

    102103

    // Used for Tx/Rx data

    104const int BUFFER_SIZE=4098;

    105byte gRxDataBuffer[BUFFER_SIZE];

    106byte gTxDataBuffer[BUFFER_SIZE];

    107byte Aux_DataBuffer[BUFFER_SIZE];

    108char txArraySize;

    109char variant[4];

    110111

    // Used for Security Access

    112BYTE ALG_eese_data[3];

    113114

    mstimer UserScan;

    115mstimer StartDefaultSession;

    116mstimer StartExtendedSession;

    117mstimer Scheduler;

    118mstimer Watchdog;

    119mstimer ControlOutputs;

    120mstimer GetLINTestResults;

    121122

    long sendCounter = 0; // Max: NDID

    123long sendCounterAdd = 0; // To periodically read other

    variables

    124long writeIndex = 0; // Max: NVARS

    125BYTE controlOutputsActive = 0; // In order to avoid timer

    overlap

    126127

    DWORD timeStart = 0;

    128DWORD timeStop = 0;

    129BYTE schedulerStarted = 0;

    130BYTE state = 0;

    131132

    // PROGRAMMED MESSAGE SENDINGS

    133BYTE hasToSendGetVariant = 0;

    134BYTE hasToSendGetSoftwareVersionS12Lear = 0;

    135BYTE hasToSendGetSoftwareVersionS12Jlr = 0;

    136BYTE hasToSendGetSoftwareVersionAtmel = 0;

    137BYTE hasToSendSetVariant = 0;

    138BYTE hasToSendReadStartLogicControl = 0;

    139BYTE hasToDisableProtections = 0;

    140BYTE hasToEnableProtections = 0;

    141BYTE hasToSendGetPowerMode = 0;

    142BYTE hasToSendChangePowerMode = 0;

    143BYTE hasToChangeWatchdogState = 0;

    144BYTE hasToSendFastGoToSleep = 0;

    145BYTE hasToSendLINTestStart = 0;

    146BYTE hasToSendLINTestGetResults = 0;

    147BYTE hasToSendWakeupTestStart = 0;

    148BYTE hasToSendWakeupTestGetResults = 0;

    149BYTE hasToSendGetSerialNumber = 0;

    150BYTE hasToSendReadColumnConfig = 0;

    X10_Tester.can

    Page 3 of 128

  • 151BYTE hasToSendWriteColumnConfig = 0;

    152BYTE hasToSendWriteColumnDefault = 0;

    153154

    BYTE StartLogicControl[6];

    155BYTE PowerMode = 0;

    156BYTE StopWatchdog = 0;

    157BYTE ColumnState = 0;

    158DWORD ColumnParamVal[16];

    159BYTE ColumnParamId[16];

    160BYTE ColumnCycleState;

    161162

    BYTE SvpasPwm = 0;

    163164

    // AUTO TESTING

    165mstimer AT_Delay;

    166const long AT_MAX_STEPS = 300;

    167const long AT_MAX_LINE_CHARS = 1024;

    168WORD AT_TYPES[VARS_SIZE];

    169char AT_NAMES[VARS_SIZE][MAX_VAR_LENGTH];

    170WORD AT_TOLERANCE[VARS_SIZE];

    171WORD AT_VALUES[VARS_SIZE][AT_MAX_STEPS];

    172WORD AT_MEASURED_VALUES[VARS_SIZE][AT_MAX_STEPS];

    173WORD AT_VALIDATION_RESULTS[VARS_SIZE][AT_MAX_STEPS]; // 0: Not

    Tested, 1: Not Applicable, 2: OK, 3: NOK

    174175

    BYTE AT_State; // 0: Write Outputs, 1: Wait Stabilisation, 2:Read Inputs & Diags

    176BYTE AT_Mode; // 0: Playing, 1: Recording

    177BYTE AT_IncMode; // 0: Decreasing Steps, 1: Increasing Steps

    178BYTE AT_OneStep;

    179long AT_SeqIndex; // Sequential output index

    180BYTE AT_SeqState; // 0: Activation, 1: Deactivation

    181long AT_OUT_INDEX[VARS_SIZE];

    182long AT_NUM_OUTPUTS;

    183184

    //DTC's variables

    185int DTRL_DTC=0;

    186int x;

    187188

    //Variables de rutines

    189mstimer Routine_T;

    190byte RoutineDataBuffer[BUFFER_SIZE];

    191char RoutineArraySize;

    192193

    // Char

    194char buffer[64];

    195char DiagInfoASCII_[3];

    196int Asciifound=0;

    197char inhibit;

    198char Auto_Test=0;

    199200

    //BSS Test

    201int sec,min,hour;

    202int increase;

    203float Voltage;

    204char aux[6];

    205mstimer TimerCount;

    X10_Tester.can

    Page 4 of 128

  • 206Timer VoltageScheduler;

    207dword glbHandle = 0;

    208209

    //Syst.Ident.

    210int SwNum1,SwNum2;

    211int EdNum1,EdNum2;

    212char fileUsed[32];

    213byte CheckingSwNum, CheckingEditNum;

    214215

    //AC Valve test

    216Timer Test_Time;

    217msTimer timeT;

    218msTimer ReadT;

    219msTimer StopRT;

    220int AC_Valve_DC;

    221int TestingTime;

    222int t=0,s=0,m=0,ms=0;

    223int up,ACV_T=0;

    224int Offset;

    225226

    int LINErrors_Inicial;

    227228

    //Control_Lighting_Test

    229mstimer t_ControlLighting;

    230int CL_x=0;

    231int SPI_Check=0;

    232mstimer t_ReadFeedbacks;

    233234

    //Iocab DO_0 pulse generator

    235mstimer t_PulseGenerator;

    236int T_On,T_Off,iter;

    237int ciclesCount;

    238239

    byte HW_Testing=0;

    240}

    241242

    on start

    243{

    244OSEKTL_SetTxId(msgTesterToEcu.id);

    245OSEKTL_SetRxId(msgEcuToTester.id);

    246247

    LoadConfigFromFile();

    248LoadSystemIdent();

    249ProcessDIDs();

    250251

    //PrintConfig();

    252//PrintDIDs();

    253//LoadCyclingFromFile();

    254//PrintCycling();

    255//

    LoadDTCsFromFi

    256257

    CopyNameToDataBase();

    258InitializeValues();

    259putValue(VAR_DiagSession, ActiveSessionStr[ActiveSession]);

    X10_Tester.can

    Page 5 of 128

  • 260settimer(UserScan, USER_SCAN_RATE);

    261putValue(AT_Continous,0);

    262putValue(EBCM_WakeUpSleepCommand_,3);

    263setTimer(DelayCalibration,1000);

    264265

    }

    266267

    LoadConfigFromFile ()

    268{

    269dword readHandle = 0;

    270char readBuffer[255];

    271char dataBuffer[255];

    272long i = 0;

    273long j = 0;

    274long k = 0;

    27