@@ -422,6 +422,8 @@ fn main() {
422
422
daq_register_static ! ( static_vars. test_f64, static_event, "Test static f64" ) ;
423
423
424
424
let mut current_session_status = xcp. get_session_status ( ) ;
425
+
426
+ let mut idle_time = 0.0 ;
425
427
while RUN . load ( Ordering :: Acquire ) {
426
428
// @@@@ Dev: Terminate mainloop for shutdown if calibration parameter run is false, for test automation
427
429
if !calseg. run {
@@ -467,11 +469,17 @@ fn main() {
467
469
current_session_status = session_status;
468
470
}
469
471
472
+ // Log idle time
473
+ if !xcp. is_connected ( ) {
474
+ idle_time += calseg. cycle_time_ms as f64 / 1000.0 ;
475
+ } else {
476
+ idle_time = 0.0 ;
477
+ }
470
478
// @@@@ Dev:
471
479
// Finalize A2l after 2s delay
472
- // This is just for testing, to force immediate creation of A2L file
480
+ // This is just for testing, to force creation of A2L file for inspection
473
481
// Without this, the A2L file will be automatically written on XCP connect, to be available for download by CANape
474
- if !xcp . is_connected ( ) && * mainloop_counter2 == ( 2000 / calseg . cycle_time_ms as u16 ) as u64 {
482
+ if idle_time >= 2.0 {
475
483
// Test A2L write
476
484
xcp. write_a2l ( ) ;
477
485
@@ -483,20 +491,11 @@ fn main() {
483
491
}
484
492
485
493
// Terminate after more than 10s disconnected to test shutdown behaviour
486
-
487
- // This is just for testing, to force immediate creation of A2L file
488
- // Without this, the A2L file will be automatically written on XCP connect, to be available for download by CANape
489
- if !xcp. is_connected ( ) {
490
- if * mainloop_counter2 % 200 == 0 {
491
- println ! ( "." ) ;
492
- }
493
- if mainloop_counter1 == ( 10000 / calseg. cycle_time_ms as u16 ) as u64 {
494
- // after 10s when disconnected
495
- thread:: sleep ( Duration :: from_secs ( 2 ) ) ;
496
- break ;
497
- }
494
+ if idle_time >= 10.0 {
495
+ break ;
498
496
}
499
497
}
498
+
500
499
info ! ( "Main task finished" ) ;
501
500
RUN . store ( false , Ordering :: Relaxed ) ;
502
501
0 commit comments