##// END OF EJS Templates
snapshot synchronization slightly upgraded...
paul -
r263:b01d69cdd902 R3a
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 fa4fff498e7a3208f9f7ba469d6e25c84fe6ad71 header/lfr_common_headers
2 b0e42058c39c77fc42a5bd3bf529e4547497c4c3 header/lfr_common_headers
@@ -13,8 +13,8
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14 #include "fsw_init.h"
14 #include "fsw_init.h"
15
15
16 extern spw_stats spacewire_stats;
16 extern spw_stats grspw_stats;
17 extern spw_stats spacewire_stats_backup;
17 extern spw_stats spw_backup;
18 extern rtems_name timecode_timer_name;
18 extern rtems_name timecode_timer_name;
19 extern rtems_id timecode_timer_id;
19 extern rtems_id timecode_timer_id;
20
20
@@ -31,8 +31,11 int spacewire_configure_link(int fd );
31 int spacewire_several_connect_attemps( void );
31 int spacewire_several_connect_attemps( void );
32 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
32 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
33 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
33 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
34 void spacewire_compute_stats_offsets( void );
34 void spacewire_save_stats( void );
35 void spacewire_restore_stats( void );
35 void spacewire_update_statistics( void );
36 void spacewire_update_statistics( void );
37 void update_hk_lfr_last_er_fields(unsigned int rid, unsigned char code);
38 void update_hk_with_grspw_stats( spw_stats stats );
36 void increase_unsigned_char_counter( unsigned char *counter );
39 void increase_unsigned_char_counter( unsigned char *counter );
37
40
38 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header );
41 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header );
@@ -77,7 +77,7 unsigned short sequenceCounters_SCIENCE_
77 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
77 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
78 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID];
78 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID];
79 unsigned short sequenceCounterHK;
79 unsigned short sequenceCounterHK;
80 spw_stats spacewire_stats;
80 spw_stats grspw_stats;
81 spw_stats spacewire_stats_backup;
81 spw_stats spw_backup;
82
82
83
83
@@ -297,6 +297,8 rtems_task hous_task(rtems_task_argument
297
297
298 spacewire_update_statistics();
298 spacewire_update_statistics();
299
299
300 update_hk_with_grspw_stats( grspw_stats );
301
300 set_hk_lfr_time_not_synchro();
302 set_hk_lfr_time_not_synchro();
301
303
302 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
304 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
@@ -751,6 +753,7 void set_hk_lfr_time_not_synchro()
751 {
753 {
752 synchroLost = 1;
754 synchroLost = 1;
753 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
755 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
756 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO );
754 }
757 }
755 break;
758 break;
756 default:
759 default:
@@ -66,8 +66,9 rtems_task spiq_task(rtems_task_argument
66 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
66 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
67 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
67 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
68 {
68 {
69 spacewire_compute_stats_offsets();
69 spacewire_save_stats();
70 status = spacewire_several_connect_attemps( );
70 status = spacewire_several_connect_attemps( );
71 spacewire_restore_stats();
71 }
72 }
72 else // [2.b] in run state, start the link
73 else // [2.b] in run state, start the link
73 {
74 {
@@ -352,7 +353,9 rtems_task link_task( rtems_task_argumen
352 watchdog_reload();
353 watchdog_reload();
353 }
354 }
354
355
356 spacewire_save_stats();
355 status = spacewire_stop_and_start_link( fdSPW );
357 status = spacewire_stop_and_start_link( fdSPW );
358 spacewire_restore_stats();
356
359
357 if (status != RTEMS_SUCCESSFUL)
360 if (status != RTEMS_SUCCESSFUL)
358 {
361 {
@@ -505,6 +508,7 int spacewire_several_connect_attemps( v
505 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
508 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
506
509
507 status_spw = spacewire_stop_and_start_link( fdSPW );
510 status_spw = spacewire_stop_and_start_link( fdSPW );
511
508 if ( status_spw != RTEMS_SUCCESSFUL )
512 if ( status_spw != RTEMS_SUCCESSFUL )
509 {
513 {
510 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
514 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
@@ -563,107 +567,314 void spacewire_set_RE( unsigned char val
563 }
567 }
564 }
568 }
565
569
566 void spacewire_compute_stats_offsets( void )
570 void spacewire_save_stats( void )
567 {
571 {
568 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
572 /** This function save the SpaceWire statistics.
569 *
573 *
570 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
574 * @param void
571 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
575 *
572 * during the open systel call).
576 * @return void
573 *
577 *
574 */
578 */
575
579
576 spw_stats spacewire_stats_grspw;
580 spw_stats spw_current;
577 rtems_status_code status;
581 rtems_status_code status;
578
582
579 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
583 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spw_current );
584
585 // typedef struct {
586 // unsigned int tx_link_err; // NOT IN HK
587 // unsigned int rx_rmap_header_crc_err; // NOT IN HK
588 // unsigned int rx_rmap_data_crc_err; // NOT IN HK
589 // unsigned int rx_eep_err;
590 // unsigned int rx_truncated;
591 // unsigned int parity_err;
592 // unsigned int escape_err;
593 // unsigned int credit_err;
594 // unsigned int write_sync_err;
595 // unsigned int disconnect_err;
596 // unsigned int early_ep;
597 // unsigned int invalid_address;
598 // unsigned int packets_sent;
599 // unsigned int packets_received;
600 // } spw_stats;
580
601
581 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
602 // rx_eep_err
582 + spacewire_stats.packets_received;
603 spw_backup.rx_eep_err = grspw_stats.rx_eep_err + spw_current.rx_eep_err;
583 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
604 // rx_truncated
584 + spacewire_stats.packets_sent;
605 spw_backup.rx_truncated = grspw_stats.rx_truncated + spw_current.rx_truncated;
585 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
606 // parity_err
586 + spacewire_stats.parity_err;
607 spw_backup.parity_err = grspw_stats.parity_err + spw_current.parity_err;
587 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
608 // escape_err
588 + spacewire_stats.disconnect_err;
609 spw_backup.escape_err = grspw_stats.escape_err + spw_current.escape_err;
589 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
610 // credit_err
590 + spacewire_stats.escape_err;
611 spw_backup.credit_err = grspw_stats.credit_err + spw_current.credit_err;
591 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
612 // write_sync_err
592 + spacewire_stats.credit_err;
613 spw_backup.write_sync_err = grspw_stats.write_sync_err + spw_current.write_sync_err;
593 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
614 // disconnect_err
594 + spacewire_stats.write_sync_err;
615 spw_backup.disconnect_err = grspw_stats.disconnect_err + spw_current.disconnect_err;
595 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
616 // early_ep
596 + spacewire_stats.rx_rmap_header_crc_err;
617 spw_backup.early_ep = grspw_stats.early_ep + spw_current.early_ep;
597 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
618 // invalid_address
598 + spacewire_stats.rx_rmap_data_crc_err;
619 spw_backup.invalid_address = grspw_stats.invalid_address + spw_current.invalid_address;
599 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
620 // packets_sent
600 + spacewire_stats.early_ep;
621 spw_backup.packets_sent = grspw_stats.packets_sent + spw_current.packets_sent;
601 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
622 // packets_received
602 + spacewire_stats.invalid_address;
623 spw_backup.packets_received = grspw_stats.packets_received + spw_current.packets_received;
603 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
624
604 + spacewire_stats.rx_eep_err;
625 }
605 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
626
606 + spacewire_stats.rx_truncated;
627 void spacewire_restore_stats( void )
628 {
629 /** This function restore the SpaceWire statistics values recorded before a link restart which reset the counters.
630 *
631 * @param void
632 *
633 * @return void
634 *
635 */
636
637 // rx_eep_err
638 grspw_stats.rx_eep_err = spw_backup.rx_eep_err ;
639 // rx_truncated
640 grspw_stats.rx_truncated = spw_backup.rx_truncated;
641 // parity_err
642 grspw_stats.parity_err = spw_backup.parity_err;
643 // escape_err
644 grspw_stats.escape_err = spw_backup.escape_err;
645 // credit_err
646 grspw_stats.credit_err = spw_backup.credit_err;
647 // write_sync_err
648 grspw_stats.write_sync_err = spw_backup.write_sync_err;
649 // disconnect_err
650 grspw_stats.disconnect_err = spw_backup.disconnect_err;
651 // early_ep
652 grspw_stats.early_ep = spw_backup.early_ep;
653 // invalid_address
654 grspw_stats.invalid_address = spw_backup.invalid_address;
655 // packets_sent
656 grspw_stats.packets_sent = spw_backup.packets_sent;
657 // packets_received
658 grspw_stats.packets_received= spw_backup.packets_received;
659
607 }
660 }
608
661
609 void spacewire_update_statistics( void )
662 void spacewire_update_statistics( void )
610 {
663 {
611 rtems_status_code status;
664 rtems_status_code status;
612 spw_stats spacewire_stats_grspw;
665 spw_stats spw_current;
666
667 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spw_current );
668
669 // typedef struct {
670 // unsigned int tx_link_err; // NOT IN HK
671 // unsigned int rx_rmap_header_crc_err; // NOT IN HK
672 // unsigned int rx_rmap_data_crc_err; // NOT IN HK
673 // unsigned int rx_eep_err;
674 // unsigned int rx_truncated;
675 // unsigned int parity_err;
676 // unsigned int escape_err;
677 // unsigned int credit_err;
678 // unsigned int write_sync_err;
679 // unsigned int disconnect_err;
680 // unsigned int early_ep;
681 // unsigned int invalid_address;
682 // unsigned int packets_sent;
683 // unsigned int packets_received;
684 // } spw_stats;
613
685
614 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
686 // rx_eep_err
687 grspw_stats.rx_eep_err = grspw_stats.rx_eep_err + spw_current.rx_eep_err;
688 // rx_truncated
689 grspw_stats.rx_truncated = grspw_stats.rx_truncated + spw_current.rx_truncated;
690 // parity_err
691 grspw_stats.parity_err = grspw_stats.parity_err + spw_current.parity_err;
692 // escape_err
693 grspw_stats.escape_err = grspw_stats.escape_err + spw_current.escape_err;
694 // credit_err
695 grspw_stats.credit_err = grspw_stats.credit_err + spw_current.credit_err;
696 // write_sync_err
697 grspw_stats.write_sync_err = grspw_stats.write_sync_err + spw_current.write_sync_err;
698 // disconnect_err
699 grspw_stats.disconnect_err = grspw_stats.disconnect_err + spw_current.disconnect_err;
700 // early_ep
701 grspw_stats.early_ep = grspw_stats.early_ep + spw_current.early_ep;
702 // invalid_address
703 grspw_stats.invalid_address = grspw_stats.invalid_address + spw_current.invalid_address;
704 // packets_sent
705 grspw_stats.packets_sent = grspw_stats.packets_sent + spw_current.packets_sent;
706 // packets_received
707 grspw_stats.packets_received= grspw_stats.packets_received + spw_current.packets_received;
708
709 }
710
711 void spacewire_get_last_error( void )
712 {
713 static spw_stats previous;
714 spw_stats current;
715 rtems_status_code status;
716
717 unsigned int hk_lfr_last_er_rid;
718 unsigned char hk_lfr_last_er_code;
719 int coarseTime;
720 int fineTime;
721 unsigned char update_hk_lfr_last_er;
722
723 update_hk_lfr_last_er = 0;
724
725 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &current );
726
727 // get current time
728 coarseTime = time_management_regs->coarse_time;
729 fineTime = time_management_regs->fine_time;
730
731 // typedef struct {
732 // unsigned int tx_link_err; // NOT IN HK
733 // unsigned int rx_rmap_header_crc_err; // NOT IN HK
734 // unsigned int rx_rmap_data_crc_err; // NOT IN HK
735 // unsigned int rx_eep_err;
736 // unsigned int rx_truncated;
737 // unsigned int parity_err;
738 // unsigned int escape_err;
739 // unsigned int credit_err;
740 // unsigned int write_sync_err;
741 // unsigned int disconnect_err;
742 // unsigned int early_ep;
743 // unsigned int invalid_address;
744 // unsigned int packets_sent;
745 // unsigned int packets_received;
746 // } spw_stats;
615
747
616 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
748 // tx_link_err *** no code associated to this field
617 + spacewire_stats_grspw.packets_received;
749 // rx_rmap_header_crc_err *** LE *** in HK
618 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
750 if (previous.rx_rmap_header_crc_err != current.rx_rmap_header_crc_err)
619 + spacewire_stats_grspw.packets_sent;
751 {
620 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
752 hk_lfr_last_er_rid = RID_LE_LFR_DPU_SPW;
621 + spacewire_stats_grspw.parity_err;
753 hk_lfr_last_er_code = CODE_HEADER_CRC;
622 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
754 update_hk_lfr_last_er = 1;
623 + spacewire_stats_grspw.disconnect_err;
755 }
624 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
756 // rx_rmap_data_crc_err *** LE *** NOT IN HK
625 + spacewire_stats_grspw.escape_err;
757 if (previous.rx_rmap_data_crc_err != current.rx_rmap_data_crc_err)
626 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
758 {
627 + spacewire_stats_grspw.credit_err;
759 hk_lfr_last_er_rid = RID_LE_LFR_DPU_SPW;
628 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
760 hk_lfr_last_er_code = CODE_DATA_CRC;
629 + spacewire_stats_grspw.write_sync_err;
761 update_hk_lfr_last_er = 1;
630 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
762 }
631 + spacewire_stats_grspw.rx_rmap_header_crc_err;
763 // rx_eep_err
632 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
764 if (previous.rx_eep_err != current.rx_eep_err)
633 + spacewire_stats_grspw.rx_rmap_data_crc_err;
765 {
634 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
766 hk_lfr_last_er_rid = RID_ME_LFR_DPU_SPW;
635 + spacewire_stats_grspw.early_ep;
767 hk_lfr_last_er_code = CODE_EEP;
636 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
768 update_hk_lfr_last_er = 1;
637 + spacewire_stats_grspw.invalid_address;
769 }
638 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
770 // rx_truncated
639 + spacewire_stats_grspw.rx_eep_err;
771 if (previous.rx_truncated != current.rx_truncated)
640 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
772 {
641 + spacewire_stats_grspw.rx_truncated;
773 hk_lfr_last_er_rid = RID_ME_LFR_DPU_SPW;
642 //spacewire_stats.tx_link_err;
774 hk_lfr_last_er_code = CODE_RX_TOO_BIG;
775 update_hk_lfr_last_er = 1;
776 }
777 // parity_err
778 if (previous.parity_err != current.parity_err)
779 {
780 hk_lfr_last_er_rid = RID_LE_LFR_DPU_SPW;
781 hk_lfr_last_er_code = CODE_PARITY;
782 update_hk_lfr_last_er = 1;
783 }
784 // escape_err
785 if (previous.parity_err != current.parity_err)
786 {
787 hk_lfr_last_er_rid = RID_LE_LFR_DPU_SPW;
788 hk_lfr_last_er_code = CODE_ESCAPE;
789 update_hk_lfr_last_er = 1;
790 }
791 // credit_err
792 if (previous.credit_err != current.credit_err)
793 {
794 hk_lfr_last_er_rid = RID_LE_LFR_DPU_SPW;
795 hk_lfr_last_er_code = CODE_CREDIT;
796 update_hk_lfr_last_er = 1;
797 }
798 // write_sync_err
799 if (previous.write_sync_err != current.write_sync_err)
800 {
801 hk_lfr_last_er_rid = RID_LE_LFR_DPU_SPW;
802 hk_lfr_last_er_code = CODE_WRITE_SYNC;
803 update_hk_lfr_last_er = 1;
804 }
805 // disconnect_err
806 if (previous.disconnect_err != current.disconnect_err)
807 {
808 hk_lfr_last_er_rid = RID_LE_LFR_DPU_SPW;
809 hk_lfr_last_er_code = CODE_DISCONNECT;
810 update_hk_lfr_last_er = 1;
811 }
812 // early_ep
813 if (previous.early_ep != current.early_ep)
814 {
815 hk_lfr_last_er_rid = RID_ME_LFR_DPU_SPW;
816 hk_lfr_last_er_code = CODE_EARLY_EOP_EEP;
817 update_hk_lfr_last_er = 1;
818 }
819 // invalid_address
820 if (previous.invalid_address != current.invalid_address)
821 {
822 hk_lfr_last_er_rid = RID_ME_LFR_DPU_SPW;
823 hk_lfr_last_er_code = CODE_INVALID_ADDRESS;
824 update_hk_lfr_last_er = 1;
825 }
643
826
827 // if a field has changed, update the hk_last_er fields
828 if (update_hk_lfr_last_er == 1)
829 {
830 update_hk_lfr_last_er_fields( hk_lfr_last_er_rid, hk_lfr_last_er_code );
831 }
832
833 previous = current;
834 }
835
836 void update_hk_lfr_last_er_fields(unsigned int rid, unsigned char code)
837 {
838 unsigned char *coarseTimePtr;
839 unsigned char *fineTimePtr;
840
841 coarseTimePtr = (unsigned char*) &time_management_regs->coarse_time;
842 fineTimePtr = (unsigned char*) &time_management_regs->fine_time;
843
844 housekeeping_packet.hk_lfr_last_er_rid[0] = (unsigned char) ((rid & 0xff00) >> 8 );
845 housekeeping_packet.hk_lfr_last_er_rid[1] = (unsigned char) (rid & 0x00ff);
846 housekeeping_packet.hk_lfr_last_er_code = code;
847 housekeeping_packet.hk_lfr_last_er_time[0] = coarseTimePtr[0];
848 housekeeping_packet.hk_lfr_last_er_time[1] = coarseTimePtr[1];
849 housekeeping_packet.hk_lfr_last_er_time[2] = coarseTimePtr[2];
850 housekeeping_packet.hk_lfr_last_er_time[3] = coarseTimePtr[3];
851 housekeeping_packet.hk_lfr_last_er_time[4] = fineTimePtr[2];
852 housekeeping_packet.hk_lfr_last_er_time[5] = fineTimePtr[3];
853 }
854
855 void update_hk_with_grspw_stats( spw_stats stats )
856 {
644 //****************************
857 //****************************
645 // DPU_SPACEWIRE_IF_STATISTICS
858 // DPU_SPACEWIRE_IF_STATISTICS
646 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
859 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (stats.packets_received >> 8);
647 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
860 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (stats.packets_received);
648 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
861 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (stats.packets_sent >> 8);
649 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
862 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (stats.packets_sent);
650 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
651 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
652
863
653 //******************************************
864 //******************************************
654 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
865 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
655 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
866 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) stats.parity_err;
656 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
867 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) stats.disconnect_err;
657 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
868 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) stats.escape_err;
658 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
869 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) stats.credit_err;
659 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
870 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) stats.write_sync_err;
660
871
661 //*********************************************
872 //*********************************************
662 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
873 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
663 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
874 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) stats.early_ep;
664 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
875 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) stats.invalid_address;
665 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
876 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) stats.rx_eep_err;
666 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
877 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) stats.rx_truncated;
667 }
878 }
668
879
669 void increase_unsigned_char_counter( unsigned char *counter )
880 void increase_unsigned_char_counter( unsigned char *counter )
@@ -695,6 +906,7 rtems_timer_service_routine timecode_tim
695 // HK_LFR_TIMECODE_MISSING
906 // HK_LFR_TIMECODE_MISSING
696 // the timecode value has not changed, no valid timecode has been received, the timecode is MISSING
907 // the timecode value has not changed, no valid timecode has been received, the timecode is MISSING
697 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing );
908 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing );
909 update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_MISSING );
698 }
910 }
699 else if (currentTimecodeCtr == (previousTimecodeCtr+1))
911 else if (currentTimecodeCtr == (previousTimecodeCtr+1))
700 {
912 {
@@ -708,6 +920,7 rtems_timer_service_routine timecode_tim
708 // the timecode value has changed and the value is not valid, no tickout has been generated
920 // the timecode value has changed and the value is not valid, no tickout has been generated
709 // this is why the timer has fired
921 // this is why the timer has fired
710 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_invalid );
922 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_invalid );
923 update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_INVALID );
711 }
924 }
712 }
925 }
713 else
926 else
@@ -716,6 +929,7 rtems_timer_service_routine timecode_tim
716 //************************
929 //************************
717 // HK_LFR_TIMECODE_MISSING
930 // HK_LFR_TIMECODE_MISSING
718 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing );
931 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_missing );
932 update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_MISSING );
719 }
933 }
720
934
721 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_13 );
935 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_13 );
@@ -815,6 +1029,7 void timecode_irq_handler( void *pDev, v
815 {
1029 {
816 // this is unexpected but a tickout could have been raised despite of the timecode being erroneous
1030 // this is unexpected but a tickout could have been raised despite of the timecode being erroneous
817 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_erroneous );
1031 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_timecode_erroneous );
1032 update_hk_lfr_last_er_fields( RID_LE_LFR_TIMEC, CODE_ERRONEOUS );
818 }
1033 }
819
1034
820 //************************
1035 //************************
@@ -823,6 +1038,7 void timecode_irq_handler( void *pDev, v
823 if (check_timecode_and_internal_time_coherency( incomingTimecode, internalTime ) == LFR_DEFAULT)
1038 if (check_timecode_and_internal_time_coherency( incomingTimecode, internalTime ) == LFR_DEFAULT)
824 {
1039 {
825 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_time_timecode_it );
1040 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_time_timecode_it );
1041 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_TIMECODE_IT );
826 }
1042 }
827
1043
828 //********************
1044 //********************
@@ -831,6 +1047,7 void timecode_irq_handler( void *pDev, v
831 if (incomingTimecode != updateTime)
1047 if (incomingTimecode != updateTime)
832 {
1048 {
833 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_time_timecode_ctr );
1049 increase_unsigned_char_counter( &housekeeping_packet.hk_lfr_time_timecode_ctr );
1050 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_TIMECODE_CTR );
834 }
1051 }
835
1052
836 // launch the timecode timer to detect missing or invalid timecodes
1053 // launch the timecode timer to detect missing or invalid timecodes
@@ -920,13 +920,27 void applyCorrection( double correction
920 {
920 {
921 int correctionInt;
921 int correctionInt;
922
922
923 if (correction>=0)
923 if (correction>=0.)
924 {
924 {
925 correctionInt = floor(correction);
925 if ( correction > 0.5 )
926 {
927 correctionInt = 1;
928 }
929 else
930 {
931 correctionInt = floor(correction);
932 }
926 }
933 }
927 else
934 else
928 {
935 {
929 correctionInt = ceil(correction);
936 if ( correction < -0.5)
937 {
938 correctionInt = -1;
939 }
940 else
941 {
942 correctionInt = ceil(correction);
943 }
930 }
944 }
931 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt;
945 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt;
932 }
946 }
@@ -934,7 +948,6 void applyCorrection( double correction
934 void snapshot_resynchronization( unsigned char *timePtr )
948 void snapshot_resynchronization( unsigned char *timePtr )
935 {
949 {
936 static double correction = 0.;
950 static double correction = 0.;
937 static double delay_0 = 0.;
938 static resynchro_state state = MEASURE_0;
951 static resynchro_state state = MEASURE_0;
939
952
940 int correctionInt;
953 int correctionInt;
@@ -948,8 +961,7 void snapshot_resynchronization( unsigne
948 // ********
961 // ********
949 PRINTF("MEASURE_0 ===\n");
962 PRINTF("MEASURE_0 ===\n");
950 state = CORRECTION_0;
963 state = CORRECTION_0;
951 delay_0 = computeCorrection( timePtr );
964 correction = computeCorrection( timePtr );
952 correction = delay_0;
953 PRINTF1("MEASURE_0 === correction = %.2f\n", correction );
965 PRINTF1("MEASURE_0 === correction = %.2f\n", correction );
954 applyCorrection( correction );
966 applyCorrection( correction );
955 PRINTF1("MEASURE_0 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
967 PRINTF1("MEASURE_0 === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot);
General Comments 0
You need to be logged in to leave comments. Login now