*/
int dlt_user_check_buffer(int *total_size, int *used_size);
+/**
+ * Try to resend log message in the user buffer. Stops if the dlt_uptime is bigger than
+ * dlt_uptime() + DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT. A pause between the resending
+ * attempts can be defined with DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP
+ * @return number of messages in the user buffer
+ */
+int dlt_user_atexit_blow_out_user_buffer(void);
+
#ifdef __cplusplus
}
#endif
void dlt_user_atexit_handler(void)
{
+
+ /* Try to resend potential log messages in the user buffer */
+ int count = dlt_user_atexit_blow_out_user_buffer();
+
+ if(count != 0){
+ char tmp[256];
+ sprintf(&tmp,"Lost log messages in user buffer when exiting: %i\n",count);
+ dlt_log(LOG_ERR, tmp);
+ }
+
/* Unregister app (this also unregisters all contexts in daemon) */
/* Ignore return value */
dlt_unregister_app();
dlt_free();
}
+int dlt_user_atexit_blow_out_user_buffer(void){
+
+ int count,ret;
+
+ uint32_t exitTime = dlt_uptime() + DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT;
+
+ while(dlt_uptime() < exitTime ){
+
+ ret = dlt_user_log_resend_buffer();
+
+ if(ret == 0)
+ {
+ return 0;
+ }
+
+ usleep(DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP);
+ }
+
+ DLT_SEM_LOCK();
+ count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+ DLT_SEM_FREE();
+
+ return count;
+}
+
int dlt_free(void)
{
int i;
/* Name of environment variable for local print mode */\r
#define DLT_USER_ENV_LOCAL_PRINT_MODE "DLT_LOCAL_PRINT_MODE"\r
\r
+/* Timeout offset for resending user buffer at exit in usec (1000 usec = 1ms)*/\r
+#define DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT 100000\r
+\r
+/* Sleeps between resending user buffer at exit in usec (1000 usec = 1ms)*/\r
+#define DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP 1000\r
+\r
+\r
/************************/\r
/* Don't change please! */\r
/************************/\r