1919#define OPTION_USE_TCP false // TCP or UDP
2020#define OPTION_SERVER_PORT 5555 // Port
2121// #define OPTION_SERVER_ADDR {0, 0, 0, 0} // Bind addr, 0.0.0.0 = ANY
22- // #define OPTION_SERVER_ADDR {127, 0, 0, 1} // Bind addr, 0.0.0.0 = ANY
23- #define OPTION_SERVER_ADDR {172, 19, 13, 239} // Bind addr, 0.0.0.0 = ANY
24- #define OPTION_QUEUE_SIZE 1024 * 32 // Size of the measurement queue in bytes, must be a multiple of 8
22+ #define OPTION_SERVER_ADDR {127, 0, 0, 1} // Bind addr, 0.0.0.0 = ANY
23+ #define OPTION_QUEUE_SIZE 1024 * 32 // Size of the measurement queue in bytes, must be a multiple of 8
2524#define OPTION_LOG_LEVEL 3
2625
2726//-----------------------------------------------------------------------------------------------------
@@ -40,11 +39,6 @@ const params_t params = {.counter_max = 100, .delay_us = 1000, .test_byte1 = -1,
4039
4140//-----------------------------------------------------------------------------------------------------
4241
43- // Global demo measurement variable
44- static uint16_t counter_global = 0 ;
45-
46- //-----------------------------------------------------------------------------------------------------
47-
4842// Demo main
4943int main (void ) {
5044
@@ -83,13 +77,6 @@ int main(void) {
8377 A2lCreateCurve (params .curve , 8 , "" , "" );
8478 A2lCreateMap (params .map , 8 , 8 , "" , "" );
8579
86- // Create a measurement event for global variables
87- uint16_t event_global = XcpCreateEvent ("mainloop_global" , 0 , 0 );
88-
89- // Register global measurement variables
90- A2lSetAbsAddrMode (); // Set absolute addressing
91- A2lCreatePhysMeasurement (counter_global , "Measurement variable" , 1.0 , 0.0 , "counts" );
92-
9380 // Variables on stack
9481 uint8_t counter8 = 0 ;
9582 uint16_t counter16 = 0 ;
@@ -101,18 +88,18 @@ int main(void) {
10188 int64_t counter64s = 0 ;
10289
10390 // Create a measurement event for local variables
104- uint16_t event = XcpCreateEvent ( "mainloop_local" , 0 , 0 );
91+ DaqCreateEvent ( mainloop );
10592
10693 // Register measurement variables located on stack
107- A2lSetDynAddrMode ( & event ); // Set event relative addressing with write access
108- A2lCreatePhysMeasurement (counter8 , "Measurement variable" , 1.0 , 0.0 , "counts " );
109- A2lCreatePhysMeasurement (counter16 , "Measurement variable" , 1.0 , 0.0 , "counts " );
110- A2lCreatePhysMeasurement (counter32 , "Measurement variable" , 1.0 , 0.0 , "counts " );
111- A2lCreatePhysMeasurement (counter64 , "Measurement variable" , 1.0 , 0.0 , "counts " );
112- A2lCreatePhysMeasurement (counter8s , "Measurement variable" , 1.0 , 0.0 , "counts " );
113- A2lCreatePhysMeasurement (counter16s , "Measurement variable" , 1.0 , 0.0 , "counts " );
114- A2lCreatePhysMeasurement (counter32s , "Measurement variable" , 1.0 , 0.0 , "counts " );
115- A2lCreatePhysMeasurement (counter64s , "Measurement variable" , 1.0 , 0.0 , "counts " );
94+ A2lSetStackAddrMode ( mainloop );
95+ A2lCreatePhysMeasurement (counter8 , "Measurement variable" , 1.0 , 0.0 , "" );
96+ A2lCreatePhysMeasurement (counter16 , "Measurement variable" , 1.0 , 0.0 , "" );
97+ A2lCreatePhysMeasurement (counter32 , "Measurement variable" , 1.0 , 0.0 , "" );
98+ A2lCreatePhysMeasurement (counter64 , "Measurement variable" , 1.0 , 0.0 , "" );
99+ A2lCreatePhysMeasurement (counter8s , "Measurement variable" , 1.0 , 0.0 , "" );
100+ A2lCreatePhysMeasurement (counter16s , "Measurement variable" , 1.0 , 0.0 , "" );
101+ A2lCreatePhysMeasurement (counter32s , "Measurement variable" , 1.0 , 0.0 , "" );
102+ A2lCreatePhysMeasurement (counter64s , "Measurement variable" , 1.0 , 0.0 , "" );
116103
117104 // Multidimensional measurements on stack
118105 float curve_f32 [8 ] = {000 , 100 , 200 , 300 , 400 , 500 , 600 , 700 };
@@ -124,9 +111,8 @@ int main(void) {
124111
125112 };
126113
127- A2lSetDynAddrMode (& event ); // Set event relative addressing with write access
128114 A2lCreateMeasurementArray (curve_f32 , "array float[8]" );
129- A2lCreateMeasurementMatrix (map_f32 , "matrix float[8 ][8]" );
115+ A2lCreateMeasurementMatrix (map_f32 , "matrix float[4 ][8]" );
130116
131117 // Create a measurement typedef for the calibration parameter struct
132118 A2lTypedefBegin (params_t , "The calibration parameter struct as measurement typedef" );
@@ -155,10 +141,10 @@ int main(void) {
155141 if (curve_f32 [i ] > 2000 ) {
156142 curve_f32 [i ] = 0 ;
157143 }
158- for (int j = 0 ; j < 8 ; j ++ ) {
159- map_f32 [i ][ j ] += i + j ;
160- if (map_f32 [i ][ j ] > 2000 ) {
161- map_f32 [i ][ j ] = 0 ;
144+ for (int j = 0 ; j < 4 ; j ++ ) {
145+ map_f32 [j ][ i ] += i + j ;
146+ if (map_f32 [j ][ i ] > 2000 ) {
147+ map_f32 [j ][ i ] = 0 ;
162148 }
163149 }
164150 }
@@ -187,12 +173,8 @@ int main(void) {
187173 // Unlock the calibration segment
188174 XcpUnlockCalSeg (calseg );
189175
190- // Global variable
191- counter_global = counter16 ;
192-
193- // Trigger measurement events
194- XcpEventDyn (& event ); // For local variables
195- XcpEvent (event_global ); // For global variables
176+ // Trigger the measurement event
177+ DaqEvent (mainloop );
196178
197179 // Check server status
198180 if (!XcpEthServerStatus ()) {
@@ -202,7 +184,7 @@ int main(void) {
202184
203185 A2lFinalize (); // Optional: Finalize the A2L file generation early, to write the A2L now, not when the client connects
204186
205- } // for(;;)
187+ } // for (;;)
206188
207189 // Force disconnect the XCP client
208190 XcpDisconnect ();
0 commit comments