Line data Source code
1 : /*------------------------------------------------------------------------------ 2 : -- Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW), 3 : -- This file is a part of the LFR FSW 4 : -- Copyright (C) 2021, Plasma Physics Laboratory - CNRS 5 : -- 6 : -- This program is free software; you can redistribute it and/or modify 7 : -- it under the terms of the GNU General Public License as published by 8 : -- the Free Software Foundation; either version 2 of the License, or 9 : -- (at your option) any later version. 10 : -- 11 : -- This program is distributed in the hope that it will be useful, 12 : -- but WITHOUT ANY WARRANTY; without even the implied warranty of 13 : -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 : -- GNU General Public License for more details. 15 : -- 16 : -- You should have received a copy of the GNU General Public License 17 : -- along with this program; if not, write to the Free Software 18 : -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 : -------------------------------------------------------------------------------*/ 20 : /*-- Author : Alexis Jeandet 21 : -- Contact : Alexis Jeandet 22 : -- Mail : alexis.jeandet@lpp.polytechnique.fr 23 : ----------------------------------------------------------------------------*/ 24 : #include "fsw_housekeeping.h" 25 : #include "fsw_debug.h" 26 : #include "fsw_globals.h" 27 : #include "fsw_misc.h" 28 : #include "lfr_cpu_usage_report.h" 29 : 30 : 31 18 : void init_housekeeping_parameters(void) 32 : { 33 : /** This function initialize the housekeeping_packet global variable with default values. 34 : * 35 : */ 36 : 37 : unsigned char* parameters; 38 : unsigned char sizeOfHK; 39 : 40 18 : sizeOfHK = sizeof(Packet_TM_LFR_HK_t); 41 : 42 18 : parameters = (unsigned char*)&housekeeping_packet; 43 : 44 2538 : for (int i = 0; i < sizeOfHK; i++) 45 : { 46 2520 : parameters[i] = INIT_CHAR; 47 : } 48 : 49 18 : housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; 50 18 : housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; 51 18 : housekeeping_packet.reserved = DEFAULT_RESERVED; 52 18 : housekeeping_packet.userApplication = CCSDS_USER_APP; 53 18 : housekeeping_packet.packetID[0] = (unsigned char)(APID_TM_HK >> SHIFT_1_BYTE); 54 18 : housekeeping_packet.packetID[1] = (unsigned char)(APID_TM_HK); 55 18 : housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; 56 18 : housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; 57 18 : housekeeping_packet.packetLength[0] = (unsigned char)(PACKET_LENGTH_HK >> SHIFT_1_BYTE); 58 18 : housekeeping_packet.packetLength[1] = (unsigned char)(PACKET_LENGTH_HK); 59 18 : housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; 60 18 : housekeeping_packet.serviceType = TM_TYPE_HK; 61 18 : housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; 62 18 : housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; 63 18 : housekeeping_packet.sid = SID_HK; 64 : 65 : // init status word 66 18 : housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; 67 18 : housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; 68 : // init software version 69 18 : housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; 70 18 : housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; 71 18 : housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; 72 18 : housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; 73 : // init fpga version 74 18 : parameters = (unsigned char*)(REGS_ADDR_VHDL_VERSION); 75 18 : housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 76 18 : housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 77 18 : housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 78 : 79 18 : housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; 80 18 : housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; 81 18 : housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; 82 18 : housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; 83 18 : housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; 84 18 : } 85 : 86 197 : void set_hk_lfr_sc_potential_flag(bool state) 87 : { 88 197 : if (state == true) 89 : { 90 197 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] 91 : | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] 92 : } 93 : else 94 : { 95 0 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] 96 : & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] 97 : } 98 197 : } 99 : 100 98 : void set_sy_lfr_pas_filter_enabled(bool state) 101 : { 102 98 : if (state == true) 103 : { 104 78 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] 105 : | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000] 106 : } 107 : else 108 : { 109 20 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] 110 : & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111] 111 : } 112 98 : } 113 : 114 18 : void set_sy_lfr_watchdog_enabled(bool state) 115 : { 116 18 : if (state == true) 117 : { 118 18 : housekeeping_packet.lfr_status_word[1] 119 18 : = housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] 120 : } 121 : else 122 : { 123 0 : housekeeping_packet.lfr_status_word[1] 124 0 : = housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] 125 : } 126 18 : } 127 : 128 162 : void set_hk_lfr_calib_enable(bool state) 129 : { 130 162 : if (state == true) 131 : { 132 72 : housekeeping_packet.lfr_status_word[1] 133 72 : = housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] 134 : } 135 : else 136 : { 137 90 : housekeeping_packet.lfr_status_word[1] 138 90 : = housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] 139 : } 140 162 : } 141 : 142 18 : void set_hk_lfr_reset_cause(enum lfr_reset_cause_t lfr_reset_cause) 143 : { 144 18 : housekeeping_packet.lfr_status_word[1] 145 18 : = housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] 146 : 147 18 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] 148 : | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS); // [0000 0111] 149 18 : } 150 : 151 0 : void increment_hk_counter(unsigned char newValue, unsigned char oldValue, unsigned int* counter) 152 : { 153 87984 : int delta = 0; 154 : 155 87984 : if (newValue >= oldValue) 156 : { 157 87982 : delta = newValue - oldValue; 158 : } 159 : else 160 : { 161 2 : delta = (MAX_OF(unsigned char) + 1 - oldValue) + newValue; 162 : } 163 : 164 87984 : *counter = *counter + delta; 165 0 : } 166 : 167 : // Low severity error counters update 168 5499 : void hk_lfr_le_update(void) 169 : { 170 : static hk_lfr_le_t old_hk_lfr_le = { 0 }; 171 : hk_lfr_le_t new_hk_lfr_le; 172 : unsigned int counter; 173 : 174 10998 : counter = (((unsigned int)housekeeping_packet.hk_lfr_le_cnt[0]) * CONST_256) 175 5499 : + housekeeping_packet.hk_lfr_le_cnt[1]; 176 : 177 : // DPU 178 5499 : new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; 179 5499 : new_hk_lfr_le.dpu_spw_disconnect = housekeeping_packet.hk_lfr_dpu_spw_disconnect; 180 5499 : new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; 181 5499 : new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; 182 5499 : new_hk_lfr_le.dpu_spw_write_sync = housekeeping_packet.hk_lfr_dpu_spw_write_sync; 183 : // TIMECODE 184 5499 : new_hk_lfr_le.timecode_erroneous = housekeeping_packet.hk_lfr_timecode_erroneous; 185 5499 : new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; 186 5499 : new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; 187 : // TIME 188 5499 : new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; 189 5499 : new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; 190 5499 : new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; 191 : // AHB 192 5499 : new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; 193 : // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver 194 : // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver 195 : 196 : // update the le counter 197 : // DPU 198 5499 : increment_hk_counter(new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter); 199 10998 : increment_hk_counter( 200 10998 : new_hk_lfr_le.dpu_spw_disconnect, old_hk_lfr_le.dpu_spw_disconnect, &counter); 201 5499 : increment_hk_counter(new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter); 202 5499 : increment_hk_counter(new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter); 203 10998 : increment_hk_counter( 204 10998 : new_hk_lfr_le.dpu_spw_write_sync, old_hk_lfr_le.dpu_spw_write_sync, &counter); 205 : // TIMECODE 206 10998 : increment_hk_counter( 207 10998 : new_hk_lfr_le.timecode_erroneous, old_hk_lfr_le.timecode_erroneous, &counter); 208 5499 : increment_hk_counter(new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter); 209 5499 : increment_hk_counter(new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter); 210 : // TIME 211 5499 : increment_hk_counter(new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter); 212 5499 : increment_hk_counter(new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter); 213 10998 : increment_hk_counter( 214 10998 : new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter); 215 : // AHB 216 5499 : increment_hk_counter(new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter); 217 : 218 : 219 5499 : old_hk_lfr_le = new_hk_lfr_le; 220 : // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver 221 : // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver 222 : 223 : // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers 224 : // LE 225 5499 : housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char)((counter & BYTE0_MASK) >> SHIFT_1_BYTE); 226 5499 : housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char)(counter & BYTE1_MASK); 227 5499 : } 228 : 229 : // Medium severity error counters update 230 5499 : void hk_lfr_me_update(void) 231 : { 232 : static hk_lfr_me_t old_hk_lfr_me = { 0 }; 233 : hk_lfr_me_t new_hk_lfr_me; 234 : unsigned int counter; 235 : 236 10998 : counter = (((unsigned int)housekeeping_packet.hk_lfr_me_cnt[0]) * CONST_256) 237 5499 : + housekeeping_packet.hk_lfr_me_cnt[1]; 238 : 239 : // get the current values 240 5499 : new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; 241 5499 : new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; 242 5499 : new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; 243 5499 : new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; 244 : 245 : // update the me counter 246 10998 : increment_hk_counter( 247 10998 : new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter); 248 10998 : increment_hk_counter( 249 10998 : new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter); 250 5499 : increment_hk_counter(new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter); 251 10998 : increment_hk_counter( 252 10998 : new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter); 253 : 254 : // store the counters for the next time 255 5499 : old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; 256 5499 : old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; 257 5499 : old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; 258 5499 : old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; 259 : 260 : // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers 261 : // ME 262 5499 : housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char)((counter & BYTE0_MASK) >> SHIFT_1_BYTE); 263 5499 : housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char)(counter & BYTE1_MASK); 264 5499 : } 265 : 266 : // High severity error counters update 267 5499 : void hk_lfr_le_me_he_update() 268 : { 269 : 270 : // update the low severity error counter 271 5499 : hk_lfr_le_update(); 272 : 273 : // update the medium severity error counter 274 5499 : hk_lfr_me_update(); 275 : 276 : // update the high severity error counter 277 : // LFR has no high severity errors 278 5499 : housekeeping_packet.hk_lfr_he_cnt[0] = 0; 279 5499 : housekeeping_packet.hk_lfr_he_cnt[1] = 0; 280 5499 : } 281 : 282 5499 : void set_hk_lfr_time_not_synchro() 283 : { 284 : static unsigned char synchroLost = 1; 285 : int synchronizationBit; 286 : 287 : // get the synchronization bit 288 5499 : synchronizationBit = (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) 289 : >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 290 : 291 5499 : switch (synchronizationBit) 292 : { 293 : case 0: 294 1020 : if (synchroLost == 1) 295 : { 296 6 : synchroLost = 0; 297 : } 298 : break; 299 : case 1: 300 4479 : if (synchroLost == 0) 301 : { 302 0 : synchroLost = 1; 303 0 : housekeeping_packet.hk_lfr_time_not_synchro 304 0 : = increase_unsigned_char_counter(housekeeping_packet.hk_lfr_time_not_synchro); 305 0 : update_hk_lfr_last_er_fields(RID_LE_LFR_TIME, CODE_NOT_SYNCHRO); 306 : } 307 : break; 308 : default: 309 : LFR_PRINTF( 310 : "in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", 311 : synchronizationBit); 312 : break; 313 : } 314 5499 : } 315 : 316 5499 : void increment_seq_counter(unsigned short* packetSequenceControl) 317 : { 318 : /** This function increment the sequence counter passes in argument. 319 : * 320 : * The increment does not affect the grouping flag. In case of an overflow, the counter is reset 321 : * to 0. 322 : * 323 : */ 324 : 325 : unsigned short segmentation_grouping_flag; 326 : unsigned short sequence_cnt; 327 : 328 5499 : segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE 329 : << SHIFT_1_BYTE; // keep bits 7 downto 6 330 5499 : sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] 331 : 332 5499 : if (sequence_cnt < SEQ_CNT_MAX) 333 : { 334 5499 : sequence_cnt = sequence_cnt + 1; 335 : } 336 : else 337 : { 338 0 : sequence_cnt = 0; 339 : } 340 : 341 5499 : *packetSequenceControl = segmentation_grouping_flag | sequence_cnt; 342 5499 : } 343 : 344 1682 : void update_hk_lfr_last_er_fields(unsigned int rid, unsigned char code) 345 : { 346 : const volatile unsigned char* const coarseTimePtr 347 1682 : = (volatile unsigned char*)&time_management_regs->coarse_time; 348 : const volatile unsigned char* const fineTimePtr 349 1682 : = (volatile unsigned char*)&time_management_regs->fine_time; 350 : 351 1682 : housekeeping_packet.hk_lfr_last_er_rid[0] = (unsigned char)((rid & BYTE0_MASK) >> SHIFT_1_BYTE); 352 1682 : housekeeping_packet.hk_lfr_last_er_rid[1] = (unsigned char)(rid & BYTE1_MASK); 353 1682 : housekeeping_packet.hk_lfr_last_er_code = code; 354 1682 : housekeeping_packet.hk_lfr_last_er_time[0] = coarseTimePtr[0]; 355 1682 : housekeeping_packet.hk_lfr_last_er_time[1] = coarseTimePtr[1]; 356 1682 : housekeeping_packet.hk_lfr_last_er_time[BYTE_2] = coarseTimePtr[BYTE_2]; 357 1682 : housekeeping_packet.hk_lfr_last_er_time[BYTE_3] = coarseTimePtr[BYTE_3]; 358 1682 : housekeeping_packet.hk_lfr_last_er_time[BYTE_4] = fineTimePtr[BYTE_2]; 359 1682 : housekeeping_packet.hk_lfr_last_er_time[BYTE_5] = fineTimePtr[BYTE_3]; 360 1682 : } 361 : 362 0 : void set_hk_lfr_ahb_correctable() // CRITICITY L 363 : { 364 : /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided 365 : * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control 366 : * Register (ASR16) on the detected errors in the cache, in the integer unit and in the floating 367 : * point unit. 368 : * 369 : * @param void 370 : * 371 : * @return void 372 : * 373 : * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. 374 : * 375 : */ 376 : 377 : unsigned int ahb_correctable; 378 : unsigned int instructionErrorCounter; 379 : unsigned int dataErrorCounter; 380 : unsigned int fprfErrorCounter; 381 : unsigned int iurfErrorCounter; 382 : 383 0 : instructionErrorCounter = 0; 384 0 : dataErrorCounter = 0; 385 0 : fprfErrorCounter = 0; 386 0 : iurfErrorCounter = 0; 387 : 388 0 : CCR_getInstructionAndDataErrorCounters(&instructionErrorCounter, &dataErrorCounter); 389 0 : ASR16_get_FPRF_IURF_ErrorCounters(&fprfErrorCounter, &iurfErrorCounter); 390 : 391 0 : ahb_correctable = instructionErrorCounter + dataErrorCounter + fprfErrorCounter 392 0 : + iurfErrorCounter + housekeeping_packet.hk_lfr_ahb_correctable; 393 : 394 0 : housekeeping_packet.hk_lfr_ahb_correctable 395 0 : = (unsigned char)(ahb_correctable & INT8_ALL_F); // [1111 1111] 396 0 : } 397 : 398 : 399 2212 : void getTime(unsigned char* time) 400 : { 401 : /** This function write the current local time in the time buffer passed in argument. 402 : * 403 : */ 404 : 405 2212 : time[0] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_3_BYTES); 406 2212 : time[1] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_2_BYTES); 407 2212 : time[2] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_1_BYTE); 408 2212 : time[3] = (unsigned char)(time_management_regs->coarse_time); 409 2212 : time[4] = (unsigned char)(time_management_regs->fine_time >> SHIFT_1_BYTE); 410 2212 : time[5] = (unsigned char)(time_management_regs->fine_time); 411 2212 : } 412 : 413 0 : unsigned long long int getTimeAsUnsignedLongLongInt() 414 : { 415 : /** This function write the current local time in the time buffer passed in argument. 416 : * 417 : */ 418 : unsigned long long int time; 419 : 420 0 : time = ((unsigned long long int)(time_management_regs->coarse_time & COARSE_TIME_MASK) 421 : << SHIFT_2_BYTES) 422 0 : + time_management_regs->fine_time; 423 : 424 0 : return time; 425 : } 426 : 427 : 428 : /** 429 : * @brief get_cpu_load, computes CPU load, CPU load average and CPU load max 430 : * @param resource_statistics stores: 431 : * - CPU load at index 0 432 : * - CPU load max at index 1 433 : * - CPU load average at index 2 434 : * 435 : * The CPU load average is computed on the last 60 values with a simple moving average. 436 : */ 437 5499 : void encode_cpu_load(Packet_TM_LFR_HK_t* hk_packet) 438 : { 439 : #define LOAD_AVG_SIZE 60 440 : static unsigned char cpu_load_hist[LOAD_AVG_SIZE] = { 0 }; 441 : static char old_avg_pos = 0; 442 : static unsigned int cpu_load_avg; 443 : unsigned char cpu_load; 444 : 445 5499 : cpu_load = lfr_rtems_cpu_usage_report(); 446 : 447 : // HK_LFR_CPU_LOAD 448 5499 : hk_packet->hk_lfr_cpu_load = cpu_load; 449 : 450 : // HK_LFR_CPU_LOAD_MAX 451 5499 : if (cpu_load > hk_packet->hk_lfr_cpu_load_max) 452 : { 453 182 : hk_packet->hk_lfr_cpu_load_max = cpu_load; 454 : } 455 : 456 5499 : cpu_load_avg 457 5499 : = cpu_load_avg - (unsigned int)cpu_load_hist[(int)old_avg_pos] + (unsigned int)cpu_load; 458 5499 : cpu_load_hist[(int)old_avg_pos] = cpu_load; 459 5499 : old_avg_pos += 1; 460 5499 : old_avg_pos %= LOAD_AVG_SIZE; 461 : // CPU_LOAD_AVE 462 5499 : hk_packet->hk_lfr_cpu_load_aver = (unsigned char)(cpu_load_avg / LOAD_AVG_SIZE); 463 : // this will change the way LFR compute usage 464 : #ifndef PRINT_TASK_STATISTICS 465 5499 : rtems_cpu_usage_reset(); 466 : #endif 467 5499 : }