Skip to content

Commit

Permalink
Sync with xcp-lite
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerZ committed Nov 11, 2024
1 parent 83b343d commit d43faa4
Show file tree
Hide file tree
Showing 40 changed files with 1,696 additions and 1,122 deletions.
2 changes: 1 addition & 1 deletion CPP_Demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ project(CPP_Demo VERSION 6.0 LANGUAGES CXX)

set(CPP_Demo_SOURCES
main.cpp
../src/xcpAppl.c ../src/xcp.cpp ../src/xcpLite.c ../src/xcpEthTl.c ../src/xcpEthServer.c ../src/A2L.c ../src/A2Lpp.cpp ../src/platform.c ../src/options.c
../src/xcpAppl.c ../src/xcp.cpp ../src/xcpLite.c ../src/xcpEthServer.c ../src/xcpEthTl.c ../src/xcpTl.c ../src/xcpTlQueue.c ../src/A2L.c ../src/A2Lpp.cpp ../src/platform.c ../src/options.c
)

# compile *.c as C++
Expand Down
133 changes: 133 additions & 0 deletions CPP_Demo/C_Demo.a2l
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
ASAP2_VERSION 1 71
/begin PROJECT CPP_DEMO ""
/begin HEADER "" VERSION "1.0" /end HEADER
/begin MODULE CPP_DEMO ""
/include "XCP_104.aml"

/begin MOD_COMMON ""
BYTE_ORDER MSB_LAST
ALIGNMENT_BYTE 1
ALIGNMENT_WORD 1
ALIGNMENT_LONG 1
ALIGNMENT_FLOAT16_IEEE 1
ALIGNMENT_FLOAT32_IEEE 1
ALIGNMENT_FLOAT64_IEEE 1
ALIGNMENT_INT64 1
/end MOD_COMMON

/begin RECORD_LAYOUT R_FLOAT64_IEEE FNC_VALUES 1 FLOAT64_IEEE ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_FLOAT64_IEEE "" FLOAT64_IEEE NO_COMPU_METHOD 0 0 -1E12 1E12 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_FLOAT64_IEEE "" VALUE R_FLOAT64_IEEE 0 NO_COMPU_METHOD -1E12 1E12 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_FLOAT32_IEEE FNC_VALUES 1 FLOAT32_IEEE ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_FLOAT32_IEEE "" FLOAT32_IEEE NO_COMPU_METHOD 0 0 -1E12 1E12 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_FLOAT32_IEEE "" VALUE R_FLOAT32_IEEE 0 NO_COMPU_METHOD -1E12 1E12 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_A_INT64 FNC_VALUES 1 A_INT64 ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_A_INT64 "" A_INT64 NO_COMPU_METHOD 0 0 -1E12 1E12 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_A_INT64 "" VALUE R_A_INT64 0 NO_COMPU_METHOD -1E12 1E12 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_SLONG FNC_VALUES 1 SLONG ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_SLONG "" SLONG NO_COMPU_METHOD 0 0 -2147483648 2147483647 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_SLONG "" VALUE R_SLONG 0 NO_COMPU_METHOD -2147483648 2147483647 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_SWORD FNC_VALUES 1 SWORD ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_SWORD "" SWORD NO_COMPU_METHOD 0 0 -32768 32767 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_SWORD "" VALUE R_SWORD 0 NO_COMPU_METHOD -32768 32767 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_SBYTE FNC_VALUES 1 SBYTE ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_SBYTE "" SBYTE NO_COMPU_METHOD 0 0 -128 127 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_SBYTE "" VALUE R_SBYTE 0 NO_COMPU_METHOD -128 127 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_UBYTE FNC_VALUES 1 UBYTE ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_UBYTE "" UBYTE NO_COMPU_METHOD 0 0 0 255 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_UBYTE "" VALUE R_UBYTE 0 NO_COMPU_METHOD 0 255 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_UWORD FNC_VALUES 1 UWORD ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_UWORD "" UWORD NO_COMPU_METHOD 0 0 0 65535 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_UWORD "" VALUE R_UWORD 0 NO_COMPU_METHOD 0 65535 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_ULONG FNC_VALUES 1 ULONG ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_ULONG "" ULONG NO_COMPU_METHOD 0 0 0 4294967295 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_ULONG "" VALUE R_ULONG 0 NO_COMPU_METHOD 0 4294967295 /end TYPEDEF_CHARACTERISTIC
/begin RECORD_LAYOUT R_A_UINT64 FNC_VALUES 1 A_UINT64 ROW_DIR DIRECT /end RECORD_LAYOUT
/begin TYPEDEF_MEASUREMENT M_A_UINT64 "" A_UINT64 NO_COMPU_METHOD 0 0 0 1E12 /end TYPEDEF_MEASUREMENT
/begin TYPEDEF_CHARACTERISTIC C_A_UINT64 "" VALUE R_A_UINT64 0 NO_COMPU_METHOD 0 1E12 /end TYPEDEF_CHARACTERISTIC

/begin TYPEDEF_STRUCTURE sSignalParameters "This is the global signal parameters structure type" 0x18 SYMBOL_TYPE_LINK "sSignalParameters"
/begin STRUCTURE_COMPONENT ampl C_FLOAT64_IEEE 0x0 SYMBOL_TYPE_LINK "ampl" /end STRUCTURE_COMPONENT
/begin STRUCTURE_COMPONENT offset C_FLOAT64_IEEE 0x8 SYMBOL_TYPE_LINK "offset" /end STRUCTURE_COMPONENT
/begin STRUCTURE_COMPONENT phase C_FLOAT64_IEEE 0x10 SYMBOL_TYPE_LINK "phase" /end STRUCTURE_COMPONENT
/end TYPEDEF_STRUCTURE
/begin INSTANCE gSignalParameters "This is the global signal parameters structure instance" sSignalParameters 0x4CA4000 /end INSTANCE
/begin CHARACTERISTIC gPeriod "Period of sinus signal in s" VALUE 0x4CA4018 R_FLOAT64_IEEE 0 NO_COMPU_METHOD 0 10 PHYS_UNIT "s" SYMBOL_LINK "gPeriod" 0 /end CHARACTERISTIC
/begin CHARACTERISTIC gCycleTime "Cycle time of demo event loop in us" VALUE 0x4CA4020 R_SLONG 0 NO_COMPU_METHOD 0 1e+06 PHYS_UNIT "us" SYMBOL_LINK "gCycleTime" 0 /end CHARACTERISTIC
/begin CHARACTERISTIC gDebugLevel "Console output verbosity level" VALUE 0x4CA4024 R_SBYTE 0 NO_COMPU_METHOD -128 127 SYMBOL_LINK "gDebugLevel" 0 /end CHARACTERISTIC
/begin COMPU_METHOD gChannel1.Conversion "" LINEAR "%6.3" "V" COEFFS_LINEAR 1 0 /end COMPU_METHOD
/begin MEASUREMENT gChannel1 "Sinus signal as double with physical conversion rule" FLOAT64_IEEE gChannel1.Conversion 0 0 -1000000000000.0000 1000000000000.00000 ECU_ADDRESS 0x4CA4038 PHYS_UNIT "V" READ_WRITE SYMBOL_LINK "gChannel1" 0 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x0 /end DAQ_EVENT /end IF_DATA /end MEASUREMENT
/begin COMPU_METHOD gCounter.Conversion "" LINEAR "%6.3" "" COEFFS_LINEAR 1 0 /end COMPU_METHOD
/begin MEASUREMENT gCounter "Event counter as uint32" SWORD gCounter.Conversion 0 0 -32768.000000 32767.000000 ECU_ADDRESS 0x4CA4040 READ_WRITE SYMBOL_LINK "gCounter" 0 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x0 /end DAQ_EVENT /end IF_DATA /end MEASUREMENT
/begin INSTANCE SigGen1 "" SigGen 0x10000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x1 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen2 "" SigGen 0x20000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x2 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen3 "" SigGen 0x30000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x3 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen4 "" SigGen 0x40000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x4 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen5 "" SigGen 0x50000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x5 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen6 "" SigGen 0x60000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x6 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen7 "" SigGen 0x70000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x7 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen8 "" SigGen 0x80000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x8 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen9 "" SigGen 0x90000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0x9 /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin INSTANCE SigGen10 "" SigGen 0xA0000 ECU_ADDRESS_EXTENSION 1 /begin IF_DATA XCP /begin DAQ_EVENT FIXED_EVENT_LIST EVENT 0xA /end DAQ_EVENT /end IF_DATA /end INSTANCE
/begin TYPEDEF_STRUCTURE SigGen "" 0x48 SYMBOL_TYPE_LINK "SigGen"
/begin STRUCTURE_COMPONENT xcpInstanceId M_SWORD 0x14 SYMBOL_TYPE_LINK "xcpInstanceId" /end STRUCTURE_COMPONENT
/begin STRUCTURE_COMPONENT value M_FLOAT64_IEEE 0x38 SYMBOL_TYPE_LINK "value" /end STRUCTURE_COMPONENT
/begin STRUCTURE_COMPONENT par_ampl C_FLOAT64_IEEE 0x20 SYMBOL_TYPE_LINK "par_ampl" /end STRUCTURE_COMPONENT
/begin STRUCTURE_COMPONENT par_phase C_FLOAT64_IEEE 0x28 SYMBOL_TYPE_LINK "par_phase" /end STRUCTURE_COMPONENT
/begin STRUCTURE_COMPONENT par_offset C_FLOAT64_IEEE 0x30 SYMBOL_TYPE_LINK "par_offset" /end STRUCTURE_COMPONENT
/end TYPEDEF_STRUCTURE

/begin IF_DATA XCP
/begin PROTOCOL_LAYER
0x0104 1000 2000 0 0 0 0 0 248 1468 BYTE_ORDER_MSB_LAST ADDRESS_GRANULARITY_BYTE
OPTIONAL_CMD GET_COMM_MODE_INFO
OPTIONAL_CMD GET_ID
OPTIONAL_CMD SET_MTA
OPTIONAL_CMD UPLOAD
OPTIONAL_CMD SHORT_UPLOAD
OPTIONAL_CMD DOWNLOAD
OPTIONAL_CMD SHORT_DOWNLOAD
OPTIONAL_CMD GET_CAL_PAGE
OPTIONAL_CMD SET_CAL_PAGE
OPTIONAL_CMD BUILD_CHECKSUM
OPTIONAL_CMD GET_DAQ_RESOLUTION_INFO
OPTIONAL_CMD GET_DAQ_PROCESSOR_INFO
OPTIONAL_CMD FREE_DAQ
OPTIONAL_CMD ALLOC_DAQ
OPTIONAL_CMD ALLOC_ODT
OPTIONAL_CMD ALLOC_ODT_ENTRY
OPTIONAL_CMD SET_DAQ_PTR
OPTIONAL_CMD WRITE_DAQ
OPTIONAL_CMD GET_DAQ_LIST_MODE
OPTIONAL_CMD SET_DAQ_LIST_MODE
OPTIONAL_CMD START_STOP_SYNCH
OPTIONAL_CMD START_STOP_DAQ_LIST
OPTIONAL_CMD GET_DAQ_CLOCK
OPTIONAL_CMD WRITE_DAQ_MULTIPLE
OPTIONAL_CMD TIME_CORRELATION_PROPERTIES
OPTIONAL_LEVEL1_CMD GET_VERSION
/end PROTOCOL_LAYER
/begin DAQ
DYNAMIC 0 11 0 OPTIMISATION_TYPE_DEFAULT ADDRESS_EXTENSION_FREE IDENTIFICATION_FIELD_TYPE_RELATIVE_BYTE GRANULARITY_ODT_ENTRY_SIZE_DAQ_BYTE 0xF8 OVERLOAD_INDICATION_PID
/begin TIMESTAMP_SUPPORTED
0x01 SIZE_DWORD UNIT_1NS TIMESTAMP_FIXED
/end TIMESTAMP_SUPPORTED
/begin EVENT "mainLoop" "mainLoop" 0x0 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen1" "SigGen1" 0x1 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen2" "SigGen2" 0x2 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen3" "SigGen3" 0x3 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen4" "SigGen4" 0x4 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen5" "SigGen5" 0x5 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen6" "SigGen6" 0x6 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen7" "SigGen7" 0x7 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen8" "SigGen8" 0x8 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen9" "SigGen9" 0x9 DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/begin EVENT "SigGen10" "SigGen10" 0xA DAQ 0xFF 0 0 0 CONSISTENCY EVENT /end EVENT
/end DAQ
/begin XCP_ON_UDP_IP
0x0104 5555 ADDRESS "127.0.0.1"
/end XCP_ON_UDP_IP
/end IF_DATA

/end MODULE
/end PROJECT
16 changes: 8 additions & 8 deletions CPP_Demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ uint32_t gCycleTime = 10000; // us



#if OPTION_ENABLE_DYNAMIC_DEMO
#ifdef OPTION_ENABLE_DYNAMIC_DEMO

//-----------------------------------------------------------------------------------------------------
// Demo
Expand All @@ -69,7 +69,7 @@ class SigGen : public XcpObject {
protected:

// Create A2L desription of this instance
#if OPTION_ENABLE_A2L_GEN
#ifdef OPTION_ENABLE_A2L_GEN
virtual void xcpCreateA2lTypedefComponents(A2L* a2l) {
a2l->createDynTypedefMeasurementComponent(value);
a2l->createDynTypedefParameterComponent(par_ampl);
Expand Down Expand Up @@ -144,11 +144,11 @@ int main(int argc, char* argv[]) {

// A2L generation (optional)
// Declare all measurement variable and calibration parameters
#if OPTION_ENABLE_A2L_GEN
#ifdef OPTION_ENABLE_A2L_GEN
A2L* a2l = xcp->createA2L("CPP_DEMO");

// Declare calibration parameters in global address space
a2l->createTypedefBegin(gSignalParameters, "This is the global signal parameters structure type"); // global struct signal_parameters signal_parameters
a2l->createTypedefBegin(sSignalParameters, "This is the global signal parameters structure type"); // global struct signal_parameters signal_parameters
a2l->createTypedefParameterComponent(gSignalParameters,ampl);
a2l->createTypedefParameterComponent(gSignalParameters,offset);
a2l->createTypedefParameterComponent(gSignalParameters,phase);
Expand All @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) {
// a2l->createParameterWithLimits(gSignalParameters.phase, "Phase of sinus signal in s", "s", 0, 10); // global signal_parameters.phase, this is an alternative way to define components of global structs
a2l->createParameterWithLimits(gPeriod, "Period of sinus signal in s", "s", 0, 10); // global double period
a2l->createParameterWithLimits(gCycleTime, "Cycle time of demo event loop in us", "us", 0, 1000000); // global uint32_t cycleTime
#if OPTION_ENABLE_DBG_PRINTS
#ifdef OPTION_ENABLE_DBG_PRINTS
a2l->createParameter(gDebugLevel, "Console output verbosity level", ""); // Create a calibration parameter to control the debug output verbosity
#endif
// Declare measurement variables in global address space
Expand All @@ -167,7 +167,7 @@ int main(int argc, char* argv[]) {
#endif // OPTION_ENABLE_A2L_GEN

//Demo: Measure and calibrate multiple instances of a class (optional)
#if OPTION_ENABLE_DYNAMIC_DEMO
#ifdef OPTION_ENABLE_DYNAMIC_DEMO

// Create 10 different SigGen sine signal generator task instances with calibration parameters and dynamic addressing
// The constructor of SigGen will create an instance and an associated XCP event for each
Expand All @@ -178,14 +178,14 @@ int main(int argc, char* argv[]) {
}

// Create A2L description for class SigGen, use any instance to do this, function can't be static
#if OPTION_ENABLE_A2L_GEN
#ifdef OPTION_ENABLE_A2L_GEN
sigGen[0]->xcpCreateA2lTypedef();
#endif

#endif // OPTION_ENABLE_DYNAMIC_DEMO

// Optional: Finalize and close A2l, this would be done automatic on XCP connect, to make the A2L file immediately available, its done explicitly here
#if OPTION_ENABLE_A2L_GEN
#ifdef OPTION_ENABLE_A2L_GEN
xcp->closeA2L();
#endif // OPTION_ENABLE_A2L_GEN

Expand Down
84 changes: 58 additions & 26 deletions CPP_Demo/main_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,74 @@
// Application configuration:
// XCP configuration is in xcp_cfg.h (Protocol Layer) and xcptl_cfg.h (Transport Layer)

#define ON 1
#define OFF 0

// Set clock resolution (for clock function in platform.c)
#define CLOCK_USE_APP_TIME_US
//#define CLOCK_USE_UTC_TIME_NS

// Platform options
#define PLATFORM_ENABLE_GET_LOCAL_ADDR
#define PLATFORM_ENABLE_KEYBOARD
// Application configuration:
// XCP configuration is in xcp_cfg.h (Protocol Layer) and xcptl_cfg.h (Transport Layer)

// Ethernet Server
// TCP or/and UDP server enabled
#define XCPTL_ENABLE_TCP
#define XCPTL_ENABLE_UDP
#define XCP_SERVER_FORCEFULL_TERMINATION // Otherwise use gracefull server thread termination in xcplib

// Enable C++ class wrapper
#define OPTION_ENABLE_XCP_CLASS ON
#define OPTION_ENABLE_XCP_CLASS

// Enable demo how to measure dynamic instances
#define OPTION_ENABLE_DYNAMIC_DEMO ON
#define OPTION_ENABLE_DYNAMIC_DEMO

// 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


/*
XCP library build options:
// Logging
#define OPTION_ENABLE_DBG_PRINTS Enable debug prints
#define OPTION_DEFAULT_DBG_LEVEL Default log level: 1 - Error, 2 - Warn, 3 - Info, 4 - Trace, 5 - Debug
// Clock
#define OPTION_CLOCK_EPOCH_ARB Arbitrary epoch or since 1.1.1970
#define OPTION_CLOCK_EPOCH_PTP
#define OPTION_CLOCK_TICKS_1NS Resolution 1ns or 1us, granularity depends on platform
#define OPTION_CLOCK_TICKS_1US
// XCP
#define OPTION_ENABLE_TCP
#define OPTION_ENABLE_UDP
#define OPTION_MTU UDP MTU
#define OPTION_QUEUE_SIZE Size of the DAQ queue in XCP DTO/CRM packets (not messages as in V1.x)
#define OPTION_DAQ_MEM_SIZE Size of memory for DAQ setup in bytes
#define OPTION_ENABLE_A2L_UPLOAD Enable GET_ID A2L upload
*/

// Ethernet Transport Layer
#define OPTION_USE_TCP OFF
#define OPTION_ENABLE_UDP
// #define OPTION_ENABLE_TCP
#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

#if defined(_LINUX) && !defined(_MACOS)
#define XCP_SERVER_FORCEFULL_TERMINATION // @@@@
#endif

// Platform options
#define PLATFORM_ENABLE_GET_LOCAL_ADDR
#define PLATFORM_ENABLE_KEYBOARD

// Clock
#define OPTION_CLOCK_EPOCH_ARB
#define OPTION_CLOCK_TICKS_1NS // OPTION_CLOCK_TICKS_1NS or OPTION_CLOCK_TICKS_1US

// Enable demo how to create a calibration segment with page switching
// #define OPTION_ENABLE_CAL_SEGMENT

// Enable A2L generation and upload
#define OPTION_ENABLE_A2L_GEN // Enable A2L generation
#define OPTION_ENABLE_A2L_UPLOAD
#ifdef OPTION_ENABLE_A2L_GEN
#define OPTION_A2L_NAME "C_Demo" // A2L name
#define OPTION_A2L_FILE_NAME "C_Demo.a2l" // A2L filename
#endif

// Debug prints
#define OPTION_ENABLE_DBG_PRINTS ON
#define OPTION_DEBUG_LEVEL 3 // 1 - Error, 2 - Warn, 3 - Info, 4 - Trace, 5 - Debug
#define OPTION_ENABLE_DBG_PRINTS
#define OPTION_DEFAULT_DBG_LEVEL 4 // 1 - Error, 2 - Warn, 3 - Info, 4 - Trace, 5 - Debug



29 changes: 11 additions & 18 deletions CPP_Demo/xcp_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@
// Driver version (GET_COMM_MODE_INFO)
#define XCP_DRIVER_VERSION 0x01

// Enable Ethernet specific protocol layer commands
#define XCP_ENABLE_PROTOCOL_LAYER_ETH

// 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
// #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


/*----------------------------------------------------------------------------*/
/* Adress, address extension coding */

// Use addr_ext XCP_ADDR_EXT_ABS to indicate absulute addr format (ApplXcpGetBaseAddr()+(uint32_t)addr)
#define XCP_ENABLE_ABS_ADDRESSING
#define XCP_ADDR_EXT_ABS 0x01 // Absolute address format
#define XCP_ADDR_EXT_ABS 0x00 // Absolute address format

// Use addr_ext XCP_ADDR_EXT_DYN to indicate relative addr format (event<<16)|offset
#if OPTION_ENABLE_XCP_CLASS
#ifdef OPTION_ENABLE_XCP_CLASS
#define XCP_ENABLE_DYN_ADDRESSING
#define XCP_ADDR_EXT_DYN 0x02 // Relative address format
#endif
Expand Down Expand Up @@ -66,7 +69,7 @@
/*----------------------------------------------------------------------------*/
/* GET_ID command */

#if OPTION_ENABLE_A2L_GEN
#ifdef OPTION_ENABLE_A2L_GEN
#define XCP_ENABLE_IDT_A2L_UPLOAD // Upload A2L via XCP UPLOAD
#endif

Expand All @@ -75,7 +78,7 @@

// #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_MAX_EVENT_COUNT 16 // 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

Expand Down Expand Up @@ -108,18 +111,8 @@
//-------------------------------------------------------------------------------
// Debug

// Debug console prints
#if !defined(OPTION_ENABLE_DBG_PRINTS) || !defined(OPTION_DEBUG_LEVEL)
#warning "Please define OPTION_ENABLE_DBG_PRINTS and OPTION_DEBUG_LEVEL in main_cfg.h to ON or OFF"
#else
#if OPTION_ENABLE_DBG_PRINTS
#define XCP_ENABLE_DEBUG_PRINTS
#define XCP_DBG_LEVEL OPTION_DEBUG_LEVEL
#else
#undef XCP_ENABLE_DEBUG_PRINTS
#undef XCP_DBG_LEVEL OPTION_DEBUG_LEVEL
#endif
#endif
// Enable logging
#define OPTION_ENABLE_DBG_PRINTS

// Enable extended error checks, performance penalty !!!
#define XCP_ENABLE_TEST_CHECKS
Expand Down
Loading

0 comments on commit d43faa4

Please sign in to comment.