643 |
643 |
644 off += sprintf(buffer + off, "\n"); |
644 off += sprintf(buffer + off, "\n"); |
645 |
645 |
646 return off; |
646 return off; |
647 } |
647 } |
648 |
|
649 /*****************************************************************************/ |
|
650 |
|
651 #if 0 |
|
652 |
|
653 /** |
|
654 Outputs the values of the CRC faoult counters and resets them. |
|
655 \return 0 in case of success, else < 0 |
|
656 */ |
|
657 |
|
658 int ec_slave_check_crc(ec_slave_t *slave /**< EtherCAT slave */) |
|
659 { |
|
660 ec_datagram_t *datagram; |
|
661 |
|
662 datagram = &slave->master->simple_datagram; |
|
663 |
|
664 if (ec_datagram_nprd(datagram, slave->station_address, 0x0300, 4)) |
|
665 return -1; |
|
666 if (unlikely(ec_master_simple_io(slave->master, datagram))) { |
|
667 EC_WARN("Reading CRC fault counters failed on slave %i!\n", |
|
668 slave->ring_position); |
|
669 return -1; |
|
670 } |
|
671 |
|
672 if (!EC_READ_U32(datagram->data)) return 0; // no CRC faults |
|
673 |
|
674 if (EC_READ_U8(datagram->data)) |
|
675 EC_WARN("%3i RX-error%s on slave %i, channel A.\n", |
|
676 EC_READ_U8(datagram->data), |
|
677 EC_READ_U8(datagram->data) == 1 ? "" : "s", |
|
678 slave->ring_position); |
|
679 if (EC_READ_U8(datagram->data + 1)) |
|
680 EC_WARN("%3i invalid frame%s on slave %i, channel A.\n", |
|
681 EC_READ_U8(datagram->data + 1), |
|
682 EC_READ_U8(datagram->data + 1) == 1 ? "" : "s", |
|
683 slave->ring_position); |
|
684 if (EC_READ_U8(datagram->data + 2)) |
|
685 EC_WARN("%3i RX-error%s on slave %i, channel B.\n", |
|
686 EC_READ_U8(datagram->data + 2), |
|
687 EC_READ_U8(datagram->data + 2) == 1 ? "" : "s", |
|
688 slave->ring_position); |
|
689 if (EC_READ_U8(datagram->data + 3)) |
|
690 EC_WARN("%3i invalid frame%s on slave %i, channel B.\n", |
|
691 EC_READ_U8(datagram->data + 3), |
|
692 EC_READ_U8(datagram->data + 3) == 1 ? "" : "s", |
|
693 slave->ring_position); |
|
694 |
|
695 // reset CRC counters |
|
696 if (ec_datagram_npwr(datagram, slave->station_address, 0x0300, 4)) |
|
697 return -1; |
|
698 EC_WRITE_U32(datagram->data, 0x00000000); |
|
699 if (unlikely(ec_master_simple_io(slave->master, datagram))) { |
|
700 EC_WARN("Resetting CRC fault counters failed on slave %i!\n", |
|
701 slave->ring_position); |
|
702 return -1; |
|
703 } |
|
704 |
|
705 return 0; |
|
706 } |
|
707 |
|
708 #endif |
|
709 |
648 |
710 /*****************************************************************************/ |
649 /*****************************************************************************/ |
711 |
650 |
712 /** |
651 /** |
713 Schedules an EEPROM write operation. |
652 Schedules an EEPROM write operation. |