Open KJA000 opened 9 months ago
// Generated by RTAA2LGen.exe, version 1.1.1.0. Copyright � ETAS Group 2013-2015.
ASAP2_VERSION 1 60 /begin PROJECT Example_Template "Prototype Template layout" /begin HEADER "" VERSION "000" PROJECT_NO RTA_A2L_TEST /end HEADER /begin MODULE A_MODULE /begin A2ML /include XCP_v1_0_definitions.aml block "IF_DATA" taggedunion if_data { /include XCP_v1_0.aml }; /end A2ML /begin MOD_PAR "Prototype" SUPPLIER "ETAS" ECU "VRTA" CPU_TYPE "x86" /begin MEMORY_SEGMENT CALIB "CALIB" DATA FLASH EXTERNAL 0x00000000 0x0 -1 -1 -1 -1 -1 /begin IF_DATA XCP
/begin SEGMENT
0x00 /* segment logical number */
0x02 /* number of pages */
0x00 /* address extension */
0x00 /* compression method */
0x00 /* encryption method */
/begin PAGE /* Reference page */
0x00 /* page number */
ECU_ACCESS_WITH_XCP_ONLY
XCP_READ_ACCESS_WITH_ECU_ONLY
XCP_WRITE_ACCESS_NOT_ALLOWED
INIT_SEGMENT 0
/end PAGE
/begin PAGE /* Working page */
0x01 /* page number */
ECU_ACCESS_WITH_XCP_ONLY
XCP_READ_ACCESS_WITH_ECU_ONLY
XCP_WRITE_ACCESS_WITH_ECU_ONLY
INIT_SEGMENT 0
/end PAGE
/end SEGMENT
/end IF_DATA
/end MEMORY_SEGMENT
/end MOD_PAR
/begin MOD_COMMON
"Prototype"
BYTE_ORDER MSB_LAST
ALIGNMENT_BYTE 1
ALIGNMENT_WORD 1
ALIGNMENT_LONG 1
ALIGNMENT_INT64 1
ALIGNMENT_FLOAT32_IEEE 1
ALIGNMENT_FLOAT64_IEEE 1
/end MOD_COMMON
/begin IF_DATA XCP / Insert this block within the MODULE block of the A2L file. /
/begin PROTOCOL_LAYER
0x0100 /* XCP protocol layer 1.0 */
2000 /* T1 [ms] */
2000 /* T2 [ms] */
2000 /* T3 [ms] */
2000 /* T4 [ms] */
2000 /* T5 [ms] */
0005 /* T6 [ms] */
0005 /* T7 [ms] */
0xff /* MAX_CTO */
0x05bc /* MAX_DTO */
BYTE_ORDER_MSB_LAST
ADDRESS_GRANULARITY_BYTE
OPTIONAL_CMD SET_REQUEST
OPTIONAL_CMD SET_MTA
OPTIONAL_CMD UPLOAD
OPTIONAL_CMD TRANSPORT_LAYER_CMD
OPTIONAL_CMD CLEAR_DAQ_LIST
OPTIONAL_CMD SET_DAQ_PTR
OPTIONAL_CMD WRITE_DAQ
OPTIONAL_CMD SET_DAQ_LIST_MODE
OPTIONAL_CMD START_STOP_DAQ_LIST
OPTIONAL_CMD START_STOP_SYNCH
OPTIONAL_CMD GET_DAQ_CLOCK
OPTIONAL_CMD MODIFY_BITS
OPTIONAL_CMD DOWNLOAD
OPTIONAL_CMD DOWNLOAD_NEXT
OPTIONAL_CMD SET_CAL_PAGE
OPTIONAL_CMD GET_CAL_PAGE
OPTIONAL_CMD COPY_CAL_PAGE
OPTIONAL_CMD SET_SEGMENT_MODE
OPTIONAL_CMD GET_SEGMENT_MODE
COMMUNICATION_MODE_SUPPORTED
BLOCK
SLAVE
MASTER
0xff /* MAX_BS */
100 /* MIN_ST */
/end PROTOCOL_LAYER
/begin DAQ
STATIC /* DAQ_CONFIG_TYPE */
8 /* MAX_DAQ */
8 /* MAX_EVENT_CHANNEL */
0 /* MIN_DAQ, i.e. the number of predefined DAQ lists */
OPTIMISATION_TYPE_DEFAULT
ADDRESS_EXTENSION_DAQ /* ADDR_EXTENSION_TYPE */
IDENTIFICATION_FIELD_TYPE_ABSOLUTE
GRANULARITY_ODT_ENTRY_SIZE_DAQ_BYTE
127 /* MAX_ODT_ENTRY_SIZE_DAQ */
NO_OVERLOAD_INDICATION
/begin TIMESTAMP_SUPPORTED
1 /* TIMESTAMP_TICKS */
SIZE_WORD /* TIMESTAMP_SIZE */
UNIT_1MS /* TIMESTAMP_RESOLUTION */
/end TIMESTAMP_SUPPORTED
/begin DAQ_LIST /* Event0 */
0 /* DAQ_LIST_NUMBER */
DAQ_LIST_TYPE DAQ
MAX_ODT 1
MAX_ODT_ENTRIES 255
FIRST_PID 0
EVENT_FIXED 0
/end DAQ_LIST
/begin DAQ_LIST /* Event1 */
1 /* DAQ_LIST_NUMBER */
DAQ_LIST_TYPE DAQ
MAX_ODT 1
MAX_ODT_ENTRIES 255
FIRST_PID 1
EVENT_FIXED 1
/end DAQ_LIST
/begin DAQ_LIST /* Event2 */
2 /* DAQ_LIST_NUMBER */
DAQ_LIST_TYPE DAQ
MAX_ODT 1
MAX_ODT_ENTRIES 255
FIRST_PID 2
EVENT_FIXED 2
/end DAQ_LIST
/begin DAQ_LIST /* Event3 */
3 /* DAQ_LIST_NUMBER */
DAQ_LIST_TYPE DAQ
MAX_ODT 1
MAX_ODT_ENTRIES 255
FIRST_PID 3
EVENT_FIXED 3
/end DAQ_LIST
/begin DAQ_LIST /* Event4 */
4 /* DAQ_LIST_NUMBER */
DAQ_LIST_TYPE DAQ
MAX_ODT 1
MAX_ODT_ENTRIES 255
FIRST_PID 4
EVENT_FIXED 4
/end DAQ_LIST
/begin DAQ_LIST /* Event5 */
5 /* DAQ_LIST_NUMBER */
DAQ_LIST_TYPE DAQ
MAX_ODT 1
MAX_ODT_ENTRIES 255
FIRST_PID 5
EVENT_FIXED 5
/end DAQ_LIST
/begin DAQ_LIST /* Event6 */
6 /* DAQ_LIST_NUMBER */
DAQ_LIST_TYPE DAQ
MAX_ODT 1
MAX_ODT_ENTRIES 255
FIRST_PID 6
EVENT_FIXED 6
/end DAQ_LIST
/begin DAQ_LIST /* Event7 */
7 /* DAQ_LIST_NUMBER */
DAQ_LIST_TYPE DAQ
MAX_ODT 1
MAX_ODT_ENTRIES 255
FIRST_PID 7
EVENT_FIXED 7
/end DAQ_LIST
/begin EVENT
"Event0" /* EVENT_CHANNEL_NAME */
"Event0" /* EVENT_CHANNEL_SHORT_NAME */
0 /* EVENT_CHANNEL_NUMBER */
DAQ_STIM /* EVENT_CHANNEL_DIRECTION */
0xff /* MAX_DAQ_LIST */
0 /* TIME_CYCLE */
6 /* TIME_UNIT */
0 /* PRIORITY */
/end EVENT
/begin EVENT
"Event1" /* EVENT_CHANNEL_NAME */
"Event1" /* EVENT_CHANNEL_SHORT_NAME */
1 /* EVENT_CHANNEL_NUMBER */
DAQ_STIM /* EVENT_CHANNEL_DIRECTION */
0xff /* MAX_DAQ_LIST */
0 /* TIME_CYCLE */
6 /* TIME_UNIT */
0 /* PRIORITY */
/end EVENT
/begin EVENT
"Event2" /* EVENT_CHANNEL_NAME */
"Event2" /* EVENT_CHANNEL_SHORT_NAME */
2 /* EVENT_CHANNEL_NUMBER */
DAQ_STIM /* EVENT_CHANNEL_DIRECTION */
0xff /* MAX_DAQ_LIST */
0 /* TIME_CYCLE */
6 /* TIME_UNIT */
0 /* PRIORITY */
/end EVENT
/begin EVENT
"Event3" /* EVENT_CHANNEL_NAME */
"Event3" /* EVENT_CHANNEL_SHORT_NAME */
3 /* EVENT_CHANNEL_NUMBER */
DAQ_STIM /* EVENT_CHANNEL_DIRECTION */
0xff /* MAX_DAQ_LIST */
0 /* TIME_CYCLE */
6 /* TIME_UNIT */
0 /* PRIORITY */
/end EVENT
/begin EVENT
"Event4" /* EVENT_CHANNEL_NAME */
"Event4" /* EVENT_CHANNEL_SHORT_NAME */
4 /* EVENT_CHANNEL_NUMBER */
DAQ_STIM /* EVENT_CHANNEL_DIRECTION */
0xff /* MAX_DAQ_LIST */
0 /* TIME_CYCLE */
6 /* TIME_UNIT */
0 /* PRIORITY */
/end EVENT
/begin EVENT
"Event5" /* EVENT_CHANNEL_NAME */
"Event5" /* EVENT_CHANNEL_SHORT_NAME */
5 /* EVENT_CHANNEL_NUMBER */
DAQ_STIM /* EVENT_CHANNEL_DIRECTION */
0xff /* MAX_DAQ_LIST */
0 /* TIME_CYCLE */
6 /* TIME_UNIT */
0 /* PRIORITY */
/end EVENT
/begin EVENT
"Event6" /* EVENT_CHANNEL_NAME */
"Event6" /* EVENT_CHANNEL_SHORT_NAME */
6 /* EVENT_CHANNEL_NUMBER */
DAQ_STIM /* EVENT_CHANNEL_DIRECTION */
0xff /* MAX_DAQ_LIST */
0 /* TIME_CYCLE */
6 /* TIME_UNIT */
0 /* PRIORITY */
/end EVENT
/begin EVENT
"Event7" /* EVENT_CHANNEL_NAME */
"Event7" /* EVENT_CHANNEL_SHORT_NAME */
7 /* EVENT_CHANNEL_NUMBER */
DAQ_STIM /* EVENT_CHANNEL_DIRECTION */
0xff /* MAX_DAQ_LIST */
0 /* TIME_CYCLE */
6 /* TIME_UNIT */
0 /* PRIORITY */
/end EVENT
/end DAQ
/begin PAG
2 /* MAX_SEGMENTS */
FREEZE_SUPPORTED
/end PAG
/begin PGM
PGM_MODE_ABSOLUTE
0 /* MAX_SECTORS */
0x08 /* MAX_CTO_PGM */
COMMUNICATION_MODE_SUPPORTED
BLOCK
SLAVE
MASTER
0xff /* MAX_BS_PGM */
100 /* MIN_ST_PGM */
/end PGM
/begin XCP_ON_UDP_IP
0x0100 /* XCP on IP 1.0 */
<UDPPORT> /* Port */
ADDRESS "<IPADDR>"
/end XCP_ON_UDP_IP
/end IF_DATA /begin CHARACTERISTIC Hysteresis_LightOffIntensity "unsigned integer 16bit" VALUE 0x00000000 RTAA2L_Internal_Scalar_UnsignedWord 0 CompuMethods_STEP_100_OFFSET_0 0 100 DISPLAY_IDENTIFIER Hysteresis_LightOffIntensity /end CHARACTERISTIC /begin CHARACTERISTIC Hysteresis_LightOffTime "unsigned integer 16bit" VALUE 0x00000000 RTAA2L_Internal_Scalar_UnsignedWord 0 NO_COMPU_METHOD 0 65535 DISPLAY_IDENTIFIER Hysteresis_LightOffTime /end CHARACTERISTIC /begin CHARACTERISTIC Hysteresis_LightOnIntensity "unsigned integer 16bit" VALUE 0x00000000 RTAA2L_Internal_Scalar_UnsignedWord 0 CompuMethods_STEP_100_OFFSET_0 0 100 SYMBOL_LINK "Rte_PmGroup.HP_NM0N_TUNING_CALIB.MotPwrEstim.MotPwrEstimIndld" 0 DISPLAY_IDENTIFIER Hysteresis_LightOnIntensity /end CHARACTERISTIC /begin CHARACTERISTIC Hysteresis_LightOnTime "unsigned integer 16bit" VALUE 0x00000000 RTAA2L_Internal_Scalar_UnsignedWord 0 NO_COMPU_METHOD 0 65535 DISPLAY_IDENTIFIER Hysteresis_LightOnTime /end CHARACTERISTIC /begin CHARACTERISTIC Hysteresis_WiperOffIntensity "unsigned integer 16bit" VALUE 0x00000000 RTAA2L_Internal_Scalar_UnsignedWord 0 CompuMethods_STEP_100_OFFSET_0 0 100 DISPLAY_IDENTIFIER Hysteresis_WiperOffIntensity /end CHARACTERISTIC /begin CHARACTERISTIC Hysteresis_WiperOffTime "unsigned integer 16bit" VALUE 0x00000000 RTAA2L_Internal_Scalar_UnsignedWord 0 NO_COMPU_METHOD 0 65535 DISPLAY_IDENTIFIER Hysteresis_WiperOffTime /end CHARACTERISTIC /begin CHARACTERISTIC Hysteresis_WiperOnIntensity "unsigned integer 16bit" VALUE 0x00000000 RTAA2L_Internal_Scalar_UnsignedWord 0 CompuMethods_STEP_100_OFFSET_0 0 100 DISPLAY_IDENTIFIER Hysteresis_WiperOnIntensity /end CHARACTERISTIC /begin CHARACTERISTIC Hysteresis_WiperOnTime "unsigned integer 16bit" VALUE 0x00000000 RTAA2L_Internal_Scalar_UnsignedWord 0 NO_COMPU_METHOD 0 65535 DISPLAY_IDENTIFIER Hysteresis_WiperOnTime /end CHARACTERISTIC /begin MEASUREMENT Rte_Rx_000011_CL15Active "Boolean" UBYTE CompuMethods_boolean 0 0 0 1 DISPLAYIDENTIFIER CL15Active ECU_ADDRESS 0x00000000 /end MEASUREMENT /begin MEASUREMENT Rte_Rx_000012_LightActive "Boolean" UBYTE CompuMethods_boolean 0 0 0 1 DISPLAY_IDENTIFIER LightActive ECU_ADDRESS 0x00000000 READ_WRITE /end MEASUREMENT /begin MEASUREMENT Rte_Rx_000015_WiperActive "Boolean" UBYTE CompuMethods_boolean 0 0 0 1 DISPLAY_IDENTIFIER WiperActive ECU_ADDRESS 0x00000000 READ_WRITE /end MEASUREMENT /begin MEASUREMENT Rte_Rx_000000_IgnitionKeyPosition "unsigned integer 8bit" UBYTE CompuMethods_ENUM_OFF_ON 0 0 0 1 SYMBOL_LINK "Rte_PmGroup.HP_NM0N_TUNING_CALIB.MotPwrEstim.MotPwrEstimIndld" 0 DISPLAY_IDENTIFIER IgnitionKeyPosition ECU_ADDRESS 0x00000000 READ_WRITE /end MEASUREMENT /begin MEASUREMENT Rte_Rx_000004_LightIntensity "unsigned integer 16bit" UWORD CompuMethods_STEP_100_OFFSET_0 0 0 0 100 DISPLAY_IDENTIFIER LightIntensity ECU_ADDRESS 0x00000000 READ_WRITE /end MEASUREMENT /begin MEASUREMENT Rte_Rx_000005_RainIntensitity "unsigned integer 16bit" UWORD CompuMethods_STEP_100_OFFSET_0 0 0 0 100 DISPLAY_IDENTIFIER RainIntensitity ECU_ADDRESS 0x00000000 READ_WRITE /end MEASUREMENT /begin MEASUREMENT Rte_Rx_000003_LightSwitchPosition "unsigned integer 8bit" UBYTE NO_COMPU_METHOD 0 0 0 255 DISPLAYIDENTIFIER LightSwitchPosition ECU_ADDRESS 0x00000000 READ_WRITE /end MEASUREMENT /begin COMPU_METHOD CompuMethods_STEP_100_OFFSET_0 "CompuMethods_STEP_100_OFFSET_0" LINEAR "%.2" "" COEFFS_LINEAR 0.01 0 /end COMPU_METHOD /begin COMPU_METHOD CompuMethods_boolean "CompuMethods_boolean" TAB_VERB "%.2" "" COMPU_TAB_REF CompuMethods_boolean_TAB /end COMPU_METHOD /begin COMPU_METHOD CompuMethods_ENUM_OFF_ON "CompuMethods_ENUM_OFF_ON" TAB_VERB "%.2" "" COMPU_TAB_REF CompuMethods_ENUM_OFF_ON_TAB /end COMPU_METHOD /begin COMPU_VTAB CompuMethods_boolean_TAB "CompuMethods_boolean" TAB_VERB 2 0 "FALSE" 1 "TRUE" /end COMPU_VTAB /begin COMPU_VTAB CompuMethods_ENUM_OFF_ON_TAB "CompuMethods_ENUM_OFF_ON" TAB_VERB 2 0 "OFF" 1 "ON" /end COMPU_VTAB /begin RECORD_LAYOUT RTAA2L_Internal_Scalar_UnsignedWord FNC_VALUES 1 UWORD ROW_DIR DIRECT /end RECORD_LAYOUT
/end MODULE /end PROJECT
/begin CHARACTERISTIC ModMgr.BC0brdguDifTfhd "" VALUE 0x803C168 RL FLOAT32_IEEE 20 NO_COMPU_METHOD 0 20 SYMBOL_LINK "Rte_PmGroup.HP_NM0N_TUNING_CALIB.ModMgr.BC0brdguDifTfhd" 0 DISPLAY_IDENTIFIER ModMgr.BC0brdguDifTfhd ECU_ADDRESS_EXTENSION 0x0 PHYS_UNIT "V" /end CHARACTERISTIC
/begin CHARACTERISTIC MotPwrEstim.MotPwrEstimIndld "" MAP 0x803C39C RL UNORD 3 Mando_CompuMethods_Fac3 3 0 20 AXIS_PTS_REF MotPwrEstim.MotPwrEstimInq AXIS_PTS 0x803C1B0 DEPOSIT ABSOLUTE FORMAT "4.5" PHYS_UNIT "As" /begin AXIS_DESCR COM_AXIS MotPwrEstim.MotPwrEstimInqRtef Mando_CompuMethods_AmpR 8 0 20 /end AXIS_DESCR SYMBOL_LINK "Rte_PmGroup.HP_NM0N_TUNING_CALIB.MotPwrEstim.MotPwrEstimIndld" 0 DISPLAY_IDENTIFIER MotPwrEstim.MotPwrEstimIndld ECU_ADDRESS_EXTENSION 0x0 /end CHARACTERISTIC
/begin MEASUREMENT SbwSigVotg.ConsolYawRate.YawRateInvl "" UBYTE NO_COMPU_METHOD 0 0 0 1 DISPLAY_IDENTIFIER SbwSigVotg.ConsolYawRate.YawRateInvl ECU_ADDRESS 0x70006FE4 ECU_ADDRESS_EXTENSION 0x0 SYMBOL_LINK "Rte_Smc.Rte_YawRateCorrn.YawRate_YawRateInvl" 0 /end MEASUREMENT
/begin CHARACTERISTIC ExampleName "" VALUE 0x123456 RL FLOAT32_IEEE 20 NO_COMPU_METHOD 0 20 SYMBOL_LINK "ExampleName" 0 DISPLAY_IDENTIFIER ExampleName ECU_ADDRESS_EXTENSION 0x0 PHYS_UNIT "V" /end CHARACTERISTIC
/begin CHARACTERISTIC UniqueName "" VALUE 0x123456 RL FLOAT32_IEEE 20 NO_COMPU_METHOD 0 20 SYMBOL_LINK "DifferentName" 0 DISPLAY_IDENTIFIER UniqueName ECU_ADDRESS_EXTENSION 0x0 PHYS_UNIT "V" /end CHARACTERISTIC
import re import csv
def extract_blocks(a2l_content): blockpattern = re.compile(r'/begin\s+(\w+)\s*([\w\s"])\s(.)\s/end\s+\1', re.DOTALL) blocks = block_pattern.findall(a2l_content) return blocks
def extract_symbol_link_display_identifier(block_content): characteristic_pattern = re.compile(r'/begin\s+(CHARACTERISTIC|MEASUREMENT)\s+(\w+)\s"([^"]+)"\s+.?SYMBOL_LINK\s+"([^"]+)".*?DISPLAY_IDENTIFIER\s+([^/]+)\s+/end \1', re.DOTALL) characteristics = characteristic_pattern.findall(block_content) return characteristics
def write_csv(filename, data): with open(filename, 'w', newline='') as csvfile: csvwriter = csv.writer(csvfile) csvwriter.writerows(data)
def main(): with open('BCU.a2l', 'r') as file: a2l_content = file.read()
blocks = extract_blocks(a2l_content)
data = []
for _, name, block_content in blocks:
characteristics = extract_symbol_link_display_identifier(block_content)
for _, name, _, symbol_link, display_identifier in characteristics:
if name != symbol_link:
print(data,' ')
data.append([symbol_link, name])
write_csv('output.csv', data)
if name == "main": main()
import re import csv
def process_code_within_begin_end(input_code, output_csv):
pattern = re.compile(r'/begin (\S+)\s+(\S+)(.*?)\n\s*/end \1', re.DOTALL)
matches = pattern.findall(input_code)
csv_data = []
for match in matches:
_, name, section_content = match
symbol_link_match = re.search(r'SYMBOL_LINK\s+"(\S+)"', section_content)
if symbol_link_match:
symbol_link_value = symbol_link_match.group(1)
if name != symbol_link_value:
csv_data.append([symbol_link_value, name])
with open(output_csv, 'w', newline='') as csvfile:
csv_writer = csv.writer(csvfile)
csv_writer.writerows(csv_data)
with open('BCU.a2l', 'r') as file: a2l_content = file.read()
process_code_within_begin_end(a2l_content, 'output.csv')