796 allow_signal(SIGTERM); |
796 allow_signal(SIGTERM); |
797 |
797 |
798 while (!signal_pending(current)) { |
798 while (!signal_pending(current)) { |
799 cycles_start = get_cycles(); |
799 cycles_start = get_cycles(); |
800 |
800 |
801 if (ec_fsm_master_running(&master->fsm)) { |
801 if (ec_fsm_master_running(&master->fsm)) { // datagram on the way |
802 // receive |
802 // receive |
803 spin_lock_bh(&master->internal_lock); |
803 spin_lock_bh(&master->internal_lock); |
804 ecrt_master_receive(master); |
804 ecrt_master_receive(master); |
805 spin_unlock_bh(&master->internal_lock); |
805 spin_unlock_bh(&master->internal_lock); |
806 } |
806 |
807 |
807 if (master->fsm_datagram.state == EC_DATAGRAM_SENT) |
808 if (master->fsm_datagram.state == EC_DATAGRAM_SENT) |
808 goto schedule; |
809 goto schedule; |
809 } |
810 |
810 |
811 // execute master state machine |
811 // execute master state machine |
812 if (ec_fsm_master_exec(&master->fsm)) { |
812 if (ec_fsm_master_exec(&master->fsm)) { // datagram ready for sending |
813 // queue and send |
813 // queue and send |
|
814 spin_lock_bh(&master->internal_lock); |
814 ec_master_queue_datagram(master, &master->fsm_datagram); |
815 ec_master_queue_datagram(master, &master->fsm_datagram); |
815 spin_lock_bh(&master->internal_lock); |
|
816 ecrt_master_send(master); |
816 ecrt_master_send(master); |
817 spin_unlock_bh(&master->internal_lock); |
817 spin_unlock_bh(&master->internal_lock); |
818 } |
818 } |
819 |
819 |
820 cycles_end = get_cycles(); |
820 cycles_end = get_cycles(); |
1512 datagram->state = EC_DATAGRAM_TIMED_OUT; |
1512 datagram->state = EC_DATAGRAM_TIMED_OUT; |
1513 master->stats.timeouts++; |
1513 master->stats.timeouts++; |
1514 ec_master_output_stats(master); |
1514 ec_master_output_stats(master); |
1515 |
1515 |
1516 if (unlikely(master->debug_level > 0)) { |
1516 if (unlikely(master->debug_level > 0)) { |
1517 EC_DBG("TIMED OUT datagram index %02X waited %u us.\n", |
1517 EC_DBG("TIMED OUT datagram %08x, index %02X waited %u us.\n", |
1518 datagram->index, |
1518 (unsigned int) datagram, datagram->index, |
1519 (unsigned int) (master->main_device.cycles_poll |
1519 (unsigned int) (master->main_device.cycles_poll |
1520 - datagram->cycles_sent) * 1000 / cpu_khz); |
1520 - datagram->cycles_sent) * 1000 / cpu_khz); |
1521 } |
1521 } |
1522 } |
1522 } |
1523 } |
1523 } |