-void dlt_daemon_timingpacket_thread(void *ptr)
-{
- DltDaemonPeriodicData info;
- int j;
-
- DltDaemonTimingPacketThreadData *data;
- DltDaemon *daemon;
- DltDaemonLocal *daemon_local;
-
- if (ptr==0)
- {
- dlt_log(LOG_ERR, "No data pointer passed to timingpacket thread\n");
- return;
- }
-
- data = (DltDaemonTimingPacketThreadData*)ptr;
- daemon = data->daemon;
- daemon_local = data->daemon_local;
-
- if ((daemon==0) || (daemon_local==0))
- {
- dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_timingpacket_thread()");
- return;
- }
-
- if (dlt_daemon_make_periodic (1000000, &info, daemon_local->flags.vflag)<0)
- {
- dlt_log(LOG_CRIT,"Can't initialize thread timer!\n");
- return;
- }
-
- while (1)
- {
- /* If enabled, send timing packets to all clients */
- if (daemon->timingpackets)
- {
- for (j = 0; j <= daemon_local->fdmax; j++)
- {
- /* send to everyone! */
- if (FD_ISSET(j, &(daemon_local->master)))
- {
- /* except the listener and ourselves */
- if ((j != daemon_local->fp) && (j != daemon_local->sock))
- {
- dlt_daemon_control_message_time(j, daemon, daemon_local->flags.vflag);
- }
- }
- }
- }
- /* Wait for next period */
- dlt_daemon_wait_period (&info, daemon_local->flags.vflag);
- }
-}
-
-void dlt_daemon_ecu_version_thread(void *ptr)
-{
- DltDaemonECUVersionThreadData *data = (DltDaemonECUVersionThreadData *)ptr;
- DltDaemonPeriodicData info;
- const unsigned int DLT_ECU_VERSION_PERIOD_TIME = 1000000*60; // 60 Seconds
-
- if (dlt_daemon_make_periodic (DLT_ECU_VERSION_PERIOD_TIME, &info, data->daemon_local->flags.vflag)<0)
- {
- dlt_log(LOG_CRIT,"Can't initialize thread timer!\n");
- return;
- }
-
- while(1)
- {
- int i;
- for (i = 0; i <= data->daemon_local->fdmax; i++)
- {
- /* send to everyone! */
- if (FD_ISSET(i, &(data->daemon_local->master)))
- {
- /* except the listener and ourselves */
- if ((i != data->daemon_local->fp) && (i != data->daemon_local->sock))
- {
- dlt_daemon_control_get_software_version(i, data->daemon, data->daemon_local->flags.vflag);
- }
- }
- }
- dlt_daemon_wait_period (&info, data->daemon_local->flags.vflag);
- }
-}
-
-#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
-void dlt_daemon_systemd_watchdog_thread(void *ptr)
-{
- char *watchdogUSec;
- int watchdogTimeoutSeconds;
- int notifyPeriodNSec;
- DltDaemonPeriodicData info;
- DltDaemonTimingPacketThreadData *data;
- DltDaemon *daemon;
- DltDaemonLocal *daemon_local;
- static uint32_t lastDaemonOperation;
-
- if (ptr==0)
- {
- dlt_log(LOG_ERR, "No data pointer passed to systemd watchdog thread\n");
- return;
- }
-
- data = (DltDaemonTimingPacketThreadData*)ptr;
- daemon = data->daemon;
- daemon_local = data->daemon_local;
-
- if ((daemon==0) || (daemon_local==0))
- {
- dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_timingpacket_thread()");
- return;
- }
-
- watchdogUSec = getenv("WATCHDOG_USEC");
-
- if(watchdogUSec)
- {
- watchdogTimeoutSeconds = atoi(watchdogUSec);
- // Calculate half of WATCHDOG_USEC in ns for timer tick
- notifyPeriodNSec = watchdogTimeoutSeconds / 2 ;
-
- if( notifyPeriodNSec > 0 )
- {
- sprintf(str,"systemd watchdog timeout: %i nsec - timer will be initialized: %i nsec\n", watchdogTimeoutSeconds, notifyPeriodNSec );
- dlt_log(LOG_INFO, str);
-
- if (dlt_daemon_make_periodic (notifyPeriodNSec, &info, daemon_local->flags.vflag)<0)
- {
- dlt_log(LOG_CRIT, "Could not initialize systemd watchdog timer");
- return;
- }
-
- while (1)
- {
- /* If main thread has changed its last operation time, reset watchdog */
- if(daemon_local->lastOperationTime != lastDaemonOperation)
- {
- if(sd_notify(0, "WATCHDOG=1") < 0)
- {
- dlt_log(LOG_CRIT, "Could not reset systemd watchdog\n");
- }
- lastDaemonOperation = daemon_local->lastOperationTime;
- }
-
- /* Wait for next period */
- dlt_daemon_wait_period (&info, daemon_local->flags.vflag);
- }
- }
- else
- {
- sprintf(str,"systemd watchdog timeout incorrect: %i\n", watchdogTimeoutSeconds);
- dlt_log(LOG_CRIT, str);
- }
- }
- else
- {
- dlt_log(LOG_CRIT, "systemd watchdog timeout (WATCHDOG_USEC) is null!\n");
- }
-}
-#endif
-