Zyklische Ausgaben um "Verzögerte" Rahmen erweitert.
This commit is contained in:
parent
eadaf72e40
commit
a84b1adce5
|
|
@ -279,7 +279,7 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom
|
|||
frame = &domain->frame;
|
||||
working_counter_sum = 0;
|
||||
|
||||
ec_output_lost_frames(master); // Evtl. verlorene Frames ausgeben
|
||||
ec_cyclic_output(master);
|
||||
|
||||
rdtscl(start_ticks); // Sendezeit nehmen
|
||||
timeout_ticks = domain->timeout_us * cpu_khz / 1000;
|
||||
|
|
@ -309,10 +309,16 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom
|
|||
master->bus_time = (end_ticks - start_ticks) * 1000 / cpu_khz;
|
||||
|
||||
if (unlikely(end_ticks - start_ticks >= timeout_ticks)) {
|
||||
master->device.state = EC_DEVICE_STATE_READY;
|
||||
master->frames_lost++;
|
||||
ec_output_lost_frames(master);
|
||||
return -1;
|
||||
if (master->device.state == EC_DEVICE_STATE_RECEIVED) {
|
||||
master->frames_delayed++;
|
||||
ec_cyclic_output(master);
|
||||
}
|
||||
else {
|
||||
master->device.state = EC_DEVICE_STATE_READY;
|
||||
master->frames_lost++;
|
||||
ec_cyclic_output(master);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely(ec_frame_receive(frame) < 0)) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ void ec_master_init(ec_master_t *master /**< EtherCAT-Master */)
|
|||
master->debug_level = 0;
|
||||
master->bus_time = 0;
|
||||
master->frames_lost = 0;
|
||||
master->t_lost_output = 0;
|
||||
master->frames_delayed = 0;
|
||||
master->t_last_cyclic_output = 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -84,7 +85,8 @@ void ec_master_reset(ec_master_t *master
|
|||
master->debug_level = 0;
|
||||
master->bus_time = 0;
|
||||
master->frames_lost = 0;
|
||||
master->t_lost_output = 0;
|
||||
master->frames_delayed = 0;
|
||||
master->t_last_cyclic_output = 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -237,22 +239,30 @@ int ec_scan_for_slaves(ec_master_t *master /**< EtherCAT-Master */)
|
|||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Gibt die Anzahl verlorener Frames aus.
|
||||
Ausgaben während des zyklischen Betriebs.
|
||||
|
||||
Diese Funktion sorgt dafür, dass Ausgaben (Zählerstände) während
|
||||
des zyklischen Betriebs nicht zu oft getätigt werden.
|
||||
|
||||
Die Ausgabe erfolgt gesammelt höchstens einmal pro Sekunde.
|
||||
*/
|
||||
|
||||
void ec_output_lost_frames(ec_master_t *master /**< EtherCAT-Master */)
|
||||
void ec_cyclic_output(ec_master_t *master /**< EtherCAT-Master */)
|
||||
{
|
||||
unsigned long int t;
|
||||
|
||||
if (master->frames_lost) {
|
||||
rdtscl(t);
|
||||
if ((t - master->t_lost_output) / cpu_khz > 1000) {
|
||||
rdtscl(t);
|
||||
|
||||
if ((t - master->t_last_cyclic_output) / cpu_khz > 1000) {
|
||||
if (master->frames_lost) {
|
||||
EC_WARN("%u frame(s) LOST!\n", master->frames_lost);
|
||||
master->frames_lost = 0;
|
||||
master->t_lost_output = t;
|
||||
}
|
||||
if (master->frames_delayed) {
|
||||
EC_WARN("%u frame(s) DELAYED!\n", master->frames_delayed);
|
||||
master->frames_delayed = 0;
|
||||
}
|
||||
master->t_last_cyclic_output = t;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,10 @@ struct ec_master
|
|||
unsigned int domain_count; /**< Anzahl Domänen */
|
||||
int debug_level; /**< Debug-Level im Master-Code */
|
||||
unsigned int bus_time; /**< Letzte Bus-Zeit in Mikrosekunden */
|
||||
unsigned int frames_lost; /**< Anzahl verlorene Frames */
|
||||
unsigned long t_lost_output; /**< Timer-Ticks bei der letzten Ausgabe von
|
||||
verlorenen Frames */
|
||||
unsigned int frames_lost; /**< Anzahl verlorener Frames */
|
||||
unsigned int frames_delayed; /**< Anzahl verzögerter Frames */
|
||||
unsigned long t_last_cyclic_output; /**< Timer-Ticks bei den letzten
|
||||
zyklischen Ausgaben */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -59,7 +60,7 @@ ec_slave_t *ec_address(const ec_master_t *, const char *);
|
|||
|
||||
// Misc
|
||||
void ec_output_debug_data(const ec_master_t *);
|
||||
void ec_output_lost_frames(ec_master_t *);
|
||||
void ec_cyclic_output(ec_master_t *);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue