/begin A2ML

  struct Protocol_Layer {
    uint;     // XCP protocol layer version, currently 0x101
    uint;     // T1 [ms] Time-out of the standard CTO, for example CONNECT
    uint;     // T2 [ms] Time-out of the checksum calculation
    uint;     // T3 [ms] Time-out of the non-volatile memory programming: PROGRAM_START, PROGRAM_VERIFY, PROGRAM_PREPARE
    uint;     // T4 [ms] Time-out of the non-volatile memory programming: PROGRAM_CLEAR
    uint;     // T5 [ms] Time-out of the non-volatile memory programming: PROGRAM, PROGRAM_RESET, PROGRAM_MAX
    uint;     // T6 [ms] Time-out of the command CONNECT(USER_DEFINED)
    uint;     // T7 [ms] Time-out of the pre-action
    uchar;    // MAX_CTO: Indicates the maximum length of a CTO packet in bytes. 
    uint;     // MAX_DTO: Indicates the maximum length of a DTO packet in bytes. 
    enum {
      "BYTE_ORDER_MSB_LAST" = 0,
      "BYTE_ORDER_MSB_FIRST" = 1
    };// BYTE_ORDER: BYTE_ORDER_MSB_LAST = Intel, BYTE_ORDER_MSB_FIRST = Motorola
    enum {
      "ADDRESS_GRANULARITY_BYTE" = 1,
      "ADDRESS_GRANULARITY_WORD" = 2,
      "ADDRESS_GRANULARITY_DWORD" = 4
    };//The address granularity indicates the size of an element contained at a single address.
    taggedstruct {
      ("OPTIONAL_CMD" enum {
        "GET_COMM_MODE_INFO"       = 0xFB,
        "GET_ID"                   = 0xFA,
        "SET_REQUEST"              = 0xF9,
        "GET_SEED"                 = 0xF8,
        "UNLOCK"                   = 0xF7,
        "SET_MTA"                  = 0xF6,
        "UPLOAD"                   = 0xF5,
        "SHORT_UPLOAD"             = 0xF4,
        "BUILD_CHECKSUM"           = 0xF3,
        "TRANSPORT_LAYER_CMD"      = 0xF2,
        "USER_CMD"                 = 0xF1,
        "DOWNLOAD"                 = 0xF0,
        "DOWNLOAD_NEXT"            = 0xEF,
        "DOWNLOAD_MAX"             = 0xEE,
        "SHORT_DOWNLOAD"           = 0xED,
        "MODIFY_BITS"              = 0xEC,
        "SET_CAL_PAGE"             = 0xEB,
        "GET_CAL_PAGE"             = 0xEA,
        "GET_PAG_PROCESSOR_INFO"   = 0xE9,
        "GET_SEGMENT_INFO"         = 0xE8,
        "GET_PAGE_INFO"            = 0xE7,
        "SET_SEGMENT_MODE"         = 0xE6,
        "GET_SEGMENT_MODE"         = 0xE5,
        "COPY_CAL_PAGE"            = 0xE4,
        "CLEAR_DAQ_LIST"           = 0xE3,
        "SET_DAQ_PTR"              = 0xE2,
        "WRITE_DAQ"                = 0xE1,
        "SET_DAQ_LIST_MODE"        = 0xE0,
        "GET_DAQ_LIST_MODE"        = 0xDF,
        "START_STOP_DAQ_LIST"      = 0xDE,
        "START_STOP_SYNCH"         = 0xDD,
        "GET_DAQ_CLOCK"            = 0xDC,
        "READ_DAQ"                 = 0xDB,
        "GET_DAQ_PROCESSOR_INFO"   = 0xDA,
        "GET_DAQ_RESOLUTION_INFO"  = 0xD9,
        "GET_DAQ_LIST_INFO"        = 0xD8,
        "GET_DAQ_EVENT_INFO"       = 0xD7,
        "FREE_DAQ"                 = 0xD6,
        "ALLOC_DAQ"                = 0xD5,
        "ALLOC_ODT"                = 0xD4,
        "ALLOC_ODT_ENTRY"          = 0xD3,
        "PROGRAM_START"            = 0xD2,
        "PROGRAM_CLEAR"            = 0xD1,
        "PROGRAM"                  = 0xD0,
        "PROGRAM_RESET"            = 0xCF,
        "GET_PGM_PROCESSOR_INFO"   = 0xCE,
        "GET_SECTOR_INFO"          = 0xCD,
        "PROGRAM_PREPARE"          = 0xCC,
        "PROGRAM_FORMAT"           = 0xCB,
        "PROGRAM_NEXT"             = 0xCA,
        "PROGRAM_MAX"              = 0xC9,
        "PROGRAM_VERIFY"           = 0xC8,
        "WRITE_DAQ_MULTIPLE"       = 0xC7
      })*;  // XCP-Code of optional command supported by the slave
      "COMMUNICATION_MODE_SUPPORTED" taggedunion {
        "BLOCK" taggedstruct {
          "SLAVE";
          "MASTER" struct {
            uchar; // MAX_BS: Indicates the maximum allowed block size as the number of consecutive command packets in a block sequence
            uchar; // MIN_ST: Indicates the required minimum separation time between the packets of a block transfer from the master device to the slave device in units of 100 ms
          };
        };
        "INTERLEAVED" uchar; // QUEUE_SIZE: indicates the maximum number of consecutive command packets the master can send to the receipt queue of the slave
      };
      "SEED_AND_KEY_EXTERNAL_FUNCTION" char[256]; // Name of the Seed&Key function
    };
  };

  struct Daq {
    enum { // DAQ_CONFIG_TYPE
      "STATIC"  = 0,
      "DYNAMIC" = 1
    };//The flag indicates whether the DAQ lists that are not PREDEFINED shall be configured statically or dynamically
    uint;  // MAX_DAQ: Total number of available DAQ lists 
    uint;  // MAX_EVENT_CHANNEL: Total number of available event channels
    uchar; // MIN_DAQ: Total number of predefined DAQ lists 
    enum {
      "OPTIMISATION_TYPE_DEFAULT"            = 0,
      "OPTIMISATION_TYPE_ODT_TYPE_16"        = 1,
      "OPTIMISATION_TYPE_ODT_TYPE_32"        = 2,
      "OPTIMISATION_TYPE_ODT_TYPE_64"        = 3,
      "OPTIMISATION_TYPE_ODT_TYPE_ALIGNMENT" = 4,
      "OPTIMISATION_TYPE_MAX_ENTRY_SIZE"     = 5
    };// Indicate the Type of Optimisation Method the master preferably should use.
    enum {
      "ADDRESS_EXTENSION_FREE" = 0,
      "ADDRESS_EXTENSION_ODT"  = 1,
      "ADDRESS_EXTENSION_DAQ"  = 3
    };//The flag indicates whether the address extension of all entries within one ODT or within one DAQ must be the same. 
    enum {
      "IDENTIFICATION_FIELD_TYPE_ABSOLUTE"              = 0,
      "IDENTIFICATION_FIELD_TYPE_RELATIVE_BYTE"         = 1,
      "IDENTIFICATION_FIELD_TYPE_RELATIVE_WORD"         = 2,
      "IDENTIFICATION_FIELD_TYPE_RELATIVE_WORD_ALIGNED" = 3
    };// The type of Identification Field the slave will use when transferring DAQ Packets to the master
    enum {
      "GRANULARITY_ODT_ENTRY_SIZE_DAQ_BYTE"  = 1,
      "GRANULARITY_ODT_ENTRY_SIZE_DAQ_WORD"  = 2,
      "GRANULARITY_ODT_ENTRY_SIZE_DAQ_DWORD" = 4,
      "GRANULARITY_ODT_ENTRY_SIZE_DAQ_DLONG" = 8
    };// Granularity for size of ODT entry 
    uchar;// MAX_ODT_ENTRY_SIZE_DAQ Maximum size of ODT entry (DIRECTION = DAQ) 
    enum {
      "NO_OVERLOAD_INDICATION"    = 0,
      "OVERLOAD_INDICATION_PID"   = 1,
      "OVERLOAD_INDICATION_EVENT" = 2
    };//OVERLOAD_INDICATION_PID: This means the higest bit is set in the PID, when an overload occurs
      //OVERLOAD_INDICATION_EVENT: This means an event is set, when an overload occurs
    taggedstruct {
      "DAQ_ALTERNATING_SUPPORTED" uint;//This flag selects the alternating display mode.
      "PRESCALER_SUPPORTED";//This flag indicates that all DAQ lists support the prescaler for reducing the transmission period.
      "RESUME_SUPPORTED";//This  flag indicates that all DAQ lists can be put in RESUME mode. 
      "STORE_DAQ_SUPPORTED";//This flag indicates that the slave can store DAQ configurations. 
      block "STIM" struct {
        enum {
          "GRANULARITY_ODT_ENTRY_SIZE_STIM_BYTE"  = 1,
          "GRANULARITY_ODT_ENTRY_SIZE_STIM_WORD"  = 2,
          "GRANULARITY_ODT_ENTRY_SIZE_STIM_DWORD" = 4,
          "GRANULARITY_ODT_ENTRY_SIZE_STIM_DLONG" = 8
        };// Granularity for size of ODT entry direction STIM
        uchar;  // MAX_ODT_ENTRY_SIZE_STIM Maximum size of ODT entry (DIRECTION = STIM)
        taggedstruct {
          "BIT_STIM_SUPPORTED";//The flag indicates  whether  bitwise  data  stimulation  through BIT_OFFSET in WRITE_DAQ is supported.
          "MIN_ST_STIM" uchar;//Separation time between DTOs time in units of 100 microseconds
        };
      };
      block "TIMESTAMP_SUPPORTED" struct {
        uint;   //The timestamp will increment by TIMESTAMP_TICKS per unit and wrap around if an overflow occurs. 
        enum {
          "NO_TIME_STAMP" = 0,
          "SIZE_BYTE"     = 1,
          "SIZE_WORD"     = 2,
          "SIZE_DWORD"    = 4
        };//Timestamp size in bytes
        enum {
          "UNIT_1NS"   = 0,
          "UNIT_10NS"  = 1,
          "UNIT_100NS" = 2,
          "UNIT_1US"   = 3,
          "UNIT_10US"  = 4,
          "UNIT_100US" = 5,
          "UNIT_1MS"   = 6,
          "UNIT_10MS"  = 7,
          "UNIT_100MS" = 8,
          "UNIT_1S"    = 9,
          "UNIT_1PS"   = 10,
          "UNIT_10PS"  = 11,
          "UNIT_100PS" = 12
        };//Ticks per unit
        taggedstruct {
          "TIMESTAMP_FIXED";
        };// TIMESTAMP_FIXED flag indicates that the Slave always will send DTO Packets in time stamped mode. 
      };
      "PID_OFF_SUPPORTED";//Flag in DAQ_PROPERTIES indicates that transfer of DTO Packets without Identification Field is possible. 

      (block "DAQ_LIST" struct {
        uint;  // DAQ_LIST_NUMBER  is in the range [0,1,..MIN_DAQ-1]. 
        taggedstruct {
          "DAQ_LIST_TYPE" enum {
            "DAQ"      = 1,  
            "STIM"     = 2,  
            "DAQ_STIM" = 3   
          };  // DAQ: DIRECTION = DAQ only 
              // STIM: DIRECTION = STIM only 
              // DAQ_STIM: both directions are possible 
          "MAX_ODT" uchar;//Number of ODTs in this DAQ list 
          "MAX_ODT_ENTRIES" uchar;//Maximum number of entries in an ODT
          "FIRST_PID" uchar;//FIRST_PID: Is the PID in the DTO Packet of the first ODT transferred by this DAQ list.
          "EVENT_FIXED" uint;//The flag indicates that the Event Channel for this DAQ list can not be changed. 

          block "PREDEFINED" taggedstruct {
            (block "ODT" struct {
              uchar;   // ODT number 
              taggedstruct {
                ("ODT_ENTRY" struct {
                  uchar;   // ODT_ENTRY number 
                  ulong;   // address of element 
                  uchar;   // address extension of element 
                  uchar;   // size of element [AG] 
                  uchar;   // BIT_OFFSET 
                })*;
              };
            })*;
          };//PREDEFINED;The DAQ list is predefined and fixed in the slave devices memory.
        };
      })*;
      (block "EVENT" struct {
        char[101];  // EVENT_CHANNEL_NAME
        char[9];    // EVENT_CHANNEL_SHORT_NAME
        uint;       // EVENT_CHANNEL_NUMBER
        enum {
          "DAQ"      = 1,
          "STIM"     = 2,
          "DAQ_STIM" = 3
        };  // DAQ: only DAQ_LISTs with DIRECTION = DAQ
            // STIM: only DAQ_LISTs with DIRECTION = STIM
            // DAQ_STIM both kind of DAQ_LISTs
        uchar;  // MAX_DAQ_LIST:Maximum number of DAQ lists in this event channel
        uchar;  // TIME_CYCLE: Event channel time cycle
        uchar;  // TIME_UNIT: Event channel time unit
        uchar;  // PRIORITY:The event channel with event channel priority = FF has the highest priority 
        taggedstruct {
          "COMPLEMENTARY_BYPASS_EVENT_CHANNEL_NUMBER" uint;//This keyword is used to make a combination of two event channels building a bypassing raster.
          "CONSISTENCY" enum {
            "DAQ"   = 0,
            "EVENT" = 1
          };//With this keyword, the slave can indicate what kind of data consistency exists when data are processed within this Event.
        };
      })*;
    };
  };

  taggedunion Daq_Event {       
    "FIXED_EVENT_LIST" taggedstruct {
      ("EVENT" uint)*;
    };
    "VARIABLE" taggedstruct {
      block "AVAILABLE_EVENT_LIST" taggedstruct {
        ("EVENT" uint)*;
      };
      block "DEFAULT_EVENT_LIST" taggedstruct {
        ("EVENT" uint)*;
      };
    };
  }; //This are characteristic for measurement objects

  struct Pag {
    uchar;    // MAX_SEGMENTS: Is the total number of segments in the slave device
    taggedstruct {
      "FREEZE_SUPPORTED";//This flag indicates that all SEGMENTS can be put in FREEZE 
    };
  };

  struct Pgm {
    enum {
      "PGM_MODE_ABSOLUTE"                = 1,
      "PGM_MODE_FUNCTIONAL"              = 2,
      "PGM_MODE_ABSOLUTE_AND_FUNCTIONAL" = 3
    };//The  ABSOLUTE_MODE  and  FUNCTIONAL_MODE  flags  indicate  the  clear/programming mode that can be used 
    uchar;  // MAX_SECTORS: Total number of available sectors 
    uchar;  // MAX_CTO_PGM: Maximum CTO size for PGM 
    taggedstruct {
      (block "SECTOR" struct {
        char[101];   // SECTOR_NAME 
        uchar;       // SECTOR_NUMBER
        ulong;       // Start address for this SECTOR 
        ulong;       // Length of this SECTOR [AG] 
        uchar;       // CLEAR_SEQUENCE_NUMBER: The Clear Sequence Number describe, in which subsequential order the master has to clear and program flash memory sectors.
        uchar;       // PROGRAM_SEQUENCE_NUMBER: The Program Sequence Number describe, in which subsequential order the master has to clear and program flash memory sectors.
        uchar;       // PROGRAM_METHOD: The work flow depends on mode  absolute access or functional access
      })*;
      "COMMUNICATION_MODE_SUPPORTED" taggedunion {
        "BLOCK" taggedstruct {
          "SLAVE";//This flag indicates whether the Slave Block Mode is available during Programming. 
          "MASTER" struct {
            uchar; // MAX_BS_PGM:MAX_BS: indicates the maximum allowed block size as the number of consecutive command packets in a block sequence
            uchar; // MIN_ST_PGM ndicates the required minimum separation time between the packets of a block transfer from the master device to the slave device in units of 100 ms
          };//This flag indicates whether the Master Block Mode is available 
        };
        "INTERLEAVED" uchar;  // QUEUE_SIZE_PGM: This value describe the total count of bytes for this queue
      };
    };
  };

  struct Segment {   
    uchar;     // SEGMENT_NUMBER: Logical data segment number
    uchar;     // Total number of available pages 
    uchar;     // ADDRESS_EXTENSION: Address extension for this SEGMENT
    uchar;     // COMPRESSION_METHOD: The COMPRESSION_x flags indicate which compression state of the incoming data the slave can process
    uchar;     // ENCRYPTION_METHOD: The  ENCRYPTION_x flags indicate which encryption state of the incoming data the slave can process.
    taggedstruct {
      block "CHECKSUM" struct {
        enum {
          "XCP_ADD_11"      =   1,
          "XCP_ADD_12"      =   2,
          "XCP_ADD_14"      =   3,
          "XCP_ADD_22"      =   4,
          "XCP_ADD_24"      =   5,
          "XCP_ADD_44"      =   6,
          "XCP_CRC_16"      =   7,
          "XCP_CRC_16_CITT" =   8,
          "XCP_CRC_32"      =   9,
          "XCP_USER_DEFINED" = 255
        };// Checksum type
        taggedstruct {
          "MAX_BLOCK_SIZE" ulong;// Maximum block size for checksum calculation 
          "EXTERNAL_FUNCTION" char[256];// Name of the Checksum.DLL 
        };
      };
      (block "PAGE" struct {  
        uchar;  // PAGE_NUMBER: Logical page number
        enum {
          "ECU_ACCESS_NOT_ALLOWED"      = 0,
          "ECU_ACCESS_WITHOUT_XCP_ONLY" = 1,
          "ECU_ACCESS_WITH_XCP_ONLY"    = 2,
          "ECU_ACCESS_DONT_CARE"        = 3
        };//The ECU_ACCESS_x  flags indicate whether and how the ECU can access this page.
        enum {
          "XCP_READ_ACCESS_NOT_ALLOWED"      = 0,
          "XCP_READ_ACCESS_WITHOUT_ECU_ONLY" = 1,
          "XCP_READ_ACCESS_WITH_ECU_ONLY"    = 2,
          "XCP_READ_ACCESS_DONT_CARE"        = 3
        };//The XCP_x_ACCESS_y flags indicate whether and how the XCP master can access this page.
        enum {
          "XCP_WRITE_ACCESS_NOT_ALLOWED"      = 0,
          "XCP_WRITE_ACCESS_WITHOUT_ECU_ONLY" = 1,
          "XCP_WRITE_ACCESS_WITH_ECU_ONLY"    = 2,
          "XCP_WRITE_ACCESS_DONT_CARE"        = 3
        };//The XCP_WRITE_ACCESS_x flags indicate whether the  X CP master can write to this PAGE
        taggedstruct {
          "INIT_SEGMENT" uchar; // references segment that initialises this page 
        };
      })*;  // PAGES for this SEGMENT 
      (block "ADDRESS_MAPPING" struct {
        ulong;   // source address 
        ulong;   // destination address 
        ulong;   // length 
      })*;
      "PGM_VERIFY" ulong; // verification value for PGM 
    };
  };  //Settings for MEMORY_SEGMENT 

  taggedstruct Common_Parameters {
    block "PROTOCOL_LAYER" struct Protocol_Layer;
    block "SEGMENT" struct Segment;
    block "DAQ" struct Daq;
    block "PAG" struct Pag;
    block "PGM" struct Pgm;
    block "DAQ_EVENT" taggedunion Daq_Event;
  };

  struct CAN_Parameters {
    uint;   // XCP on CAN version, currently 0x0101 
    taggedstruct {
      "CAN_ID_BROADCAST" ulong;    // Auto-detection CAN-ID 
      "CAN_ID_MASTER" ulong;       // CMD/STIM CAN-ID 
      "CAN_ID_MASTER_INCREMENTAL"; // Master uses range of CAN-IDs. Start of range = CAN_ID_MASTER
      "CAN_ID_SLAVE" ulong;        // RES/ERR/EV/SERV/DAQ CAN-ID 
      "BAUDRATE" ulong;            // Baudrate in Hz 
      "SAMPLE_POINT" uchar;        // Sample point in % of bit time 
      "SAMPLE_RATE" enum {
        "SINGLE" = 1,
        "TRIPLE" = 3
      };// Sample per bit 
      "BTL_CYCLES" uchar; // slots per bit time 
      "SJW" uchar;//Length synchr. segment 
      "SYNC_EDGE" enum {
        "SINGLE" = 1,  
        "DUAL"   = 2   
      };  // SINGLE: on falling edge only
          // DUAL: on falling and rising edge
      "MAX_DLC_REQUIRED"; // master to slave frames always to have DLC = MAX_DLC = 8
      (block "DAQ_LIST_CAN_ID" struct {
        uint;     // reference to DAQ_LIST_NUMBER 
        taggedstruct {   
          "VARIABLE";     
          "FIXED" ulong;  // this DAQ_LIST always on this CAN_ID 
        }; // exclusive tags: either VARIABLE or FIXED 
      })*;  
    };
  };

  struct SxI_Parameters {
    uint;    // XCP on SxI version, currently 0x0101 
    ulong; // BAUDRATE [Hz] 
    taggedstruct {
      "ASYNCH_FULL_DUPLEX_MODE" struct {
        enum {
          "PARITY_NONE" = 0,
          "PARITY_ODD"  = 1,
          "PARITY_EVEN" = 2
        };// Parity bit settings
        enum {
          "ONE_STOP_BIT"  = 1,
          "TWO_STOP_BITS" = 2
        };//Stop bit settings
        taggedstruct {
          block "FRAMING" struct {
            uchar;   // SYNC character
            uchar;   // ESC character
          };
        }; // Support for framing mechanism
      };
      "SYNCH_FULL_DUPLEX_MODE_BYTE";
      "SYNCH_FULL_DUPLEX_MODE_WORD";
      "SYNCH_FULL_DUPLEX_MODE_DWORD";
      "SYNCH_MASTER_SLAVE_MODE_BYTE";
      "SYNCH_MASTER_SLAVE_MODE_WORD";
      "SYNCH_MASTER_SLAVE_MODE_DWORD";
    };  // exclusive tags
    enum {
      "HEADER_LEN_BYTE"      = 0,
      "HEADER_LEN_CTR_BYTE"  = 1,
      "HEADER_LEN_FILL_BYTE" = 2,
      "HEADER_LEN_WORD"      = 3,
      "HEADER_LEN_CTR_WORD"  = 4,
      "HEADER_LEN_FILL_WORD" = 5
    };// XCP packet header 
    enum {
      "NO_CHECKSUM"   = 0,
      "CHECKSUM_BYTE" = 1,
      "CHECKSUM_WORD" = 2
    };// Checksum type
  };

  struct TCP_IP_Parameters {
     uint;    /* XCP on TCP_IP version, currently 0x0100 */
     uint;    /* PORT */
     taggedunion {
       "HOST_NAME" char[256];//Name of the host like localhost
       "ADDRESS" char[15];// IP address like 127.0.0.1
     };
  };

  struct UDP_IP_Parameters {
     uint;    /* XCP on UDP version, currently 0x0100 */
     uint;    /* PORT */
     taggedunion {
       "HOST_NAME" char[256];//Name of the host like localhost
       "ADDRESS" char[15];// IP address like 127.0.0.1
     };
  };

  struct ep_parameters {
      uchar;                         /* ENDPOINT_NUMBER, not endpoint address */
      enum {
          "BULK_TRANSFER"         = 2,
          "INTERRUPT_TRANSFER"    = 3
      };
      uint;                                /* wMaxPacketSize: Maximum packet  */
                                           /* size of endpoint in bytes       */

      uchar;                               /* bInterval: polling of endpoint  */

      enum {                               
          "MESSAGE_PACKING_SINGLE"    = 0, 
          "MESSAGE_PACKING_MULTIPLE"  = 1, 
          "MESSAGE_PACKING_STREAMING" = 2  
      };  /* Packing of XCP Messages         */
          /* SINGLE: Single per USB data packet    */
          /* MULTIPLE: Multiple per USB data packet  */
          /* STREAMING: No restriction by packet sizes*/
      enum {                               
          "ALIGNMENT_8_BIT" = 0,
          "ALIGNMENT_16_BIT"= 1,
          "ALIGNMENT_32_BIT"= 2,
          "ALIGNMENT_64_BIT"= 3
      };  // Alignment mandatory for all packing types

      taggedstruct {
          "RECOMMENDED_HOST_BUFSIZE" uint; /* Recommended size for the host */
                                           /* buffer size. The size is defined*/
                                           /* as multiple of wMaxPacketSize.  */
      };
  }; 

  struct USB_Parameters {
      uint;                                /* XCP on USB version  */
                                           /* e.g. "1.0" = 0x0100 */

      uint;                                /* Vendor ID                       */
      uint;                                /* Product ID                      */
      uchar;                               /* Number of interface             */


      enum { 
          "HEADER_LEN_BYTE"       = 0,
          "HEADER_LEN_CTR_BYTE"   = 1,
          "HEADER_LEN_FILL_BYTE"  = 2,
          "HEADER_LEN_WORD"       = 3,
          "HEADER_LEN_CTR_WORD"   = 4,
          "HEADER_LEN_FILL_WORD"  = 5
      };// XCP packet header 

      taggedunion {                  
          block "OUT_EP_CMD_STIM" struct ep_parameters; // OUT-EP for CMD and STIM (if not specified otherwise)
      };

      taggedunion {                  
         block "IN_EP_RESERR_DAQ_EVSERV" struct ep_parameters;  /* IN-EP for RES/ERR, */
                                                                /* DAQ (if not specified otherwise) and  */
                                                                /* EV/SERV (if not specified otherwise)  */
      };

      taggedstruct {
          "ALTERNATE_SETTING_NO" uchar;                      // Number of alternate setting   */
          "INTERFACE_STRING_DESCRIPTOR" char [101];          // String Descriptor of XCP interface
          (block "OUT_EP_ONLY_STIM" struct ep_parameters)*;  // multiple OUT-EP's for STIM 
          (block "IN_EP_ONLY_DAQ" struct ep_parameters)*;    // multiple IN-EP's for DAQ
          block "IN_EP_ONLY_EVSERV" struct ep_parameters;    // only one IN-EP for EV/SERV

          (block "DAQ_LIST_USB_ENDPOINT" struct {
              uint;                  /* reference to DAQ_LIST_NUMBER          */
              taggedstruct {         /* only mentioned if not VARIABLE        */
                  "FIXED_IN" uchar;  /* this DAQ list always                */
                                     /* ENDPOINT_NUMBER, not endpoint address */
                  "FIXED_OUT" uchar; /* this STIM list always               */
                                     /* ENDPOINT_NUMBER, not endpoint address */
              };
          })*;
      };
  };

  enum packet_assignment_type {
    "NOT_ALLOWED",
    "FIXED",
    "VARIABLE_INITIALISED",
    "VARIABLE"
  };

  struct buffer {

    uchar; // Buffer number

    taggedstruct {

      "MAX_FLX_LEN_BUF" taggedunion {
        "FIXED"    uchar; // constant value, can't be modified on runtime 
        "VARIABLE" uchar; // initial value, can be modified on runtime
      }; // maximal size of the buffer [byte]

      block "LPDU_ID" taggedstruct {

        "FLX_SLOT_ID" taggedunion {
          "FIXED"    uint; // constant value, can't be modified on runtime
          "VARIABLE" taggedstruct{
            "INITIAL_VALUE" uint;
          }; // initial value, can be modified on runtime
        }; // FlexRay timing, slot id

        "OFFSET" taggedunion {
          "FIXED" uchar; // constant value, can't be modified on runtime
          "VARIABLE" taggedstruct{
            "INITIAL_VALUE" uchar;
          }; // initial value, can be modified on runtime
        }; // FlexRay timing, base cycle

        "CYCLE_REPETITION" taggedunion {
          "FIXED" uchar; // constant value, can't be modified on runtime
          "VARIABLE" taggedstruct{
            "INITIAL_VALUE" uchar;
          }; // initial value, can be modified on runtime
        }; // FlexRay timing, cycle repetition

        "CHANNEL" taggedunion {
          "FIXED" enum {
            "A" = 0,
            "B" = 1
          }; // constant value, can't be modified on runtime
          "VARIABLE" taggedstruct{
            "INITIAL_VALUE" enum {
              "A" = 0,
              "B" = 1
            };
          }; // initial value, can be modified on runtime
        }; // FlexRay Channel A or B
      }; // LPDU-ID,  Data  Link  Layer  Protocol  Data  Unit  Identifier

      block "XCP_PACKET" taggedstruct {
       "CMD" enum packet_assignment_type;      
       "RES_ERR" enum packet_assignment_type;  
       "EV_SERV" enum packet_assignment_type;  
       "DAQ" enum packet_assignment_type;      
       "STIM" enum packet_assignment_type;     
     }; // XCP packet type
    }; 
  };

  struct FLX_Parameters {

    uint;              // XCP on FlexRay version
                       // e.g. "1.0" = 0x0100

    uint;              // T1_FLX [ms] Time-out while waiting for an XCP on FlexRay response
                       // e.g. FLX_ASSIGN

    char[256];         // FIBEX-file with extension and without path, including CHI information

    char[256];         // cluster-ID, id attribute of the FIBEX cluster

    uchar;             // NAX, node address of the ECU

    enum { 
      "HEADER_NAX"              = 0,
      "HEADER_NAX_FILL"         = 1,
      "HEADER_NAX_CTR"          = 2,
      "HEADER_NAX_FILL3"        = 3,
      "HEADER_NAX_CTR_FILL2"    = 4,
      "HEADER_NAX_LEN"          = 5,
      "HEADER_NAX_CTR_LEN"      = 6,
      "HEADER_NAX_FILL2_LEN"    = 7,
      "HEADER_NAX_CTR_FILL_LEN" = 8
    };                 // header type of the XCP on FlexRay message

    enum {
      "PACKET_ALIGNMENT_8"  = 0,
      "PACKET_ALIGNMENT_16" = 1,
      "PACKET_ALIGNMENT_32" = 2
    };                 // XCP packet alignment within the XCP on FlexRay Message

    taggedunion {
      block "INITIAL_CMD_BUFFER" struct buffer;
    };                // XCP dedicated buffer used to transmit XCP commands

    taggedunion {
      block "INITIAL_RES_ERR_BUFFER" struct buffer;
    };                // XCP dedicated buffer used to receive the responses on the XCP commands

    taggedstruct {
      (block "POOL_BUFFER" struct buffer)*;
    };                // XCP dedicated buffer(s) used for XCP-DAQ, -STIM and -EV/SERV
  };

  block "IF_DATA" taggedunion if_data {
    "XCP" struct {
      taggedstruct Common_Parameters ; /* default parameters */
      taggedstruct {
        block "XCP_ON_CAN" struct {
          struct CAN_Parameters;            /* specific for CAN */
          taggedstruct Common_Parameters;   /* overruling of default */
        };
        block "XCP_ON_SxI" struct {
          struct SxI_Parameters;            /* specific for SxI */
          taggedstruct Common_Parameters;   /* overruling of default */
        };
        block "XCP_ON_TCP_IP" struct {
          struct TCP_IP_Parameters;         /* specific for TCP_IP */
          taggedstruct Common_Parameters;   /* overruling of default */
        };
        block "XCP_ON_UDP_IP" struct {
          struct UDP_IP_Parameters;         /* specific for UDP */
          taggedstruct Common_Parameters;   /* overruling of default */
        };
        block "XCP_ON_USB" struct {
          struct USB_Parameters ;          /* specific for USB      */
          taggedstruct Common_Parameters;  /* overruling of default */
        };
        block "XCP_ON_FLX" struct {
          struct FLX_Parameters ;          /* specific for FlexRay  */
          taggedstruct Common_Parameters;  /* overruling of default */
        };
      }; // transport layer parameters
    };
  };

/end A2ML
