Browse Source

add files

master
Ian Ilkyun Oh 6 months ago
parent
commit
9289b3de28
  1. 31
      A2lTestDlg/A2lTestDlg.sln
  2. 718
      A2lTestDlg/A2lTestDlg/A2L.c
  3. 121
      A2lTestDlg/A2lTestDlg/A2L.h
  4. 124
      A2lTestDlg/A2lTestDlg/A2Lpp.cpp
  5. 122
      A2lTestDlg/A2lTestDlg/A2Lpp.hpp
  6. 153
      A2lTestDlg/A2lTestDlg/A2lTestDlg.cpp
  7. 33
      A2lTestDlg/A2lTestDlg/A2lTestDlg.h
  8. 29
      A2lTestDlg/A2lTestDlg/A2lTestDlg.idl
  9. BIN
      A2lTestDlg/A2lTestDlg/A2lTestDlg.rc
  10. 17
      A2lTestDlg/A2lTestDlg/A2lTestDlg.reg
  11. 252
      A2lTestDlg/A2lTestDlg/A2lTestDlg.vcxproj
  12. 118
      A2lTestDlg/A2lTestDlg/A2lTestDlg.vcxproj.filters
  13. 6
      A2lTestDlg/A2lTestDlg/A2lTestDlg.vcxproj.user
  14. 252
      A2lTestDlg/A2lTestDlg/A2lTestDlgDlg.cpp
  15. 60
      A2lTestDlg/A2lTestDlg/A2lTestDlgDlg.h
  16. 226
      A2lTestDlg/A2lTestDlg/A2lTestDlg_h.h
  17. 84
      A2lTestDlg/A2lTestDlg/A2lTestDlg_i.c
  18. 87
      A2lTestDlg/A2lTestDlg/DlgProxy.cpp
  19. 43
      A2lTestDlg/A2lTestDlg/DlgProxy.h
  20. 50
      A2lTestDlg/A2lTestDlg/dbg_print.h
  21. 60
      A2lTestDlg/A2lTestDlg/framework.h
  22. 95
      A2lTestDlg/A2lTestDlg/main.h
  23. 48
      A2lTestDlg/A2lTestDlg/main_cfg.h
  24. 39
      A2lTestDlg/A2lTestDlg/main_cfg.h.in
  25. 5
      A2lTestDlg/A2lTestDlg/pch.cpp
  26. 13
      A2lTestDlg/A2lTestDlg/pch.h
  27. 183
      A2lTestDlg/A2lTestDlg/platform.h
  28. BIN
      A2lTestDlg/A2lTestDlg/res/A2lTestDlg.ico
  29. BIN
      A2lTestDlg/A2lTestDlg/res/A2lTestDlg.rc2
  30. 24
      A2lTestDlg/A2lTestDlg/resource.h
  31. 8
      A2lTestDlg/A2lTestDlg/targetver.h
  32. 1235
      A2lTestDlg/A2lTestDlg/xcp.h
  33. 27
      A2lTestDlg/A2lTestDlg/xcpEthTl.h
  34. 188
      A2lTestDlg/A2lTestDlg/xcpLite.h
  35. 32
      A2lTestDlg/A2lTestDlg/xcpTl.h
  36. 104
      A2lTestDlg/A2lTestDlg/xcp_cfg.h
  37. 70
      A2lTestDlg/A2lTestDlg/xcptl_cfg.h

31
A2lTestDlg/A2lTestDlg.sln

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.35731.53
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "A2lTestDlg", "A2lTestDlg\A2lTestDlg.vcxproj", "{86752C60-05E4-465C-9D79-876C97ABD2BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{86752C60-05E4-465C-9D79-876C97ABD2BA}.Debug|x64.ActiveCfg = Debug|x64
{86752C60-05E4-465C-9D79-876C97ABD2BA}.Debug|x64.Build.0 = Debug|x64
{86752C60-05E4-465C-9D79-876C97ABD2BA}.Debug|x86.ActiveCfg = Debug|Win32
{86752C60-05E4-465C-9D79-876C97ABD2BA}.Debug|x86.Build.0 = Debug|Win32
{86752C60-05E4-465C-9D79-876C97ABD2BA}.Release|x64.ActiveCfg = Release|x64
{86752C60-05E4-465C-9D79-876C97ABD2BA}.Release|x64.Build.0 = Release|x64
{86752C60-05E4-465C-9D79-876C97ABD2BA}.Release|x86.ActiveCfg = Release|Win32
{86752C60-05E4-465C-9D79-876C97ABD2BA}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F96F38CF-D37B-45D8-9FA2-665EB10C5913}
EndGlobalSection
EndGlobal

718
A2lTestDlg/A2lTestDlg/A2L.c

@ -0,0 +1,718 @@
/*----------------------------------------------------------------------------
| File:
| A2L.c
|
| Description:
| Create A2L file
|
| Copyright (c) Vector Informatik GmbH. All rights reserved.
| Licensed under the MIT license. See LICENSE file in the project root for details.
|
----------------------------------------------------------------------------*/
#include "pch.h"
#include "framework.h"
#include "main.h"
#include "platform.h"
#include "dbg_print.h"
#include "xcpLite.h"
#include "A2L.h"
static FILE* gA2lFile = NULL;
static uint16_t gA2lFixedEvent = XCP_INVALID_EVENT;
static uint16_t gA2lDefaultEvent = XCP_INVALID_EVENT;
static uint32_t gA2lMeasurements;
static uint32_t gA2lParameters;
static uint32_t gA2lTypedefs;
static uint32_t gA2lComponents;
static uint32_t gA2lInstances;
static uint32_t gA2lConversions;
//----------------------------------------------------------------------------------
// Check for memory accessibility
//#define A2L_ENABLE_MEMORY_CHECK
#ifdef A2L_ENABLE_MEMORY_CHECK
static void mem_check(const char* name, int32_t type, uint8_t ext, uint32_t addr) {
(void)type; (void)name;
volatile uint8_t *p = ApplXcpGetPointer(ext,addr);
if (p==NULL) { DBG_PRINTF1("ERROR: memory address 0x%04X of variable %s not accessible !\n",addr,name); assert(0); }
volatile uint8_t b = *p; // if this leads to a memory protection error, check if address transformation from A2L to uint_8_p* transformation is correct
}
#endif
//----------------------------------------------------------------------------------
static const char* gA2lHeader =
"ASAP2_VERSION 1 71\n"
"/begin PROJECT %s \"\"\n"
"/begin HEADER \"\" VERSION \"1.0\" /end HEADER\n"
"/begin MODULE %s \"\"\n"
"/include \"XCP_104.aml\"\n\n"
"/begin MOD_COMMON \"\"\n"
"BYTE_ORDER MSB_LAST\n"
"ALIGNMENT_BYTE 1\n"
"ALIGNMENT_WORD 1\n"
"ALIGNMENT_LONG 1\n"
"ALIGNMENT_FLOAT16_IEEE 1\n"
"ALIGNMENT_FLOAT32_IEEE 1\n"
"ALIGNMENT_FLOAT64_IEEE 1\n"
"ALIGNMENT_INT64 1\n"
"/end MOD_COMMON\n"
"\n";
//----------------------------------------------------------------------------------
static const char* gA2lMemorySegment =
"/begin MEMORY_SEGMENT\n"
"CALRAM \"\" DATA FLASH INTERN 0x%08X 0x%08X -1 -1 -1 -1 -1\n" // CALRAM_START, CALRAM_SIZE
"/begin IF_DATA XCP\n"
"/begin SEGMENT 0x01 0x02 0x00 0x00 0x00 \n"
"/begin CHECKSUM XCP_ADD_44 MAX_BLOCK_SIZE 0xFFFF EXTERNAL_FUNCTION \"\" /end CHECKSUM\n"
"/begin PAGE 0x01 ECU_ACCESS_WITH_XCP_ONLY XCP_READ_ACCESS_WITH_ECU_ONLY XCP_WRITE_ACCESS_NOT_ALLOWED /end PAGE\n"
"/begin PAGE 0x00 ECU_ACCESS_WITH_XCP_ONLY XCP_READ_ACCESS_WITH_ECU_ONLY XCP_WRITE_ACCESS_WITH_ECU_ONLY /end PAGE\n"
"/end SEGMENT\n"
"/end IF_DATA\n"
"/end MEMORY_SEGMENT\n";
//----------------------------------------------------------------------------------
static const char* const gA2lIfDataBegin =
"\n/begin IF_DATA XCP\n";
//----------------------------------------------------------------------------------
static const char* gA2lIfDataProtocolLayer = // Parameter: XCP_PROTOCOL_LAYER_VERSION, MAX_CTO, MAX_DTO
"/begin PROTOCOL_LAYER\n"
" 0x%04X" // XCP_PROTOCOL_LAYER_VERSION
" 1000 2000 0 0 0 0 0" // Timeouts T1-T7
" %u %u " // MAX_CTO, MAX_DTO
"BYTE_ORDER_MSB_LAST ADDRESS_GRANULARITY_BYTE\n" // Intel and BYTE pointers
"OPTIONAL_CMD GET_COMM_MODE_INFO\n" // Optional commands
"OPTIONAL_CMD GET_ID\n"
"OPTIONAL_CMD SET_MTA\n"
"OPTIONAL_CMD UPLOAD\n"
"OPTIONAL_CMD SHORT_UPLOAD\n"
"OPTIONAL_CMD DOWNLOAD\n"
"OPTIONAL_CMD SHORT_DOWNLOAD\n"
#ifdef XCP_ENABLE_CAL_PAGE
"OPTIONAL_CMD GET_CAL_PAGE\n"
"OPTIONAL_CMD SET_CAL_PAGE\n"
//"OPTIONAL_CMD CC_GET_PAG_PROCESSOR_INFO\n"
//"OPTIONAL_CMD CC_GET_SEGMENT_INFO\n"
//"OPTIONAL_CMD CC_GET_PAGE_INFO\n"
//"OPTIONAL_CMD CC_SET_SEGMENT_MODE\n"
//"OPTIONAL_CMD CC_GET_SEGMENT_MODE\n"
//"OPTIONAL_CMD CC_COPY_CAL_PAGE\n"
#endif
#ifdef XCP_ENABLE_CHECKSUM
"OPTIONAL_CMD BUILD_CHECKSUM\n"
#endif
//"OPTIONAL_CMD TRANSPORT_LAYER_CMD\n"
//"OPTIONAL_CMD USER_CMD\n"
"OPTIONAL_CMD GET_DAQ_RESOLUTION_INFO\n"
"OPTIONAL_CMD GET_DAQ_PROCESSOR_INFO\n"
#ifdef XCP_ENABLE_DAQ_EVENT_INFO
"OPTIONAL_CMD GET_DAQ_EVENT_INFO\n"
#endif
//"OPTIONAL_CMD GET_DAQ_LIST_INFO\n"
"OPTIONAL_CMD FREE_DAQ\n"
"OPTIONAL_CMD ALLOC_DAQ\n"
"OPTIONAL_CMD ALLOC_ODT\n"
"OPTIONAL_CMD ALLOC_ODT_ENTRY\n"
//"OPTIONAL_CMD CLEAR_DAQ_LIST\n"
//"OPTIONAL_CMD READ_DAQ\n"
"OPTIONAL_CMD SET_DAQ_PTR\n"
"OPTIONAL_CMD WRITE_DAQ\n"
"OPTIONAL_CMD GET_DAQ_LIST_MODE\n"
"OPTIONAL_CMD SET_DAQ_LIST_MODE\n"
"OPTIONAL_CMD START_STOP_SYNCH\n"
"OPTIONAL_CMD START_STOP_DAQ_LIST\n"
"OPTIONAL_CMD GET_DAQ_CLOCK\n"
#if XCP_TRANSPORT_LAYER_TYPE == XCP_TRANSPORT_LAYER_ETH
"OPTIONAL_CMD WRITE_DAQ_MULTIPLE\n"
#if XCP_PROTOCOL_LAYER_VERSION >= 0x0103
"OPTIONAL_CMD TIME_CORRELATION_PROPERTIES\n"
//"OPTIONAL_CMD DTO_CTR_PROPERTIES\n"
#endif
#if XCP_PROTOCOL_LAYER_VERSION >= 0x0104
"OPTIONAL_LEVEL1_CMD GET_VERSION\n"
#ifdef XCP_ENABLE_PACKED_MODE
"OPTIONAL_LEVEL1_CMD SET_DAQ_PACKED_MODE\n"
"OPTIONAL_LEVEL1_CMD GET_DAQ_PACKED_MODE\n"
#endif
#endif
#if XCP_PROTOCOL_LAYER_VERSION >= 0x0150
//"OPTIONAL_LEVEL1_CMD SW_DBG_COMMAND_SPACE\n"
//"OPTIONAL_LEVEL1_CMD POD_COMMAND_SPACE\n"
#endif
#endif // ETH
"/end PROTOCOL_LAYER\n"
#if XCP_PROTOCOL_LAYER_VERSION >= 0x0103
/*
"/begin TIME_CORRELATION\n" // TIME
"/end TIME_CORRELATION\n"
*/
#endif
;
//----------------------------------------------------------------------------------
static const char* gA2lIfDataBeginDAQ = // Parameter: %u max event, %s timestamp unit
"/begin DAQ\n"
"DYNAMIC 0 %u 0 OPTIMISATION_TYPE_DEFAULT ADDRESS_EXTENSION_FREE IDENTIFICATION_FIELD_TYPE_RELATIVE_BYTE GRANULARITY_ODT_ENTRY_SIZE_DAQ_BYTE 0xF8 OVERLOAD_INDICATION_PID\n"
"/begin TIMESTAMP_SUPPORTED\n"
"0x01 SIZE_DWORD %s TIMESTAMP_FIXED\n"
"/end TIMESTAMP_SUPPORTED\n";
// ... Event list follows, before EndDaq
//----------------------------------------------------------------------------------
static const char * const gA2lIfDataEndDAQ =
"/end DAQ\n";
//----------------------------------------------------------------------------------
// XCP_ON_ETH
static const char* gA2lIfDataEth = // Parameter: %s TCP or UDP, %04X tl version, %u port, %s ip address string, %s TCP or UDP
"/begin XCP_ON_%s_IP\n" // Transport Layer
" 0x%04X %u ADDRESS \"%s\"\n"
//"OPTIONAL_TL_SUBCMD GET_SERVER_ID\n"
//"OPTIONAL_TL_SUBCMD GET_DAQ_ID\n"
//"OPTIONAL_TL_SUBCMD SET_DAQ_ID\n"
#if defined(XCPTL_ENABLE_MULTICAST) && defined(XCP_ENABLE_DAQ_CLOCK_MULTICAST)
" OPTIONAL_TL_SUBCMD GET_DAQ_CLOCK_MULTICAST\n"
#endif
"/end XCP_ON_%s_IP\n" // Transport Layer
;
//----------------------------------------------------------------------------------
// XCP_ON_CAN (CAN_FD not implemented yet)
static const char* gA2lIfDataCan = // Parameter: TRANSPORT_LAYER_VERSION, CRO_ID, DTO_ID, BITRATE
"/begin XCP_ON_CAN\n" // Transport Layer
" 0x%04X\n"
" CAN_ID_MASTER 0x%x\n"
" CAN_ID_SLAVE 0x%x\n"
" BAUDRATE %u\n"
" SAMPLE_POINT 0x4B\n"
" SAMPLE_RATE SINGLE\n"
" BTL_CYCLES 0x08\n"
" SJW 0x02\n"
" SYNC_EDGE SINGLE\n"
"/end XCP_ON_CAN\n";
//----------------------------------------------------------------------------------
static const char* const gA2lIfDataEnd =
"/end IF_DATA\n\n";
//----------------------------------------------------------------------------------
static const char* const gA2lFooter =
"/end MODULE\n"
"/end PROJECT\n";
#define printPhysUnit(unit) if (unit != NULL && strlen(unit) > 0) fprintf(gA2lFile, " PHYS_UNIT \"%s\"", unit);
#define printAddrExt(ext) if (ext>0) fprintf(gA2lFile, " ECU_ADDRESS_EXTENSION %u",ext);
const char* A2lGetSymbolName(const char* instanceName, const char* name) {
static char s[256];
if (instanceName != NULL && strlen(instanceName) > 0) {
SNPRINTF(s, 256, "%s.%s", instanceName, name);
return s;
}
else {
return name;
}
}
static const char* getType(int32_t type) {
const char* types;
switch (type) {
case A2L_TYPE_INT8: types = "SBYTE"; break;
case A2L_TYPE_INT16: types = "SWORD"; break;
case A2L_TYPE_INT32: types = "SLONG"; break;
case A2L_TYPE_INT64: types = "A_INT64"; break;
case A2L_TYPE_UINT8: types = "UBYTE"; break;
case A2L_TYPE_UINT16: types = "UWORD"; break;
case A2L_TYPE_UINT32: types = "ULONG"; break;
case A2L_TYPE_UINT64: types = "A_UINT64"; break;
case A2L_TYPE_FLOAT: types = "FLOAT32_IEEE"; break;
case A2L_TYPE_DOUBLE: types = "FLOAT64_IEEE"; break;
default:
types = NULL;
}
return types;
}
static const char* getTypeMin(int32_t type) {
const char* min;
switch (type) {
case A2L_TYPE_INT8: min = "-128"; break;
case A2L_TYPE_INT16: min = "-32768"; break;
case A2L_TYPE_INT32: min = "-2147483648"; break;
case A2L_TYPE_INT64: min = "-1E12"; break;
case A2L_TYPE_FLOAT: min = "-1E12"; break;
case A2L_TYPE_DOUBLE: min = "-1E12"; break;
default: min = "0";
}
return min;
}
static const char* getTypeMax(int32_t type) {
const char* max;
switch (type) {
case A2L_TYPE_INT8: max = "127"; break;
case A2L_TYPE_INT16: max = "32767"; break;
case A2L_TYPE_INT32: max = "2147483647"; break;
case A2L_TYPE_UINT8: max = "255"; break;
case A2L_TYPE_UINT16: max = "65535"; break;
case A2L_TYPE_UINT32: max = "4294967295"; break;
default: max = "1E12";
}
return max;
}
static const char* getPhysMin(int32_t type, double factor, double offset) {
double value = 0.0;
switch (type) {
case A2L_TYPE_INT8: value = -128; break;
case A2L_TYPE_INT16: value = -32768; break;
case A2L_TYPE_INT32: value = -(double)2147483648; break;
case A2L_TYPE_INT64: value = -1E12; break;
case A2L_TYPE_FLOAT: value = -1E12; break;
case A2L_TYPE_DOUBLE: value = -1E12; break;
default: value = 0.0;
}
static char str[20];
snprintf(str, 20, "%f", factor * value + offset);
return str;
}
static const char* getPhysMax(int32_t type, double factor, double offset) {
double value = 0.0;
switch (type) {
case A2L_TYPE_INT8: value = 127; break;
case A2L_TYPE_INT16: value = 32767; break;
case A2L_TYPE_INT32: value = 2147483647; break;
case A2L_TYPE_UINT8: value = 255; break;
case A2L_TYPE_UINT16: value = 65535; break;
case A2L_TYPE_UINT32: value = 4294967295; break;
default: value = 1E12;
}
static char str[20];
snprintf(str, 20, "%f", factor * value + offset);
return str;
}
BOOL A2lOpen(const char *filename, const char* projectName ) {
DBG_PRINTF1("\nCreate A2L %s\n", filename);
gA2lFile = NULL;
gA2lFixedEvent = XCP_INVALID_EVENT;
gA2lMeasurements = gA2lParameters = gA2lTypedefs = gA2lInstances = gA2lConversions = gA2lComponents = 0;
gA2lFile = fopen(filename, "w");
if (gA2lFile == 0) {
DBG_PRINTF_ERROR("ERROR: Could not create A2L file %s!\n", filename);
return FALSE;
}
// Create header
fprintf(gA2lFile, gA2lHeader, projectName, projectName);
// Create standard record layouts for elementary types
for (int i = -10; i <= +10; i++) {
const char* t = getType(i);
if (t != NULL) {
fprintf(gA2lFile, "/begin RECORD_LAYOUT R_%s FNC_VALUES 1 %s ROW_DIR DIRECT /end RECORD_LAYOUT\n", t, t);
fprintf(gA2lFile, "/begin TYPEDEF_MEASUREMENT M_%s \"\" %s NO_COMPU_METHOD 0 0 %s %s /end TYPEDEF_MEASUREMENT\n", t, t, getTypeMin(i), getTypeMax(i));
fprintf(gA2lFile, "/begin TYPEDEF_CHARACTERISTIC C_%s \"\" VALUE R_%s 0 NO_COMPU_METHOD %s %s /end TYPEDEF_CHARACTERISTIC\n", t, t, getTypeMin(i), getTypeMax(i));
}
}
fprintf(gA2lFile, "\n");
return TRUE;
}
// Memory segments
void A2lCreate_MOD_PAR(uint32_t startAddr, uint32_t size, char *epk) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin MOD_PAR \"\"\n");
fprintf(gA2lFile, "EPK \"%s\"\n", epk);
fprintf(gA2lFile, "ADDR_EPK 0x%08X\n", ApplXcpGetAddr((uint8_t*)epk));
fprintf(gA2lFile, gA2lMemorySegment, startAddr, size);
DBG_PRINTF1(" A2L MOD_PAR MEMORY_SEGMENT 1: 0x%08X %u\n", startAddr, size);
fprintf(gA2lFile, "/end MOD_PAR\n\n");
#if OPTION_ENABLE_DBG_PRINTS
if (epk) DBG_PRINTF1(" A2L MOD_PAR EPK \"%s\" 0x%08X\n", epk, ApplXcpGetAddr((uint8_t*)epk));
#endif
}
static void A2lCreate_IF_DATA_DAQ() {
assert(gA2lFile != NULL);
#if defined( XCP_ENABLE_DAQ_EVENT_LIST ) && !defined( XCP_ENABLE_DAQ_EVENT_INFO )
tXcpEvent* eventList;
#endif
uint16_t eventCount = 0;
#if (XCP_TIMESTAMP_UNIT==DAQ_TIMESTAMP_UNIT_1NS)
#define XCP_TIMESTAMP_UNIT_S "UNIT_1NS"
#elif (XCP_TIMESTAMP_UNIT==DAQ_TIMESTAMP_UNIT_1US)
#define XCP_TIMESTAMP_UNIT_S "UNIT_1US"
#else
#error
#endif
// Event list in A2L file (if event info by XCP is not active)
#if defined( XCP_ENABLE_DAQ_EVENT_LIST ) && !defined( XCP_ENABLE_DAQ_EVENT_INFO )
eventList = XcpGetEventList(&eventCount);
#endif
fprintf(gA2lFile, gA2lIfDataBeginDAQ, eventCount, XCP_TIMESTAMP_UNIT_S);
// Eventlist
#if defined( XCP_ENABLE_DAQ_EVENT_LIST ) && !defined( XCP_ENABLE_DAQ_EVENT_INFO )
for (uint32_t i = 0; i < eventCount; i++) {
fprintf(gA2lFile, "/begin EVENT \"%s\" \"%s\" 0x%X DAQ 0xFF %u %u %u CONSISTENCY EVENT", eventList[i].shortName, eventList[i].shortName, i, eventList[i].timeCycle, eventList[i].timeUnit, eventList[i].priority);
#ifdef XCP_ENABLE_PACKED_MODE
if (eventList[i].sampleCount != 0) {
fprintf(gA2lFile, " /begin DAQ_PACKED_MODE ELEMENT_GROUPED STS_LAST MANDATORY %u /end DAQ_PACKED_MODE", eventList[i].sampleCount);
}
#endif
fprintf(gA2lFile, " /end EVENT\n");
}
#endif
fprintf(gA2lFile, gA2lIfDataEndDAQ);
}
void A2lCreate_ETH_IF_DATA(BOOL useTCP, const uint8_t* addr, uint16_t port) {
fprintf(gA2lFile, gA2lIfDataBegin);
// Protocol Layer info
fprintf(gA2lFile, gA2lIfDataProtocolLayer, XCP_PROTOCOL_LAYER_VERSION, XCPTL_MAX_CTO_SIZE, XCPTL_MAX_DTO_SIZE);
// DAQ info
A2lCreate_IF_DATA_DAQ();
// Transport Layer info
uint8_t addr0[] = { 127,0,0,1 }; // Use localhost if no other option
if (addr != NULL && addr[0] != 0) {
memcpy(addr0, addr, 4);
} else {
socketGetLocalAddr(NULL, addr0);
}
char addrs[17];
SPRINTF(addrs, "%u.%u.%u.%u", addr0[0], addr0[1], addr0[2], addr0[3]);
char* prot = useTCP ? (char*)"TCP" : (char*)"UDP";
fprintf(gA2lFile, gA2lIfDataEth, prot, XCP_TRANSPORT_LAYER_VERSION, port, addrs, prot);
fprintf(gA2lFile, gA2lIfDataEnd);
DBG_PRINTF1(" IF_DATA XCP_ON_%s, ip=%s, port=%u\n", prot, addrs, port);
}
void A2lCreate_CAN_IF_DATA(BOOL useCANFD, uint16_t croId, uint16_t dtoId, uint32_t bitRate) {
(void)useCANFD;
fprintf(gA2lFile, gA2lIfDataBegin);
// Protocol Layer info
fprintf(gA2lFile, gA2lIfDataProtocolLayer, XCP_PROTOCOL_LAYER_VERSION, XCPTL_MAX_CTO_SIZE, XCPTL_MAX_DTO_SIZE);
// DAQ info
A2lCreate_IF_DATA_DAQ();
// Transport Layer info
uint32_t _croId = croId;
uint32_t _dtoId = dtoId;
if (useCANFD) {
_croId |= 0x40000000;
_dtoId |= 0x40000000;
}
fprintf(gA2lFile, gA2lIfDataCan, XCP_TRANSPORT_LAYER_VERSION, _croId, _dtoId, bitRate);
fprintf(gA2lFile, gA2lIfDataEnd);
DBG_PRINTF1(" IF_DATA XCP_ON_CAN, CRO=%u, DTO=%u, BITRATE=%u\n", croId, dtoId, bitRate);
}
void A2lCreateMeasurement_IF_DATA() {
assert(gA2lFile != NULL);
if (gA2lFixedEvent != XCP_INVALID_EVENT) {
fprintf(gA2lFile, " /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x%X /end DAQ_EVENT /end IF_DATA", gA2lFixedEvent);
}
else if (gA2lDefaultEvent != XCP_INVALID_EVENT) {
fprintf(gA2lFile, " /begin IF_DATA XCP /begin DAQ_EVENT VARIABLE DEFAULT_EVENT_LIST EVENT 0x%X /end DAQ_EVENT /end IF_DATA", gA2lDefaultEvent);
}
}
void A2lSetDefaultEvent(uint16_t event) {
#if defined( XCP_ENABLE_DAQ_EVENT_LIST ) && !defined( XCP_ENABLE_DAQ_EVENT_INFO )
uint16_t eventCount = 0;
XcpGetEventList(&eventCount);
assert(event >= 0 && event < eventCount);
#endif
A2lRstFixedEvent();
gA2lDefaultEvent = event;
}
void A2lSetFixedEvent(uint16_t event) {
#if defined( XCP_ENABLE_DAQ_EVENT_LIST ) && !defined( XCP_ENABLE_DAQ_EVENT_INFO )
uint16_t eventCount = 0;
XcpGetEventList(&eventCount);
assert(event >= 0 && event < eventCount);
#endif
gA2lFixedEvent = event;
}
uint16_t A2lGetFixedEvent() {
return gA2lFixedEvent;
}
void A2lRstDefaultEvent() {
gA2lDefaultEvent = XCP_INVALID_EVENT;
}
void A2lRstFixedEvent() {
gA2lFixedEvent = XCP_INVALID_EVENT;
}
void A2lTypedefBegin_(const char* name, uint32_t size, const char* comment) {
assert(gA2lFile != NULL);
fprintf(gA2lFile,"/begin TYPEDEF_STRUCTURE %s \"%s\" 0x%X SYMBOL_TYPE_LINK \"%s\"\n", name, comment, size, name);
gA2lTypedefs++;
}
void A2lTypedefMeasurementComponent_(const char* name, int32_t type, uint32_t offset) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, " /begin STRUCTURE_COMPONENT %s M_%s 0x%X SYMBOL_TYPE_LINK \"%s\" /end STRUCTURE_COMPONENT\n", name, getType(type), offset, name);
gA2lComponents++;
}
void A2lTypedefParameterComponent_(const char* name, int32_t type, uint32_t offset) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, " /begin STRUCTURE_COMPONENT %s C_%s 0x%X SYMBOL_TYPE_LINK \"%s\" /end STRUCTURE_COMPONENT\n", name, getType(type), offset, name);
gA2lComponents++;
}
void A2lTypedefEnd_() {
assert(gA2lFile != NULL);
fprintf(gA2lFile,"/end TYPEDEF_STRUCTURE\n");
}
void A2lCreateTypedefInstance_(const char* instanceName, const char* typeName, uint8_t ext, uint32_t addr, const char* comment) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin INSTANCE %s \"%s\" %s 0x%X", instanceName, comment, typeName, addr);
printAddrExt(ext);
A2lCreateMeasurement_IF_DATA();
fprintf(gA2lFile, " /end INSTANCE\n");
gA2lInstances++;
}
void A2lCreateMeasurement_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, double factor, double offset, const char* unit, const char* comment) {
assert(gA2lFile != NULL);
#ifdef A2L_ENABLE_MEMORY_CHECK
mem_check(name, type, ext, addr);
#endif
if (unit == NULL) unit = "";
if (comment == NULL) comment = "";
const char *conv = "NO";
if (factor != 0.0 || offset != 0.0) {
fprintf(gA2lFile, "/begin COMPU_METHOD %s.Conversion \"\" LINEAR \"%%6.3\" \"%s\" COEFFS_LINEAR %g %g /end COMPU_METHOD\n", name, unit!=NULL?unit:"", factor,offset);
conv = name;
gA2lConversions++;
}
//fprintf(gA2lFile, "/begin MEASUREMENT %s \"%s\" %s %s.Conversion 0 0 %s %s ECU_ADDRESS 0x%X", A2lGetSymbolName(instanceName, name), comment, getType(type), conv, getTypeMin(type), getTypeMax(type), addr);
fprintf(gA2lFile, "/begin MEASUREMENT %s \"%s\" %s %s.Conversion 0 0 %s %s ECU_ADDRESS 0x%X", A2lGetSymbolName(instanceName, name), comment, getType(type), conv, getPhysMin(type, factor, offset), getPhysMax(type, factor, offset), addr);
printAddrExt(ext);
printPhysUnit(unit);
fprintf(gA2lFile, " READ_WRITE");
#if OPTION_ENABLE_A2L_SYMBOL_LINKS
fprintf(gA2lFile, " SYMBOL_LINK \"%s\" %u", A2lGetSymbolName(instanceName, name), 0);
#else
(void)symbolLink;
#endif
A2lCreateMeasurement_IF_DATA();
fprintf(gA2lFile, " /end MEASUREMENT\n");
gA2lMeasurements++;
}
void A2lCreateMeasurementArray_(const char* instanceName, const char* name, int32_t type, int dim, uint8_t ext, uint32_t addr) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin CHARACTERISTIC %s \"\" VAL_BLK 0x%X R_%s 0 NO_COMPU_METHOD %s %s MATRIX_DIM %u", A2lGetSymbolName(instanceName, name), addr, getType(type), getTypeMin(type), getTypeMax(type), dim);
printAddrExt(ext);
#if OPTION_ENABLE_A2L_SYMBOL_LINKS
fprintf(gA2lFile, " SYMBOL_LINK \"%s\" %u", A2lGetSymbolName(instanceName, name), 0);
#endif
A2lCreateMeasurement_IF_DATA();
fprintf(gA2lFile, " /end CHARACTERISTIC\n");
gA2lMeasurements++;
}
void A2lCreateParameterWithLimits_(const char* name, int32_t type, uint8_t ext, uint32_t addr, const char* comment, const char* unit, double min, double max) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin CHARACTERISTIC %s \"%s\" VALUE 0x%X R_%s 0 NO_COMPU_METHOD %g %g", name, comment, addr, getType(type), min, max);
printPhysUnit(unit);
printAddrExt(ext);
#if OPTION_ENABLE_A2L_SYMBOL_LINKS
fprintf(gA2lFile, " SYMBOL_LINK \"%s\" %u", name, 0);
#endif
fprintf(gA2lFile, " /end CHARACTERISTIC\n");
gA2lParameters++;
}
void A2lCreateParameter_(const char* name, int32_t type, uint8_t ext, uint32_t addr, const char* comment, const char* unit) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin CHARACTERISTIC %s \"%s\" VALUE 0x%X R_%s 0 NO_COMPU_METHOD %s %s", name, comment, addr, getType(type), getTypeMin(type), getTypeMax(type));
printPhysUnit(unit);
printAddrExt(ext);
#if OPTION_ENABLE_A2L_SYMBOL_LINKS
fprintf(gA2lFile, " SYMBOL_LINK \"%s\" %u", name, 0);
#endif
fprintf(gA2lFile, " /end CHARACTERISTIC\n");
gA2lParameters++;
}
void A2lCreateMap_(const char* name, int32_t type, uint8_t ext, uint32_t addr, uint32_t xdim, uint32_t ydim, const char* comment, const char* unit) {
assert(gA2lFile != NULL);
fprintf(gA2lFile,
"/begin CHARACTERISTIC %s \"%s\" MAP 0x%X R_%s 0 NO_COMPU_METHOD %s %s"
" /begin AXIS_DESCR FIX_AXIS NO_INPUT_QUANTITY NO_COMPU_METHOD %u 0 %u FIX_AXIS_PAR_DIST 0 1 %u /end AXIS_DESCR"
" /begin AXIS_DESCR FIX_AXIS NO_INPUT_QUANTITY NO_COMPU_METHOD %u 0 %u FIX_AXIS_PAR_DIST 0 1 %u /end AXIS_DESCR",
name, comment, addr, getType(type), getTypeMin(type), getTypeMax(type), xdim, xdim-1, xdim, ydim, ydim-1, ydim);
printPhysUnit(unit);
printAddrExt(ext);
#if OPTION_ENABLE_A2L_SYMBOL_LINKS
fprintf(gA2lFile, " SYMBOL_LINK \"%s\" %u", name, 0);
#endif
fprintf(gA2lFile, " /end CHARACTERISTIC\n");
gA2lParameters++;
}
void A2lCreateCurve_(const char* name, int32_t type, uint8_t ext, uint32_t addr, uint32_t xdim, const char* comment, const char* unit) {
assert(gA2lFile != NULL);
fprintf(gA2lFile,
"/begin CHARACTERISTIC %s \"%s\" CURVE 0x%X R_%s 0 NO_COMPU_METHOD %s %s"
" /begin AXIS_DESCR FIX_AXIS NO_INPUT_QUANTITY NO_COMPU_METHOD %u 0 %u FIX_AXIS_PAR_DIST 0 1 %u /end AXIS_DESCR",
name, comment, addr, getType(type), getTypeMin(type), getTypeMax(type), xdim, xdim-1, xdim);
printPhysUnit(unit);
printAddrExt(ext);
#if OPTION_ENABLE_A2L_SYMBOL_LINKS
fprintf(gA2lFile, " SYMBOL_LINK \"%s\" %u", name, 0);
#endif
fprintf(gA2lFile, " /end CHARACTERISTIC\n");
gA2lParameters++;
}
void A2lParameterGroup(const char* name, int count, ...) {
va_list ap;
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin GROUP %s \"\"", name);
fprintf(gA2lFile, " /begin REF_CHARACTERISTIC\n");
va_start(ap, count);
for (int i = 0; i < count; i++) {
fprintf(gA2lFile, " %s", va_arg(ap, char*));
}
va_end(ap);
fprintf(gA2lFile, "\n/end REF_CHARACTERISTIC ");
fprintf(gA2lFile, "/end GROUP\n\n");
}
void A2lParameterGroupFromList(const char* name, const char* pNames[], size_t count) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin GROUP %s \"\"", name);
fprintf(gA2lFile, " /begin REF_CHARACTERISTIC\n");
for (size_t i = 0; i < count; i++) {
fprintf(gA2lFile, " %s", pNames[i]);
}
fprintf(gA2lFile, "\n/end REF_CHARACTERISTIC ");
fprintf(gA2lFile, "/end GROUP\n\n");
}
void A2lMeasurementGroup(const char* name, int count, ...) {
va_list ap;
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin GROUP %s \"\"", name);
fprintf(gA2lFile, " /begin REF_MEASUREMENT");
va_start(ap, count);
for (int i = 0; i < count; i++) {
fprintf(gA2lFile, " %s", va_arg(ap, char*));
}
va_end(ap);
fprintf(gA2lFile, " /end REF_MEASUREMENT");
fprintf(gA2lFile, " /end GROUP\n\n");
}
void A2lMeasurementGroupFromList(const char *name, char* names[], uint32_t count) {
assert(gA2lFile != NULL);
fprintf(gA2lFile, "/begin GROUP %s \"\" \n", name);
fprintf(gA2lFile, " /begin REF_MEASUREMENT");
for (uint32_t i1 = 0; i1 < count; i1++) {
fprintf(gA2lFile, " %s", names[i1]);
}
fprintf(gA2lFile, " /end REF_MEASUREMENT");
fprintf(gA2lFile, "\n/end GROUP\n");
}
void A2lClose() {
if (gA2lFile != NULL) {
fprintf(gA2lFile, "%s", gA2lFooter);
fclose(gA2lFile);
gA2lFile = NULL;
DBG_PRINTF1("A2L created: %u measurements, %u params, %u typedefs, %u components, %u instances, %u conversions\n\n",
gA2lMeasurements, gA2lParameters, gA2lTypedefs, gA2lComponents, gA2lInstances, gA2lConversions);
}
}

121
A2lTestDlg/A2lTestDlg/A2L.h

@ -0,0 +1,121 @@
#pragma once
/* A2L.h */
/* Copyright(c) Vector Informatik GmbH.All rights reserved.
Licensed under the MIT license.See LICENSE file in the project root for details. */
#define OPTION_ENABLE_A2L_SYMBOL_LINKS ON // Enable generation of symbol links (required for CANape integrated linker map update)
#define A2L_TYPE_UINT8 1
#define A2L_TYPE_UINT16 2
#define A2L_TYPE_UINT32 4
#define A2L_TYPE_UINT64 8
#define A2L_TYPE_INT8 -1
#define A2L_TYPE_INT16 -2
#define A2L_TYPE_INT32 -4
#define A2L_TYPE_INT64 -8
#define A2L_TYPE_FLOAT -9
#define A2L_TYPE_DOUBLE -10
#define A2L_TYPE_BOOL sizeof(BOOL)
#ifndef A2lGetAddr
#define A2lGetAddr(p) ApplXcpGetAddr(p)
#endif
#ifdef __cplusplus
#include <typeinfo>
#ifndef A2lGetType
#define A2lGetSign_(var) ((int)(typeid(var).name()[0]=='u'?+1:-1))
#define A2lGetType(var) (A2lGetSign_(var)*(typeid(var).name()[0]=='f'?9:typeid(var).name()[0]=='d'?10:sizeof(var)))
#endif
#ifndef A2lGetOffset
#define A2lGetOffset(var) (uint32_t)((uint8_t*)&(var) - (uint8_t*)this)
#endif
// Create parameters
#define A2lCreateParameter(name,comment,unit) A2lCreateParameter_(#name, A2lGetType(name), 0, A2lGetAddr((uint8_t*)&name), comment, unit)
#define A2lCreateParameterWithLimits(name,comment,unit,min,max) A2lCreateParameterWithLimits_(#name, A2lGetType(name), 0, A2lGetAddr((uint8_t*)&name), comment, unit, min, max)
#define A2lCreateCurve(name,xdim,comment,unit) A2lCreateCurve_(#name, A2lGetType(name[0]), 0, A2lGetAddr((uint8_t*)&name[0]), xdim, comment, unit)
#define A2lCreateMap(name,xdim,ydim,comment,unit) A2lCreateMap_(#name, A2lGetType(name[0][0]), 0, A2lGetAddr((uint8_t*)&name[0][0]), xdim, ydim, comment, unit)
// Create measurements
#define A2lCreateMeasurement(name,comment) A2lCreateMeasurement_(NULL, #name, A2lGetType(name), 0, A2lGetAddr((uint8_t*)&(name)), 1.0, 0.0, NULL, comment)
#define A2lCreatePhysMeasurement(name,comment,factor,offset,unit) A2lCreateMeasurement_(NULL, #name, A2lGetType(name), 0, A2lGetAddr((uint8_t*)&name), factor, offset, unit, comment) // unsigned integer (8/16/32) with linear physical conversion rule
#define A2lCreateMeasurementArray(name) A2lCreateMeasurementArray_(NULL,#name, A2lGetType(name[0]), sizeof(name)/sizeof(name[0]), 0, A2lGetAddr((uint8_t*)&name[0])) // unsigned integer (8/16/32) or double array
// Create typedefs
#define A2lTypedefComponent(name) A2lTypedefMeasurementComponent_(#name, A2lGetType(name), A2lGetOffset(name))
#else
// Create parameters
#define A2lCreateParameter(name,type,comment,unit) A2lCreateParameter_(#name, type, 0, A2lGetAddr((uint8_t*)&name), comment, unit)
#define A2lCreateParameterWithLimits(name,type,comment,unit,min,max) A2lCreateParameterWithLimits_(#name, type, 0, A2lGetAddr((uint8_t*)&name), comment, unit, min, max)
#define A2lCreateCurve(name,type,xdim,comment,unit) A2lCreateCurve_(#name, type, 0, A2lGetAddr((uint8_t*)&name[0]), xdim, comment, unit)
#define A2lCreateMap(name,type,xdim,ydim,comment,unit) A2lCreateMap_(#name, type, 0, A2lGetAddr((uint8_t*)&name[0][0]), xdim, ydim, comment, unit)
// Create measurements
#define A2lCreateMeasurement(name,type,comment) A2lCreateMeasurement_(NULL,#name,type, 0, A2lGetAddr((uint8_t*)&(name)), 1.0, 0.0, NULL, comment)
#define A2lCreatePhysMeasurement(name,type,comment,factor,offset,unit) A2lCreateMeasurement_(NULL, #name,type, 0, A2lGetAddr((uint8_t*)&name), factor, offset, unit, comment) // unsigned integer (8/16/32) with linear physical conversion rule
#define A2lCreateMeasurementArray(name,type) A2lCreateMeasurementArray_(NULL, #name, type, sizeof(name)/sizeof(name[0]), 0, A2lGetAddr((uint8_t*)&name[0])) // unsigned integer (8/16/32) or double array
// Create typedefs
#define A2lTypedefComponent(name,type,offset) A2lTypedefMeasurementComponent_(#name, type, offset)
#endif
#define A2lTypedefBegin(name,comment) A2lTypedefBegin_(#name,(uint32_t)sizeof(name),comment)
#define A2lTypedefEnd() A2lTypedefEnd_()
#define A2lCreateTypedefInstance(instanceName, typeName, addr, comment) A2lCreateTypedefInstance_(instanceName, typeName, 0, A2lGetAddr((uint8_t*)&instanceName), comment)
#define A2lCreateDynTypedefInstance(instanceName, typeName, comment) A2lCreateTypedefInstance_(instanceName, typeName, 1, 0, comment)
// Init A2L generation
extern BOOL A2lOpen(const char *filename, const char* projectName);
// Create memory segments
extern void A2lCreate_MOD_PAR( uint32_t startAddr, uint32_t size, char* epk);
// Create XCP IF_DATA
extern void A2lCreate_ETH_IF_DATA(BOOL useTCP, const uint8_t* addr, uint16_t port);
extern void A2lCreate_CAN_IF_DATA(BOOL useCANFD, uint16_t croId, uint16_t dtoId, uint32_t bitRate);
// Set fixec or default event for all following creates
extern void A2lSetFixedEvent(uint16_t event);
extern void A2lRstFixedEvent();
extern void A2lSetDefaultEvent(uint16_t event);
extern void A2lRstDefaultEvent();
// Create measurements
extern void A2lCreateMeasurement_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, double factor, double offset, const char* unit, const char* comment);
extern void A2lCreateMeasurementArray_(const char* instanceName, const char* name, int32_t type, int dim, uint8_t ext, uint32_t addr);
// Create typedefs
void A2lTypedefBegin_(const char* name, uint32_t size, const char* comment);
void A2lTypedefMeasurementComponent_(const char* name, int32_t type, uint32_t offset);
void A2lTypedefParameterComponent_(const char* name, int32_t type, uint32_t offset);
void A2lTypedefEnd_();
void A2lCreateTypedefInstance_(const char* instanceName, const char* typeName, uint8_t ext, uint32_t addr, const char* comment);
// Create parameters
void A2lCreateParameter_(const char* name, int32_t type, uint8_t ext, uint32_t addr, const char* comment, const char* unit);
void A2lCreateParameterWithLimits_(const char* name, int32_t type, uint8_t ext, uint32_t addr, const char* comment, const char* unit, double min, double max);
void A2lCreateMap_(const char* name, int32_t type, uint8_t ext, uint32_t addr, uint32_t xdim, uint32_t ydim, const char* comment, const char* unit);
void A2lCreateCurve_(const char* name, int32_t type, uint8_t ext, uint32_t addr, uint32_t xdim, const char* comment, const char* unit);
// Create groups
void A2lParameterGroup(const char* name, int count, ...);
void A2lParameterGroupFromList(const char* name, const char* pNames[], size_t count);
void A2lMeasurementGroup(const char* name, int count, ...);
void A2lMeasurementGroupFromList(const char *name, char* names[], uint32_t count);
// Finish A2L generation
extern void A2lClose();
// For A2L.CPP
extern const char* A2lGetSymbolName(const char* instanceName, const char* name);
extern uint16_t A2lGetFixedEvent();

124
A2lTestDlg/A2lTestDlg/A2Lpp.cpp

@ -0,0 +1,124 @@
/*----------------------------------------------------------------------------
| File:
| A2L.cpp
|
| Description:
| Create A2L file
|
| Copyright (c) Vector Informatik GmbH. All rights reserved.
| Licensed under the MIT license. See LICENSE file in the project root for details.
|
----------------------------------------------------------------------------*/
#include "main.h"
#include "platform.h"
#include "xcp.hpp"
#include "A2L.h"
#include "A2Lpp.hpp"
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
A2L::A2L(const char * name) {
filename = name;
}
A2L::~A2L() {
close();
}
void A2L::close() {
A2lClose();
}
BOOL A2L::open(const char *projectName) {
return A2lOpen(filename, projectName);
}
// Create memory segments
void A2L::create_MOD_PAR(uint32_t startAddr, uint32_t size) {
A2lCreate_MOD_PAR(startAddr, size, NULL);
}
// Create XCP IF_DATA
void A2L::create_XCP_IF_DATA(BOOL tcp, const uint8_t* addr, uint16_t port) {
A2lCreate_ETH_IF_DATA(tcp, addr, port);
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void A2L::setDefaultEvent(uint16_t e) {
A2lSetDefaultEvent(e);
}
void A2L::setFixedEvent(uint16_t e) {
A2lSetFixedEvent(e);
}
void A2L::rstFixedEvent() {
A2lRstFixedEvent();
}
uint16_t A2L::getFixedEvent() {
return A2lGetFixedEvent();
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void A2L::createTypedefBegin_(const char* name, int32_t size, const char* comment) {
A2lTypedefBegin_(name,size,comment);
}
void A2L::createTypedefMeasurementComponent_(const char* name, int32_t type, uint32_t offset) {
A2lTypedefMeasurementComponent_(name,type,offset);
}
void A2L::createTypedefParameterComponent_(const char* name, int32_t type, uint32_t offset) {
A2lTypedefParameterComponent_(name, type, offset);
}
void A2L::createTypedefEnd_() {
A2lTypedefEnd_();
}
void A2L::createTypedefInstance_(const char* instanceName, const char* typeName, uint8_t ext, uint32_t addr, const char* comment) {
A2lCreateTypedefInstance_(instanceName, typeName, ext, addr, comment);
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void A2L::createMeasurement_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, double factor, double offset, const char* unit, const char* comment) {
A2lCreateMeasurement_(instanceName, name, type, ext, addr, factor, offset, unit, comment);
}
void A2L::createMeasurementArray_(const char* instanceName, const char* name, int32_t type, int dim, uint8_t ext, uint32_t addr) {
A2lCreateMeasurementArray_(instanceName, name, type, dim, ext, addr);
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void A2L::createParameterWithLimits_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, const char* comment, const char* unit, double min, double max) {
A2lCreateParameterWithLimits_(A2lGetSymbolName(instanceName, name), type, ext, addr, comment, unit, min, max);
}
void A2L::createParameter_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, const char* comment, const char* unit) {
A2lCreateParameter_(A2lGetSymbolName(instanceName, name), type, ext, addr, comment, unit);
}
void A2L::createMap_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, uint32_t xdim, uint32_t ydim, const char* comment, const char* unit) {
A2lCreateMap_(A2lGetSymbolName(instanceName, name), type, ext, addr, xdim, ydim, comment, unit);
}
void A2L::createCurve_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, uint32_t xdim, const char* comment, const char* unit) {
A2lCreateCurve_(A2lGetSymbolName(instanceName, name), type, ext, addr, xdim, comment, unit);
}

122
A2lTestDlg/A2lTestDlg/A2Lpp.hpp

@ -0,0 +1,122 @@
#pragma once
/* A2L.h - A2L Generator */
/* Copyright(c) Vector Informatik GmbH.All rights reserved.
Licensed under the MIT license.See LICENSE file in the project root for details. */
#ifndef __cplusplus
#error
#endif
#include "A2L.h"
#define A2lGetSign_(var) ((int)(typeid(var).name()[0]=='u'?+1:-1))
#define A2lGetType_(var) (A2lGetSign_(var)*(typeid(var).name()[0]=='f'?9:typeid(var).name()[0]=='d'?10:sizeof(var)))
#define A2lGetAddr_(var) Xcp::getInstance()->getA2lAddr((uint8_t*)&var)
#define A2lGetOffset_(struct_name,full_name) (uint16_t)((uint8_t*)&(full_name) - (uint8_t*)&struct_name)
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Create typedefs
#define createTypedefBegin(name,comment) createTypedefBegin_(#name,(int)sizeof(name),comment)
#define createTypedefParameterComponent(struct_name,var_name) createTypedefParameterComponent_(#var_name,A2lGetType_(struct_name.var_name),A2lGetOffset_(struct_name,struct_name.var_name))
#define createTypedefMeasurementComponent(struct_name,var_name) createTypedefMeasurementComponent_(#var_name,A2lGetType_(struct_name.var_name),A2lGetOffset_(struct_name,struct_name.var_name))
#define createTypedefEnd() createTypedefEnd_()
// Create measurement or parameter from typedef
#define createTypedefInstance(instanceName,typeName,comment) createTypedefInstance_(#instanceName, #typeName, 0, A2lGetAddr_(instanceName), comment)
// Create measurements
#define createMeasurement(name,comment) createMeasurement_(NULL,#name,A2lGetType_(name),0,A2lGetAddr_(name),1.0,0.0,NULL,comment)
#define createPhysMeasurement(name,comment,factor,offset,unit) createMeasurement_(NULL,#name,A2lGetType_(name),0,A2lGetAddr_(name),factor,offset,unit,comment) // unsigned integer (8/16/32) with linear physical conversion rule
#define createMeasurementArray(name) createMeasurementArray_(NULL,#name,A2lGetType_(name[0]),sizeof(name)/sizeof(name[0]),0,A2lGetAddr_(name[0])) // unsigned integer (8/16/32) or double array
// Create parameters
#define createParameter(name,comment,unit) createParameter_(NULL,#name,A2lGetType_(name),0,A2lGetAddr_(name),comment,unit)
#define createParameterWithLimits(name,comment,unit,min,max) createParameterWithLimits_(NULL,#name, A2lGetType_(name), 0, A2lGetAddr_(name), comment, unit, min, max)
#define createCurve(name,xdim,comment,unit) createCurve_(NULL,#name, A2lGetType_(name[0]), 0, A2lGetAddr_(name[0]), xdim, comment, unit)
#define createMap(name,xdim,ydim,comment,unit) createMap_(NULL,#name, A2lGetType_(name[0][0]), 0, A2lGetAddr_(name[0][0]), xdim, ydim, comment, unit)
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// The functions below are assumed to be called from methods of classes derived from XcpObject !
#define A2lGetDynAddr_(var) xcpGetA2lDynAddr(A2lGetDynOffset_(var))
#define A2lGetDynBaseAddr_() xcpGetA2lDynAddr(0)
#define A2lGetDynOffset_(var) (uint16_t)((uint8_t*)&(var) - (uint8_t*)this) // object data size limited to 64K !
// Create measurement or parameter from typedef
#define createDynTypedefInstance(instanceName,typeName,comment) createTypedefInstance_(instanceName, typeName, 1, A2lGetDynBaseAddr_(), comment)
#define createDynTypedefParameterComponent(name) createTypedefParameterComponent_(#name,A2lGetType_(name),A2lGetDynOffset_(name))
#define createDynTypedefMeasurementComponent(name) createTypedefMeasurementComponent_(#name,A2lGetType_(name),A2lGetDynOffset_(name))
// Create measurements
#define createDynMeasurement(instanceName,name,comment) createMeasurement_(instanceName,#name,A2lGetType_(name),1,A2lGetDynAddr_(name),1.0,0.0,NULL,comment)
#define createDynPhysMeasurement(instanceName,name,var,comment,factor,offset,unit) createMeasurement_(instanceName,name,A2lGetType_(var),1,A2lGetDynAddr_(name),factor,offset,unit,comment) // named unsigned integer (8/16/32) with linear physical conversion rule
#define createDynMeasurementArray(name) createMeasurementArray_(NULL,#name,A2lGetType_(name[0]),sizeof(name)/sizeof(name[0]),0,A2lGetDynAddr_(name[0])) // unsigned integer (8/16/32) or double array
// Create parameters
#define createDynParameter(instanceName,name,comment,unit) createParameter_(instanceName,#name,A2lGetType_(name),1,A2lGetDynAddr_(name),comment,unit)
#define createDynParameterWithLimits(instanceName,name,comment,unit,min,max) createParameterWithLimits_(instanceName,#name, A2lGetType_(name), 1, A2lGetDynAddr_(name), comment, unit, min, max)
#define createDynCurve(instanceName,name,xdim,comment,unit) createCurve_(instanceName,#name, A2lGetType_(name[0]), 0, A2lGetDynAddr_(name[0]), xdim, comment, unit)
#define createDynMap(instanceName,name,xdim,ydim,comment,unit) createMap_(instanceName,#name, A2lGetType_(name[0][0]), 1, A2lGetDynAddr_(name[0][0]), xdim, ydim, comment, unit)
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
class A2L {
private:
const char* filename;
public:
A2L(const char* filename);
~A2L();
// Start A2L generation
BOOL open(const char* projectName);
// Create memory segments
void create_MOD_PAR(uint32_t startAddr, uint32_t size);
// Create IF_DATA for XCP
// All XCP events must have been be created before
void create_XCP_IF_DATA(BOOL tcp, const uint8_t* addr, uint16_t port);
// Set XCP events for all following creates
void setFixedEvent(uint16_t xcp_event);
void setDefaultEvent(uint16_t xcp_event);
void rstFixedEvent();
uint16_t getFixedEvent();
// Create measurements
void createMeasurement_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, double factor, double offset, const char* unit, const char* comment);
void createMeasurementArray_(const char* instanceName, const char* name, int32_t type, int32_t dim, uint8_t ext, uint32_t addr);
// Create typedefs
void createTypedefBegin_(const char* name, int32_t size, const char* comment);
void createTypedefParameterComponent_(const char* name, int32_t type, uint32_t offset);
void createTypedefMeasurementComponent_(const char* name, int32_t type, uint32_t offset);
void createTypedefEnd_();
void createTypedefInstance_(const char* instanceName, const char* typeName, uint8_t ext, uint32_t addr, const char* comment);
// Create parameters
void createParameter_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, const char* comment, const char* unit);
void createParameterWithLimits_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, const char* comment, const char* unit, double min, double max);
void createMap_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, uint32_t xdim, uint32_t ydim, const char* comment, const char* unit);
void createCurve_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, uint32_t xdim, const char* comment, const char* unit);
// Finalize and close A2L file
void close();
};

153
A2lTestDlg/A2lTestDlg/A2lTestDlg.cpp

@ -0,0 +1,153 @@
// A2lTestDlg.cpp : Defines the class behaviors for the application.
//
#include "pch.h"
#include "framework.h"
#include "A2lTestDlg.h"
#include "A2lTestDlgDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CA2lTestDlgApp
BEGIN_MESSAGE_MAP(CA2lTestDlgApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CA2lTestDlgApp construction
CA2lTestDlgApp::CA2lTestDlgApp()
{
// support Restart Manager
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CA2lTestDlgApp object
CA2lTestDlgApp theApp;
const GUID CDECL BASED_CODE _tlid =
{0xaacf2bb9,0x0c94,0x4623,{0x8c,0x20,0xbb,0xe3,0x07,0x07,0x21,0xea}};
const WORD _wVerMajor = 1;
const WORD _wVerMinor = 0;
// CA2lTestDlgApp initialization
BOOL CA2lTestDlgApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;
// Activate "Windows Native" visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
// Parse command line for automation or reg/unreg switches.
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// App was launched with /Embedding or /Automation switch.
// Run app as automation server.
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
// Register class factories via CoRegisterClassObject().
COleTemplateServer::RegisterAll();
}
// App was launched with /Unregserver or /Unregister switch. Remove
// entries from the registry.
else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
{
COleObjectFactory::UpdateRegistryAll(FALSE);
AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
return FALSE;
}
// App was launched standalone or with other switches (e.g. /Register
// or /Regserver). Update registry entries, including typelibrary.
else
{
COleObjectFactory::UpdateRegistryAll();
AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister)
return FALSE;
}
CA2lTestDlgDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
else if (nResponse == -1)
{
TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n");
TRACE(traceAppMsg, 0, "Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n");
}
// Delete the shell manager created above.
if (pShellManager != nullptr)
{
delete pShellManager;
}
#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
ControlBarCleanUp();
#endif
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
int CA2lTestDlgApp::ExitInstance()
{
AfxOleTerm(FALSE);
return CWinApp::ExitInstance();
}

33
A2lTestDlg/A2lTestDlg/A2lTestDlg.h

@ -0,0 +1,33 @@
// A2lTestDlg.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'pch.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CA2lTestDlgApp:
// See A2lTestDlg.cpp for the implementation of this class
//
class CA2lTestDlgApp : public CWinApp
{
public:
CA2lTestDlgApp();
// Overrides
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CA2lTestDlgApp theApp;

29
A2lTestDlg/A2lTestDlg/A2lTestDlg.idl

@ -0,0 +1,29 @@
// A2lTestDlg.idl : type library source for A2lTestDlg.exe
// This file will be processed by the MIDL compiler to produce the
// type library (A2lTestDlg.tlb).
[ uuid(aacf2bb9-0c94-4623-8c20-bbe3070721ea), version(1.0) ]
library A2lTestDlg
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
// Primary dispatch interface for CA2lTestDlgDoc
[ uuid(9fc78fa1-82e8-4469-9a9f-60c6d387b64a) ]
dispinterface IA2lTestDlg
{
properties:
methods:
};
// Class information for CA2lTestDlgDoc
[ uuid(04615303-44d9-45b7-b802-02b06c0dde4f) ]
coclass A2lTestDlg
{
[default] dispinterface IA2lTestDlg;
};
};

BIN
A2lTestDlg/A2lTestDlg/A2lTestDlg.rc

Binary file not shown.

17
A2lTestDlg/A2lTestDlg/A2lTestDlg.reg

@ -0,0 +1,17 @@
REGEDIT
; This .REG file may be used by your SETUP program.
; If a SETUP program is not available, the entries below will be
; registered in your InitInstance automatically with a call to
; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll.
HKEY_CLASSES_ROOT\A2lTestDlg.Application = A2lTestDlg Application
HKEY_CLASSES_ROOT\A2lTestDlg.Application\CLSID = {04615303-44d9-45b7-b802-02b06c0dde4f}
HKEY_CLASSES_ROOT\CLSID\{04615303-44d9-45b7-b802-02b06c0dde4f} = A2lTestDlg Application
HKEY_CLASSES_ROOT\CLSID\{04615303-44d9-45b7-b802-02b06c0dde4f}\ProgId = A2lTestDlg.Application
HKEY_CLASSES_ROOT\CLSID\{04615303-44d9-45b7-b802-02b06c0dde4f}\LocalServer32 = A2lTestDlg.EXE

252
A2lTestDlg/A2lTestDlg/A2lTestDlg.vcxproj

@ -0,0 +1,252 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{86752C60-05E4-465C-9D79-876C97ABD2BA}</ProjectGuid>
<Keyword>MFCProj</Keyword>
<RootNamespace>A2lTestDlg</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<RegisterOutput>true</RegisterOutput>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>$(IntDir)A2lTestDlg.tlb</TypeLibraryName>
<HeaderFileName>A2lTestDlg_h.h</HeaderFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<RegisterOutput>true</RegisterOutput>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>$(IntDir)A2lTestDlg.tlb</TypeLibraryName>
<HeaderFileName>A2lTestDlg_h.h</HeaderFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<RegisterOutput>true</RegisterOutput>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>$(IntDir)A2lTestDlg.tlb</TypeLibraryName>
<HeaderFileName>A2lTestDlg_h.h</HeaderFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<RegisterOutput>true</RegisterOutput>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>$(IntDir)A2lTestDlg.tlb</TypeLibraryName>
<HeaderFileName>A2lTestDlg_h.h</HeaderFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="A2L.h" />
<ClInclude Include="A2Lpp.hpp" />
<ClInclude Include="A2lTestDlg.h" />
<ClInclude Include="A2lTestDlgDlg.h" />
<ClInclude Include="dbg_print.h" />
<ClInclude Include="DlgProxy.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="main.h" />
<ClInclude Include="main_cfg.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="platform.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="xcp.h" />
<ClInclude Include="xcpEthTl.h" />
<ClInclude Include="xcpLite.h" />
<ClInclude Include="xcpTl.h" />
<ClInclude Include="xcptl_cfg.h" />
<ClInclude Include="xcp_cfg.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="A2L.c" />
<ClCompile Include="A2Lpp.cpp" />
<ClCompile Include="A2lTestDlg.cpp" />
<ClCompile Include="A2lTestDlgDlg.cpp" />
<ClCompile Include="DlgProxy.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="A2lTestDlg.idl" />
</ItemGroup>
<ItemGroup>
<None Include="A2lTestDlg.reg" />
<None Include="main_cfg.h.in" />
<None Include="res\A2lTestDlg.rc2" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="A2lTestDlg.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="res\A2lTestDlg.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

118
A2lTestDlg/A2lTestDlg/A2lTestDlg.vcxproj.filters

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="A2lTestDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="A2lTestDlgDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DlgProxy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="A2Lpp.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="A2L.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="platform.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dbg_print.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="xcpLite.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="main_cfg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="xcp_cfg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="xcptl_cfg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="xcp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="xcpEthTl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="xcpTl.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="A2lTestDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="A2lTestDlgDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DlgProxy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="A2Lpp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="A2L.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="A2lTestDlg.idl">
<Filter>Source Files</Filter>
</Midl>
</ItemGroup>
<ItemGroup>
<None Include="A2lTestDlg.reg" />
<None Include="res\A2lTestDlg.rc2">
<Filter>Resource Files</Filter>
</None>
<None Include="main_cfg.h.in" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="A2lTestDlg.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="res\A2lTestDlg.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

6
A2lTestDlg/A2lTestDlg/A2lTestDlg.vcxproj.user

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RESOURCE_FILE>A2lTestDlg.rc</RESOURCE_FILE>
</PropertyGroup>
</Project>

252
A2lTestDlg/A2lTestDlg/A2lTestDlgDlg.cpp

@ -0,0 +1,252 @@
// A2lTestDlgDlg.cpp : implementation file
//
#include "pch.h"
#include "framework.h"
#include "A2lTestDlg.h"
#include "A2lTestDlgDlg.h"
#include "DlgProxy.h"
#include "afxdialogex.h"
#include <iostream>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//template<typename ... Args>
//std::wstring wstring_format(const std::wstring& format, Args ... args);
template<typename ... Args>
std::string string_format(const std::string& format, Args ... args)
{
size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; // Extra space for '\0'
if (size <= 0) {
throw std::runtime_error("Error during formatting.");
}
std::unique_ptr<char[]> buf(new char[size]);
snprintf(buf.get(), size, format.c_str(), args ...);
return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside }
}
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// CA2lTestDlgDlg dialog
IMPLEMENT_DYNAMIC(CA2lTestDlgDlg, CDialogEx);
CA2lTestDlgDlg::CA2lTestDlgDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_A2LTESTDLG_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pAutoProxy = nullptr;
}
CA2lTestDlgDlg::~CA2lTestDlgDlg()
{
// If there is an automation proxy for this dialog, set
// its back pointer to this dialog to null, so it knows
// the dialog has been deleted.
if (m_pAutoProxy != nullptr)
m_pAutoProxy->m_pDialog = nullptr;
}
void CA2lTestDlgDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CA2lTestDlgDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_CLOSE()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_OPEN, &CA2lTestDlgDlg::OnBnClickedButtonOpen)
END_MESSAGE_MAP()
// CA2lTestDlgDlg message handlers
BOOL CA2lTestDlgDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != nullptr)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CA2lTestDlgDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CA2lTestDlgDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CA2lTestDlgDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
// Automation servers should not exit when a user closes the UI
// if a controller still holds on to one of its objects. These
// message handlers make sure that if the proxy is still in use,
// then the UI is hidden but the dialog remains around if it
// is dismissed.
void CA2lTestDlgDlg::OnClose()
{
if (CanExit())
CDialogEx::OnClose();
}
void CA2lTestDlgDlg::OnOK()
{
if (CanExit())
CDialogEx::OnOK();
}
void CA2lTestDlgDlg::OnCancel()
{
if (CanExit())
CDialogEx::OnCancel();
}
BOOL CA2lTestDlgDlg::CanExit()
{
// If the proxy object is still around, then the automation
// controller is still holding on to this application. Leave
// the dialog around, but hide its UI.
if (m_pAutoProxy != nullptr)
{
ShowWindow(SW_HIDE);
return FALSE;
}
return TRUE;
}
void CA2lTestDlgDlg::OnBnClickedButtonOpen()
{
// TODO: Add your control notification handler code here
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
TCHAR a2lExt[] = _T("*.a2l");
TCHAR a2lBaseFilter[] = _T("A2L file(*.A2L) | *.a2l;*.A2L | 모든파일(*.*) | *.* ||");
CFileDialog dlg(TRUE, a2lExt, NULL, OFN_HIDEREADONLY, a2lBaseFilter);
if (dlg.DoModal() == IDOK) {
std::wstring strPath = dlg.GetPathName().GetBuffer();
std::string strA2lPath;
strA2lPath.assign(strPath.begin(), strPath.end());
loadA2lFile(strA2lPath.c_str());
}
}
void CA2lTestDlgDlg::AddLogString(std::string strMessage)
{
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST_DATA);
std::wstring message_w;
message_w.assign(strMessage.begin(), strMessage.end());
pListBox->AddString(message_w.c_str());
}

60
A2lTestDlg/A2lTestDlg/A2lTestDlgDlg.h

@ -0,0 +1,60 @@
// A2lTestDlgDlg.h : header file
//
#pragma once
#include <chrono>
#include <filesystem>
#include <map>
#include <string>
#include "A2Lpp.hpp" // A2L generator
class CA2lTestDlgDlgAutoProxy;
// CA2lTestDlgDlg dialog
class CA2lTestDlgDlg : public CDialogEx
{
DECLARE_DYNAMIC(CA2lTestDlgDlg);
friend class CA2lTestDlgDlgAutoProxy;
// Construction
public:
CA2lTestDlgDlg(CWnd* pParent = nullptr); // standard constructor
virtual ~CA2lTestDlgDlg();
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_A2LTESTDLG_DIALOG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
CA2lTestDlgDlgAutoProxy* m_pAutoProxy;
HICON m_hIcon;
BOOL CanExit();
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnClose();
virtual void OnOK();
virtual void OnCancel();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonOpen();
void AddLogString(std::string strMessage);
A2L* a2lFile;
};

226
A2lTestDlg/A2lTestDlg/A2lTestDlg_h.h

@ -0,0 +1,226 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.01.0628 */
/* at Tue Jan 19 12:14:07 2038
*/
/* Compiler settings for A2lTestDlg.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0628
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING( ) */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 500
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif /* __RPCNDR_H_VERSION__ */
#ifndef __A2lTestDlg_h_h__
#define __A2lTestDlg_h_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#ifndef DECLSPEC_XFGVIRT
#if defined(_CONTROL_FLOW_GUARD_XFG)
#define DECLSPEC_XFGVIRT(base, func) __declspec(xfg_virtual(base, func))
#else
#define DECLSPEC_XFGVIRT(base, func)
#endif
#endif
/* Forward Declarations */
#ifndef __IA2lTestDlg_FWD_DEFINED__
#define __IA2lTestDlg_FWD_DEFINED__
typedef interface IA2lTestDlg IA2lTestDlg;
#endif /* __IA2lTestDlg_FWD_DEFINED__ */
#ifndef __A2lTestDlg_FWD_DEFINED__
#define __A2lTestDlg_FWD_DEFINED__
#ifdef __cplusplus
typedef class A2lTestDlg A2lTestDlg;
#else
typedef struct A2lTestDlg A2lTestDlg;
#endif /* __cplusplus */
#endif /* __A2lTestDlg_FWD_DEFINED__ */
#ifdef __cplusplus
extern "C"{
#endif
#ifndef __A2lTestDlg_LIBRARY_DEFINED__
#define __A2lTestDlg_LIBRARY_DEFINED__
/* library A2lTestDlg */
/* [version][uuid] */
EXTERN_C const IID LIBID_A2lTestDlg;
#ifndef __IA2lTestDlg_DISPINTERFACE_DEFINED__
#define __IA2lTestDlg_DISPINTERFACE_DEFINED__
/* dispinterface IA2lTestDlg */
/* [uuid] */
EXTERN_C const IID DIID_IA2lTestDlg;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("9fc78fa1-82e8-4469-9a9f-60c6d387b64a")
IA2lTestDlg : public IDispatch
{
};
#else /* C style interface */
typedef struct IA2lTestDlgVtbl
{
BEGIN_INTERFACE
DECLSPEC_XFGVIRT(IUnknown, QueryInterface)
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
IA2lTestDlg * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
DECLSPEC_XFGVIRT(IUnknown, AddRef)
ULONG ( STDMETHODCALLTYPE *AddRef )(
IA2lTestDlg * This);
DECLSPEC_XFGVIRT(IUnknown, Release)
ULONG ( STDMETHODCALLTYPE *Release )(
IA2lTestDlg * This);
DECLSPEC_XFGVIRT(IDispatch, GetTypeInfoCount)
HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(
IA2lTestDlg * This,
/* [out] */ UINT *pctinfo);
DECLSPEC_XFGVIRT(IDispatch, GetTypeInfo)
HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(
IA2lTestDlg * This,
/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo **ppTInfo);
DECLSPEC_XFGVIRT(IDispatch, GetIDsOfNames)
HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(
IA2lTestDlg * This,
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR *rgszNames,
/* [range][in] */ UINT cNames,
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID *rgDispId);
DECLSPEC_XFGVIRT(IDispatch, Invoke)
/* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(
IA2lTestDlg * This,
/* [annotation][in] */
_In_ DISPID dispIdMember,
/* [annotation][in] */
_In_ REFIID riid,
/* [annotation][in] */
_In_ LCID lcid,
/* [annotation][in] */
_In_ WORD wFlags,
/* [annotation][out][in] */
_In_ DISPPARAMS *pDispParams,
/* [annotation][out] */
_Out_opt_ VARIANT *pVarResult,
/* [annotation][out] */
_Out_opt_ EXCEPINFO *pExcepInfo,
/* [annotation][out] */
_Out_opt_ UINT *puArgErr);
END_INTERFACE
} IA2lTestDlgVtbl;
interface IA2lTestDlg
{
CONST_VTBL struct IA2lTestDlgVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define IA2lTestDlg_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define IA2lTestDlg_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define IA2lTestDlg_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define IA2lTestDlg_GetTypeInfoCount(This,pctinfo) \
( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) )
#define IA2lTestDlg_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) )
#define IA2lTestDlg_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) )
#define IA2lTestDlg_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __IA2lTestDlg_DISPINTERFACE_DEFINED__ */
EXTERN_C const CLSID CLSID_A2lTestDlg;
#ifdef __cplusplus
class DECLSPEC_UUID("04615303-44d9-45b7-b802-02b06c0dde4f")
A2lTestDlg;
#endif
#endif /* __A2lTestDlg_LIBRARY_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif

84
A2lTestDlg/A2lTestDlg/A2lTestDlg_i.c

@ -0,0 +1,84 @@
/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
/* link this file in with the server and any clients */
/* File created by MIDL compiler version 8.01.0628 */
/* at Tue Jan 19 12:14:07 2038
*/
/* Compiler settings for A2lTestDlg.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0628
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING( ) */
#ifdef __cplusplus
extern "C"{
#endif
#include <rpc.h>
#include <rpcndr.h>
#ifdef _MIDL_USE_GUIDDEF_
#ifndef INITGUID
#define INITGUID
#include <guiddef.h>
#undef INITGUID
#else
#include <guiddef.h>
#endif
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
#else // !_MIDL_USE_GUIDDEF_
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
typedef struct _IID
{
unsigned long x;
unsigned short s1;
unsigned short s2;
unsigned char c[8];
} IID;
#endif // __IID_DEFINED__
#ifndef CLSID_DEFINED
#define CLSID_DEFINED
typedef IID CLSID;
#endif // CLSID_DEFINED
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
EXTERN_C __declspec(selectany) const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
#endif // !_MIDL_USE_GUIDDEF_
MIDL_DEFINE_GUID(IID, LIBID_A2lTestDlg,0xaacf2bb9,0x0c94,0x4623,0x8c,0x20,0xbb,0xe3,0x07,0x07,0x21,0xea);
MIDL_DEFINE_GUID(IID, DIID_IA2lTestDlg,0x9fc78fa1,0x82e8,0x4469,0x9a,0x9f,0x60,0xc6,0xd3,0x87,0xb6,0x4a);
MIDL_DEFINE_GUID(CLSID, CLSID_A2lTestDlg,0x04615303,0x44d9,0x45b7,0xb8,0x02,0x02,0xb0,0x6c,0x0d,0xde,0x4f);
#undef MIDL_DEFINE_GUID
#ifdef __cplusplus
}
#endif

87
A2lTestDlg/A2lTestDlg/DlgProxy.cpp

@ -0,0 +1,87 @@
// DlgProxy.cpp : implementation file
//
#include "pch.h"
#include "framework.h"
#include "A2lTestDlg.h"
#include "DlgProxy.h"
#include "A2lTestDlgDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CA2lTestDlgDlgAutoProxy
IMPLEMENT_DYNCREATE(CA2lTestDlgDlgAutoProxy, CCmdTarget)
CA2lTestDlgDlgAutoProxy::CA2lTestDlgDlgAutoProxy()
{
EnableAutomation();
// To keep the application running as long as an automation
// object is active, the constructor calls AfxOleLockApp.
AfxOleLockApp();
// Get access to the dialog through the application's
// main window pointer. Set the proxy's internal pointer
// to point to the dialog, and set the dialog's back pointer to
// this proxy.
ASSERT_VALID(AfxGetApp()->m_pMainWnd);
if (AfxGetApp()->m_pMainWnd)
{
ASSERT_KINDOF(CA2lTestDlgDlg, AfxGetApp()->m_pMainWnd);
if (AfxGetApp()->m_pMainWnd->IsKindOf(RUNTIME_CLASS(CA2lTestDlgDlg)))
{
m_pDialog = reinterpret_cast<CA2lTestDlgDlg*>(AfxGetApp()->m_pMainWnd);
m_pDialog->m_pAutoProxy = this;
}
}
}
CA2lTestDlgDlgAutoProxy::~CA2lTestDlgDlgAutoProxy()
{
// To terminate the application when all objects created with
// with automation, the destructor calls AfxOleUnlockApp.
// Among other things, this will destroy the main dialog
if (m_pDialog != nullptr)
m_pDialog->m_pAutoProxy = nullptr;
AfxOleUnlockApp();
}
void CA2lTestDlgDlgAutoProxy::OnFinalRelease()
{
// When the last reference for an automation object is released
// OnFinalRelease is called. The base class will automatically
// deletes the object. Add additional cleanup required for your
// object before calling the base class.
CCmdTarget::OnFinalRelease();
}
BEGIN_MESSAGE_MAP(CA2lTestDlgDlgAutoProxy, CCmdTarget)
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CA2lTestDlgDlgAutoProxy, CCmdTarget)
END_DISPATCH_MAP()
// Note: we add support for IID_IA2lTestDlg to support typesafe binding
// from VBA. This IID must match the GUID that is attached to the
// dispinterface in the .IDL file.
// {9fc78fa1-82e8-4469-9a9f-60c6d387b64a}
static const IID IID_IA2lTestDlg =
{0x9fc78fa1,0x82e8,0x4469,{0x9a,0x9f,0x60,0xc6,0xd3,0x87,0xb6,0x4a}};
BEGIN_INTERFACE_MAP(CA2lTestDlgDlgAutoProxy, CCmdTarget)
INTERFACE_PART(CA2lTestDlgDlgAutoProxy, IID_IA2lTestDlg, Dispatch)
END_INTERFACE_MAP()
// The IMPLEMENT_OLECREATE2 macro is defined in pch.h of this project
// {04615303-44d9-45b7-b802-02b06c0dde4f}
IMPLEMENT_OLECREATE2(CA2lTestDlgDlgAutoProxy, "A2lTestDlg.Application", 0x04615303,0x44d9,0x45b7,0xb8,0x02,0x02,0xb0,0x6c,0x0d,0xde,0x4f)
// CA2lTestDlgDlgAutoProxy message handlers

43
A2lTestDlg/A2lTestDlg/DlgProxy.h

@ -0,0 +1,43 @@
// DlgProxy.h: header file
//
#pragma once
class CA2lTestDlgDlg;
// CA2lTestDlgDlgAutoProxy command target
class CA2lTestDlgDlgAutoProxy : public CCmdTarget
{
DECLARE_DYNCREATE(CA2lTestDlgDlgAutoProxy)
CA2lTestDlgDlgAutoProxy(); // protected constructor used by dynamic creation
// Attributes
public:
CA2lTestDlgDlg* m_pDialog;
// Operations
public:
// Overrides
public:
virtual void OnFinalRelease();
// Implementation
protected:
virtual ~CA2lTestDlgDlgAutoProxy();
// Generated message map functions
DECLARE_MESSAGE_MAP()
DECLARE_OLECREATE(CA2lTestDlgDlgAutoProxy)
// Generated OLE dispatch map functions
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
};

50
A2lTestDlg/A2lTestDlg/dbg_print.h

@ -0,0 +1,50 @@
#pragma once
/* dbg_print.h */
/*
| Code released into public domain, no attribution required
*/
//-------------------------------------------------------------------------------
// Debug print
#if OPTION_ENABLE_DBG_PRINTS
extern unsigned int gDebugLevel;
#define DBG_LEVEL gDebugLevel
#define DBG_PRINTF_ERROR(format, ...) printf(format, __VA_ARGS__)
#define DBG_PRINTF(level, format, ...) if (DBG_LEVEL>=level) printf(format, __VA_ARGS__)
#define DBG_PRINTF1(format, ...) if (DBG_LEVEL>=1) printf(format, __VA_ARGS__)
#define DBG_PRINTF2(format, ...) if (DBG_LEVEL>=2) printf(format, __VA_ARGS__)
#define DBG_PRINTF3(format, ...) if (DBG_LEVEL>=3) printf(format, __VA_ARGS__)
#define DBG_PRINTF4(format, ...) if (DBG_LEVEL>=4) printf(format, __VA_ARGS__)
#define DBG_PRINT_ERROR(format) printf(format)
#define DBG_PRINT(level, format) if (DBG_LEVEL>=level) printf(format)
#define DBG_PRINT1(format) if (DBG_LEVEL>=1) printf(format)
#define DBG_PRINT2(format) if (DBG_LEVEL>=2) printf(format)
#define DBG_PRINT3(format) if (DBG_LEVEL>=3) printf(format)
#define DBG_PRINT4(format) if (DBG_LEVEL>=4) printf(format)
#else
#undef DBG_LEVEL
#define DBG_PRINTF_ERROR(s, ...) // printf(s,__VA_ARGS__)
#define DBG_PRINTF(level, s, ...)
#define DBG_PRINTF1(s, ...)
#define DBG_PRINTF2(s, ...)
#define DBG_PRINTF3(s, ...)
#define DBG_PRINTF4(s, ...)
#define DBG_PRINT_ERROR(s, ...) // printf(s,__VA_ARGS__)
#define DBG_PRINT(level, s, ...)
#define DBG_PRINT1(s, ...)
#define DBG_PRINT2(s, ...)
#define DBG_PRINT3(s, ...)
#define DBG_PRINT4(s, ...)
#endif

60
A2lTestDlg/A2lTestDlg/framework.h

@ -0,0 +1,60 @@
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
// This macro is the same as IMPLEMENT_OLECREATE, except it passes TRUE
// for the bMultiInstance parameter to the COleObjectFactory constructor.
// We want a separate instance of this application to be launched for
// each automation proxy object requested by automation controllers.
#ifndef IMPLEMENT_OLECREATE2
#define IMPLEMENT_OLECREATE2(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
AFX_DATADEF COleObjectFactory class_name::factory(class_name::guid, \
RUNTIME_CLASS(class_name), TRUE, _T(external_name)); \
const AFX_DATADEF GUID class_name::guid = \
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } };
#endif // IMPLEMENT_OLECREATE2
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

95
A2lTestDlg/A2lTestDlg/main.h

@ -0,0 +1,95 @@
#pragma once
/* main.h */
/*
| Code released into public domain, no attribution required
*/
// Windows or Linux ?
#if defined(_WIN32) || defined(_WIN64)
#define _WIN
#if defined(_WIN32) && defined(_WIN64)
#undef _WIN32
#endif
#if defined(_LINUX) || defined(_LINUX64)|| defined(_LINUX32)
#error
#endif
#else
#define _LINUX
#if defined (_ix64_) || defined (__x86_64__) || defined (__aarch64__)
#define _LINUX64
#else
#define _LINUX32
#endif
#if defined(_WIN) || defined(_WIN64)|| defined(_WIN32)
#error
#endif
#endif
#ifdef _WIN
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_WARNINGS
#else
#define _DEFAULT_SOURCE
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <math.h>
#ifdef _WIN
#define M_PI 3.14159265358979323846
#endif
#define M_2PI (M_PI*2)
#include <assert.h>
#ifndef _WIN // Linux
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include <sys/stat.h>
#include <pthread.h>
#include <ifaddrs.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#define MAX_PATH 256
#define BOOL int
#define FALSE 0
#define TRUE 1
#else // Windows
#include <windows.h>
#include <time.h>
#include <conio.h>
#define BOOL int
#define FALSE 0
#define TRUE 1
#endif
#ifdef __cplusplus
#include <typeinfo>
#include <thread>
#include <string>
#include <vector>
#endif
#include "main_cfg.h"

48
A2lTestDlg/A2lTestDlg/main_cfg.h

@ -0,0 +1,48 @@
#pragma once
// main_cfg.h
// CPP_Demo
/* Copyright(c) Vector Informatik GmbH.All rights reserved.
Licensed under the MIT license.See LICENSE file in the project root for details. */
// Application configuration:
// XCP configuration is in xcp_cfg.h (Protocol Layer) and xcptl_cfg.h (Transport Layer)
#define ON 1
#define OFF 0
// Debug prints
#define OPTION_ENABLE_DBG_PRINTS ON
#define OPTION_DEBUG_LEVEL 2
#define OPTION_UDP_DEBUG_LEVEL 0
// Enable C++ class wrapper
#define OPTION_ENABLE_XCP_CLASS ON
// Enable demo how to measure dynamic instances
#define OPTION_ENABLE_DYNAMIC_DEMO ON
// A2L generation
#define OPTION_ENABLE_A2L_GEN ON // Enable A2L generation
#if OPTION_ENABLE_A2L_GEN
#define OPTION_A2L_NAME "CPP_Demo" // A2L name
#define OPTION_A2L_FILE_NAME "CPP_Demo.a2l" // A2L filename
#endif
// Set clock resolution (for clock function in platform.c)
#define CLOCK_USE_APP_TIME_US
//#define CLOCK_USE_UTC_TIME_NS
// Ethernet Transport Layer
#define OPTION_USE_TCP OFF
#define OPTION_MTU 1500 // Ethernet MTU
#define OPTION_SERVER_PORT 5555 // Default UDP port
#define OPTION_SERVER_ADDR {127,0,0,1} // IP addr to bind, 0.0.0.0 = ANY

39
A2lTestDlg/A2lTestDlg/main_cfg.h.in

@ -0,0 +1,39 @@
#pragma once
// main_cfg.h
// CPP_Demo
/* Copyright(c) Vector Informatik GmbH.All rights reserved.
Licensed under the MIT license.See LICENSE file in the project root for details. */
#define APP_CPP_Demo
#define APP_NAME "CPP_Demo"
#define APP_VERSION_MAJOR @CPP_Demo_VERSION_MAJOR@
#define APP_VERSION_MINOR @CPP_Demo_VERSION_MINOR@
//-----------------------------------------------------------------------------------------------------
// Application configuration:
// XCP configuration is in xcp_cfg.h (Protocol Layer) and xcptl_cfg.h (Transport Layer)
#define ON 1
#define OFF 0
#define OPTION_DEBUG_LEVEL @OPTION_DEBUG_LEVEL@
// A2L generation
#define OPTION_ENABLE_A2L_GEN ON // Enable A2L generation
#if OPTION_ENABLE_A2L_GEN
#define OPTION_ENABLE_A2L_SYMBOL_LINKS ON // Enable generation of symbol links (required for CANape integrated linker map update)
#define OPTION_A2L_NAME "CPP_Demo" // A2L name
#define OPTION_A2L_FILE_NAME "CPP_Demo.a2l" // A2L filename
#define OPTION_A2L_PROJECT_NAME "CPP_Demo" // A2L project name
#endif
// Default communication parameters
#define OPTION_ENABLE_TCP @OPTION_ENABLE_TCP@ // Enable TCP support
#define OPTION_USE_TCP @OPTION_USE_TCP@ // Default
#define OPTION_MTU @OPTION_MTU@ // Ethernet MTU
#define OPTION_SERVER_PORT @OPTION_SERVER_PORT@ // Default UDP port, overwritten by commandline option -port
#define OPTION_SERVER_ADDR @OPTION_SERVER_ADDR@ // Default IP addr to bind, 0.0.0.0 = ANY, overwritten by commandline option -bind x.x.x.x

5
A2lTestDlg/A2lTestDlg/pch.cpp

@ -0,0 +1,5 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

13
A2lTestDlg/A2lTestDlg/pch.h

@ -0,0 +1,13 @@
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
// add headers that you want to pre-compile here
#include "framework.h"
#endif //PCH_H

183
A2lTestDlg/A2lTestDlg/platform.h

@ -0,0 +1,183 @@
#pragma once
/* platform.h */
/*
| Code released into public domain, no attribution required
*/
//-------------------------------------------------------------------------------
// Keyboard
#ifdef _LINUX
#include <termios.h>
extern int _getch();
extern int _kbhit();
#endif
//-------------------------------------------------------------------------------
// Safe sprintf
#if defined(_WIN) // Windows
#define SPRINTF(dest,format,...) sprintf_s((char*)dest,sizeof(dest),format,__VA_ARGS__)
#define SNPRINTF(dest,len,format,...) sprintf_s((char*)dest,len,format,__VA_ARGS__)
#elif defined(_LINUX) // Linux
#define SPRINTF(dest,format,...) snprintf((char*)dest,sizeof(dest),format,__VA_ARGS__)
#define SNPRINTF(dest,len,format,...) snprintf((char*)dest,len,format,__VA_ARGS__)
#endif
//-------------------------------------------------------------------------------
// Delay
// Delay based on clock
extern void sleepNs(uint32_t ns);
// Delay - Less precise and less CPU load, not based on clock, time domain different
extern void sleepMs(uint32_t ms);
//-------------------------------------------------------------------------------
// Mutex
#if defined(_WIN) // Windows
#define MUTEX CRITICAL_SECTION
#define mutexLock EnterCriticalSection
#define mutexUnlock LeaveCriticalSection
#elif defined(_LINUX) // Linux
#define MUTEX pthread_mutex_t
#define MUTEX_INTIALIZER PTHREAD_MUTEX_INITIALIZER
#define mutexLock pthread_mutex_lock
#define mutexUnlock pthread_mutex_unlock
#endif
void mutexInit(MUTEX* m, BOOL recursive, uint32_t spinCount);
void mutexDestroy(MUTEX* m);
//-------------------------------------------------------------------------------
// Threads
#if defined(_WIN) // Windows
typedef HANDLE tXcpThread;
#define create_thread(h,t) *h = CreateThread(0, 0, t, NULL, 0, NULL)
#define join_thread(h) WaitForSingleObject(h, INFINITE);
#define terminate_thread(h) { TerminateThread(h,0); WaitForSingleObject(h,1000); CloseHandle(h); }
#define cancel_thread terminate_thread
#elif defined(_LINUX) // Linux
typedef pthread_t tXcpThread;
#define create_thread(h,t) pthread_create(h, NULL, t, NULL);
#define join_thread(h) pthread_join(h,NULL);
#define detach_thread(h) { pthread_detach(h); pthread_cancel(h); }
#define cancel_thread detach_thread
#endif
//-------------------------------------------------------------------------------
// Platform independant socket functions
#ifdef _LINUX // Linux sockets
#define SOCKET int
#define INVALID_SOCKET (-1)
#define SOCKADDR_IN struct sockaddr_in
#define SOCKADDR struct sockaddr
#define SOCKET_ERROR_ABORT EBADF
#define SOCKET_ERROR_RESET EBADF
#define SOCKET_ERROR_INTR EBADF
#define SOCKET_ERROR_WBLOCK EAGAIN
#undef htonll
#define htonll(val) ((((uint64_t)htonl((uint32_t)val)) << 32) + htonl((uint32_t)(val >> 32)))
#define socketGetLastError() errno
#endif
#if defined(_WIN) // Windows // Windows sockets or XL-API
#include <winsock2.h>
#include <ws2tcpip.h>
#define SOCKET_ERROR_OTHER 1
#define SOCKET_ERROR_WBLOCK WSAEWOULDBLOCK
#define SOCKET_ERROR_ABORT WSAECONNABORTED
#define SOCKET_ERROR_RESET WSAECONNRESET
#define SOCKET_ERROR_INTR WSAEINTR
#endif
// Timestamp mode
#define SOCKET_TIMESTAMP_NONE 0 // No timestamps
#define SOCKET_TIMESTAMP_HW 1 // Hardware clock
#define SOCKET_TIMESTAMP_HW_SYNT 2 // Hardware clock syntonized to PC clock
#define SOCKET_TIMESTAMP_PC 3 // PC clock
// Clock mode
#define SOCKET_TIMESTAMP_FREE_RUNNING 0
#define SOCKET_TIMESTAMP_SOFTWARE_SYNC 1
extern BOOL socketStartup();
extern int32_t socketGetLastError();
extern void socketCleanup();
extern BOOL socketOpen(SOCKET* sp, BOOL useTCP, BOOL nonBlocking, BOOL reuseaddr, BOOL timestamps);
extern BOOL socketBind(SOCKET sock, uint8_t* addr, uint16_t port);
extern BOOL socketJoin(SOCKET sock, uint8_t* maddr);
extern BOOL socketListen(SOCKET sock);
extern SOCKET socketAccept(SOCKET sock, uint8_t addr[]);
extern int16_t socketRecv(SOCKET sock, uint8_t* buffer, uint16_t bufferSize, BOOL waitAll);
extern int16_t socketRecvFrom(SOCKET sock, uint8_t* buffer, uint16_t bufferSize, uint8_t* srcAddr, uint16_t* srcPort, uint64_t *time);
extern int16_t socketSend(SOCKET sock, const uint8_t* buffer, uint16_t bufferSize);
extern int16_t socketSendTo(SOCKET sock, const uint8_t* buffer, uint16_t bufferSize, const uint8_t* addr, uint16_t port, uint64_t *time);
extern BOOL socketShutdown(SOCKET sock);
extern BOOL socketClose(SOCKET* sp);
extern BOOL socketGetLocalAddr(uint8_t* mac, uint8_t* addr);
//-------------------------------------------------------------------------------
// Clock
// Clock resolution and epoch
#if !defined(CLOCK_USE_UTC_TIME_NS) && !defined(CLOCK_USE_APP_TIME_US)
// Default
#define CLOCK_USE_UTC_TIME_NS // Use ns timestamps relative to 1.1.1970 (TAI monotonic - no backward jumps)
//#define CLOCK_USE_APP_TIME_US // Use arbitrary us timestamps relative to application start
#endif
#ifdef CLOCK_USE_UTC_TIME_NS
#define CLOCK_TICKS_PER_M (1000000000ULL*60)
#define CLOCK_TICKS_PER_S 1000000000
#define CLOCK_TICKS_PER_MS 1000000
#define CLOCK_TICKS_PER_US 1000
#define CLOCK_TICKS_PER_NS 1
#else
#define CLOCK_TICKS_PER_S 1000000
#define CLOCK_TICKS_PER_MS 1000
#define CLOCK_TICKS_PER_US 1
#endif
// Clock
extern BOOL clockInit();
extern uint64_t clockGet();
extern uint64_t clockGetLast();
extern char* clockGetString(char* s, uint32_t l, uint64_t c);
extern char* clockGetTimeString(char* s, uint32_t l, int64_t c);

BIN
A2lTestDlg/A2lTestDlg/res/A2lTestDlg.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
A2lTestDlg/A2lTestDlg/res/A2lTestDlg.rc2

Binary file not shown.

24
A2lTestDlg/A2lTestDlg/resource.h

@ -0,0 +1,24 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by A2lTestDlg.rc
//
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDP_OLE_INIT_FAILED 100
#define IDS_ABOUTBOX 101
#define IDD_A2LTESTDLG_DIALOG 102
#define IDR_MAINFRAME 128
#define IDC_LIST2 1001
#define IDC_LIST_DATA 1001
#define IDC_BUTTON_OPEN 1002
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1003
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

8
A2lTestDlg/A2lTestDlg/targetver.h

@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>

1235
A2lTestDlg/A2lTestDlg/xcp.h

File diff suppressed because it is too large

27
A2lTestDlg/A2lTestDlg/xcpEthTl.h

@ -0,0 +1,27 @@
#pragma once
/* xcpEthTl.h */
/* Copyright(c) Vector Informatik GmbH.All rights reserved.
Licensed under the MIT license.See LICENSE file in the project root for details. */
/* ETH transport Layer functions called by application */
extern BOOL XcpEthTlInit(const uint8_t* addr, uint16_t port, BOOL useTCP, uint16_t segmentSize, BOOL blockingRx); // Start transport layer
// Test mode
#ifdef XCPTL_ENABLE_SELF_TEST
extern void XcpEthTlCreateA2lDescription();
extern void XcpEthTlCreateXcpEvents();
extern uint64_t XcpEthTlGetBytesWritten(); // Get the number of bytes send
#endif
/* ETH transport Layer functions called by XCPlite.c */
extern void XcpEthTlSendMulticastCrm(const uint8_t* data, uint16_t n, const uint8_t* addr, uint16_t port); // Send multicast command response
#ifdef XCPTL_ENABLE_MULTICAST
extern void XcpEthTlSetClusterId(uint16_t clusterId); // Set cluster id for GET_DAQ_CLOCK_MULTICAST reception
#endif
extern void XcpEthTlGetInfo(BOOL* isTCP, uint8_t* mac, uint8_t* addr, uint16_t* port);

188
A2lTestDlg/A2lTestDlg/xcpLite.h

@ -0,0 +1,188 @@
#pragma once
/* xcpLite.h */
/* Copyright(c) Vector Informatik GmbH.All rights reserved.
Licensed under the MIT license.See LICENSE file in the project root for details. */
#ifdef __XCPTL_CFG_H__
#error "Include dependency error!"
#endif
#ifdef __XCP_CFG_H__
#error "Include dependency error!"
#endif
// Transport layer type
// The protocol layer implementation has some dependencies on the transport layer type
// Some XCP commands are only supported on Ethernet and can not be compiled with MAX_CTO == 8
#define XCP_TRANSPORT_LAYER_ETH 1
#define XCP_TRANSPORT_LAYER_CAN 0
#include "xcptl_cfg.h" // Transport layer configuration
// Transport layer definitions and configuration
#if XCP_TRANSPORT_LAYER_TYPE==XCP_TRANSPORT_LAYER_ETH
#include "xcpTl.h"
#include "xcpEthTl.h" // Ethernet transport layer specific functions
#elif XCP_TRANSPORT_LAYER_TYPE==XCP_TRANSPORT_LAYER_CAN
#include "xcptl.h"
#include "xcpcantl.h"
#else
#error "Define XCP_TRANSPORT_LAYER_ETH or XCP_TRANSPORT_LAYER_CAN"
#endif
// Protocol layer definitions and configuration
#include "xcp_cfg.h" // Protocol layer configuration
#include "xcp.h" // XCP protocol defines
/****************************************************************************/
/* DAQ event information */
/****************************************************************************/
#ifdef XCP_ENABLE_DAQ_EVENT_LIST
#define XCP_MAX_EVENT_NAME 8
typedef struct {
char shortName[XCP_MAX_EVENT_NAME+1]; // A2L XCP IF_DATA short event name, long name not supported
uint32_t size; // ext event size
uint8_t timeUnit; // timeCycle unit, 1ns=0, 10ns=1, 100ns=2, 1us=3, ..., 1ms=6, ...
uint8_t timeCycle; // cycletime in units, 0 = sporadic or unknown
uint16_t sampleCount; // packed event sample count
uint16_t daqList; // associated DAQ list
uint8_t priority; // priority 0 = queued, 1 = pushing, 2 = realtime
#ifdef XCP_ENABLE_MULTITHREAD_EVENTS
MUTEX mutex;
#endif
#ifdef XCP_ENABLE_TEST_CHECKS
uint64_t time; // last event time stamp
#endif
} tXcpEvent;
#endif
/****************************************************************************/
/* Protocol layer interface */
/****************************************************************************/
/* Initialization for the XCP Protocol Layer */
extern void XcpInit(void);
extern void XcpStart(void);
extern void XcpDisconnect();
extern void XcpReset();
/* Trigger a XCP data acquisition or stimulation event */
extern void XcpEvent(uint16_t event);
extern void XcpEventExt(uint16_t event, uint8_t* base);
extern void XcpEventAt(uint16_t event, uint64_t clock);
/* XCP command processor */
extern void XcpCommand( const uint32_t* pCommand, uint16_t len );
/* Send an XCP event message */
extern void XcpSendEvent(uint8_t evc, const uint8_t* d, uint8_t l);
/* Check status */
extern BOOL XcpIsStarted();
extern BOOL XcpIsConnected();
extern BOOL XcpIsDaqRunning();
extern BOOL XcpIsDaqEventRunning(uint16_t event);
extern uint64_t XcpGetDaqStartTime();
extern uint32_t XcpGetDaqOverflowCount();
/* Time synchronisation */
#ifdef XCP_ENABLE_DAQ_CLOCK_MULTICAST
extern uint16_t XcpGetClusterId();
#endif
// Event list
#ifdef XCP_ENABLE_DAQ_EVENT_LIST
#define XCP_INVALID_EVENT 0xFFFF
// Clear event list
extern void XcpClearEventList();
// Add a measurement event to event list, return event number (0..MAX_EVENT-1)
extern uint16_t XcpCreateEvent(const char* name, uint32_t cycleTimeNs /* ns */, uint8_t priority /* 0-normal, >=1 realtime*/, uint16_t sampleCount, uint32_t size);
// Get event list
extern tXcpEvent* XcpGetEventList(uint16_t* eventCount);
// Lookup event
extern tXcpEvent* XcpGetEvent(uint16_t event);
#endif
/****************************************************************************/
/* Protocol layer external dependencies */
/****************************************************************************/
// All callback functions supplied by the application
// Must be thread save
/* Callbacks on connect, measurement prepare, start and stop */
extern BOOL ApplXcpConnect();
#if XCP_PROTOCOL_LAYER_VERSION >= 0x0104
extern BOOL ApplXcpPrepareDaq();
#endif
extern BOOL ApplXcpStartDaq();
extern void ApplXcpStopDaq();
/* Address conversions from A2L address to pointer and vice versa */
/* Note that xcpAddrExt 0x01 and 0xFF are reserved for special use cases (0x01 if XCP_ENABLE_DYN_ADDRESSING, 0xFF if XCP_ENABLE_IDT_A2L_UPLOAD) */
extern uint8_t* ApplXcpGetPointer(uint8_t xcpAddrExt, uint32_t xcpAddr); /* Create a pointer (uint8_t*) from xcpAddrExt and xcpAddr, returns NULL if no access */
extern uint32_t ApplXcpGetAddr(uint8_t* p); // Calculate the xcpAddr address from a pointer
extern uint8_t *ApplXcpGetBaseAddr(); // Get the base address for DAQ data access */
/*
Note 1:
For DAQ performance and memory optimization:
XCPlite DAQ tables do not store address extensions and do not use ApplXcpGetPointer(), addr is stored as 32 Bit value and access is hardcoded by *(baseAddr+xcpAddr)
All accesible DAQ data is within a 4GByte range starting at ApplXcpGetBaseAddr()
Address extensions to increase the addressable range are not supported yet
Attempting to setup an ODT entry with address extension != 0 gives a CRC_ACCESS_DENIED error message
Note 2:
ApplXcpGetPointer may do address transformations according to active calibration page
When measuring calibration variables inswitch
*/
/* Switch calibration pages */
#ifdef XCP_ENABLE_CAL_PAGE
extern uint8_t ApplXcpGetCalPage(uint8_t segment, uint8_t mode);
extern uint8_t ApplXcpSetCalPage(uint8_t segment, uint8_t page, uint8_t mode);
#endif
/* DAQ clock */
extern uint64_t ApplXcpGetClock64();
#define CLOCK_STATE_SYNCH_IN_PROGRESS (0)
#define CLOCK_STATE_SYNCH (1)
#define CLOCK_STATE_FREE_RUNNING (7)
#define CLOCK_STATE_GRANDMASTER_STATE_SYNCH (1 << 3)
extern uint8_t ApplXcpGetClockState();
#ifdef XCP_ENABLE_PTP
#define CLOCK_STRATUM_LEVEL_UNKNOWN 255
#define CLOCK_STRATUM_LEVEL_ARB 16 // unsychronized
#define CLOCK_STRATUM_LEVEL_UTC 0 // Atomic reference clock
#define CLOCK_EPOCH_TAI 0 // Atomic monotonic time since 1.1.1970 (TAI)
#define CLOCK_EPOCH_UTC 1 // Universal Coordinated Time (with leap seconds) since 1.1.1970 (UTC)
#define CLOCK_EPOCH_ARB 2 // Arbitrary (epoch unknown)
extern BOOL ApplXcpGetClockInfoGrandmaster(uint8_t* uuid, uint8_t* epoch, uint8_t* stratum);
#endif
/* Get info for GET_ID command (pointer to and length of data) */
/* Supports IDT_ASCII, IDT_ASAM_NAME, IDT_ASAM_PATH, IDT_ASAM_URL, IDT_ASAM_EPK and IDT_ASAM_UPLOAD */
/* Returns 0 if not available */
extern uint32_t ApplXcpGetId(uint8_t id, uint8_t* buf, uint32_t bufLen);
/* Read a chunk (offset,size) of the A2L file for upload */
/* Return FALSE if out of bounds */
#ifdef XCP_ENABLE_IDT_A2L_UPLOAD // Enable A2L content upload to host (IDT_ASAM_UPLOAD)
extern BOOL ApplXcpReadA2L(uint8_t size, uint32_t offset, uint8_t* data);
#endif

32
A2lTestDlg/A2lTestDlg/xcpTl.h

@ -0,0 +1,32 @@
#pragma once
/* xcpTl.h */
/* Copyright(c) Vector Informatik GmbH.All rights reserved.
Licensed under the MIT license.See LICENSE file in the project root for details. */
#define XCPTL_TIMEOUT_INFINITE 0xFFFFFFFF // Infinite timeout (blocking mode) for XcpTlHandleCommands, XcpTlWaitForTransmitData
/* Transport Layer functions called by XCPlite.c */
extern BOOL XcpTlHandleCommands(uint32_t timeout_ms); // Handle all incoming XCP commands, (wait for at least timeout_ms)
extern void XcpTlSendCrm(const uint8_t* data, uint16_t n); // Send or queue (depending on XCPTL_QUEUED_CRM) a command response
extern uint8_t* XcpTlGetTransmitBuffer(void** par, uint16_t size); // Get a buffer for a message with size
extern void XcpTlCommitTransmitBuffer(void* par, BOOL flush); // Commit a buffer (by handle returned from XcpTlGetTransmitBuffer)
extern void XcpTlFlushTransmitBuffer(); // Finalize the current transmit packet (ETH only)
extern void XcpTlWaitForTransmitQueueEmpty(); // Wait (sleep) until transmit queue is empty
/* Generic transport Layer functions called by application */
/* All other application functions functions declared in xcpCanTl.h or xcpEthTl.h */
extern int32_t XcpTlHandleTransmitQueue(); // Send all outgoing packets in the transmit queue
extern BOOL XcpTlWaitForTransmitData(uint32_t timeout_ms); // Wait for at least timeout_ms, until packets are pending in the transmit queue
extern void XcpTlShutdown();
// Get last error code
#define XCPTL_OK 0
#define XCPTL_ERROR_WOULD_BLOCK 1
#define XCPTL_ERROR_SEND_FAILED 2
#define XCPTL_ERROR_INVALID_MASTER 3
extern int32_t XcpTlGetLastError();
// Get transmit queue level
extern int32_t XcpTlGetTransmitQueueLevel();

104
A2lTestDlg/A2lTestDlg/xcp_cfg.h

@ -0,0 +1,104 @@
#pragma once
/*----------------------------------------------------------------------------
| File:
| xcp_cfg.h
|
| Description:
| User configuration file for XCP protocol layer parameters
|
| Code released into public domain, no attribution required
|
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Version */
// Driver version (GET_COMM_MODE_INFO)
#define XCP_DRIVER_VERSION 0x01
// Protocol layer version
// #define XCP_PROTOCOL_LAYER_VERSION 0x0101
#define XCP_PROTOCOL_LAYER_VERSION 0x0103 // GET_DAQ_CLOCK_MULTICAST, GET_TIME_CORRELATION_PROPERTIES
// #define XCP_PROTOCOL_LAYER_VERSION 0x0104 // PACKED_MODE, CC_START_STOP_SYNCH prepare
/*----------------------------------------------------------------------------*/
/* Driver features */
#define XCP_TRANSPORT_LAYER_TYPE XCP_TRANSPORT_LAYER_ETH // Enable ethernet specific commands
#if OPTION_ENABLE_XCP_CLASS
#define XCP_ENABLE_DYN_ADDRESSING // Enable addr_ext=1 indicating relative addr format (event<<16)|offset
#endif
/*----------------------------------------------------------------------------*/
/* Protocol features */
//#define XCP_ENABLE_INTERLEAVED
//#define XCP_INTERLEAVED_QUEUE_SIZE 16
#define XCP_ENABLE_CHECKSUM // Enable checksum calculation command
#define XCP_ENABLE_CAL_PAGE // Enable cal page switch
/*----------------------------------------------------------------------------*/
/* GET_ID command */
#if OPTION_ENABLE_A2L_GEN
#define XCP_ENABLE_IDT_A2L_UPLOAD // Upload A2L via XCP UPLOAD
#endif
/*----------------------------------------------------------------------------*/
/* DAQ features and parameters */
// #define XCP_ENABLE_DAQ_EVENT_INFO // Enable XCP_GET_EVENT_INFO, if this is enabled, A2L file event information will be ignored
#define XCP_ENABLE_DAQ_EVENT_LIST // Enable event list
#define XCP_MAX_EVENT 256 // Maximum number of events, size of event table
#define XCP_ENABLE_MULTITHREAD_EVENTS // Make XcpEvent thread safe also for same event from different thread
// #define XCP_ENABLE_PACKED_MODE // Enable packed mode emulation
#define XCP_DAQ_MEM_SIZE (5*100) // Amount of memory for DAQ tables, each ODT entry (e.g. measurement variable) needs 5 bytes
// CLOCK_USE_UTC_TIME_NS
// Settings for 64 bit ns since 1.1.1970 TAI clock (CLOCK_USE_UTC_TIME_NS)
#define XCP_DAQ_CLOCK_64BIT // Use 64 Bit time stamps in GET_DAQ_CLOCK
#define XCP_DAQ_CLOCK_UIID { 0xdc,0xa6,0x32,0xFF,0xFE,0x7e,0x66,0xdc }
// Server DAQ clock info (mandatory)
#define XCP_TIMESTAMP_UNIT DAQ_TIMESTAMP_UNIT_1NS // unit DAQ_TIMESTAMP_UNIT_xxx
#define XCP_TIMESTAMP_TICKS 1 // ticks per unit
#define XCP_TIMESTAMP_EPOCH XCP_EPOCH_TAI
// Grandmaster clock (optional, use XcpSetGrandmasterClockInfo, implement ApplXcpGetClockInfoGrandmaster)
// #define XCP_ENABLE_PTP
//#define XCP_ENABLE_DAQ_CLOCK_MULTICAST // Enable GET_DAQ_CLOCK_MULTICAST
#ifdef XCP_ENABLE_DAQ_CLOCK_MULTICAST
// XCP default cluster id (multicast addr 239,255,0,1, group 127,0,1 (mac 01-00-5E-7F-00-01)
#define XCP_MULTICAST_CLUSTER_ID 1
#endif
#define XCP_TIMESTAMP_TICKS_S CLOCK_TICKS_PER_S // ticks per s (for debug output)
//-------------------------------------------------------------------------------
// Debug
// Debug console prints
#if OPTION_ENABLE_DBG_PRINTS
#define XCP_ENABLE_DEBUG_PRINTS
#define XCP_DBG_LEVEL XCP_DEBUG_LEVEL
#endif
// Enable extended error checks, performance penalty !!!
#define XCP_ENABLE_TEST_CHECKS

70
A2lTestDlg/A2lTestDlg/xcptl_cfg.h

@ -0,0 +1,70 @@
#pragma once
/*----------------------------------------------------------------------------
| File:
| xcptl_cfg.h
|
| Description:
| User configuration file for XCP transport layer parameters
|
| Code released into public domain, no attribution required
|
----------------------------------------------------------------------------*/
// Transport layer
#define XCP_TRANSPORT_LAYER_TYPE XCP_TRANSPORT_LAYER_ETH
#define XCP_TRANSPORT_LAYER_VERSION 0x0104
// TCP or/and UDP option enabled
#define XCPTL_ENABLE_TCP
#define XCPTL_ENABLE_UDP
// Transmit mode
#define XCPTL_QUEUED_CRM // Use transmit queue for command responces
/*
Benefits:
- Unique transport layers message counters for CRM and DTO (CANape default transport layer option is "include command response")
- Transmit queue empty before DAQ is stopped (end of measurement consistent for all event channels)
- socketSendTo needs not to be thread safe for a socket
Drawbacks:
- Increased latency for GET_DAQ_CLOCK response during DAQ running, which impacts time sync quality if XCP 1.3 trigger initiator "sampled on reception" is not supported
- Impact on DAQ performance because transport layer packet is flushed for command responses
- DAQ queue overflow can happen on command responses, CANape aborts when response to GET_DAQ_CLOCK is missing
*/
// Transport layer header size
// This is fixed, no other options supported
#define XCPTL_TRANSPORT_LAYER_HEADER_SIZE 4
// TL segment size and DTO size
// Segment size is the maximum data buffer size given to send/sendTo, for UDP it is the MTU
#define XCPTL_MAX_SEGMENT_SIZE (OPTION_MTU-20-8) // UDP MTU (MTU - IP-header - UDP-header)
#define XCPTL_MAX_DTO_SIZE (XCPTL_MAX_SEGMENT_SIZE-XCPTL_TRANSPORT_LAYER_HEADER_SIZE) // Normal ETH frame MTU - IPhdr - UDPhdr- XCPhdr, DTO size must be mod 4
#define XCPTL_PACKET_ALIGNMENT 4 // Packet alignment for multiple XCP transport layer packets in a XCP transport layer message
// CTO size
// Maximum size of a XCP command
#define XCPTL_MAX_CTO_SIZE 252 // must be mod 4
// DAQ transmit queue
// Transmit queue size in segments, should at least be able to hold all data produced until the next call to HandleTransmitQueue
#define XCPTL_QUEUE_SIZE 64 // array[XCPTL_QUEUE_SIZE] of tXcpMessageBuffer (XCPTL_MAX_SEGMENT_SIZE+4)
// Maximum queue trigger event rate
#define XCPTL_QUEUE_TRANSMIT_CYCLE_TIME (1*CLOCK_TICKS_PER_MS)
// Flush cycle
#define XCPTL_QUEUE_FLUSH_CYCLE_MS 50 // Send a DTO packet at least every x ms, XCPTL_TIMEOUT_INFINITE to turn off
// Transport layer header size
// This is fixed, no other options supported
#define XCPTL_TRANSPORT_LAYER_HEADER_SIZE 4
// Multicast (GET_DAQ_CLOCK_MULTICAST)
// Use multicast time synchronisation to improve synchronisation of multiple XCP slaves
// This is standard in XCP V1.3, but it needs to create an additional thread and socket for multicast reception
// Has no benefit with PTP time synchronized slave and is just unnesserary effort
// CANape expects this by default -> adjust setting in device/protocol/event/TIME_CORRELATION_GETDAQCLOCK from "multicast" to "extended response" to switch it of
//#define XCPTL_ENABLE_MULTICAST
#ifdef XCPTL_ENABLE_MULTICAST
#define XCPTL_MULTICAST_PORT 5557
#endif
Loading…
Cancel
Save