# HG changeset patch # User paul # Date 2014-04-28 13:34:54 # Node ID 5ae10b1b807871d194d7d804be17ee2d11cacdcd # Parent de367ad91bd062e8efcd0eed1870ad315689b25b Sources reorganized static inline functions addded for better performances 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.5) on: Sun Apr 27 16:27:36 2014 +# Generated by qmake (2.01a) (Qt 4.8.5) on: Mon Apr 28 15:02:06 2014 # Project: fsw-qt.pro # Template: app # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro @@ -10,10 +10,10 @@ CC = sparc-rtems-gcc CXX = sparc-rtems-g++ -DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES -DPRINT_TASK_STATISTICS -DBOOT_MESSAGES +DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS CFLAGS = -pipe -O3 -Wall $(DEFINES) CXXFLAGS = -pipe -O3 -Wall $(DEFINES) -INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters -I../src/avf_prc +INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/basic_parameters LINK = sparc-rtems-g++ LFLAGS = LIBS = $(SUBLIBS) @@ -53,10 +53,10 @@ SOURCES = ../src/wf_handler.c \ ../src/tm_lfr_tc_exe.c \ ../src/tc_acceptance.c \ ../src/basic_parameters/basic_parameters.c \ - ../src/avf_prc/fsw_processing.c \ - ../src/avf_prc/avf0_prc0.c \ - ../src/avf_prc/avf1_prc1.c \ - ../src/avf_prc/avf2_prc2.c + ../src/processing/fsw_processing.c \ + ../src/processing/avf0_prc0.c \ + ../src/processing/avf1_prc1.c \ + ../src/processing/avf2_prc2.c OBJECTS = obj/wf_handler.o \ obj/tc_handler.o \ obj/fsw_misc.o \ @@ -246,20 +246,17 @@ obj/tc_acceptance.o: ../src/tc_acceptanc obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c -obj/fsw_processing.o: ../src/avf_prc/fsw_processing.c ../src/avf_prc/fsw_processing.h - $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/avf_prc/fsw_processing.c +obj/fsw_processing.o: ../src/processing/fsw_processing.c + $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c -obj/avf0_prc0.o: ../src/avf_prc/avf0_prc0.c ../src/avf_prc/avf0_prc0.h \ - ../src/avf_prc/fsw_processing.h - $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/avf_prc/avf0_prc0.c +obj/avf0_prc0.o: ../src/processing/avf0_prc0.c + $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c -obj/avf1_prc1.o: ../src/avf_prc/avf1_prc1.c ../src/avf_prc/avf1_prc1.h \ - ../src/avf_prc/fsw_processing.h - $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/avf_prc/avf1_prc1.c +obj/avf1_prc1.o: ../src/processing/avf1_prc1.c + $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c -obj/avf2_prc2.o: ../src/avf_prc/avf2_prc2.c ../src/avf_prc/avf2_prc2.h \ - ../src/avf_prc/fsw_processing.h - $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/avf_prc/avf2_prc2.c +obj/avf2_prc2.o: ../src/processing/avf2_prc2.c + $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c ####### Install diff --git a/FSW-qt/bin/__init__.py b/FSW-qt/bin/__init__.py new file mode 100644 diff --git a/FSW-qt/bin/lfr_fsw.sublime-project b/FSW-qt/bin/lfr_fsw.sublime-project new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/lfr_fsw.sublime-project @@ -0,0 +1,11 @@ +{ + "folders": + [ + { + "path": "/opt/DEV_PLE/FSW-qt/bin" + }, + { + "path": "spectralmatrix" + } + ] +} diff --git a/FSW-qt/bin/lfr_fsw.sublime-workspace b/FSW-qt/bin/lfr_fsw.sublime-workspace new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/lfr_fsw.sublime-workspace @@ -0,0 +1,282 @@ +{ + "auto_complete": + { + "selected_items": + [ + [ + "data", + "dataInIntReorganized" + ], + [ + "index", + "indexTransformDecimationInFrequency" + ], + [ + "in", + "indexTransformDecimationInFrequency" + ], + [ + "dft", + "dft_val" + ], + [ + "butter", + "butterflyProcessor" + ], + [ + "chec", + "checkbox_sy_lfr_bw" + ], + [ + "send", + "sendLoadCommonPar" + ], + [ + "groupbo", + "groupbox_tc_lfr_load_common_par" + ], + [ + "l", + "layout_tc" + ], + [ + "button", + "button_tc_lfr_load_common_par" + ], + [ + "a", + "addWidget" + ], + [ + "group", + "groupbox_tc_lfr_load_common_par" + ], + [ + "c", + "common" + ], + [ + "laben", + "label_UNKNOWN_nb" + ], + [ + "UN", + "UNKNOWN_nb" + ] + ] + }, + "buffers": + [ + { + "file": "spectralmatrix/readmatrix.py", + "settings": + { + "buffer_size": 1115, + "line_ending": "Unix" + } + } + ], + "build_system": "", + "command_palette": + { + "height": 392.0, + "selected_items": + [ + ], + "width": 392.0 + }, + "console": + { + "height": 0.0 + }, + "distraction_free": + { + "menu_visible": true, + "show_minimap": false, + "show_open_files": false, + "show_tabs": false, + "side_bar_visible": false, + "status_bar_visible": false + }, + "file_history": + [ + "/opt/DEV_PLE/FSW-qt/bin/spectralmatrix/asm_f0_test_20140403_case1.txt", + "/opt/DEV_PLE/FSW-qt/bin/spectralmatrix/asm_f0_test_paul_1.txt", + "/opt/DEV_PLE/FSW-qt/bin/load_spectral_matrix.py", + "/opt/DEV_PLE/FSW-qt/bin/floatconversion.py", + "/opt/VALIDATION/waveform_analysis/main_sbm2.py", + "/opt/VALIDATION/waveform_analysis/main_cwf_f1.py", + "/opt/VALIDATION/waveform_analysis/main_cwf_f3.py", + "/opt/VALIDATION/waveform_analysis/main_cwf_f2.py", + "/opt/VALIDATION/waveform_analysis/main_128.py", + "/opt/VALIDATION/waveform_analysis/main_64.py", + "/opt/LFR_EMULATOR/SRC/testing_FFT.py", + "/opt/LFR_EMULATOR/main.py", + "/opt/LFR_EMULATOR/fft_8_decimation_in_frequency.py", + "/opt/LFR_EMULATOR/index_transform_decimation_in_frequency.py", + "/opt/LFR_EMULATOR/efficient_complex_multiplier.py", + "/opt/LFR_EMULATOR/butterfly_processor.py", + "/opt/LFR_EMULATOR/twiddle_factors.py", + "/opt/LFR_EMULATOR/SRC/filters.py", + "/opt/LFR_EMULATOR/SRC/test_cases1.py", + "/opt/VALIDATION/lfrverif/LFR_SVS/SVS-0001/Step02/UploadDumpMemory.py", + "/opt/VALIDATION/lfrverif/LFR_SVS/SVS-0001/Step02/UploadDumpMemory (copy).py", + "/opt/VALIDATION/lfrverif/LFR_SVS/SVS-0001/Step01/grspw_registers.py", + "/opt/VALIDATION/lfrverif/LFR_SVS/SVS-0002/tc_during_matrix_transmission.py", + "/opt/VALIDATION/lfrverif/common/actions_tc_lfr_launcher.py", + "/opt/VALIDATION/lfrverif/common/test_monitor.py", + "/opt/VALIDATION/validation.sublime-workspace", + "/opt/VALIDATION/validation.sublime-project", + "/opt/PYTHON/lfrverif/test1/test1main.py", + "/opt/PYTHON/lfrverif/test1/test1launcher.py", + "/opt/PYTHON/lfrverif/common/crcforlfr.py", + "/opt/PYTHON/lfrverif/common/tcparams.py", + "/opt/PYTHON/lfrverif/test1/testgui.py", + "/opt/PYTHON/lfrverif/test1/tcmonitor.py", + "/opt/PYTHON/lfrverif/test1/lppmoncfg.py", + "/opt/PYTHON/lfrverif/test1/wfdisplay.py", + "/opt/PYTHON/lfrverif/test1/lppmonplot.py", + "/opt/PYTHON/lfrverif/test1/tmmonitor.py" + ], + "find": + { + "height": 34.0 + }, + "find_in_files": + { + "height": 0.0, + "where_history": + [ + "/opt/VALIDATION/lfrverif", + "/opt/VALIDATION/lfrverif/LFR_SVS" + ] + }, + "find_state": + { + "case_sensitive": false, + "find_history": + [ + "snapshots", + "def displayInfoSendTc", + "dump", + "tc_lfr_dump_par", + "processpac", + "WriteSPWDelay", + "sendPacket", + "sendLoadCommonPar" + ], + "highlight": true, + "in_selection": false, + "preserve_case": false, + "regex": false, + "replace_history": + [ + ], + "reverse": false, + "show_context": true, + "use_buffer2": true, + "whole_word": false, + "wrap": true + }, + "groups": + [ + { + "selected": 0, + "sheets": + [ + { + "buffer": 0, + "file": "spectralmatrix/readmatrix.py", + "settings": + { + "buffer_size": 1115, + "regions": + { + }, + "selection": + [ + [ + 208, + 208 + ] + ], + "settings": + { + "syntax": "Packages/Python/Python.tmLanguage" + }, + "translation.x": 0.0, + "translation.y": 0.0, + "zoom_level": 1.0 + }, + "type": "text" + } + ] + } + ], + "incremental_find": + { + "height": 0.0 + }, + "input": + { + "height": 0.0 + }, + "layout": + { + "cells": + [ + [ + 0, + 0, + 1, + 1 + ] + ], + "cols": + [ + 0.0, + 1.0 + ], + "rows": + [ + 0.0, + 1.0 + ] + }, + "menu_visible": true, + "output.exec": + { + "height": 257.0 + }, + "replace": + { + "height": 0.0 + }, + "save_all_on_build": true, + "select_file": + { + "height": 0.0, + "selected_items": + [ + ], + "width": 0.0 + }, + "select_project": + { + "height": 500.0, + "selected_items": + [ + [ + "", + "/opt/VALIDATION/waveform_analysis/wfmr_plots.sublime-project" + ] + ], + "width": 380.0 + }, + "show_minimap": true, + "show_open_files": false, + "show_tabs": true, + "side_bar_visible": true, + "side_bar_width": 255.0, + "status_bar_visible": true +} diff --git a/FSW-qt/bin/load_spectral_matrix_TCH.py b/FSW-qt/bin/load_spectral_matrix_TCH.py new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/load_spectral_matrix_TCH.py @@ -0,0 +1,57 @@ +#!/usr/bin/lppmon -e + +#################### +## BUILD THE DATA ## +#################### + +with open('/opt/DEV_PLE/FSW-qt/bin/spectralmatrix/asm_f0_test_20140403_case2.txt', 'r') as f: + listOfLines = [] + for line in f.readlines(): + listOfLines.append(line) + +data = listOfLines[10] # line 10 contains the data +data = data.split() # get the data from the global string + +dataInFloat = [] +nbData = len(data) +print "nbData = " + str(nbData) +for i in range( nbData ): + dataInFloat.append( float( data[i] ) ) # convert each string into a float + +# reorganize the data to have a matrix in the VHDL format +# INPUT (ICD format) +# matrix_0[0 .. 24] matrix_1[0 .. 24] .. matrix_127[0 .. 24] +# OUTPUT (VHDL format) +# component_0[0 .. 127] component_1[0 .. 127] .. component_24[0 .. 127] + +dataInFloatReorganized = [] +dataInIntReorganized = [] +nbComponentsByMatrix = 25 +nbFrequencyBins = 128 +for indexComponent in range(nbComponentsByMatrix): + for frequencyBin in range(nbFrequencyBins): + dataInFloatReorganized.append( + dataInFloat[ indexComponent + frequencyBin * nbComponentsByMatrix ] + ) + dataInIntReorganized.append( + int( dataInFloat[ indexComponent + frequencyBin * nbComponentsByMatrix ] ) + ) + +#################### +## WRITE THE DATA ## +#################### + +address_to_read = 0x80000f08 +val = RMAPPlugin0.Read( address_to_read, 1) +matrixF0_Address0 = val[0] +print str( len(dataInIntReorganized) ) + " data to write" +RMAPPlugin0.Write( matrixF0_Address0, dataInIntReorganized ) +print str( len(dataInIntReorganized) ) + " data written @" + hex(matrixF0_Address0) + + + + + + + + diff --git a/FSW-qt/bin/load_spectral_matrix_sinus.py b/FSW-qt/bin/load_spectral_matrix_sinus.py new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/load_spectral_matrix_sinus.py @@ -0,0 +1,22 @@ +#!/usr/bin/lppmon -e +import math + +address_to_read = 0x80000f08 +val = RMAPPlugin0.Read( address_to_read, 1) +matrixF0_Address0 = val[0] +print hex(matrixF0_Address0) + +teta = [] +for i in range(128): + teta.append( i * 2 * math.pi / 128 ) +amplitude = 10000 + +# BUILD THE DATA +dataToWrite = [] +for frequencyBin in range(128): + for component in range (25): + dataToWrite.append( amplitude * math.sin( teta[frequencyBin] * component ) ) + +# WRITE THE DATA +print len(dataToWrite) +RMAPPlugin0.Write( matrixF0_Address0, dataToWrite ) diff --git a/FSW-qt/bin/spectralmatrix/__init__.py b/FSW-qt/bin/spectralmatrix/__init__.py new file mode 100644 diff --git a/FSW-qt/bin/spectralmatrix/readmatrix.py b/FSW-qt/bin/spectralmatrix/readmatrix.py new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/spectralmatrix/readmatrix.py @@ -0,0 +1,34 @@ +with open('asm_f0_test_paul_1.txt', 'r') as f: + listOfLines = [] + for line in f.readlines(): + listOfLines.append(line) + +data = listOfLines[10] # line 9 contains the data +data = data.split() # get the data from the global string + +dataInFloat = [] +nbData = len(data) +print "nbData = " + str(nbData) +for i in range( nbData ): + dataInFloat.append( float( data[i] ) ) # convert each string into a float + +# reorganize the data to have a matrix in the VHDL format +# input format (ICD format) +# matrix_0[0 .. 24] matrix_1[0 .. 24] .. matrix_127[0 .. 127] +# output format (VHDL format) +# component_0[0 .. 127] component_1[0 .. 127] .. component_24[0 .. 127] + +dataInFloatReorganized = [] +dataInIntReorganized = [] +nbComponentsByMatrix = 25 +nbFrequencyBins = 128 +for indexComponent in range(nbComponentsByMatrix): + for frequencyBin in range(nbFrequencyBins): + dataInFloatReorganized.append( + dataInFloat[ indexComponent + frequencyBin * nbComponentsByMatrix ] + ) + dataInIntReorganized.append( + int( dataInFloat[ indexComponent + frequencyBin * nbComponentsByMatrix ] ) + ) + +print dataInIntReorganized diff --git a/FSW-qt/fsw-qt.pro b/FSW-qt/fsw-qt.pro --- a/FSW-qt/fsw-qt.pro +++ b/FSW-qt/fsw-qt.pro @@ -1,7 +1,7 @@ TEMPLATE = app # CONFIG += console v8 sim # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch -CONFIG += console verbose cpu_usage_report boot_messages debug_messages +CONFIG += console verbose cpu_usage_report CONFIG -= qt include(./sparc.pri) @@ -50,8 +50,8 @@ TARGET = fsw INCLUDEPATH += \ ../src \ ../header \ - ../src/basic_parameters \ - ../src/avf_prc + ../header/processing \ + ../src/basic_parameters SOURCES += \ ../src/wf_handler.c \ @@ -64,11 +64,10 @@ SOURCES += \ ../src/tm_lfr_tc_exe.c \ ../src/tc_acceptance.c \ ../src/basic_parameters/basic_parameters.c \ - ../src/avf_prc/fsw_processing.c \ - ../src/avf_prc/avf0_prc0.c \ - ../src/avf_prc/avf1_prc1.c \ - ../src/avf_prc/avf2_prc2.c - + ../src/processing/fsw_processing.c \ + ../src/processing/avf0_prc0.c \ + ../src/processing/avf1_prc1.c \ + ../src/processing/avf2_prc2.c HEADERS += \ ../header/wf_handler.h \ @@ -78,15 +77,15 @@ HEADERS += \ ../header/fsw_misc.h \ ../header/fsw_init.h \ ../header/ccsds_types.h \ - ../header/fsw_params_processing.h \ ../header/fsw_spacewire.h \ ../header/tc_load_dump_parameters.h \ ../header/tm_lfr_tc_exe.h \ ../header/tc_acceptance.h \ ../header/fsw_params_nb_bytes.h \ ../src/basic_parameters/basic_parameters.h \ - ../src/avf_prc/fsw_processing.h \ - ../src/avf_prc/avf0_prc0.h \ - ../src/avf_prc/avf1_prc1.h \ - ../src/avf_prc/avf2_prc2.h + ../header/processing/fsw_processing.h \ + ../header/processing/fsw_params_processing.h \ + ../header/processing/avf0_prc0.h \ + ../header/processing/avf1_prc1.h \ + ../header/processing/avf2_prc2.h 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 @@ -51,9 +51,9 @@ ProjectExplorer.Project.Target.0 - Desktop-Qt 4.8.3 in PATH (System) - Desktop-Qt 4.8.3 in PATH (System) - {be73cf6a-f9d8-4d5a-8adf-adc2d83e2e44} + Desktop-Qt 4.8.2 in PATH (System) + Desktop-Qt 4.8.2 in PATH (System) + {5289e843-9ef2-45ce-88c6-ad27d8e08def} 0 0 0 @@ -192,7 +192,7 @@ ProjectExplorer.Project.Updater.EnvironmentId - {cdbf9cdc-1e84-406e-889b-c4feef49e75c} + {2e58a81f-9962-4bba-ae6b-760177f0656c} ProjectExplorer.Project.Updater.FileVersion diff --git a/FSW-qt/fsw-qt.pro.user.cdbf9cd b/FSW-qt/fsw-qt.pro.user.cdbf9cd new file mode 100644 --- /dev/null +++ b/FSW-qt/fsw-qt.pro.user.cdbf9cd @@ -0,0 +1,201 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + true + 1 + true + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop-Qt 4.8.3 in PATH (System) + Desktop-Qt 4.8.3 in PATH (System) + {be73cf6a-f9d8-4d5a-8adf-adc2d83e2e44} + 0 + 0 + 0 + + + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + false + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 1 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + fsw-qt + + Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro + + fsw-qt.pro + false + true + + 3768 + true + false + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {cdbf9cdc-1e84-406e-889b-c4feef49e75c} + + + ProjectExplorer.Project.Updater.FileVersion + 15 + + diff --git a/header/fsw_init.h b/header/fsw_init.h --- a/header/fsw_init.h +++ b/header/fsw_init.h @@ -7,14 +7,15 @@ #include "fsw_params.h" #include "fsw_misc.h" #include "fsw_processing.h" -#include "avf0_prc0.h" -#include "avf1_prc1.h" -#include "avf2_prc2.h" #include "tc_handler.h" #include "wf_handler.h" #include "fsw_spacewire.h" +#include "avf0_prc0.h" +#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 */ diff --git a/header/fsw_params_processing.h b/header/fsw_params_processing.h deleted file mode 100644 --- a/header/fsw_params_processing.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef FSW_PARAMS_PROCESSING_H -#define FSW_PARAMS_PROCESSING_H - -#define NB_BINS_PER_SM 128 -#define NB_VALUES_PER_SM 25 -#define TOTAL_SIZE_SM 3200 // 25 * 128 -#define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99 -#define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117 -#define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108 -#define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198 -// -#define NB_RING_NODES_SM_F0 12 // AT LEAST 3 -#define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3 -#define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3 -#define NB_RING_NODES_SM_F1 3 // AT LEAST 3 -#define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3 -#define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3 -#define NB_RING_NODES_SM_F2 3 // AT LEAST 3 -#define NB_RING_NODES_ASM_BURST_SBM_F2 3 // AT LEAST 3 -#define NB_RING_NODES_ASM_NORM_F2 3 // AT LEAST 3 -// -#define NB_BINS_PER_ASM_F0 88 -#define NB_BINS_PER_PKT_ASM_F0 44 -#define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2 -#define ASM_F0_INDICE_START 17 // 88 bins -#define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins -// -#define NB_BINS_PER_ASM_F1 104 -#define NB_BINS_PER_PKT_ASM_F1 52 -#define TOTAL_SIZE_ASM_F1_IN_BYTES 5200 // 25 * 104 * 2 -#define ASM_F1_INDICE_START 6 // 104 bins -#define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins -// -#define NB_BINS_PER_ASM_F2 96 -#define NB_BINS_PER_PKT_ASM_F2 48 -#define TOTAL_SIZE_ASM_F2_IN_BYTES 4800 // 25 * 96 * 2 -#define ASM_F2_INDICE_START 7 // 96 bins -#define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins -// -#define NB_BINS_COMPRESSED_SM_F0 11 -#define NB_BINS_COMPRESSED_SM_F1 13 -#define NB_BINS_COMPRESSED_SM_F2 12 -#define NB_BINS_COMPRESSED_SM_SBM_F0 22 -#define NB_BINS_COMPRESSED_SM_SBM_F1 26 -#define NB_BINS_COMPRESSED_SM_SBM_F2 24 -// -#define NB_BINS_TO_AVERAGE_ASM_F0 8 -#define NB_BINS_TO_AVERAGE_ASM_F1 8 -#define NB_BINS_TO_AVERAGE_ASM_F2 8 -#define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4 -#define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4 -#define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4 -// -#define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS -#define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS -#define TOTAL_SIZE_COMPRESSED_ASM_NORM_F2 300 // 12 * 25 WORDS -#define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS -#define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS -#define TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 600 // 24 * 25 WORDS -// GENERAL -#define NB_SM_BEFORE_AVF0 8 // must be 8 due to the SM_average() function -#define NB_SM_BEFORE_AVF1 8 // must be 8 due to the SM_average() function -#define NB_SM_BEFORE_AVF2 1 // must be 1 due to the SM_average_f2() function - -#endif // FSW_PARAMS_PROCESSING_H diff --git a/header/processing/avf0_prc0.h b/header/processing/avf0_prc0.h new file mode 100644 --- /dev/null +++ b/header/processing/avf0_prc0.h @@ -0,0 +1,35 @@ +#ifndef AVF0_PRC0_H_INCLUDED +#define AVF0_PRC0_H_INCLUDED + +#include "fsw_processing.h" + +typedef struct { + unsigned int norm_bp1; + unsigned int norm_bp2; + unsigned int norm_asm; + unsigned int burst_sbm_bp1; + unsigned int burst_sbm_bp2; + unsigned int burst_bp1; + unsigned int burst_bp2; + unsigned int sbm1_bp1; + unsigned int sbm1_bp2; + unsigned int sbm2_bp1; + unsigned int sbm2_bp2; +} nb_sm_before_bp_asm_f0; + +//************ +// RTEMS TASKS +rtems_task avf0_task( rtems_task_argument lfrRequestedMode ); +rtems_task prc0_task( rtems_task_argument lfrRequestedMode ); + +//********** +// FUNCTIONS + +void reset_nb_sm_f0( unsigned char lfrMode ); + +//******* +// EXTERN +extern struct ring_node_sm *ring_node_for_averaging_sm_f0; +extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ); + +#endif // AVF0_PRC0_H_INCLUDED diff --git a/header/processing/avf1_prc1.h b/header/processing/avf1_prc1.h new file mode 100644 --- /dev/null +++ b/header/processing/avf1_prc1.h @@ -0,0 +1,33 @@ +#ifndef AVF1_PRC1_H +#define AVF1_PRC1_H + +#include "fsw_processing.h" + +typedef struct { + unsigned int norm_bp1; + unsigned int norm_bp2; + unsigned int norm_asm; + unsigned int burst_sbm_bp1; + unsigned int burst_sbm_bp2; + unsigned int burst_bp1; + unsigned int burst_bp2; + unsigned int sbm2_bp1; + unsigned int sbm2_bp2; +} nb_sm_before_bp_asm_f1; + +//************ +// RTEMS TASKS +rtems_task avf1_task( rtems_task_argument lfrRequestedMode ); +rtems_task prc1_task( rtems_task_argument lfrRequestedMode ); + +//********** +// FUNCTIONS + +void reset_nb_sm_f1( unsigned char lfrMode ); + +//******* +// EXTERN +extern struct ring_node_sm *ring_node_for_averaging_sm_f1; +extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); + +#endif // AVF1_PRC1_H diff --git a/header/processing/avf2_prc2.h b/header/processing/avf2_prc2.h new file mode 100644 --- /dev/null +++ b/header/processing/avf2_prc2.h @@ -0,0 +1,28 @@ +#ifndef AVF2_PRC2_H +#define AVF2_PRC2_H + +#include "fsw_processing.h" + +typedef struct { + unsigned int norm_bp1; + unsigned int norm_bp2; + unsigned int norm_asm; +} nb_sm_before_bp_asm_f2; + +//************ +// RTEMS TASKS +rtems_task avf2_task( rtems_task_argument lfrRequestedMode ); +rtems_task prc2_task( rtems_task_argument lfrRequestedMode ); + +//********** +// FUNCTIONS + +void reset_nb_sm_f2( void ); +void SM_average_f2( float *averaged_spec_mat_f2, ring_node_sm *ring_node, unsigned int nbAverageNormF2 ); + +//******* +// EXTERN +extern struct ring_node_sm *ring_node_for_averaging_sm_f2; +extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); + +#endif // AVF2_PRC2_H diff --git a/header/processing/fsw_params_processing.h b/header/processing/fsw_params_processing.h new file mode 100644 --- /dev/null +++ b/header/processing/fsw_params_processing.h @@ -0,0 +1,65 @@ +#ifndef FSW_PARAMS_PROCESSING_H +#define FSW_PARAMS_PROCESSING_H + +#define NB_BINS_PER_SM 128 +#define NB_VALUES_PER_SM 25 +#define TOTAL_SIZE_SM 3200 // 25 * 128 +#define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99 +#define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117 +#define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108 +#define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198 +// +#define NB_RING_NODES_SM_F0 12 // AT LEAST 3 +#define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3 +#define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3 +#define NB_RING_NODES_SM_F1 3 // AT LEAST 3 +#define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3 +#define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3 +#define NB_RING_NODES_SM_F2 3 // AT LEAST 3 +#define NB_RING_NODES_ASM_BURST_SBM_F2 3 // AT LEAST 3 +#define NB_RING_NODES_ASM_NORM_F2 3 // AT LEAST 3 +// +#define NB_BINS_PER_ASM_F0 88 +#define NB_BINS_PER_PKT_ASM_F0 44 +#define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2 +#define ASM_F0_INDICE_START 17 // 88 bins +#define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins +// +#define NB_BINS_PER_ASM_F1 104 +#define NB_BINS_PER_PKT_ASM_F1 52 +#define TOTAL_SIZE_ASM_F1_IN_BYTES 5200 // 25 * 104 * 2 +#define ASM_F1_INDICE_START 6 // 104 bins +#define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins +// +#define NB_BINS_PER_ASM_F2 96 +#define NB_BINS_PER_PKT_ASM_F2 48 +#define TOTAL_SIZE_ASM_F2_IN_BYTES 4800 // 25 * 96 * 2 +#define ASM_F2_INDICE_START 7 // 96 bins +#define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins +// +#define NB_BINS_COMPRESSED_SM_F0 11 +#define NB_BINS_COMPRESSED_SM_F1 13 +#define NB_BINS_COMPRESSED_SM_F2 12 +#define NB_BINS_COMPRESSED_SM_SBM_F0 22 +#define NB_BINS_COMPRESSED_SM_SBM_F1 26 +#define NB_BINS_COMPRESSED_SM_SBM_F2 24 +// +#define NB_BINS_TO_AVERAGE_ASM_F0 8 +#define NB_BINS_TO_AVERAGE_ASM_F1 8 +#define NB_BINS_TO_AVERAGE_ASM_F2 8 +#define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4 +#define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4 +#define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4 +// +#define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS +#define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS +#define TOTAL_SIZE_COMPRESSED_ASM_NORM_F2 300 // 12 * 25 WORDS +#define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS +#define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS +#define TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 600 // 24 * 25 WORDS +// GENERAL +#define NB_SM_BEFORE_AVF0 8 // must be 8 due to the SM_average() function +#define NB_SM_BEFORE_AVF1 8 // must be 8 due to the SM_average() function +#define NB_SM_BEFORE_AVF2 1 // must be 1 due to the SM_average_f2() function + +#endif // FSW_PARAMS_PROCESSING_H diff --git a/header/processing/fsw_processing.h b/header/processing/fsw_processing.h new file mode 100644 --- /dev/null +++ b/header/processing/fsw_processing.h @@ -0,0 +1,238 @@ +#ifndef FSW_PROCESSING_H_INCLUDED +#define FSW_PROCESSING_H_INCLUDED + +#include +#include +#include +#include // abs() is in the stdlib +#include // printf() +#include + +#include "fsw_params.h" +#include "fsw_spacewire.h" + +typedef struct ring_node_sm +{ + struct ring_node_sm *previous; + struct ring_node_sm *next; + int buffer_address; + unsigned int status; + unsigned int coarseTime; + unsigned int fineTime; +} ring_node_sm; + +typedef struct ring_node_asm +{ + struct ring_node_asm *next; + float matrix[ TOTAL_SIZE_SM ]; + unsigned int status; +} ring_node_asm; + +typedef struct bp_packet +{ + Header_TM_LFR_SCIENCE_BP_t header; + unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1] +} bp_packet; + +typedef struct bp_packet_with_spare +{ + Header_TM_LFR_SCIENCE_BP_with_spare_t header; + unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 +} bp_packet_with_spare; + +typedef struct asm_msg +{ + ring_node_asm *norm; + ring_node_asm *burst_sbm; + rtems_event_set event; + unsigned int coarseTime; + unsigned int fineTime; +} asm_msg; + +extern volatile int sm_f0[ ]; +extern volatile int sm_f1[ ]; +extern volatile int sm_f2[ ]; + +// parameters +extern struct param_local_str param_local; + +// registers +extern time_management_regs_t *time_management_regs; +extern spectral_matrix_regs_t *spectral_matrix_regs; + +extern rtems_name misc_name[5]; +extern rtems_id Task_id[20]; /* array of task ids */ + +// ISR +rtems_isr spectral_matrices_isr( rtems_vector_number vector ); +rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); + +//****************** +// Spectral Matrices +void reset_nb_sm( void ); +// SM +void SM_init_rings( void ); +void SM_reset_current_ring_nodes( void ); +// ASM +void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); +void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header); +void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, + unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id); + +//***************** +// Basic Parameters + +void BP_reset_current_ring_nodes( void ); +void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header, + unsigned int apid, unsigned char sid, + unsigned int packetLength , unsigned char blkNr); +void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header, + unsigned int apid, unsigned char sid, + unsigned int packetLength, unsigned char blkNr ); +void BP_send(char *data, + rtems_id queue_id , + unsigned int nbBytesToSend ); + +//****************** +// general functions +void reset_spectral_matrix_regs( void ); +void set_time(unsigned char *time, unsigned char *timeInBuffer ); + +extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); +extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); + +//*************************************** +// DEFINITIONS OF STATIC INLINE FUNCTIONS +static inline void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, + ring_node_sm *ring_node_tab[], + unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 ); +static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, + float divider ); +static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, + float divider, + unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); +static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); + +void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, + ring_node_sm *ring_node_tab[], + unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 ) +{ + float sum; + unsigned int i; + + for(i=0; ibuffer_address) ) [ i ] + + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] + + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] + + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] + + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] + + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] + + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] + + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; + + if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) ) + { + averaged_spec_mat_f0[ i ] = sum; + averaged_spec_mat_f1[ i ] = sum; + } + else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) ) + { + averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum ); + averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum ); + } + else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) ) + { + averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum ); + averaged_spec_mat_f1[ i ] = sum; + } + else + { + PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0) + } + } +} + +void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) +{ + int frequencyBin; + int asmComponent; + unsigned int offsetAveragedSpecMatReorganized; + unsigned int offsetAveragedSpecMat; + + for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) + { + for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) + { + offsetAveragedSpecMatReorganized = + frequencyBin * NB_VALUES_PER_SM + + asmComponent; + offsetAveragedSpecMat = + asmComponent * NB_BINS_PER_SM + + frequencyBin; + averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] = + averaged_spec_mat[ offsetAveragedSpecMat ] / divider; + } + } +} + +void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, + unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) +{ + int frequencyBin; + int asmComponent; + int offsetASM; + int offsetCompressed; + int k; + + // build data + for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) + { + for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) + { + offsetCompressed = // NO TIME OFFSET + frequencyBin * NB_VALUES_PER_SM + + asmComponent; + offsetASM = // NO TIME OFFSET + asmComponent * NB_BINS_PER_SM + + ASMIndexStart + + frequencyBin * nbBinsToAverage; + compressed_spec_mat[ offsetCompressed ] = 0; + for ( k = 0; k < nbBinsToAverage; k++ ) + { + compressed_spec_mat[offsetCompressed ] = + ( compressed_spec_mat[ offsetCompressed ] + + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage); + } + } + } +} + +void ASM_convert( volatile float *input_matrix, char *output_matrix) +{ + unsigned int frequencyBin; + unsigned int asmComponent; + char * pt_char_input; + char * pt_char_output; + unsigned int offsetInput; + unsigned int offsetOutput; + + pt_char_input = (char*) &input_matrix; + pt_char_output = (char*) &output_matrix; + + // convert all other data + for( frequencyBin=0; frequencyBinbuffer_address) ) [ i ] - + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; - - if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) ) - { - averaged_spec_mat_f0[ i ] = sum; - averaged_spec_mat_f1[ i ] = sum; - } - else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) ) - { - averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum ); - averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum ); - } - else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) ) - { - averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum ); - averaged_spec_mat_f1[ i ] = sum; - } - else - { - PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0) - } - } -} - -//************ -// RTEMS TASKS - -rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) -{ - int i; - - rtems_event_set event_out; - rtems_status_code status; - rtems_id queue_id_prc0; - asm_msg msgForMATR; - ring_node_sm *ring_node_tab[8]; - - unsigned int nb_norm_bp1; - unsigned int nb_norm_bp2; - unsigned int nb_norm_asm; - unsigned int nb_sbm_bp1; - unsigned int nb_sbm_bp2; - - nb_norm_bp1 = 0; - nb_norm_bp2 = 0; - nb_norm_asm = 0; - nb_sbm_bp1 = 0; - nb_sbm_bp2 = 0; - - reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions - ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 ); - ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 ); - current_ring_node_asm_norm_f0 = asm_ring_norm_f0; - current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0; - - BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) - - status = get_message_queue_id_prc0( &queue_id_prc0 ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status) - } - - while(1){ - rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 - ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0; - for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) - { - ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous; - ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0; - } - - // compute the average and store it in the averaged_sm_f1 buffer - SM_average_f0( current_ring_node_asm_norm_f0->matrix, - current_ring_node_asm_burst_sbm_f0->matrix, - ring_node_tab, - nb_norm_bp1, nb_sbm_bp1 ); - - // update nb_average - nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0; - nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0; - nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0; - nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0; - nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0; - - //**************************************** - // initialize the mesage for the MATR task - msgForMATR.event = 0x00; // this composite event will be sent to the MATR task - msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0; - msgForMATR.norm = current_ring_node_asm_norm_f0; -// msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0]; -// msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1]; - msgForMATR.coarseTime = time_management_regs->coarse_time; - msgForMATR.fineTime = time_management_regs->fine_time; - - if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1) - { - nb_sbm_bp1 = 0; - // set another ring for the ASM storage - current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next; - if ( (lfrCurrentMode == LFR_MODE_BURST) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0; - } - } - - if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2) - { - nb_sbm_bp2 = 0; - if ( (lfrCurrentMode == LFR_MODE_BURST) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0; - } - } - - if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1) - { - nb_norm_bp1 = 0; - // set another ring for the ASM storage - current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next; - if ( (lfrCurrentMode == LFR_MODE_NORMAL) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; - } - } - - if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2) - { - nb_norm_bp2 = 0; - if ( (lfrCurrentMode == LFR_MODE_NORMAL) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0; - } - } - - if (nb_norm_asm == nb_sm_before_f0.norm_asm) - { - nb_norm_asm = 0; - if ( (lfrCurrentMode == LFR_MODE_NORMAL) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { -// PRINTF1("%lld\n", localTime) - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; - } - } - - //************************* - // send the message to MATR - if (msgForMATR.event != 0x00) - { - status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); - } - - if (status != RTEMS_SUCCESSFUL) { - printf("in AVF0 *** Error sending message to MATR, code %d\n", status); - } - } -} - -rtems_task prc0_task( rtems_task_argument lfrRequestedMode ) -{ - char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer - size_t size; // size of the incoming TC packet - asm_msg *incomingMsg; - // - spw_ioctl_pkt_send spw_ioctl_send_ASM; - rtems_status_code status; - rtems_id queue_id; - rtems_id queue_id_q_p0; - Header_TM_LFR_SCIENCE_ASM_t headerASM; - bp_packet_with_spare packet_norm_bp1_f0; - bp_packet packet_norm_bp2_f0; - bp_packet packet_sbm_bp1_f0; - bp_packet packet_sbm_bp2_f0; - - unsigned long long int localTime; - - ASM_init_header( &headerASM ); - - //************* - // NORM headers - BP_init_header_with_spare( &packet_norm_bp1_f0.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); - BP_init_header( &packet_norm_bp2_f0.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); - - //**************************** - // BURST SBM1 and SBM2 headers - if ( lfrRequestedMode == LFR_MODE_BURST ) - { - BP_init_header( &packet_sbm_bp1_f0.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); - BP_init_header( &packet_sbm_bp2_f0.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); - } - else if ( lfrRequestedMode == LFR_MODE_SBM1 ) - { - BP_init_header( &packet_sbm_bp1_f0.header, - APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); - BP_init_header( &packet_sbm_bp2_f0.header, - APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); - } - else if ( lfrRequestedMode == LFR_MODE_SBM2 ) - { - BP_init_header( &packet_sbm_bp1_f0.header, - APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); - BP_init_header( &packet_sbm_bp2_f0.header, - APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); - } - else - { - PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) - } - - status = get_message_queue_id_send( &queue_id ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) - } - status = get_message_queue_id_prc0( &queue_id_q_p0); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) - } - - BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) - - while(1){ - status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ - RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 - - incomingMsg = (asm_msg*) incomingData; - - localTime = getTimeAsUnsignedLongLongInt( ); - //**************** - //**************** - // BURST SBM1 SBM2 - //**************** - //**************** - if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 ) - { - // 1) compress the matrix for Basic Parameters calculation - ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0, - nb_sm_before_f0.burst_sbm_bp1, - NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, - ASM_F0_INDICE_START); - // 2) compute the BP1 set - - // 3) send the BP1 set - set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA); - // 4) compute the BP2 set if needed - if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 ) - { - // 1) compute the BP2 set - - // 2) send the BP2 set - set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA); - } - } - - //***** - //***** - // NORM - //***** - //***** - if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) - { - // 1) compress the matrix for Basic Parameters calculation - ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0, - nb_sm_before_f0.norm_bp1, - NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, - ASM_F0_INDICE_START ); - // 2) compute the BP1 set - - // 3) send the BP1 set - set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_norm_bp1_f0.header, queue_id, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA); - if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) - { - // 1) compute the BP2 set using the same ASM as the one used for BP1 - - // 2) send the BP2 set - set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_norm_bp2_f0.header, queue_id, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA); - } - } - - if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) - { - // 1) reorganize the ASM and divide - ASM_reorganize_and_divide( incomingMsg->norm->matrix, - asm_f0_reorganized, - nb_sm_before_f0.norm_bp1 ); - // 2) convert the float array in a char array - ASM_convert( asm_f0_reorganized, asm_f0_char); - // 3) send the spectral matrix packets - set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime ); - set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); - ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id); - } - - } -} diff --git a/src/avf_prc/avf0_prc0.h b/src/avf_prc/avf0_prc0.h deleted file mode 100644 --- a/src/avf_prc/avf0_prc0.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef AVF0_PRC0_H -#define AVF0_PRC0_H - -#include "fsw_processing.h" - -typedef struct { - unsigned int norm_bp1; - unsigned int norm_bp2; - unsigned int norm_asm; - unsigned int burst_sbm_bp1; - unsigned int burst_sbm_bp2; - unsigned int burst_bp1; - unsigned int burst_bp2; - unsigned int sbm1_bp1; - unsigned int sbm1_bp2; - unsigned int sbm2_bp1; - unsigned int sbm2_bp2; -} nb_sm_before_bp_asm_f0; - -extern struct ring_node_sm *ring_node_for_averaging_sm_f0; - -extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ); - -void reset_nb_sm_f0( unsigned char lfrMode ); -void SM_average_f0( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, - ring_node_sm *ring_node_tab[], - unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 ); - -rtems_task avf0_task( rtems_task_argument lfrRequestedMode ); -rtems_task prc0_task( rtems_task_argument lfrRequestedMode ); - -#endif // AVF0_PRC0_H diff --git a/src/avf_prc/avf1_prc1.c b/src/avf_prc/avf1_prc1.c deleted file mode 100644 --- a/src/avf_prc/avf1_prc1.c +++ /dev/null @@ -1,379 +0,0 @@ -/** Functions related to data processing. - * - * @file - * @author P. LEROY - * - * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. - * - */ - -#include "avf1_prc1.h" - -ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ]; -ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ]; -ring_node_asm *current_ring_node_asm_burst_sbm_f1; -ring_node_asm *current_ring_node_asm_norm_f1; - -float asm_f1_reorganized [ TOTAL_SIZE_SM ]; -char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; -float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; -float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; - -nb_sm_before_bp_asm_f1 nb_sm_before_f1; - -void reset_nb_sm_f1( unsigned char lfrMode ) -{ - nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16; - nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16; - nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16; - nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16; - nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16; - nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16; - nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16; - - if (lfrMode == LFR_MODE_SBM2) - { - nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1; - nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2; - } - else if (lfrMode == LFR_MODE_BURST) - { - nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; - nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; - } - else - { - nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; - nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; - } -} - -void SM_average_f1( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, - ring_node_sm *ring_node_tab[], - unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 ) -{ - float sum; - unsigned int i; - - for(i=0; ibuffer_address) ) [ i ] - + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] - + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; - - if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) ) - { - averaged_spec_mat_f0[ i ] = sum; - averaged_spec_mat_f1[ i ] = sum; - } - else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) ) - { - averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum ); - averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum ); - } - else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) ) - { - averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum ); - averaged_spec_mat_f1[ i ] = sum; - } - else - { - PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0) - } - } -} - -//************ -// RTEMS TASKS - -rtems_task avf1_task( rtems_task_argument lfrRequestedMode ) -{ - int i; - - rtems_event_set event_out; - rtems_status_code status; - rtems_id queue_id_prc1; - asm_msg msgForMATR; - ring_node_sm *ring_node_tab[8]; - - unsigned int nb_norm_bp1; - unsigned int nb_norm_bp2; - unsigned int nb_norm_asm; - unsigned int nb_sbm_bp1; - unsigned int nb_sbm_bp2; - - nb_norm_bp1 = 0; - nb_norm_bp2 = 0; - nb_norm_asm = 0; - nb_sbm_bp1 = 0; - nb_sbm_bp2 = 0; - - reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions - ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 ); - ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 ); - current_ring_node_asm_norm_f1 = asm_ring_norm_f1; - current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1; - - BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) - - status = get_message_queue_id_prc1( &queue_id_prc1 ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status) - } - - while(1){ - rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 - ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1; - for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ ) - { - ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous; - ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1; - } - - // compute the average and store it in the averaged_sm_f1 buffer - SM_average_f1( current_ring_node_asm_norm_f1->matrix, - current_ring_node_asm_burst_sbm_f1->matrix, - ring_node_tab, - nb_norm_bp1, nb_sbm_bp1 ); - - // update nb_average - nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1; - nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1; - nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1; - nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1; - nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1; - - //**************************************** - // initialize the mesage for the MATR task - msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task - msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1; - msgForMATR.norm = current_ring_node_asm_norm_f1; -// msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0]; -// msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1]; - msgForMATR.coarseTime = time_management_regs->coarse_time; - msgForMATR.fineTime = time_management_regs->fine_time; - - if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1) - { - nb_sbm_bp1 = 0; - // set another ring for the ASM storage - current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next; - if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1; - } - } - - if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2) - { - nb_sbm_bp2 = 0; - if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1; - } - } - - if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1) - { - nb_norm_bp1 = 0; - // set another ring for the ASM storage - current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next; - if ( (lfrCurrentMode == LFR_MODE_NORMAL) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1; - } - } - - if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2) - { - nb_norm_bp2 = 0; - if ( (lfrCurrentMode == LFR_MODE_NORMAL) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1; - } - } - - if (nb_norm_asm == nb_sm_before_f1.norm_asm) - { - nb_norm_asm = 0; - if ( (lfrCurrentMode == LFR_MODE_NORMAL) - || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) - { - msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1; - } - } - - //************************* - // send the message to MATR - if (msgForMATR.event != 0x00) - { - status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1); - } - - if (status != RTEMS_SUCCESSFUL) { - printf("in AVF1 *** Error sending message to PRC1, code %d\n", status); - } - } -} - -rtems_task prc1_task( rtems_task_argument lfrRequestedMode ) -{ - char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer - size_t size; // size of the incoming TC packet - asm_msg *incomingMsg; - // - spw_ioctl_pkt_send spw_ioctl_send_ASM; - rtems_status_code status; - rtems_id queue_id_send; - rtems_id queue_id_q_p1; - Header_TM_LFR_SCIENCE_ASM_t headerASM; - bp_packet_with_spare packet_norm_bp1; - bp_packet packet_norm_bp2; - bp_packet packet_sbm_bp1; - bp_packet packet_sbm_bp2; - - unsigned long long int localTime; - - ASM_init_header( &headerASM ); - - //************* - // NORM headers - BP_init_header_with_spare( &packet_norm_bp1.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 ); - BP_init_header( &packet_norm_bp2.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1); - - //*********************** - // BURST and SBM2 headers - if ( lfrRequestedMode == LFR_MODE_BURST ) - { - BP_init_header( &packet_sbm_bp1.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F1); - BP_init_header( &packet_sbm_bp2.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F1); - } - else if ( lfrRequestedMode == LFR_MODE_SBM2 ) - { - BP_init_header( &packet_sbm_bp1.header, - APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); - BP_init_header( &packet_sbm_bp2.header, - APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); - } - else - { - PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) - } - - status = get_message_queue_id_send( &queue_id_send ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status) - } - status = get_message_queue_id_prc1( &queue_id_q_p1); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status) - } - - BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) - - while(1){ - status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************ - RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 - - incomingMsg = (asm_msg*) incomingData; - - localTime = getTimeAsUnsignedLongLongInt( ); - //*********** - //*********** - // BURST SBM2 - //*********** - //*********** - if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 ) - { - // 1) compress the matrix for Basic Parameters calculation - ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1, - nb_sm_before_f1.burst_sbm_bp1, - NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1, - ASM_F1_INDICE_START); - // 2) compute the BP1 set - - // 3) send the BP1 set - set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_sbm_bp1.header, queue_id_send, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA); - // 4) compute the BP2 set if needed - if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 ) - { - // 1) compute the BP2 set - - // 2) send the BP2 set - set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_sbm_bp2.header, queue_id_send, - PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA); - } - } - - //***** - //***** - // NORM - //***** - //***** - if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1) - { - // 1) compress the matrix for Basic Parameters calculation - ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1, - nb_sm_before_f1.norm_bp1, - NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, - ASM_F0_INDICE_START ); - // 2) compute the BP1 set - - // 3) send the BP1 set - set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_norm_bp1.header, queue_id_send, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA); - if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1) - { - // 1) compute the BP2 set - - // 2) send the BP2 set - set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_norm_bp2.header, queue_id_send, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA); - } - } - - if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1) - { - // 1) reorganize the ASM and divide - ASM_reorganize_and_divide( incomingMsg->norm->matrix, - asm_f1_reorganized, - nb_sm_before_f1.norm_bp1 ); - // 2) convert the float array in a char array - ASM_convert( asm_f1_reorganized, asm_f1_char); - // 3) send the spectral matrix packets - set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime ); - set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); - ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send); - } - - } -} diff --git a/src/avf_prc/avf1_prc1.h b/src/avf_prc/avf1_prc1.h deleted file mode 100644 --- a/src/avf_prc/avf1_prc1.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef AVF1_PRC1_H -#define AVF1_PRC1_H - -#include "fsw_processing.h" - -typedef struct { - unsigned int norm_bp1; - unsigned int norm_bp2; - unsigned int norm_asm; - unsigned int burst_sbm_bp1; - unsigned int burst_sbm_bp2; - unsigned int burst_bp1; - unsigned int burst_bp2; - unsigned int sbm2_bp1; - unsigned int sbm2_bp2; -} nb_sm_before_bp_asm_f1; - -extern struct ring_node_sm *ring_node_for_averaging_sm_f1; - -extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); - -void reset_nb_sm_f1( unsigned char lfrMode ); -void SM_average_f1( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, - ring_node_sm *ring_node_tab[], - unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 ); - -rtems_task avf1_task( rtems_task_argument lfrRequestedMode ); -rtems_task prc1_task( rtems_task_argument lfrRequestedMode ); - -#endif // AVF1_PRC1_H diff --git a/src/avf_prc/avf2_prc2.c b/src/avf_prc/avf2_prc2.c deleted file mode 100644 --- a/src/avf_prc/avf2_prc2.c +++ /dev/null @@ -1,240 +0,0 @@ -/** Functions related to data processing. - * - * @file - * @author P. LEROY - * - * These function are related to data processing at f2 = 256 Hz, i.e. spectral matrices averaging and basic parameters computation. - * - */ - -#include "avf2_prc2.h" - -ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; -ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ]; -ring_node_asm *current_ring_node_asm_burst_sbm_f2; -ring_node_asm *current_ring_node_asm_norm_f2; - -float asm_f2_reorganized [ TOTAL_SIZE_SM ]; -char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; -float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; -float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ]; - -nb_sm_before_bp_asm_f2 nb_sm_before_f2; - -void reset_nb_sm_f2( void ) -{ - nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; - nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; - nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; -} - -void SM_average_f2( float *averaged_spec_mat_f2, - ring_node_sm *ring_node, - unsigned int nbAverageNormF2 ) -{ - float sum; - unsigned int i; - - for(i=0; ibuffer_address) ) [ i ]; - if ( (nbAverageNormF2 == 0) ) - { - averaged_spec_mat_f2[ i ] = sum; - } - else - { - averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); - } - } -} - -//************ -// RTEMS TASKS - -rtems_task avf2_task( rtems_task_argument lfrRequestedMode ) -{ -// rtems_event_set event_out; -// rtems_status_code status; -// rtems_id queue_id_prc2; -// asm_msg msgForMATR; - -// unsigned int nb_norm_bp1; -// unsigned int nb_norm_bp2; -// unsigned int nb_norm_asm; - -// nb_norm_bp1 = 0; -// nb_norm_bp2 = 0; -// nb_norm_asm = 0; - -// reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions - -// BOOT_PRINTF1("in AVF2 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) - -// status = get_message_queue_id_prc2( &queue_id_prc2 ); -// if (status != RTEMS_SUCCESSFUL) -// { -// PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) -// } - -// while(1){ -// rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 - -// // compute the average and store it in the averaged_sm_f2 buffer -// SM_average_f2( current_ring_node_asm_norm_f2->matrix, -// ring_node_for_averaging_sm_f2, -// nb_norm_bp1 ); - -// // update nb_average -// nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; -// nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; -// nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; - -// //**************************************** -// // initialize the mesage for the MATR task -// msgForMATR.event = 0x00; // this composite event will be sent to the MATR task -// msgForMATR.burst_sbm = NULL; -// msgForMATR.norm = current_ring_node_asm_norm_f2; -//// msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0]; -//// msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1]; -// msgForMATR.coarseTime = time_management_regs->coarse_time; -// msgForMATR.fineTime = time_management_regs->fine_time; - -// if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) -// { -// nb_norm_bp1 = 0; -// // set another ring for the ASM storage -// current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; -// if ( lfrCurrentMode == LFR_MODE_NORMAL ) -// { -// msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; -// } -// } - -// if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) -// { -// nb_norm_bp2 = 0; -// if ( lfrCurrentMode == LFR_MODE_NORMAL ) -// { -// msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; -// } -// } - -// if (nb_norm_asm == nb_sm_before_f2.norm_asm) -// { -// nb_norm_asm = 0; -// if ( lfrCurrentMode == LFR_MODE_NORMAL ) -// { -//// PRINTF1("%lld\n", localTime) -// msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; -// } -// } - -// //************************* -// // send the message to MATR -// if (msgForMATR.event != 0x00) -// { -// status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); -// } - -// if (status != RTEMS_SUCCESSFUL) { -// printf("in AVF2 *** Error sending message to MATR, code %d\n", status); -// } -// } -} - -rtems_task prc2_task( rtems_task_argument argument ) -{ - char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer - size_t size; // size of the incoming TC packet - asm_msg *incomingMsg; - // - spw_ioctl_pkt_send spw_ioctl_send_ASM; - rtems_status_code status; - rtems_id queue_id; - rtems_id queue_id_q_p2; - Header_TM_LFR_SCIENCE_ASM_t headerASM; - bp_packet packet_norm_bp1_f2; - bp_packet packet_norm_bp2_f2; - - unsigned long long int localTime; - - ASM_init_header( &headerASM ); - - //************* - // NORM headers - BP_init_header( &packet_norm_bp1_f2.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); - BP_init_header( &packet_norm_bp2_f2.header, - APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); - - status = get_message_queue_id_send( &queue_id ); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) - } - status = get_message_queue_id_prc2( &queue_id_q_p2); - if (status != RTEMS_SUCCESSFUL) - { - PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) - } - - BOOT_PRINTF("in PRC2 ***\n") - - while(1){ - status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ - RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 - - incomingMsg = (asm_msg*) incomingData; - - localTime = getTimeAsUnsignedLongLongInt( ); - - //***** - //***** - // NORM - //***** - //***** - if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) - { - // 1) compress the matrix for Basic Parameters calculation - ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2, - nb_sm_before_f2.norm_bp1, - NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, - ASM_F2_INDICE_START ); - // 2) compute the BP1 set - - // 3) send the BP1 set - set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_norm_bp1_f2.header, queue_id, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA); - if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) - { - // 1) compute the BP2 set using the same ASM as the one used for BP1 - - // 2) send the BP2 set - set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime ); - set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); - BP_send( (char *) &packet_norm_bp2_f2.header, queue_id, - PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA); - } - } - - if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) - { - // 1) reorganize the ASM and divide - ASM_reorganize_and_divide( incomingMsg->norm->matrix, - asm_f2_reorganized, - nb_sm_before_f2.norm_bp1 ); - // 2) convert the float array in a char array - ASM_convert( asm_f2_reorganized, asm_f2_char); - // 3) send the spectral matrix packets - set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime ); - set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); - ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id); - } - - } -} diff --git a/src/avf_prc/avf2_prc2.h b/src/avf_prc/avf2_prc2.h deleted file mode 100644 --- a/src/avf_prc/avf2_prc2.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef AVF2_PRC2_H -#define AVF2_PRC2_H - -#include "fsw_processing.h" - -typedef struct { - unsigned int norm_bp1; - unsigned int norm_bp2; - unsigned int norm_asm; -} nb_sm_before_bp_asm_f2; - -extern struct ring_node_sm *ring_node_for_averaging_sm_f2; - -extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); - -void reset_nb_sm_f2(void ); -void SM_average_f2( float *averaged_spec_mat_f2, ring_node_sm *ring_node, unsigned int nbAverageNormF2 ); - -// RTEMS TASKS -rtems_task avf2_task( rtems_task_argument lfrRequestedMode ); -rtems_task prc2_task(rtems_task_argument argument ); - -#endif // AVF2_PRC2_H diff --git a/src/avf_prc/fsw_processing.c b/src/avf_prc/fsw_processing.c deleted file mode 100644 --- a/src/avf_prc/fsw_processing.c +++ /dev/null @@ -1,532 +0,0 @@ -/** Functions related to data processing. - * - * @file - * @author P. LEROY - * - * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. - * - */ - -#include "fsw_processing.h" -#include "fsw_processing_globals.c" - -unsigned int nb_sm_f0; -unsigned int nb_sm_f0_aux_f1; -unsigned int nb_sm_f1; -unsigned int nb_sm_f0_aux_f2; - -//************************ -// spectral matrices rings -ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ]; -ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ]; -ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ]; -ring_node_sm *current_ring_node_sm_f0; -ring_node_sm *current_ring_node_sm_f1; -ring_node_sm *current_ring_node_sm_f2; -ring_node_sm *ring_node_for_averaging_sm_f0; -ring_node_sm *ring_node_for_averaging_sm_f1; -ring_node_sm *ring_node_for_averaging_sm_f2; - -//*********************************************************** -// Interrupt Service Routine for spectral matrices processing - -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; - -// 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; -// } - -// //************************ -// // reset status error bits -// if ( (spectral_matrix_regs->status & 0x30) != 0x00) -// { -// 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; -// } - -} - -rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) -{ - //*** - // F0 - 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; - 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; - } - - //*** - // F1 - nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; - if (nb_sm_f0_aux_f1 == 6) - { - nb_sm_f0_aux_f1 = 0; - 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; - 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; - } - - //*** - // F2 -// nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; -// if (nb_sm_f0_aux_f2 == 96) -// { -// nb_sm_f0_aux_f2 = 0; -// ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; -// if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) -// { -// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); -// } -// } -} - -//****************** -// Spectral Matrices - -void reset_nb_sm( void ) -{ - nb_sm_f0 = 0; - nb_sm_f0_aux_f1 = 0; - nb_sm_f0_aux_f2 = 0; - - nb_sm_f1 = 0; -} - -void SM_init_rings( void ) -{ - unsigned char i; - - // F0 RING - sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1]; - sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1]; - sm_ring_f0[0].buffer_address = - (int) &sm_f0[ 0 ]; - - sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0]; - sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2]; - sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address = - (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ]; - - for(i=1; imatrixF0_Address0 = sm_ring_f0[0].buffer_address; - DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0) -} - -void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) -{ - unsigned char i; - - ring[ nbNodes - 1 ].next - = (ring_node_asm*) &ring[ 0 ]; - - for(i=0; itargetLogicalAddress = CCSDS_DESTINATION_ID; - header->protocolIdentifier = CCSDS_PROTOCOLE_ID; - header->reserved = 0x00; - header->userApplication = CCSDS_USER_APP; - header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); - header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); - header->packetSequenceControl[0] = 0xc0; - header->packetSequenceControl[1] = 0x00; - header->packetLength[0] = 0x00; - header->packetLength[1] = 0x00; - // DATA FIELD HEADER - header->spare1_pusVersion_spare2 = 0x10; - header->serviceType = TM_TYPE_LFR_SCIENCE; // service type - header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype - header->destinationID = TM_DESTINATION_ID_GROUND; - // AUXILIARY DATA HEADER - header->sid = 0x00; - header->biaStatusInfo = 0x00; - header->pa_lfr_pkt_cnt_asm = 0x00; - header->pa_lfr_pkt_nr_asm = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB - header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB -} - -void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) -{ - int frequencyBin; - int asmComponent; - unsigned int offsetAveragedSpecMatReorganized; - unsigned int offsetAveragedSpecMat; - - for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) - { - for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) - { - offsetAveragedSpecMatReorganized = - frequencyBin * NB_VALUES_PER_SM - + asmComponent; - offsetAveragedSpecMat = - asmComponent * NB_BINS_PER_SM - + frequencyBin; - averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] = - averaged_spec_mat[ offsetAveragedSpecMat ] / divider; - } - } -} - -void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, - unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) -{ - int frequencyBin; - int asmComponent; - int offsetASM; - int offsetCompressed; - int k; - - // build data - for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) - { - for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) - { - offsetCompressed = // NO TIME OFFSET - frequencyBin * NB_VALUES_PER_SM - + asmComponent; - offsetASM = // NO TIME OFFSET - asmComponent * NB_BINS_PER_SM - + ASMIndexStart - + frequencyBin * nbBinsToAverage; - compressed_spec_mat[ offsetCompressed ] = 0; - for ( k = 0; k < nbBinsToAverage; k++ ) - { - compressed_spec_mat[offsetCompressed ] = - ( compressed_spec_mat[ offsetCompressed ] - + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage); - } - } - } -} - -void ASM_convert( volatile float *input_matrix, char *output_matrix) -{ - unsigned int frequencyBin; - unsigned int asmComponent; - char * pt_char_input; - char * pt_char_output; - unsigned int offsetInput; - unsigned int offsetOutput; - - pt_char_input = (char*) &input_matrix; - pt_char_output = (char*) &output_matrix; - - // convert all other data - for( frequencyBin=0; frequencyBindlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent - spw_ioctl_send->data = &spectral_matrix[ - ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2 - ]; - length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0; - header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB - header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB - break; - case SID_NORM_ASM_F1: - spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent - spw_ioctl_send->data = &spectral_matrix[ - ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2 - ]; - length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1; - header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB - header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB - break; - case SID_NORM_ASM_F2: - break; - default: - PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid) - break; - } - spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES; - spw_ioctl_send->hdr = (char *) header; - spw_ioctl_send->options = 0; - - // (2) BUILD THE HEADER - header->packetLength[0] = (unsigned char) (length>>8); - header->packetLength[1] = (unsigned char) (length); - header->sid = (unsigned char) sid; // SID - header->pa_lfr_pkt_cnt_asm = 2; - header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); - - // (3) SET PACKET TIME - header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); - header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); - header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); - header->time[3] = (unsigned char) (time_management_regs->coarse_time); - header->time[4] = (unsigned char) (time_management_regs->fine_time>>8); - header->time[5] = (unsigned char) (time_management_regs->fine_time); - // - header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); - header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); - header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); - header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); - header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); - header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); - - // (4) SEND PACKET - status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); - if (status != RTEMS_SUCCESSFUL) { - printf("in ASM_send *** ERR %d\n", (int) status); - } - } -} - -//***************** -// Basic Parameters - -void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header, - unsigned int apid, unsigned char sid, - unsigned int packetLength, unsigned char blkNr ) -{ - header->targetLogicalAddress = CCSDS_DESTINATION_ID; - header->protocolIdentifier = CCSDS_PROTOCOLE_ID; - header->reserved = 0x00; - header->userApplication = CCSDS_USER_APP; - header->packetID[0] = (unsigned char) (apid >> 8); - header->packetID[1] = (unsigned char) (apid); - header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; - header->packetSequenceControl[1] = 0x00; - header->packetLength[0] = (unsigned char) (packetLength >> 8); - header->packetLength[1] = (unsigned char) (packetLength); - // DATA FIELD HEADER - header->spare1_pusVersion_spare2 = 0x10; - header->serviceType = TM_TYPE_LFR_SCIENCE; // service type - header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype - header->destinationID = TM_DESTINATION_ID_GROUND; - // AUXILIARY DATA HEADER - header->sid = sid; - header->biaStatusInfo = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB - header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB -} - -void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header, - unsigned int apid, unsigned char sid, - unsigned int packetLength , unsigned char blkNr) -{ - header->targetLogicalAddress = CCSDS_DESTINATION_ID; - header->protocolIdentifier = CCSDS_PROTOCOLE_ID; - header->reserved = 0x00; - header->userApplication = CCSDS_USER_APP; - header->packetID[0] = (unsigned char) (apid >> 8); - header->packetID[1] = (unsigned char) (apid); - header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; - header->packetSequenceControl[1] = 0x00; - header->packetLength[0] = (unsigned char) (packetLength >> 8); - header->packetLength[1] = (unsigned char) (packetLength); - // DATA FIELD HEADER - header->spare1_pusVersion_spare2 = 0x10; - header->serviceType = TM_TYPE_LFR_SCIENCE; // service type - header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype - header->destinationID = TM_DESTINATION_ID_GROUND; - // AUXILIARY DATA HEADER - header->sid = sid; - header->biaStatusInfo = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->time[0] = 0x00; - header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB - header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB -} - -void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend ) -{ - rtems_status_code status; - - // SEND PACKET - status = rtems_message_queue_send( queue_id, data, nbBytesToSend); - if (status != RTEMS_SUCCESSFUL) - { - printf("ERR *** in BP_send *** ERR %d\n", (int) status); - } -} - -//****************** -// general functions - -void reset_spectral_matrix_regs( void ) -{ - /** This function resets the spectral matrices module registers. - * - * The registers affected by this function are located at the following offset addresses: - * - * - 0x00 config - * - 0x04 status - * - 0x08 matrixF0_Address0 - * - 0x10 matrixFO_Address1 - * - 0x14 matrixF1_Address - * - 0x18 matrixF2_Address - * - */ - - spectral_matrix_regs->config = 0x00; - spectral_matrix_regs->status = 0x00; - - spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; - spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address; - spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address; - spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address; -} - -void set_time( unsigned char *time, unsigned char * timeInBuffer ) -{ -// time[0] = timeInBuffer[2]; -// time[1] = timeInBuffer[3]; -// time[2] = timeInBuffer[0]; -// time[3] = timeInBuffer[1]; -// time[4] = timeInBuffer[6]; -// time[5] = timeInBuffer[7]; - - time[0] = timeInBuffer[0]; - time[1] = timeInBuffer[1]; - time[2] = timeInBuffer[2]; - time[3] = timeInBuffer[3]; - time[4] = timeInBuffer[6]; - time[5] = timeInBuffer[7]; -} - - diff --git a/src/avf_prc/fsw_processing.h b/src/avf_prc/fsw_processing.h deleted file mode 100644 --- a/src/avf_prc/fsw_processing.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef FSW_PROCESSING_H_INCLUDED -#define FSW_PROCESSING_H_INCLUDED - -#include -#include -#include -#include // abs() is in the stdlib -#include // printf() -#include - -#include "fsw_params.h" -#include "fsw_spacewire.h" - -typedef struct ring_node_sm -{ - struct ring_node_sm *previous; - struct ring_node_sm *next; - int buffer_address; - unsigned int status; - unsigned int coarseTime; - unsigned int fineTime; -} ring_node_sm; - -typedef struct ring_node_asm -{ - struct ring_node_asm *next; - float matrix[ TOTAL_SIZE_SM ]; - unsigned int status; -} ring_node_asm; - -typedef struct bp_packet -{ - Header_TM_LFR_SCIENCE_BP_t header; - unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1] -} bp_packet; - -typedef struct bp_packet_with_spare -{ - Header_TM_LFR_SCIENCE_BP_with_spare_t header; - unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 -} bp_packet_with_spare; - -typedef struct asm_msg -{ - ring_node_asm *norm; - ring_node_asm *burst_sbm; - rtems_event_set event; - unsigned int coarseTime; - unsigned int fineTime; -} asm_msg; - -extern volatile int sm_f0[ ]; -extern volatile int sm_f1[ ]; -extern volatile int sm_f2[ ]; - -// parameters -extern struct param_local_str param_local; - -// registers -extern time_management_regs_t *time_management_regs; -extern spectral_matrix_regs_t *spectral_matrix_regs; - -extern rtems_name misc_name[5]; -extern rtems_id Task_id[20]; /* array of task ids */ - -// ISR -rtems_isr spectral_matrices_isr( rtems_vector_number vector ); -rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); - -//****************** -// Spectral Matrices -void reset_nb_sm( void ); -void SM_init_rings( void ); -void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); -void SM_reset_current_ring_nodes( void ); -void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header); -void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, - float divider ); -void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, - float divider, - unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); -void ASM_convert(volatile float *input_matrix, char *output_matrix); -void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, - unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id); - -//***************** -// Basic Parameters - -void BP_reset_current_ring_nodes( void ); -void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header, - unsigned int apid, unsigned char sid, - unsigned int packetLength , unsigned char blkNr); -void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header, - unsigned int apid, unsigned char sid, - unsigned int packetLength, unsigned char blkNr ); -void BP_send(char *data, - rtems_id queue_id , - unsigned int nbBytesToSend ); - -//****************** -// general functions -void reset_spectral_matrix_regs( void ); -void set_time(unsigned char *time, unsigned char *timeInBuffer ); - -#endif // FSW_PROCESSING_H_INCLUDED diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -547,20 +547,20 @@ int start_all_tasks( void ) // start all BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") } } -// if (status == RTEMS_SUCCESSFUL) // AVF2 -// { -// status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); -// if (status!=RTEMS_SUCCESSFUL) { -// BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") -// } -// } -// if (status == RTEMS_SUCCESSFUL) // PRC2 -// { -// status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); -// if (status!=RTEMS_SUCCESSFUL) { -// BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") -// } -// } + if (status == RTEMS_SUCCESSFUL) // AVF2 + { + status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); + if (status!=RTEMS_SUCCESSFUL) { + BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") + } + } + if (status == RTEMS_SUCCESSFUL) // PRC2 + { + status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); + if (status!=RTEMS_SUCCESSFUL) { + BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") + } + } //**************** // WAVEFORM PICKER diff --git a/src/processing/avf0_prc0.c b/src/processing/avf0_prc0.c new file mode 100644 --- /dev/null +++ b/src/processing/avf0_prc0.c @@ -0,0 +1,364 @@ +/** Functions related to data processing. + * + * @file + * @author P. LEROY + * + * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. + * + */ + +#include "avf0_prc0.h" +#include "fsw_processing.h" + +nb_sm_before_bp_asm_f0 nb_sm_before_f0; + +//*** +// F0 +ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ]; +ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ]; + +float asm_f0_reorganized [ TOTAL_SIZE_SM ]; +char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; +float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0]; +float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ]; + +//************ +// RTEMS TASKS + +rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) +{ + int i; + + rtems_event_set event_out; + rtems_status_code status; + rtems_id queue_id_prc0; + asm_msg msgForMATR; + ring_node_sm *ring_node_tab[8]; + ring_node_asm *current_ring_node_asm_burst_sbm_f0; + ring_node_asm *current_ring_node_asm_norm_f0; + + unsigned int nb_norm_bp1; + unsigned int nb_norm_bp2; + unsigned int nb_norm_asm; + unsigned int nb_sbm_bp1; + unsigned int nb_sbm_bp2; + + nb_norm_bp1 = 0; + nb_norm_bp2 = 0; + nb_norm_asm = 0; + nb_sbm_bp1 = 0; + nb_sbm_bp2 = 0; + + reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions + ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 ); + ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 ); + current_ring_node_asm_norm_f0 = asm_ring_norm_f0; + current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0; + + BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) + + status = get_message_queue_id_prc0( &queue_id_prc0 ); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status) + } + + while(1){ + rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 + ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0; + for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) + { + ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous; + ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0; + } + + // compute the average and store it in the averaged_sm_f1 buffer + SM_average( current_ring_node_asm_norm_f0->matrix, + current_ring_node_asm_burst_sbm_f0->matrix, + ring_node_tab, + nb_norm_bp1, nb_sbm_bp1 ); + + // update nb_average + nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0; + nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0; + nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0; + nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0; + nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0; + + //**************************************** + // initialize the mesage for the MATR task + msgForMATR.event = 0x00; // this composite event will be sent to the MATR task + msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0; + msgForMATR.norm = current_ring_node_asm_norm_f0; +// msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0]; +// msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1]; + msgForMATR.coarseTime = time_management_regs->coarse_time; + msgForMATR.fineTime = time_management_regs->fine_time; + + if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1) + { + nb_sbm_bp1 = 0; + // set another ring for the ASM storage + current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next; + if ( (lfrCurrentMode == LFR_MODE_BURST) + || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0; + } + } + + if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2) + { + nb_sbm_bp2 = 0; + if ( (lfrCurrentMode == LFR_MODE_BURST) + || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0; + } + } + + if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1) + { + nb_norm_bp1 = 0; + // set another ring for the ASM storage + current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) + || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; + } + } + + if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2) + { + nb_norm_bp2 = 0; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) + || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0; + } + } + + if (nb_norm_asm == nb_sm_before_f0.norm_asm) + { + nb_norm_asm = 0; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) + || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { +// PRINTF1("%lld\n", localTime) + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; + } + } + + //************************* + // send the message to MATR + if (msgForMATR.event != 0x00) + { + status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); + } + + if (status != RTEMS_SUCCESSFUL) { + printf("in AVF0 *** Error sending message to MATR, code %d\n", status); + } + } +} + +rtems_task prc0_task( rtems_task_argument lfrRequestedMode ) +{ + char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer + size_t size; // size of the incoming TC packet + asm_msg *incomingMsg; + // + spw_ioctl_pkt_send spw_ioctl_send_ASM; + rtems_status_code status; + rtems_id queue_id; + rtems_id queue_id_q_p0; + Header_TM_LFR_SCIENCE_ASM_t headerASM; + bp_packet_with_spare packet_norm_bp1_f0; + bp_packet packet_norm_bp2_f0; + bp_packet packet_sbm_bp1_f0; + bp_packet packet_sbm_bp2_f0; + + unsigned long long int localTime; + + ASM_init_header( &headerASM ); + + //************* + // NORM headers + BP_init_header_with_spare( &packet_norm_bp1_f0.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); + BP_init_header( &packet_norm_bp2_f0.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); + + //**************************** + // BURST SBM1 and SBM2 headers + if ( lfrRequestedMode == LFR_MODE_BURST ) + { + BP_init_header( &packet_sbm_bp1_f0.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); + BP_init_header( &packet_sbm_bp2_f0.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); + } + else if ( lfrRequestedMode == LFR_MODE_SBM1 ) + { + BP_init_header( &packet_sbm_bp1_f0.header, + APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); + BP_init_header( &packet_sbm_bp2_f0.header, + APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); + } + else if ( lfrRequestedMode == LFR_MODE_SBM2 ) + { + BP_init_header( &packet_sbm_bp1_f0.header, + APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); + BP_init_header( &packet_sbm_bp2_f0.header, + APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); + } + else + { + PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) + } + + status = get_message_queue_id_send( &queue_id ); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status) + } + status = get_message_queue_id_prc0( &queue_id_q_p0); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status) + } + + BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) + + while(1){ + status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************ + RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 + + incomingMsg = (asm_msg*) incomingData; + + localTime = getTimeAsUnsignedLongLongInt( ); + //**************** + //**************** + // BURST SBM1 SBM2 + //**************** + //**************** + if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 ) + { + // 1) compress the matrix for Basic Parameters calculation + ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0, + nb_sm_before_f0.burst_sbm_bp1, + NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, + ASM_F0_INDICE_START); + // 2) compute the BP1 set + + // 3) send the BP1 set + set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA); + // 4) compute the BP2 set if needed + if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 ) + { + // 1) compute the BP2 set + + // 2) send the BP2 set + set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA); + } + } + + //***** + //***** + // NORM + //***** + //***** + if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) + { + // 1) compress the matrix for Basic Parameters calculation + ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0, + nb_sm_before_f0.norm_bp1, + NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, + ASM_F0_INDICE_START ); + // 2) compute the BP1 set + + // 3) send the BP1 set + set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_norm_bp1_f0.header, queue_id, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA); + if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) + { + // 1) compute the BP2 set using the same ASM as the one used for BP1 + + // 2) send the BP2 set + set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_norm_bp2_f0.header, queue_id, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA); + } + } + + if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) + { + // 1) reorganize the ASM and divide + ASM_reorganize_and_divide( incomingMsg->norm->matrix, + asm_f0_reorganized, + nb_sm_before_f0.norm_bp1 ); + // 2) convert the float array in a char array + ASM_convert( asm_f0_reorganized, asm_f0_char); + // 3) send the spectral matrix packets + set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime ); + set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); + ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id); + } + + } +} + +//********** +// FUNCTIONS + +void reset_nb_sm_f0( unsigned char lfrMode ) +{ + nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96; + nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96; + nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96; + nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; + nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96; + nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96; + nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96; + nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96; + nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96; + + if (lfrMode == LFR_MODE_SBM1) + { + nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1; + nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2; + } + else if (lfrMode == LFR_MODE_SBM2) + { + nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1; + nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2; + } + else if (lfrMode == LFR_MODE_BURST) + { + nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; + nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; + } + else + { + nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1; + nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2; + } +} diff --git a/src/processing/avf1_prc1.c b/src/processing/avf1_prc1.c new file mode 100644 --- /dev/null +++ b/src/processing/avf1_prc1.c @@ -0,0 +1,345 @@ +/** Functions related to data processing. + * + * @file + * @author P. LEROY + * + * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. + * + */ + +#include "avf1_prc1.h" + +nb_sm_before_bp_asm_f1 nb_sm_before_f1; + +//*** +// F1 +ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ]; +ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ]; + +float asm_f1_reorganized [ TOTAL_SIZE_SM ]; +char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; +float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1]; +float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ]; + +//************ +// RTEMS TASKS + +rtems_task avf1_task( rtems_task_argument lfrRequestedMode ) +{ + int i; + + rtems_event_set event_out; + rtems_status_code status; + rtems_id queue_id_prc1; + asm_msg msgForMATR; + ring_node_sm *ring_node_tab[8]; + ring_node_asm *current_ring_node_asm_burst_sbm_f1; + ring_node_asm *current_ring_node_asm_norm_f1; + + unsigned int nb_norm_bp1; + unsigned int nb_norm_bp2; + unsigned int nb_norm_asm; + unsigned int nb_sbm_bp1; + unsigned int nb_sbm_bp2; + + nb_norm_bp1 = 0; + nb_norm_bp2 = 0; + nb_norm_asm = 0; + nb_sbm_bp1 = 0; + nb_sbm_bp2 = 0; + + reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions + ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 ); + ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 ); + current_ring_node_asm_norm_f1 = asm_ring_norm_f1; + current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1; + + BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) + + status = get_message_queue_id_prc1( &queue_id_prc1 ); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status) + } + + while(1){ + rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 + ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1; + for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ ) + { + ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous; + ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1; + } + + // compute the average and store it in the averaged_sm_f1 buffer + SM_average( current_ring_node_asm_norm_f1->matrix, + current_ring_node_asm_burst_sbm_f1->matrix, + ring_node_tab, + nb_norm_bp1, nb_sbm_bp1 ); + + // update nb_average + nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1; + nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1; + nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1; + nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1; + nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1; + + //**************************************** + // initialize the mesage for the MATR task + msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task + msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1; + msgForMATR.norm = current_ring_node_asm_norm_f1; +// msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0]; +// msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1]; + msgForMATR.coarseTime = time_management_regs->coarse_time; + msgForMATR.fineTime = time_management_regs->fine_time; + + if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1) + { + nb_sbm_bp1 = 0; + // set another ring for the ASM storage + current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next; + if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1; + } + } + + if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2) + { + nb_sbm_bp2 = 0; + if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1; + } + } + + if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1) + { + nb_norm_bp1 = 0; + // set another ring for the ASM storage + current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) + || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1; + } + } + + if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2) + { + nb_norm_bp2 = 0; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) + || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1; + } + } + + if (nb_norm_asm == nb_sm_before_f1.norm_asm) + { + nb_norm_asm = 0; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) + || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1; + } + } + + //************************* + // send the message to MATR + if (msgForMATR.event != 0x00) + { + status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1); + } + + if (status != RTEMS_SUCCESSFUL) { + printf("in AVF1 *** Error sending message to PRC1, code %d\n", status); + } + } +} + +rtems_task prc1_task( rtems_task_argument lfrRequestedMode ) +{ + char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer + size_t size; // size of the incoming TC packet + asm_msg *incomingMsg; + // + spw_ioctl_pkt_send spw_ioctl_send_ASM; + rtems_status_code status; + rtems_id queue_id_send; + rtems_id queue_id_q_p1; + Header_TM_LFR_SCIENCE_ASM_t headerASM; + bp_packet_with_spare packet_norm_bp1; + bp_packet packet_norm_bp2; + bp_packet packet_sbm_bp1; + bp_packet packet_sbm_bp2; + + unsigned long long int localTime; + + ASM_init_header( &headerASM ); + + //************* + // NORM headers + BP_init_header_with_spare( &packet_norm_bp1.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 ); + BP_init_header( &packet_norm_bp2.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1); + + //*********************** + // BURST and SBM2 headers + if ( lfrRequestedMode == LFR_MODE_BURST ) + { + BP_init_header( &packet_sbm_bp1.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F1); + BP_init_header( &packet_sbm_bp2.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F1); + } + else if ( lfrRequestedMode == LFR_MODE_SBM2 ) + { + BP_init_header( &packet_sbm_bp1.header, + APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1); + BP_init_header( &packet_sbm_bp2.header, + APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1); + } + else + { + PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode) + } + + status = get_message_queue_id_send( &queue_id_send ); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status) + } + status = get_message_queue_id_prc1( &queue_id_q_p1); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status) + } + + BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode) + + while(1){ + status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************ + RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 + + incomingMsg = (asm_msg*) incomingData; + + localTime = getTimeAsUnsignedLongLongInt( ); + //*********** + //*********** + // BURST SBM2 + //*********** + //*********** + if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 ) + { + // 1) compress the matrix for Basic Parameters calculation + ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1, + nb_sm_before_f1.burst_sbm_bp1, + NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1, + ASM_F1_INDICE_START); + // 2) compute the BP1 set + + // 3) send the BP1 set + set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_sbm_bp1.header, queue_id_send, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA); + // 4) compute the BP2 set if needed + if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 ) + { + // 1) compute the BP2 set + + // 2) send the BP2 set + set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_sbm_bp2.header, queue_id_send, + PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA); + } + } + + //***** + //***** + // NORM + //***** + //***** + if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1) + { + // 1) compress the matrix for Basic Parameters calculation + ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1, + nb_sm_before_f1.norm_bp1, + NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, + ASM_F0_INDICE_START ); + // 2) compute the BP1 set + + // 3) send the BP1 set + set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_norm_bp1.header, queue_id_send, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA); + if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1) + { + // 1) compute the BP2 set + + // 2) send the BP2 set + set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_norm_bp2.header, queue_id_send, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA); + } + } + + if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1) + { + // 1) reorganize the ASM and divide + ASM_reorganize_and_divide( incomingMsg->norm->matrix, + asm_f1_reorganized, + nb_sm_before_f1.norm_bp1 ); + // 2) convert the float array in a char array + ASM_convert( asm_f1_reorganized, asm_f1_char); + // 3) send the spectral matrix packets + set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime ); + set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); + ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send); + } + + } +} + +//********** +// FUNCTIONS + +void reset_nb_sm_f1( unsigned char lfrMode ) +{ + nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16; + nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16; + nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16; + nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16; + nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16; + nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16; + nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16; + + if (lfrMode == LFR_MODE_SBM2) + { + nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1; + nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2; + } + else if (lfrMode == LFR_MODE_BURST) + { + nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; + nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; + } + else + { + nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1; + nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2; + } +} + diff --git a/src/processing/avf2_prc2.c b/src/processing/avf2_prc2.c new file mode 100644 --- /dev/null +++ b/src/processing/avf2_prc2.c @@ -0,0 +1,251 @@ +/** Functions related to data processing. + * + * @file + * @author P. LEROY + * + * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. + * + */ + +#include "avf2_prc2.h" + +nb_sm_before_bp_asm_f2 nb_sm_before_f2; + +//*** +// F2 +ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; +ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ]; + +float asm_f2_reorganized [ TOTAL_SIZE_SM ]; +char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; +float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; +float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ]; + +//************ +// RTEMS TASKS + +//*** +// F2 +rtems_task avf2_task( rtems_task_argument argument ) +{ + rtems_event_set event_out; + rtems_status_code status; + rtems_id queue_id_prc2; + asm_msg msgForMATR; + ring_node_asm *current_ring_node_asm_norm_f2; + + unsigned int nb_norm_bp1; + unsigned int nb_norm_bp2; + unsigned int nb_norm_asm; + + nb_norm_bp1 = 0; + nb_norm_bp2 = 0; + nb_norm_asm = 0; + + reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions + ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 ); + current_ring_node_asm_norm_f2 = asm_ring_norm_f2; + + BOOT_PRINTF("in AVF2 ***\n") + + status = get_message_queue_id_prc2( &queue_id_prc2 ); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) + } + + while(1){ + rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 + + // compute the average and store it in the averaged_sm_f2 buffer + SM_average_f2( current_ring_node_asm_norm_f2->matrix, + ring_node_for_averaging_sm_f2, + nb_norm_bp1 ); + + // update nb_average + nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; + nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; + nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; + + //**************************************** + // initialize the mesage for the MATR task + msgForMATR.event = 0x00; // this composite event will be sent to the MATR task + msgForMATR.burst_sbm = NULL; + msgForMATR.norm = current_ring_node_asm_norm_f2; +// msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0]; +// msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1]; + msgForMATR.coarseTime = time_management_regs->coarse_time; + msgForMATR.fineTime = time_management_regs->fine_time; + + if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) + { + nb_norm_bp1 = 0; + // set another ring for the ASM storage + current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) + || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2; + } + } + + if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) + { + nb_norm_bp2 = 0; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) + || (lfrCurrentMode == LFR_MODE_SBM2) ) + { + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; + } + } + + if (nb_norm_asm == nb_sm_before_f2.norm_asm) + { + nb_norm_asm = 0; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) + || (lfrCurrentMode == LFR_MODE_SBM2) ) + { +// PRINTF1("%lld\n", localTime) + msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; + } + } + + //************************* + // send the message to MATR + if (msgForMATR.event != 0x00) + { + status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); + } + + if (status != RTEMS_SUCCESSFUL) { + printf("in AVF2 *** Error sending message to MATR, code %d\n", status); + } + } +} + +rtems_task prc2_task( rtems_task_argument argument ) +{ + char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer + size_t size; // size of the incoming TC packet + asm_msg *incomingMsg; + // + spw_ioctl_pkt_send spw_ioctl_send_ASM; + rtems_status_code status; + rtems_id queue_id; + rtems_id queue_id_q_p2; + Header_TM_LFR_SCIENCE_ASM_t headerASM; + bp_packet packet_norm_bp1_f2; + bp_packet packet_norm_bp2_f2; + + unsigned long long int localTime; + + ASM_init_header( &headerASM ); + + //************* + // NORM headers + BP_init_header( &packet_norm_bp1_f2.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); + BP_init_header( &packet_norm_bp2_f2.header, + APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); + + status = get_message_queue_id_send( &queue_id ); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) + } + status = get_message_queue_id_prc2( &queue_id_q_p2); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) + } + + BOOT_PRINTF("in PRC2 ***\n") + + while(1){ + status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ + RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 + + incomingMsg = (asm_msg*) incomingData; + + localTime = getTimeAsUnsignedLongLongInt( ); + + //***** + //***** + // NORM + //***** + //***** + if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) + { + // 1) compress the matrix for Basic Parameters calculation + ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2, + nb_sm_before_f2.norm_bp1, + NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, + ASM_F2_INDICE_START ); + // 2) compute the BP1 set + + // 3) send the BP1 set + set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_norm_bp1_f2.header, queue_id, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA); + if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) + { + // 1) compute the BP2 set using the same ASM as the one used for BP1 + + // 2) send the BP2 set + set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime ); + set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); + BP_send( (char *) &packet_norm_bp2_f2.header, queue_id, + PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA); + } + } + + if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) + { + // 1) reorganize the ASM and divide + ASM_reorganize_and_divide( incomingMsg->norm->matrix, + asm_f2_reorganized, + nb_sm_before_f2.norm_bp1 ); + // 2) convert the float array in a char array + ASM_convert( asm_f2_reorganized, asm_f2_char); + // 3) send the spectral matrix packets + set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime ); + set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); + ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id); + } + + } +} + +//********** +// FUNCTIONS + +void reset_nb_sm_f2( void ) +{ + nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; + nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; + nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; +} + +void SM_average_f2( float *averaged_spec_mat_f2, + ring_node_sm *ring_node, + unsigned int nbAverageNormF2 ) +{ + float sum; + unsigned int i; + + for(i=0; ibuffer_address) ) [ i ]; + if ( (nbAverageNormF2 == 0) ) + { + averaged_spec_mat_f2[ i ] = sum; + } + else + { + averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); + } + } +} diff --git a/src/processing/fsw_processing.c b/src/processing/fsw_processing.c new file mode 100644 --- /dev/null +++ b/src/processing/fsw_processing.c @@ -0,0 +1,455 @@ +/** Functions related to data processing. + * + * @file + * @author P. LEROY + * + * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. + * + */ + +#include "fsw_processing.h" +#include "fsw_processing_globals.c" + +unsigned int nb_sm_f0; +unsigned int nb_sm_f0_aux_f1; +unsigned int nb_sm_f1; +unsigned int nb_sm_f0_aux_f2; + +//************************ +// spectral matrices rings +ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ]; +ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ]; +ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ]; +ring_node_sm *current_ring_node_sm_f0; +ring_node_sm *current_ring_node_sm_f1; +ring_node_sm *current_ring_node_sm_f2; +ring_node_sm *ring_node_for_averaging_sm_f0; +ring_node_sm *ring_node_for_averaging_sm_f1; +ring_node_sm *ring_node_for_averaging_sm_f2; + +//*********************************************************** +// Interrupt Service Routine for spectral matrices processing + +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; + +// 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; +// } + +// //************************ +// // reset status error bits +// if ( (spectral_matrix_regs->status & 0x30) != 0x00) +// { +// 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; +// } + +} + +rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) +{ + //*** + // F0 + 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; + 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; + } + + //*** + // F1 + nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; + if (nb_sm_f0_aux_f1 == 6) + { + nb_sm_f0_aux_f1 = 0; + 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; + 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; + } + + //*** + // F2 + nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; + if (nb_sm_f0_aux_f2 == 96) + { + nb_sm_f0_aux_f2 = 0; + ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; + if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) + { + rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); + } + } +} + +//****************** +// Spectral Matrices + +void reset_nb_sm( void ) +{ + nb_sm_f0 = 0; + nb_sm_f0_aux_f1 = 0; + nb_sm_f0_aux_f2 = 0; + + nb_sm_f1 = 0; +} + +void SM_init_rings( void ) +{ + unsigned char i; + + // F0 RING + sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1]; + sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1]; + sm_ring_f0[0].buffer_address = + (int) &sm_f0[ 0 ]; + + sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0]; + sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2]; + sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address = + (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ]; + + for(i=1; imatrixF0_Address0 = sm_ring_f0[0].buffer_address; + DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0) +} + +void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) +{ + unsigned char i; + + ring[ nbNodes - 1 ].next + = (ring_node_asm*) &ring[ 0 ]; + + for(i=0; itargetLogicalAddress = CCSDS_DESTINATION_ID; + header->protocolIdentifier = CCSDS_PROTOCOLE_ID; + header->reserved = 0x00; + header->userApplication = CCSDS_USER_APP; + header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); + header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); + header->packetSequenceControl[0] = 0xc0; + header->packetSequenceControl[1] = 0x00; + header->packetLength[0] = 0x00; + header->packetLength[1] = 0x00; + // DATA FIELD HEADER + header->spare1_pusVersion_spare2 = 0x10; + header->serviceType = TM_TYPE_LFR_SCIENCE; // service type + header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype + header->destinationID = TM_DESTINATION_ID_GROUND; + // AUXILIARY DATA HEADER + header->sid = 0x00; + header->biaStatusInfo = 0x00; + header->pa_lfr_pkt_cnt_asm = 0x00; + header->pa_lfr_pkt_nr_asm = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB + header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB +} + +void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, + unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id) +{ + unsigned int i; + unsigned int length = 0; + rtems_status_code status; + + for (i=0; i<2; i++) + { + // (1) BUILD THE DATA + switch(sid) + { + case SID_NORM_ASM_F0: + spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent + spw_ioctl_send->data = &spectral_matrix[ + ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2 + ]; + length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0; + header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB + header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB + break; + case SID_NORM_ASM_F1: + spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent + spw_ioctl_send->data = &spectral_matrix[ + ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2 + ]; + length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1; + header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB + header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB + break; + case SID_NORM_ASM_F2: + spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent + spw_ioctl_send->data = &spectral_matrix[ + ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2 + ]; + length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; + header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB + header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB + break; + default: + PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid) + break; + } + spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES; + spw_ioctl_send->hdr = (char *) header; + spw_ioctl_send->options = 0; + + // (2) BUILD THE HEADER + header->packetLength[0] = (unsigned char) (length>>8); + header->packetLength[1] = (unsigned char) (length); + header->sid = (unsigned char) sid; // SID + header->pa_lfr_pkt_cnt_asm = 2; + header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); + + // (3) SET PACKET TIME + header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); + header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); + header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); + header->time[3] = (unsigned char) (time_management_regs->coarse_time); + header->time[4] = (unsigned char) (time_management_regs->fine_time>>8); + header->time[5] = (unsigned char) (time_management_regs->fine_time); + // + header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); + header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); + header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); + header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); + header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); + header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); + + // (4) SEND PACKET + status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); + if (status != RTEMS_SUCCESSFUL) { + printf("in ASM_send *** ERR %d\n", (int) status); + } + } +} + +//***************** +// Basic Parameters + +void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header, + unsigned int apid, unsigned char sid, + unsigned int packetLength, unsigned char blkNr ) +{ + header->targetLogicalAddress = CCSDS_DESTINATION_ID; + header->protocolIdentifier = CCSDS_PROTOCOLE_ID; + header->reserved = 0x00; + header->userApplication = CCSDS_USER_APP; + header->packetID[0] = (unsigned char) (apid >> 8); + header->packetID[1] = (unsigned char) (apid); + header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; + header->packetSequenceControl[1] = 0x00; + header->packetLength[0] = (unsigned char) (packetLength >> 8); + header->packetLength[1] = (unsigned char) (packetLength); + // DATA FIELD HEADER + header->spare1_pusVersion_spare2 = 0x10; + header->serviceType = TM_TYPE_LFR_SCIENCE; // service type + header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype + header->destinationID = TM_DESTINATION_ID_GROUND; + // AUXILIARY DATA HEADER + header->sid = sid; + header->biaStatusInfo = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB + header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB +} + +void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header, + unsigned int apid, unsigned char sid, + unsigned int packetLength , unsigned char blkNr) +{ + header->targetLogicalAddress = CCSDS_DESTINATION_ID; + header->protocolIdentifier = CCSDS_PROTOCOLE_ID; + header->reserved = 0x00; + header->userApplication = CCSDS_USER_APP; + header->packetID[0] = (unsigned char) (apid >> 8); + header->packetID[1] = (unsigned char) (apid); + header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; + header->packetSequenceControl[1] = 0x00; + header->packetLength[0] = (unsigned char) (packetLength >> 8); + header->packetLength[1] = (unsigned char) (packetLength); + // DATA FIELD HEADER + header->spare1_pusVersion_spare2 = 0x10; + header->serviceType = TM_TYPE_LFR_SCIENCE; // service type + header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype + header->destinationID = TM_DESTINATION_ID_GROUND; + // AUXILIARY DATA HEADER + header->sid = sid; + header->biaStatusInfo = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->time[0] = 0x00; + header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB + header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB +} + +void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend ) +{ + rtems_status_code status; + + // SEND PACKET + status = rtems_message_queue_send( queue_id, data, nbBytesToSend); + if (status != RTEMS_SUCCESSFUL) + { + printf("ERR *** in BP_send *** ERR %d\n", (int) status); + } +} + +//****************** +// general functions + +void reset_spectral_matrix_regs( void ) +{ + /** This function resets the spectral matrices module registers. + * + * The registers affected by this function are located at the following offset addresses: + * + * - 0x00 config + * - 0x04 status + * - 0x08 matrixF0_Address0 + * - 0x10 matrixFO_Address1 + * - 0x14 matrixF1_Address + * - 0x18 matrixF2_Address + * + */ + + spectral_matrix_regs->config = 0x00; + spectral_matrix_regs->status = 0x00; + + spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; + spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address; + spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address; + spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address; +} + +void set_time( unsigned char *time, unsigned char * timeInBuffer ) +{ +// time[0] = timeInBuffer[2]; +// time[1] = timeInBuffer[3]; +// time[2] = timeInBuffer[0]; +// time[3] = timeInBuffer[1]; +// time[4] = timeInBuffer[6]; +// time[5] = timeInBuffer[7]; + + time[0] = timeInBuffer[0]; + time[1] = timeInBuffer[1]; + time[2] = timeInBuffer[2]; + time[3] = timeInBuffer[3]; + time[4] = timeInBuffer[6]; + time[5] = timeInBuffer[7]; +} diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -628,22 +628,23 @@ int restart_science_tasks(unsigned char PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) } -// status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); -// if (status[8] != RTEMS_SUCCESSFUL) -// { -// PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) -// } + status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); + if (status[8] != RTEMS_SUCCESSFUL) + { + PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) + } -// status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); -// if (status[9] != RTEMS_SUCCESSFUL) -// { -// PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) -// } + status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); + if (status[9] != RTEMS_SUCCESSFUL) + { + PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) + } if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || - (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ) + (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || + (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) { ret = RTEMS_UNSATISFIED; } @@ -693,22 +694,22 @@ int suspend_science_tasks() PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) } } -// if (status == RTEMS_SUCCESSFUL) // suspend AVF2 -// { -// status = rtems_task_suspend( Task_id[TASKID_AVF2] ); -// if (status != RTEMS_SUCCESSFUL) -// { -// PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) -// } -// } -// if (status == RTEMS_SUCCESSFUL) // suspend PRC2 -// { -// status = rtems_task_suspend( Task_id[TASKID_PRC2] ); -// if (status != RTEMS_SUCCESSFUL) -// { -// PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) -// } -// } + if (status == RTEMS_SUCCESSFUL) // suspend AVF2 + { + status = rtems_task_suspend( Task_id[TASKID_AVF2] ); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) + } + } + if (status == RTEMS_SUCCESSFUL) // suspend PRC2 + { + status = rtems_task_suspend( Task_id[TASKID_PRC2] ); + if (status != RTEMS_SUCCESSFUL) + { + PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) + } + } if (status == RTEMS_SUCCESSFUL) // suspend WFRM { status = rtems_task_suspend( Task_id[TASKID_WFRM] );