|
@@
-66,9
+66,8
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_save_stats();
|
|
69
|
spacewire_read_statistics();
|
|
70
|
status = spacewire_several_connect_attemps( );
|
|
70
|
status = spacewire_several_connect_attemps( );
|
|
71
|
spacewire_restore_stats();
|
|
|
|
|
72
|
}
|
|
71
|
}
|
|
73
|
else // [2.b] in run state, start the link
|
|
72
|
else // [2.b] in run state, start the link
|
|
74
|
{
|
|
73
|
{
|
|
@@
-353,9
+352,8
rtems_task link_task( rtems_task_argumen
|
|
353
|
watchdog_reload();
|
|
352
|
watchdog_reload();
|
|
354
|
}
|
|
353
|
}
|
|
355
|
|
|
354
|
|
|
356
|
spacewire_save_stats();
|
|
355
|
spacewire_read_statistics();
|
|
357
|
status = spacewire_stop_and_start_link( fdSPW );
|
|
356
|
status = spacewire_stop_and_start_link( fdSPW );
|
|
358
|
spacewire_restore_stats();
|
|
|
|
|
359
|
|
|
357
|
|
|
360
|
if (status != RTEMS_SUCCESSFUL)
|
|
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 )
|
|
568
|
void spacewire_read_statistics( 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 )
|
|
|
|
|
663
|
{
|
|
569
|
{
|
|
664
|
rtems_status_code status;
|
|
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, ¤t );
|
|
|
|
|
575
|
|
|
|
|
|
576
|
// clear the counters
|
|
|
|
|
577
|
status = ioctl( fdSPW, SPACEWIRE_IOCTRL_CLR_STATISTICS );
|
|
668
|
|
|
578
|
|
|
669
|
// typedef struct {
|
|
579
|
// typedef struct {
|
|
670
|
// unsigned int tx_link_err; // NOT IN HK
|
|
580
|
// unsigned int tx_link_err; // NOT IN HK
|
|
@@
-684,27
+594,27
void spacewire_update_statistics( void )
|
|
684
|
// } spw_stats;
|
|
594
|
// } spw_stats;
|
|
685
|
|
|
595
|
|
|
686
|
// rx_eep_err
|
|
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
|
// rx_truncated
|
|
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
|
// parity_err
|
|
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
|
// escape_err
|
|
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
|
// credit_err
|
|
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
|
// write_sync_err
|
|
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
|
// disconnect_err
|
|
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
|
// early_ep
|
|
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
|
// invalid_address
|
|
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
|
// packets_sent
|
|
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
|
// packets_received
|
|
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
|
housekeeping_packet.hk_lfr_last_er_time[5] = fineTimePtr[3];
|
|
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
|
// DPU_SPACEWIRE_IF_STATISTICS
|
|
768
|
// DPU_SPACEWIRE_IF_STATISTICS
|
|
859
|
housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (stats.packets_received >> 8);
|
|
769
|
housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (grspw_stats.packets_received >> 8);
|
|
860
|
housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (stats.packets_received);
|
|
770
|
housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (grspw_stats.packets_received);
|
|
861
|
housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (stats.packets_sent >> 8);
|
|
771
|
housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (grspw_stats.packets_sent >> 8);
|
|
862
|
housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (stats.packets_sent);
|
|
772
|
housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (grspw_stats.packets_sent);
|
|
863
|
|
|
773
|
|
|
864
|
//******************************************
|
|
774
|
//******************************************
|
|
865
|
// ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
|
|
775
|
// ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
|
|
866
|
housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) stats.parity_err;
|
|
776
|
housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) grspw_stats.parity_err;
|
|
867
|
housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) stats.disconnect_err;
|
|
777
|
housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) grspw_stats.disconnect_err;
|
|
868
|
housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) stats.escape_err;
|
|
778
|
housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) grspw_stats.escape_err;
|
|
869
|
housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) stats.credit_err;
|
|
779
|
housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) grspw_stats.credit_err;
|
|
870
|
housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) stats.write_sync_err;
|
|
780
|
housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) grspw_stats.write_sync_err;
|
|
871
|
|
|
781
|
|
|
872
|
//*********************************************
|
|
782
|
//*********************************************
|
|
873
|
// ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
|
|
783
|
// ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
|
|
874
|
housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) stats.early_ep;
|
|
784
|
housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) grspw_stats.early_ep;
|
|
875
|
housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) stats.invalid_address;
|
|
785
|
housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) grspw_stats.invalid_address;
|
|
876
|
housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) stats.rx_eep_err;
|
|
786
|
housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) grspw_stats.rx_eep_err;
|
|
877
|
housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) stats.rx_truncated;
|
|
787
|
housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) grspw_stats.rx_truncated;
|
|
878
|
}
|
|
788
|
}
|
|
879
|
|
|
789
|
|
|
880
|
void increase_unsigned_char_counter( unsigned char *counter )
|
|
790
|
void increase_unsigned_char_counter( unsigned char *counter )
|