##// END OF EJS Templates
spacewire statistics management modified...
paul -
r264:2120c4473911 R3a
parent child
Show More
@@ -31,11 +31,9 int spacewire_configure_link(int fd );
31 31 int spacewire_several_connect_attemps( void );
32 32 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
33 33 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
34 void spacewire_save_stats( void );
35 void spacewire_restore_stats( void );
36 void spacewire_update_statistics( void );
34 void spacewire_read_statistics( void );
37 35 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 update_hk_with_grspw_stats(void );
39 37 void increase_unsigned_char_counter( unsigned char *counter );
40 38
41 39 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header );
@@ -295,9 +295,9 rtems_task hous_task(rtems_task_argument
295 295 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
296 296 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
297 297
298 spacewire_update_statistics();
298 spacewire_read_statistics();
299 299
300 update_hk_with_grspw_stats( grspw_stats );
300 update_hk_with_grspw_stats();
301 301
302 302 set_hk_lfr_time_not_synchro();
303 303
@@ -66,9 +66,8 rtems_task spiq_task(rtems_task_argument
66 66 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
67 67 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
68 68 {
69 spacewire_save_stats();
69 spacewire_read_statistics();
70 70 status = spacewire_several_connect_attemps( );
71 spacewire_restore_stats();
72 71 }
73 72 else // [2.b] in run state, start the link
74 73 {
@@ -353,9 +352,8 rtems_task link_task( rtems_task_argumen
353 352 watchdog_reload();
354 353 }
355 354
356 spacewire_save_stats();
355 spacewire_read_statistics();
357 356 status = spacewire_stop_and_start_link( fdSPW );
358 spacewire_restore_stats();
359 357
360 358 if (status != RTEMS_SUCCESSFUL)
361 359 {
@@ -567,104 +565,16 void spacewire_set_RE( unsigned char val
567 565 }
568 566 }
569 567
570 void spacewire_save_stats( void )
571 {
572 /** This function save the SpaceWire statistics.
573 *
574 * @param void
575 *
576 * @return void
577 *
578 */
579
580 spw_stats spw_current;
581 rtems_status_code status;
582
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;
601
602 // rx_eep_err
603 spw_backup.rx_eep_err = grspw_stats.rx_eep_err + spw_current.rx_eep_err;
604 // rx_truncated
605 spw_backup.rx_truncated = grspw_stats.rx_truncated + spw_current.rx_truncated;
606 // parity_err
607 spw_backup.parity_err = grspw_stats.parity_err + spw_current.parity_err;
608 // escape_err
609 spw_backup.escape_err = grspw_stats.escape_err + spw_current.escape_err;
610 // credit_err
611 spw_backup.credit_err = grspw_stats.credit_err + spw_current.credit_err;
612 // write_sync_err
613 spw_backup.write_sync_err = grspw_stats.write_sync_err + spw_current.write_sync_err;
614 // disconnect_err
615 spw_backup.disconnect_err = grspw_stats.disconnect_err + spw_current.disconnect_err;
616 // early_ep
617 spw_backup.early_ep = grspw_stats.early_ep + spw_current.early_ep;
618 // invalid_address
619 spw_backup.invalid_address = grspw_stats.invalid_address + spw_current.invalid_address;
620 // packets_sent
621 spw_backup.packets_sent = grspw_stats.packets_sent + spw_current.packets_sent;
622 // packets_received
623 spw_backup.packets_received = grspw_stats.packets_received + spw_current.packets_received;
624
625 }
626
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
660 }
661
662 void spacewire_update_statistics( void )
568 void spacewire_read_statistics( void )
663 569 {
664 570 rtems_status_code status;
665 spw_stats spw_current;
571 spw_stats current;
666 572
667 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spw_current );
573 // read the current statistics
574 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &current );
575
576 // clear the counters
577 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_CLR_STATISTICS );
668 578
669 579 // typedef struct {
670 580 // unsigned int tx_link_err; // NOT IN HK
@@ -684,27 +594,27 void spacewire_update_statistics( void )
684 594 // } spw_stats;
685 595
686 596 // rx_eep_err
687 grspw_stats.rx_eep_err = grspw_stats.rx_eep_err + spw_current.rx_eep_err;
597 grspw_stats.rx_eep_err = grspw_stats.rx_eep_err + current.rx_eep_err;
688 598 // rx_truncated
689 grspw_stats.rx_truncated = grspw_stats.rx_truncated + spw_current.rx_truncated;
599 grspw_stats.rx_truncated = grspw_stats.rx_truncated + current.rx_truncated;
690 600 // parity_err
691 grspw_stats.parity_err = grspw_stats.parity_err + spw_current.parity_err;
601 grspw_stats.parity_err = grspw_stats.parity_err + current.parity_err;
692 602 // escape_err
693 grspw_stats.escape_err = grspw_stats.escape_err + spw_current.escape_err;
603 grspw_stats.escape_err = grspw_stats.escape_err + current.escape_err;
694 604 // credit_err
695 grspw_stats.credit_err = grspw_stats.credit_err + spw_current.credit_err;
605 grspw_stats.credit_err = grspw_stats.credit_err + current.credit_err;
696 606 // write_sync_err
697 grspw_stats.write_sync_err = grspw_stats.write_sync_err + spw_current.write_sync_err;
607 grspw_stats.write_sync_err = grspw_stats.write_sync_err + current.write_sync_err;
698 608 // disconnect_err
699 grspw_stats.disconnect_err = grspw_stats.disconnect_err + spw_current.disconnect_err;
609 grspw_stats.disconnect_err = grspw_stats.disconnect_err + current.disconnect_err;
700 610 // early_ep
701 grspw_stats.early_ep = grspw_stats.early_ep + spw_current.early_ep;
611 grspw_stats.early_ep = grspw_stats.early_ep + current.early_ep;
702 612 // invalid_address
703 grspw_stats.invalid_address = grspw_stats.invalid_address + spw_current.invalid_address;
613 grspw_stats.invalid_address = grspw_stats.invalid_address + current.invalid_address;
704 614 // packets_sent
705 grspw_stats.packets_sent = grspw_stats.packets_sent + spw_current.packets_sent;
615 grspw_stats.packets_sent = grspw_stats.packets_sent + current.packets_sent;
706 616 // packets_received
707 grspw_stats.packets_received= grspw_stats.packets_received + spw_current.packets_received;
617 grspw_stats.packets_received= grspw_stats.packets_received + current.packets_received;
708 618
709 619 }
710 620
@@ -852,29 +762,29 void update_hk_lfr_last_er_fields(unsign
852 762 housekeeping_packet.hk_lfr_last_er_time[5] = fineTimePtr[3];
853 763 }
854 764
855 void update_hk_with_grspw_stats( spw_stats stats )
765 void update_hk_with_grspw_stats( void )
856 766 {
857 767 //****************************
858 768 // DPU_SPACEWIRE_IF_STATISTICS
859 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (stats.packets_received >> 8);
860 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (stats.packets_received);
861 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (stats.packets_sent >> 8);
862 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (stats.packets_sent);
769 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (grspw_stats.packets_received >> 8);
770 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (grspw_stats.packets_received);
771 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (grspw_stats.packets_sent >> 8);
772 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (grspw_stats.packets_sent);
863 773
864 774 //******************************************
865 775 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
866 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) stats.parity_err;
867 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) stats.disconnect_err;
868 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) stats.escape_err;
869 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) stats.credit_err;
870 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) stats.write_sync_err;
776 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) grspw_stats.parity_err;
777 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) grspw_stats.disconnect_err;
778 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) grspw_stats.escape_err;
779 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) grspw_stats.credit_err;
780 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) grspw_stats.write_sync_err;
871 781
872 782 //*********************************************
873 783 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
874 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) stats.early_ep;
875 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) stats.invalid_address;
876 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) stats.rx_eep_err;
877 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) stats.rx_truncated;
784 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) grspw_stats.early_ep;
785 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) grspw_stats.invalid_address;
786 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) grspw_stats.rx_eep_err;
787 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) grspw_stats.rx_truncated;
878 788 }
879 789
880 790 void increase_unsigned_char_counter( unsigned char *counter )
General Comments 0
You need to be logged in to leave comments. Login now