Added configure switch --disable-rt-syslog.
--- a/configure.ac Mon Oct 21 19:16:48 2013 +0200
+++ b/configure.ac Mon Oct 21 19:27:50 2013 +0200
@@ -932,6 +932,35 @@
fi
#------------------------------------------------------------------------------
+# syslog output in realtime context
+#------------------------------------------------------------------------------
+
+AC_MSG_CHECKING([whether to syslog in realtime context])
+
+AC_ARG_ENABLE([rt-syslog],
+ AS_HELP_STRING([--enable-rt-syslog],
+ [Enable RT syslog (default: yes)]),
+ [
+ case "${enableval}" in
+ yes) rtsyslog=1
+ ;;
+ no) rtsyslog=0
+ ;;
+ *) AC_MSG_ERROR([Invalid value for --enable-rt-syslog])
+ ;;
+ esac
+ ],
+ [rtsyslog=1]
+)
+
+if test "x${rtsyslog}" = "x1"; then
+ AC_DEFINE([EC_RT_SYSLOG], [1], [Output to syslog in RT context])
+ AC_MSG_RESULT([yes])
+else
+ AC_MSG_RESULT([no])
+fi
+
+#------------------------------------------------------------------------------
AC_CONFIG_FILES([
Doxyfile
--- a/master/domain.c Mon Oct 21 19:16:48 2013 +0200
+++ b/master/domain.c Mon Oct 21 19:27:50 2013 +0200
@@ -466,7 +466,10 @@
ec_fmmu_config_t, list);
unsigned int redundancy;
#endif
- unsigned int dev_idx, wc_change;
+ unsigned int dev_idx;
+#ifdef EC_RT_SYSLOG
+ unsigned int wc_change;
+#endif
#if DEBUG_REDUNDANCY
EC_MASTER_DBG(domain->master, 1, "domain %u process\n", domain->index);
@@ -569,6 +572,7 @@
redundancy = redundant_wc > 0;
if (redundancy != domain->redundancy_active) {
+#ifdef EC_RT_SYSLOG
if (redundancy) {
EC_MASTER_WARN(domain->master,
"Domain %u: Redundant link in use!\n",
@@ -578,23 +582,29 @@
"Domain %u: Redundant link unused again.\n",
domain->index);
}
+#endif
domain->redundancy_active = redundancy;
}
#else
domain->redundancy_active = 0;
#endif
+#ifdef EC_RT_SYSLOG
wc_change = 0;
+#endif
wc_total = 0;
for (dev_idx = EC_DEVICE_MAIN;
dev_idx < ec_master_num_devices(domain->master); dev_idx++) {
if (wc_sum[dev_idx] != domain->working_counter[dev_idx]) {
+#ifdef EC_RT_SYSLOG
wc_change = 1;
+#endif
domain->working_counter[dev_idx] = wc_sum[dev_idx];
}
wc_total += wc_sum[dev_idx];
}
+#ifdef EC_RT_SYSLOG
if (wc_change) {
domain->working_counter_changes++;
}
@@ -630,6 +640,7 @@
domain->working_counter_changes = 0;
}
+#endif
}
/*****************************************************************************/
--- a/master/master.c Mon Oct 21 19:16:48 2013 +0200
+++ b/master/master.c Mon Oct 21 19:27:50 2013 +0200
@@ -852,9 +852,13 @@
> ext_injection_timeout_jiffies)
#endif
{
+#if defined EC_RT_SYSLOG || DEBUG_INJECT
unsigned int time_us;
+#endif
datagram->state = EC_DATAGRAM_ERROR;
+
+#if defined EC_RT_SYSLOG || DEBUG_INJECT
#ifdef EC_HAVE_CYCLES
time_us = (unsigned int)
((cycles_now - datagram->cycles_sent) * 1000LL)
@@ -867,6 +871,7 @@
" external datagram %s size=%zu,"
" max_queue_size=%zu\n", time_us, datagram->name,
datagram->data_size, master->max_queue_size);
+#endif
}
else {
#if DEBUG_INJECT
@@ -944,8 +949,10 @@
list_for_each_entry(queued_datagram, &master->datagram_queue, queue) {
if (queued_datagram == datagram) {
datagram->skip_count++;
+#ifdef EC_RT_SYSLOG
EC_MASTER_DBG(master, 1,
"Datagram %p already queued (skipping).\n", datagram);
+#endif
datagram->state = EC_DATAGRAM_QUEUED;
return;
}
@@ -1132,7 +1139,9 @@
ec_print_data(frame_data, size);
}
master->stats.corrupted++;
+#ifdef EC_RT_SYSLOG
ec_master_output_stats(master);
+#endif
return;
}
@@ -1151,7 +1160,9 @@
ec_print_data(frame_data, size);
}
master->stats.corrupted++;
+#ifdef EC_RT_SYSLOG
ec_master_output_stats(master);
+#endif
return;
}
@@ -1173,7 +1184,9 @@
ec_print_data(frame_data, size);
}
master->stats.corrupted++;
+#ifdef EC_RT_SYSLOG
ec_master_output_stats(master);
+#endif
return;
}
@@ -1192,7 +1205,9 @@
// no matching datagram was found
if (!matched) {
master->stats.unmatched++;
+#ifdef EC_RT_SYSLOG
ec_master_output_stats(master);
+#endif
if (unlikely(master->debug_level > 0)) {
EC_MASTER_DBG(master, 0, "UNMATCHED datagram:\n");
@@ -2485,6 +2500,8 @@
list_del_init(&datagram->queue);
datagram->state = EC_DATAGRAM_TIMED_OUT;
master->stats.timeouts++;
+
+#ifdef EC_RT_SYSLOG
ec_master_output_stats(master);
if (unlikely(master->debug_level > 0)) {
@@ -2502,6 +2519,7 @@
" index %02X waited %u us.\n",
datagram, datagram->index, time_us);
}
+#endif /* RT_SYSLOG */
}
}
}