--- a/master/slave.c Fri Feb 24 14:09:51 2006 +0000
+++ b/master/slave.c Fri Feb 24 16:10:52 2006 +0000
@@ -71,8 +71,8 @@
if (unlikely(ec_frame_send_receive(&frame))) return -1;
if (unlikely(frame.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: Slave %i did not respond while reading base"
- " data!\n", slave->ring_position);
+ EC_ERR("Slave %i did not respond while reading base data!\n",
+ slave->ring_position);
return -1;
}
@@ -88,24 +88,24 @@
// Read identification from "Slave Information Interface" (SII)
if (unlikely(ec_slave_sii_read(slave, 0x0008, &slave->sii_vendor_id))) {
- printk(KERN_ERR "EtherCAT: Could not read SII vendor id!\n");
+ EC_ERR("Could not read SII vendor id!\n");
return -1;
}
if (unlikely(ec_slave_sii_read(slave, 0x000A, &slave->sii_product_code))) {
- printk(KERN_ERR "EtherCAT: Could not read SII product code!\n");
+ EC_ERR("Could not read SII product code!\n");
return -1;
}
if (unlikely(ec_slave_sii_read(slave, 0x000C,
&slave->sii_revision_number))) {
- printk(KERN_ERR "EtherCAT: Could not read SII revision number!\n");
+ EC_ERR("Could not read SII revision number!\n");
return -1;
}
if (unlikely(ec_slave_sii_read(slave, 0x000E,
&slave->sii_serial_number))) {
- printk(KERN_ERR "EtherCAT: Could not read SII serial number!\n");
+ EC_ERR("Could not read SII serial number!\n");
return -1;
}
@@ -147,8 +147,7 @@
if (unlikely(ec_frame_send_receive(&frame))) return -1;
if (unlikely(frame.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: SII-read - Slave %i did not respond!\n",
- slave->ring_position);
+ EC_ERR("SII-read - Slave %i did not respond!\n", slave->ring_position);
return -1;
}
@@ -167,8 +166,8 @@
if (unlikely(ec_frame_send_receive(&frame))) return -1;
if (unlikely(frame.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: SII-read status -"
- " Slave %i did not respond!\n", slave->ring_position);
+ EC_ERR("SII-read status - Slave %i did not respond!\n",
+ slave->ring_position);
return -1;
}
@@ -181,8 +180,7 @@
}
if (unlikely(!tries_left)) {
- printk(KERN_WARNING "EtherCAT: SSI-read. Slave %i timed out!\n",
- slave->ring_position);
+ EC_ERR("SSI-read. Slave %i timed out!\n", slave->ring_position);
return -1;
}
@@ -213,14 +211,13 @@
2, data);
if (unlikely(ec_frame_send_receive(&frame) != 0)) {
- printk(KERN_ERR "EtherCAT: Could no acknowledge state %02X - Unable to"
- " send!\n", state);
+ EC_WARN("Could no acknowledge state %02X - Unable to send!\n", state);
return;
}
if (unlikely(frame.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: Could not acknowledge state %02X - Slave"
- " %i did not respond!\n", state, slave->ring_position);
+ EC_WARN("Could not acknowledge state %02X - Slave %i did not"
+ " respond!\n", state, slave->ring_position);
return;
}
@@ -233,28 +230,27 @@
0x0130, 2);
if (unlikely(ec_frame_send_receive(&frame) != 0)) {
- printk(KERN_ERR "EtherCAT: Could not check state acknowledgement"
- " %02X - Unable to send!\n", state);
+ EC_WARN("Could not check state acknowledgement %02X - Unable to"
+ " send!\n", state);
return;
}
if (unlikely(frame.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: Could not check state acknowledgement"
- " %02X - Slave %i did not respond!\n", state,
- slave->ring_position);
+ EC_WARN("Could not check state acknowledgement %02X - Slave %i did"
+ " not respond!\n", state, slave->ring_position);
return;
}
if (unlikely(EC_READ_U8(frame.data) != state)) {
- printk(KERN_ERR "EtherCAT: Could not acknowledge state %02X on"
- " slave %i (code %02X)!\n", state, slave->ring_position,
- EC_READ_U8(frame.data));
+ EC_WARN("Could not acknowledge state %02X on slave %i (code"
+ " %02X)!\n", state, slave->ring_position,
+ EC_READ_U8(frame.data));
return;
}
if (likely(EC_READ_U8(frame.data) == state)) {
- printk(KERN_INFO "EtherCAT: Acknowleged state %02X on slave %i.\n",
- state, slave->ring_position);
+ EC_INFO("Acknowleged state %02X on slave %i.\n", state,
+ slave->ring_position);
return;
}
@@ -262,9 +258,8 @@
}
if (unlikely(!tries_left)) {
- printk(KERN_ERR "EtherCAT: Could not check state acknowledgement %02X"
- " of slave %i - Timeout while checking!\n", state,
- slave->ring_position);
+ EC_WARN("Could not check state acknowledgement %02X of slave %i -"
+ " Timeout while checking!\n", state, slave->ring_position);
return;
}
}
@@ -293,14 +288,13 @@
2, data);
if (unlikely(ec_frame_send_receive(&frame) != 0)) {
- printk(KERN_ERR "EtherCAT: Could not set state %02X - Unable to"
- " send!\n", state);
- return -1;
- }
-
- if (unlikely(frame.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: Could not set state %02X - Slave %i did not"
- " respond!\n", state, slave->ring_position);
+ EC_ERR("Could not set state %02X - Unable to send!\n", state);
+ return -1;
+ }
+
+ if (unlikely(frame.working_counter != 1)) {
+ EC_ERR("Could not set state %02X - Slave %i did not respond!\n", state,
+ slave->ring_position);
return -1;
}
@@ -313,21 +307,20 @@
0x0130, 2);
if (unlikely(ec_frame_send_receive(&frame) != 0)) {
- printk(KERN_ERR "EtherCAT: Could not check state %02X - Unable to"
- " send!\n", state);
+ EC_ERR("Could not check state %02X - Unable to send!\n", state);
return -1;
}
if (unlikely(frame.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: Could not check state %02X - Slave %i"
- " did not respond!\n", state, slave->ring_position);
+ EC_ERR("Could not check state %02X - Slave %i did not respond!\n",
+ state, slave->ring_position);
return -1;
}
if (unlikely(EC_READ_U8(frame.data) & 0x10)) { // State change error
- printk(KERN_ERR "EtherCAT: Could not set state %02X - Slave %i"
- " refused state change (code %02X)!\n", state,
- slave->ring_position, EC_READ_U8(frame.data));
+ EC_ERR("Could not set state %02X - Slave %i refused state change"
+ " (code %02X)!\n", state, slave->ring_position,
+ EC_READ_U8(frame.data));
ec_slave_state_ack(slave, EC_READ_U8(frame.data) & 0x0F);
return -1;
}
@@ -341,8 +334,7 @@
}
if (unlikely(!tries_left)) {
- printk(KERN_ERR "EtherCAT: Could not check state %02X of slave %i -"
- " Timeout while checking!\n", state,
+ EC_ERR("Could not check state %02X of slave %i - Timeout!\n", state,
slave->ring_position);
return -1;
}
@@ -378,8 +370,7 @@
return 0;
if (slave->fmmu_count >= slave->base_fmmu_count) {
- printk(KERN_ERR "EtherCAT: Slave %i supports only %i FMMUs.\n",
- slave->ring_position, slave->base_fmmu_count);
+ EC_ERR("Slave %i FMMU limit reached!\n", slave->ring_position);
return -1;
}
@@ -400,31 +391,31 @@
void ec_slave_print(const ec_slave_t *slave /**< EtherCAT-Slave */)
{
- printk(KERN_INFO "--- EtherCAT slave information ---\n");
+ EC_INFO("--- EtherCAT slave information ---\n");
if (slave->type) {
- printk(KERN_INFO " Vendor \"%s\", Product \"%s\": %s\n",
- slave->type->vendor_name, slave->type->product_name,
- slave->type->description);
+ EC_INFO(" Vendor \"%s\", Product \"%s\": %s\n",
+ slave->type->vendor_name, slave->type->product_name,
+ slave->type->description);
}
else {
- printk(KERN_INFO " *** This slave has no type information! ***\n");
- }
-
- printk(KERN_INFO " Ring position: %i, Station address: 0x%04X\n",
- slave->ring_position, slave->station_address);
-
- printk(KERN_INFO " Base information:\n");
- printk(KERN_INFO " Type %u, Revision %i, Build %i\n",
- slave->base_type, slave->base_revision, slave->base_build);
- printk(KERN_INFO " Supported FMMUs: %i, Sync managers: %i\n",
- slave->base_fmmu_count, slave->base_sync_count);
-
- printk(KERN_INFO " Slave information interface:\n");
- printk(KERN_INFO " Vendor-ID: 0x%08X, Product code: 0x%08X\n",
- slave->sii_vendor_id, slave->sii_product_code);
- printk(KERN_INFO " Revision number: 0x%08X, Serial number: 0x%08X\n",
- slave->sii_revision_number, slave->sii_serial_number);
+ EC_INFO(" *** This slave has no type information! ***\n");
+ }
+
+ EC_INFO(" Ring position: %i, Station address: 0x%04X\n",
+ slave->ring_position, slave->station_address);
+
+ EC_INFO(" Base information:\n");
+ EC_INFO(" Type %u, Revision %i, Build %i\n",
+ slave->base_type, slave->base_revision, slave->base_build);
+ EC_INFO(" Supported FMMUs: %i, Sync managers: %i\n",
+ slave->base_fmmu_count, slave->base_sync_count);
+
+ EC_INFO(" Slave information interface:\n");
+ EC_INFO(" Vendor-ID: 0x%08X, Product code: 0x%08X\n",
+ slave->sii_vendor_id, slave->sii_product_code);
+ EC_INFO(" Revision number: 0x%08X, Serial number: 0x%08X\n",
+ slave->sii_revision_number, slave->sii_serial_number);
}
/*****************************************************************************/
@@ -444,24 +435,22 @@
4);
if (unlikely(ec_frame_send_receive(&frame))) {
- printk(KERN_WARNING "EtherCAT: Reading CRC fault counters failed"
- " on slave %i - Could not send command!\n",
- slave->ring_position);
- return -1;
- }
-
- if (unlikely(frame.working_counter != 1)) {
- printk(KERN_WARNING "EtherCAT: Reading CRC fault counters -"
- " Slave %i did not respond!\n", slave->ring_position);
+ EC_WARN("Reading CRC fault counters failed on slave %i - Could not"
+ " send command!\n", slave->ring_position);
+ return -1;
+ }
+
+ if (unlikely(frame.working_counter != 1)) {
+ EC_WARN("Reading CRC fault counters - Slave %i did not respond!\n",
+ slave->ring_position);
return -1;
}
// No CRC faults.
if (!EC_READ_U16(frame.data) && !EC_READ_U16(frame.data + 2)) return 0;
- printk(KERN_INFO "EtherCAT: CRC faults on slave %i. A: %i, B: %i\n",
- slave->ring_position, EC_READ_U16(frame.data),
- EC_READ_U16(frame.data + 2));
+ EC_WARN("CRC faults on slave %i. A: %i, B: %i\n", slave->ring_position,
+ EC_READ_U16(frame.data), EC_READ_U16(frame.data + 2));
// Reset CRC counters
EC_WRITE_U16(data, 0x0000);
@@ -472,8 +461,8 @@
if (unlikely(ec_frame_send_receive(&frame))) return -1;
if (unlikely(frame.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: Resetting CRC fault counters - Slave"
- " %i did not respond!\n", slave->ring_position);
+ EC_WARN("Resetting CRC fault counters - Slave %i did not respond!\n",
+ slave->ring_position);
return -1;
}