# HG changeset patch # User Florian Pose # Date 1312214096 -7200 # Node ID 53b5128e13131f245779daf66d3311568f7df6b4 # Parent 83e9160319ec2cf001dc22654c1b756681566bad Fixed skipped datagrams output again; added datagram information on skip. diff -r 83e9160319ec -r 53b5128e1313 master/datagram.c --- a/master/datagram.c Mon Aug 01 17:02:45 2011 +0200 +++ b/master/datagram.c Mon Aug 01 17:54:56 2011 +0200 @@ -594,3 +594,53 @@ } /*****************************************************************************/ + +/** Output datagram information. + */ +void ec_datagram_output_info( + const ec_datagram_t *datagram /**< EtherCAT datagram. */ + ) +{ + printk("state=%s ", ec_datagram_type_string(datagram)); + + switch (datagram->type) { + case EC_DATAGRAM_APRD: + case EC_DATAGRAM_APWR: + case EC_DATAGRAM_APRW: + case EC_DATAGRAM_ARMW: + printk("pos=%i mem=0x%04x", + EC_READ_S16(datagram->address) * (-1), + EC_READ_U16(datagram->address + 2) + ); + break; + + case EC_DATAGRAM_FPRD: + case EC_DATAGRAM_FPWR: + case EC_DATAGRAM_FPRW: + case EC_DATAGRAM_FRMW: + printk("node=%u mem=0x%04x", + EC_READ_U16(datagram->address), + EC_READ_U16(datagram->address + 2)); + break; + + case EC_DATAGRAM_BRD: + case EC_DATAGRAM_BWR: + case EC_DATAGRAM_BRW: + printk("mem=0x%04x", EC_READ_U16(datagram->address + 2)); + break; + + case EC_DATAGRAM_LRD: + case EC_DATAGRAM_LWR: + case EC_DATAGRAM_LRW: + printk("log=0x%08x", EC_READ_U32(datagram->address)); + break; + + default: + printk("??"); + break; + } + + printk(" size=%zu", datagram->data_size); +} + +/*****************************************************************************/ diff -r 83e9160319ec -r 53b5128e1313 master/datagram.h --- a/master/datagram.h Mon Aug 01 17:02:45 2011 +0200 +++ b/master/datagram.h Mon Aug 01 17:54:56 2011 +0200 @@ -141,6 +141,7 @@ void ec_datagram_print_wc_error(const ec_datagram_t *); void ec_datagram_output_stats(ec_datagram_t *); const char *ec_datagram_type_string(const ec_datagram_t *); +void ec_datagram_output_info(const ec_datagram_t *); /*****************************************************************************/ diff -r 83e9160319ec -r 53b5128e1313 master/master.c --- a/master/master.c Mon Aug 01 17:02:45 2011 +0200 +++ b/master/master.c Mon Aug 01 17:54:56 2011 +0200 @@ -846,23 +846,6 @@ { ec_datagram_t *queued_datagram; - switch (datagram->state) { - case EC_DATAGRAM_QUEUED: - datagram->skip_count++; - EC_MASTER_DBG(master, 1, "Skipping already queued datagram %p.\n", - datagram); - break; - - case EC_DATAGRAM_SENT: - datagram->skip_count++; - EC_MASTER_DBG(master, 1, "Skipping already sent datagram %p.\n", - datagram); - break; - - default: - break; - } - /* It is possible, that a datagram in the queue is re-initialized with the * ec_datagram_() methods and then shall be queued with this method. * In that case, the state is already reset to EC_DATAGRAM_INIT. Check if @@ -872,14 +855,17 @@ list_for_each_entry(queued_datagram, &master->datagram_queue, queue) { if (queued_datagram == datagram) { datagram->skip_count++; - EC_MASTER_DBG(master, 1, "Skipping re-initialized datagram %p.\n", - datagram); - datagram->state = EC_DATAGRAM_QUEUED; - return; + if (master->debug_level) { + EC_MASTER_DBG(master, 1, "Skipping datagram %p (", datagram); + ec_datagram_output_info(datagram); + printk(")\n"); + } + goto queued; } } list_add_tail(&datagram->queue, &master->datagram_queue); +queued: datagram->state = EC_DATAGRAM_QUEUED; } @@ -933,7 +919,7 @@ datagram->index = master->datagram_index++; EC_MASTER_DBG(master, 2, "Adding datagram %p i=0x%02X size=%zu\n", - datagram, datagram->index,datagram_size); + datagram, datagram->index, datagram_size); // set "datagram following" flag in previous frame if (follows_word) {