diff --git a/.hgsubstate b/.hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,1 +1,1 @@ -b0a4fa20a3c7bd7e9ca1a1c4fda85d3269653bc8 src/basic_parameters +163519b5356a8bcd9197f504c31ad34b6233de38 src/basic_parameters diff --git a/FSW-qt/Makefile b/FSW-qt/Makefile --- a/FSW-qt/Makefile +++ b/FSW-qt/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bin/fsw -# Generated by qmake (2.01a) (Qt 4.8.6) on: Fri May 16 07:58:47 2014 +# Generated by qmake (2.01a) (Qt 4.8.6) on: Mon May 26 14:45:46 2014 # Project: fsw-qt.pro # Template: app # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro @@ -245,7 +245,8 @@ obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_ex obj/tc_acceptance.o: ../src/tc_acceptance.c $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c -obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h +obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h \ + ../src/basic_parameters/basic_parameters_params.h $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c obj/fsw_processing.o: ../src/processing/fsw_processing.c diff --git a/FSW-qt/fsw-qt.pro.user b/FSW-qt/fsw-qt.pro.user --- a/FSW-qt/fsw-qt.pro.user +++ b/FSW-qt/fsw-qt.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/header/processing/fsw_processing.h b/header/processing/fsw_processing.h --- a/header/processing/fsw_processing.h +++ b/header/processing/fsw_processing.h @@ -73,6 +73,7 @@ void reset_nb_sm( void ); // SM void SM_init_rings( void ); void SM_reset_current_ring_nodes( void ); +void SM_generic_init_ring(ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] ); // ASM void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header); diff --git a/src/fsw_misc.c b/src/fsw_misc.c --- a/src/fsw_misc.c +++ b/src/fsw_misc.c @@ -283,6 +283,10 @@ rtems_task dumb_task( rtems_task_argumen coarse_time = time_management_regs->coarse_time; fine_time = time_management_regs->fine_time; printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); + if (i==8) + { + PRINTF1("status = %x\n", spectral_matrix_regs->status) + } } } } @@ -436,7 +440,7 @@ void send_dumb_hk( void ) PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); } -void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) +void get_v_e1_e2_f3_old( unsigned char *spacecraft_potential ) { unsigned int coarseTime; unsigned int acquisitionTime; @@ -495,6 +499,65 @@ void get_v_e1_e2_f3( unsigned char *spac } } +void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) +{ + unsigned int coarseTime; + unsigned int acquisitionTime; + unsigned int deltaT = 0; + unsigned char *bufferPtr; + + unsigned int offset_in_samples; + unsigned int offset_in_bytes; + unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz + + if (lfrCurrentMode == LFR_MODE_STANDBY) + { + spacecraft_potential[0] = 0x00; + spacecraft_potential[1] = 0x00; + spacecraft_potential[2] = 0x00; + spacecraft_potential[3] = 0x00; + spacecraft_potential[4] = 0x00; + spacecraft_potential[5] = 0x00; + } + else + { + coarseTime = time_management_regs->coarse_time & 0x7fffffff; + bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address; + acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 ) + + (unsigned int) ( bufferPtr[1] << 16 ) + + (unsigned int) ( bufferPtr[2] << 8 ) + + (unsigned int) ( bufferPtr[3] ); + if ( coarseTime > acquisitionTime ) + { + deltaT = coarseTime - acquisitionTime; + offset_in_samples = (deltaT-1) * f3 ; + } + else if( coarseTime == acquisitionTime ) + { + bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer + offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1; + } + else + { + offset_in_samples = 0; + PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime) + } + + if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) ) + { + PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples) + offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1; + } + offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4; + spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0]; + spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1]; + spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2]; + spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3]; + spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4]; + spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5]; + } +} + void get_cpu_load( unsigned char *resource_statistics ) { unsigned char cpu_load; diff --git a/src/lfr_cpu_usage_report.c b/src/lfr_cpu_usage_report.c new file mode 100644 --- /dev/null +++ b/src/lfr_cpu_usage_report.c @@ -0,0 +1,145 @@ +/* + * CPU Usage Reporter + * + * COPYRIGHT (c) 1989-2009 + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "lfr_cpu_usage_report.h" + +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + #include +#endif + +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + extern Timestamp_Control CPU_usage_Uptime_at_last_reset; +#else + extern uint32_t CPU_usage_Ticks_at_last_reset; +#endif + +/*PAGE + * + * rtems_cpu_usage_report + */ + +unsigned char lfr_rtems_cpu_usage_report( void ) +{ + uint32_t api_index; + Thread_Control *the_thread; + Objects_Information *information; + uint32_t ival, fval; +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + Timestamp_Control uptime, total, ran; +#else + uint32_t total_units = 0; +#endif + + unsigned char cpu_load; + cpu_load = 0; + + /* + * When not using nanosecond CPU usage resolution, we have to count + * the number of "ticks" we gave credit for to give the user a rough + * guideline as to what each number means proportionally. + */ +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + _TOD_Get_uptime( &uptime ); + _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total ); +#else + for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) { + if ( !_Objects_Information_table[ api_index ] ) + { + continue; + } + information = _Objects_Information_table[ api_index ][ 1 ]; + if ( information ) + { + for ( i=1 ; i <= information->maximum ; i++ ) { + the_thread = (Thread_Control *)information->local_table[ i ]; + + if ( the_thread ) + total_units += the_thread->cpu_time_used; + } + } + } +#endif + + for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) + { + if ( !_Objects_Information_table[ api_index ] ) + { + continue; + } + information = _Objects_Information_table[ api_index ][ 1 ]; + if ( information ) + { + the_thread = (Thread_Control *)information->local_table[ 1 ]; + + if ( !the_thread ) + { + continue; + } + +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + /* + * If this is the currently executing thread, account for time + * since the last context switch. + */ + ran = the_thread->cpu_time_used; + if ( _Thread_Executing->Object.id == the_thread->Object.id ) + { + Timestamp_Control used; + _Timestamp_Subtract( + &_Thread_Time_of_last_context_switch, &uptime, &used + ); + _Timestamp_Add_to( &ran, &used ); + } + _Timestamp_Divide( &ran, &total, &ival, &fval ); + +#else + if (total_units) + { + uint64_t ival_64; + + ival_64 = the_thread->cpu_time_used; + ival_64 *= 100000; + ival = ival_64 / total_units; + } + else + { + ival = 0; + } + + fval = ival % 1000; + ival /= 1000; +#endif + } + } + cpu_load = (unsigned char) (100 - ival); + + return cpu_load; +} + + diff --git a/src/processing/avf0_prc0.c b/src/processing/avf0_prc0.c --- a/src/processing/avf0_prc0.c +++ b/src/processing/avf0_prc0.c @@ -248,6 +248,7 @@ rtems_task prc0_task( rtems_task_argumen incomingMsg = (asm_msg*) incomingData; localTime = getTimeAsUnsignedLongLongInt( ); + //**************** //**************** // BURST SBM1 SBM2 diff --git a/src/processing/fsw_processing.c b/src/processing/fsw_processing.c --- a/src/processing/fsw_processing.c +++ b/src/processing/fsw_processing.c @@ -32,40 +32,65 @@ ring_node_sm *ring_node_for_averaging_sm rtems_isr spectral_matrices_isr( rtems_vector_number vector ) { -// ring_node_sm *previous_ring_node_sm_f0; - -//// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); - -// previous_ring_node_sm_f0 = current_ring_node_sm_f0; + //*** + // F0 + if ( (spectral_matrix_regs->status & 0x1) == 0x01) // check the status_ready_matrix_f0 bit + { + nb_sm_f0 = nb_sm_f0 + 1; + if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) + { + ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; + current_ring_node_sm_f0 = current_ring_node_sm_f0->next; + spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; + if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) + { + rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + } + nb_sm_f0 = 0; + } + spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110 + } -// if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1 -// { -// current_ring_node_sm_f0 = current_ring_node_sm_f0->next; -// spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; -// spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101 -// nb_sm_f0 = nb_sm_f0 + 1; -// } + //*** + // F1 + if ( (spectral_matrix_regs->status & 0x4) == 0x04) // check the status_ready_matrix_f1 bit + { + nb_sm_f1 = nb_sm_f1 + 1; + if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) + { + ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; + current_ring_node_sm_f1 = current_ring_node_sm_f1->next; + spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address; + if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) + { + rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + } + nb_sm_f1 = 0; + } + spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb; // 1011 + } -// //************************ -// // reset status error bits -// if ( (spectral_matrix_regs->status & 0x30) != 0x00) + //*** + // F2 + if ( (spectral_matrix_regs->status & 0x8) == 0x08) // check the status_ready_matrix_f2 bit + { + + ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; + current_ring_node_sm_f2 = current_ring_node_sm_f2->next; + spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address; + if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) + { + rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + } + spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7; // 0111 + } + + //************************ + // reset status error bits +// if ( (spectral_matrix_regs->status & 0x3e0) != 0x00) // [0011 1110 0000] check the status bits // { // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); -// spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111 -// } - -// //************************************** -// // reset ready matrix bits for f0_0, f1 and f2 -// spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010 - -// if (nb_sm_f0 == NB_SM_BEFORE_AVF0) -// { -// ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0; -// if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) -// { -// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); -// } -// nb_sm_f0 = 0; +// spectral_matrix_regs->status = spectral_matrix_regs->status | 0xfffffc1f; // [1100 0001 1111] // } } @@ -198,6 +223,34 @@ void SM_init_rings( void ) DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0) } +void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] ) +{ + unsigned char i; + + //*************** + // BUFFER ADDRESS + for(i=0; i> 24 ); + localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); + localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); + localAcquisitionTime[3] = (unsigned char) ( coarseTime ); + localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 ); + localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 ); + + acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) + + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) + + ( localAcquisitionTime[2] << 24 ) + + ( localAcquisitionTime[3] << 16 ) + + ( localAcquisitionTime[4] << 8 ) + + ( localAcquisitionTime[5] ); + + switch( sid ) + { + case SID_NORM_SWF_F0: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; + break; + + case SID_NORM_SWF_F1: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; + break; + + case SID_NORM_SWF_F2: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; + break; + + case SID_SBM1_CWF_F1: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; + break; + + case SID_SBM2_CWF_F2: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; + break; + + case SID_BURST_CWF_F2: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; + break; + + case SID_NORM_CWF_F3: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; + break; + + case SID_NORM_CWF_LONG_F3: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; + break; + + default: + PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid) + deltaT = 0.; + break; + } + + acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; + // + acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); + acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); + acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); + acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); + acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); + acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); + +} + void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel ) { unsigned int i; @@ -1018,7 +1092,7 @@ void build_snapshot_from_ring( ring_node } } -void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node ) +void build_acquisition_time_old( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node ) { unsigned char *acquisitionTimeCharPtr; @@ -1033,6 +1107,21 @@ void build_acquisition_time( unsigned lo + ( acquisitionTimeCharPtr[5] ); } +void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node ) +{ + unsigned char *acquisitionTimeCharPtr; + + acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address; + + *acquisitionTimeAslong = 0x00; + *acquisitionTimeAslong = ( (unsigned long long int) (acquisitionTimeCharPtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit + + ( (unsigned long long int) acquisitionTimeCharPtr[1] << 32 ) + + ( acquisitionTimeCharPtr[2] << 24 ) + + ( acquisitionTimeCharPtr[3] << 16 ) + + ( acquisitionTimeCharPtr[4] << 8 ) + + ( acquisitionTimeCharPtr[5] ); +} + //************** // wfp registers void reset_wfp_burst_enable(void)