diff --git a/.hgsubstate b/.hgsubstate --- a/.hgsubstate +++ b/.hgsubstate @@ -1,2 +1,2 @@ 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters -1ffa3d630b9ced4a87a362dafb10d9838e9cc0d9 header/lfr_common_headers +94f0f2fccbcb8030d9437ffbb69ee0eefaaea188 header/lfr_common_headers diff --git a/header/fsw_init.h b/header/fsw_init.h --- a/header/fsw_init.h +++ b/header/fsw_init.h @@ -16,8 +16,8 @@ #include "avf1_prc1.h" #include "avf2_prc2.h" -extern rtems_name Task_name[20]; /* array of task names */ -extern rtems_id Task_id[20]; /* array of task ids */ +extern rtems_name Task_name[]; /* array of task names */ +extern rtems_id Task_id[]; /* array of task ids */ extern rtems_name timecode_timer_name; extern rtems_id timecode_timer_id; extern unsigned char pa_bia_status_info; diff --git a/header/fsw_misc.h b/header/fsw_misc.h --- a/header/fsw_misc.h +++ b/header/fsw_misc.h @@ -28,6 +28,8 @@ extern void CCR_getInstructionAndDataErr rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic rtems_id HK_id; // id of the HK rate monotonic period +rtems_name name_avgv_rate_monotonic; // name of the AVGV rate monotonic +rtems_id AVGV_id; // id of the AVGV rate monotonic period void timer_configure( unsigned char timer, unsigned int clock_divider, unsigned char interrupt_level, rtems_isr (*timer_isr)() ); @@ -50,6 +52,7 @@ void set_apbuart_scaler_reload_register( // RTEMS TASKS rtems_task load_task( rtems_task_argument argument ); rtems_task hous_task( rtems_task_argument argument ); +rtems_task avgv_task( rtems_task_argument argument ); rtems_task dumb_task( rtems_task_argument unused ); void init_housekeeping_parameters( void ); diff --git a/python_scripts/00_EQM_setup.py b/python_scripts/00_EQM_setup.py new file mode 100755 --- /dev/null +++ b/python_scripts/00_EQM_setup.py @@ -0,0 +1,31 @@ +import time + +proxy.loadSysDriver("SpwPlugin","SpwPlugin0") +SpwPlugin0.selectBridge("STAR-Dundee Spw USB Brick") + +proxy.loadSysDriverToParent("dsu3plugin","SpwPlugin0") +proxy.loadSysDriverToParent("LFRControlPlugin","SpwPlugin0") + +availableBrickCount = SpwPlugin0.StarDundeeGetAvailableBrickCount() +print str(availableBrickCount) + " SpaceWire brick(s) found" + +SpwPlugin0.StarDundeeSelectBrick(1) +SpwPlugin0.StarDundeeSetBrickAsARouter(1) +SpwPlugin0.StarDundeeSelectLinkNumber( 1 ) +SpwPlugin0.connectBridge() + +#SpwPlugin0.TCPServerSetIP("127.0.0.1") +SpwPlugin0.TCPServerConnect() + +# OPEN SPACEWIRE SERVER +#LFRControlPlugin0.SetSpwServerIP(129,104,27,164) +LFRControlPlugin0.TCPServerConnect() + +# OPEN TM ECHO BRIDGE SERVER +LFRControlPlugin0.TMEchoBridgeOpenPort() + +# START SENDING TIMECODES AT 1 Hz +SpwPlugin0.StarDundeeStartTimecodes( 1 ) + +# it is possible to change the time code frequency +#RMAPPlugin0.changeTimecodeFrequency(2) diff --git a/python_scripts/00_LFRControlPlugin_reload_fsw.py b/python_scripts/00_LFRControlPlugin_reload_fsw.py new file mode 100755 --- /dev/null +++ b/python_scripts/00_LFRControlPlugin_reload_fsw.py @@ -0,0 +1,14 @@ +# LOAD FSW USING LINK 1 +SpwPlugin0.StarDundeeSelectLinkNumber( 1 ) + +dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw") +#dsu3plugin0.openFile("/opt/LFR/LFR-FSW/2.0.2.3/fsw") +dsu3plugin0.loadFile() + +dsu3plugin0.run() + +# START SENDING TIMECODES AT 1 Hz +#SpwPlugin0.StarDundeeStartTimecodes( 1 ) + +# it is possible to change the time code frequency +#RMAPPlugin0.changeTimecodeFrequency(2) diff --git a/python_scripts/LFRControlPlugin_reload_fsw 3-0-0-10.py b/python_scripts/LFRControlPlugin_reload_fsw 3-0-0-10.py new file mode 100755 --- /dev/null +++ b/python_scripts/LFRControlPlugin_reload_fsw 3-0-0-10.py @@ -0,0 +1,13 @@ +# LOAD FSW USING LINK 1 +SpwPlugin0.StarDundeeSelectLinkNumber( 1 ) + +dsu3plugin0.openFile("/opt/LFR/LFR-FSW/3.0.0.10/fsw") +dsu3plugin0.loadFile() + +dsu3plugin0.run() + +# START SENDING TIMECODES AT 1 Hz +SpwPlugin0.StarDundeeStartTimecodes( 1 ) + +# it is possible to change the time code frequency +#RMAPPlugin0.changeTimecodeFrequency(2) diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -26,7 +26,7 @@ #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER -#define CONFIGURE_MAXIMUM_TASKS 20 +#define CONFIGURE_MAXIMUM_TASKS 21 // number of tasks concurrently active including INIT #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 @@ -34,7 +34,7 @@ #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) #define CONFIGURE_MAXIMUM_DRIVERS 16 -#define CONFIGURE_MAXIMUM_PERIODS 5 +#define CONFIGURE_MAXIMUM_PERIODS 5 // [hous] [load] [avgv] #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link] #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 #ifdef PRINT_STACK_REPORT @@ -143,10 +143,10 @@ rtems_task Init( rtems_task_argument ign PRINTF("*************************\n") PRINTF("** LFR Flight Software **\n") - PRINTF1("** %d.", SW_VERSION_N1) - PRINTF1("%d." , SW_VERSION_N2) - PRINTF1("%d." , SW_VERSION_N3) - PRINTF1("%d **\n", SW_VERSION_N4) + PRINTF1("** %d-", SW_VERSION_N1) + PRINTF1("%d-" , SW_VERSION_N2) + PRINTF1("%d-" , SW_VERSION_N3) + PRINTF1("%d **\n", SW_VERSION_N4) vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); PRINTF("** VHDL **\n") @@ -342,6 +342,7 @@ void create_names( void ) // create all */ // task names + Task_name[TASKID_AVGV] = rtems_build_name( 'A', 'V', 'G', 'V' ); Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); @@ -364,6 +365,7 @@ void create_names( void ) // create all // rate monotonic period names name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); + name_avgv_rate_monotonic = rtems_build_name( 'A', 'V', 'G', 'V' ); misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); @@ -553,6 +555,14 @@ int create_all_tasks( void ) // create a RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] ); } + if (status == RTEMS_SUCCESSFUL) // AVGV + { + status = rtems_task_create( + Task_name[TASKID_AVGV], TASK_PRIORITY_AVGV, RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVGV] + ); + } return status; } @@ -708,6 +718,13 @@ int start_all_tasks( void ) // start all BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") } } + if (status == RTEMS_SUCCESSFUL) // AVGV + { + status = rtems_task_start( Task_id[TASKID_AVGV], avgv_task, 1 ); + if (status!=RTEMS_SUCCESSFUL) { + BOOT_PRINTF("in INIT *** Error starting TASK_AVGV\n") + } + } if (status == RTEMS_SUCCESSFUL) // DUMB { status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); diff --git a/src/fsw_misc.c b/src/fsw_misc.c --- a/src/fsw_misc.c +++ b/src/fsw_misc.c @@ -335,6 +335,91 @@ rtems_task hous_task(rtems_task_argument return; } +rtems_task avgv_task(rtems_task_argument argument) +{ +#define MOVING_AVERAGE 16 + rtems_status_code status; + unsigned int v[MOVING_AVERAGE]; + unsigned int e1[MOVING_AVERAGE]; + unsigned int e2[MOVING_AVERAGE]; + float average_v; + float average_e1; + float average_e2; + unsigned char k; + unsigned char indexOfOldValue; + + BOOT_PRINTF("in AVGV ***\n"); + + if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { + status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); + if( status != RTEMS_SUCCESSFUL ) { + PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); + } + } + + status = rtems_rate_monotonic_cancel(AVGV_id); + if( status != RTEMS_SUCCESSFUL ) { + PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); + } + else { + DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); + } + + // initialize values + k = 0; + indexOfOldValue = MOVING_AVERAGE - 1; + for (k = 0; k < MOVING_AVERAGE; k++) + { + v[k] = 0; + e1[k] = 0; + e2[k] = 0; + average_v = 0.; + average_e1 = 0.; + average_e2 = 0.; + } + + k = 0; + + while(1){ // launch the rate monotonic task + status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); + if ( status != RTEMS_SUCCESSFUL ) { + PRINTF1( "in AVGV *** ERR period: %d\n", status); + } + else { + // store new value in buffer + v[k] = waveform_picker_regs->v; + e1[k] = waveform_picker_regs->e1; + e2[k] = waveform_picker_regs->e2; + if (k == (MOVING_AVERAGE - 1)) + { + indexOfOldValue = 0; + } + else + { + indexOfOldValue = k + 1; + } + average_v = average_v + v[k] - v[indexOfOldValue]; + average_e1 = average_e1 + e1[k] - e1[indexOfOldValue]; + average_e2 = average_e2 + e2[k] - e2[indexOfOldValue]; + } + if (k == (MOVING_AVERAGE-1)) + { + k = 0; + printf("tick\n"); + } + else + { + k++; + } + } + + PRINTF("in AVGV *** deleting task\n") + + status = rtems_task_delete( RTEMS_SELF ); // should not return + + return; +} + rtems_task dumb_task( rtems_task_argument unused ) { /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.