# HG changeset patch # User admin@pc-p-leroy3.LAB-LPP.LOCAL # Date 2013-04-08 15:29:57 # Node ID 80c27716b2cd922a9870c3f87d5083e8b0dacae0 # Parent 8c8561e284d3bd6ed8e2af56127c33a28ef9dec4 # Parent 482a184909efe8a8e088f79b79e2ddd2a87584d8 Merge diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: PAULs_LPPMON_PLUGINS -# Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Feb 1 12:36:21 2013 +# Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Apr 5 15:41:42 2013 # Project: PAULs_LPPMON_PLUGINS.pro # Template: subdirs # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile PAULs_LPPMON_PLUGINS.pro @@ -29,10 +29,10 @@ SUBTARGETS = \ rmapplugin/$(MAKEFILE): @$(CHK_DIR_EXISTS) rmapplugin/ || $(MKDIR) rmapplugin/ - cd rmapplugin/ && $(QMAKE) /home/admin/opt/LPPMON_PLUGINS_PLE/rmapplugin/rmapplugin.pro -spec /usr/lib64/qt4/mkspecs/linux-g++ -o $(MAKEFILE) + cd rmapplugin/ && $(QMAKE) /opt/LPPMON_PLUGINS_PAUL/rmapplugin/rmapplugin.pro -spec /usr/lib64/qt4/mkspecs/linux-g++ -o $(MAKEFILE) sub-rmapplugin-qmake_all: FORCE @$(CHK_DIR_EXISTS) rmapplugin/ || $(MKDIR) rmapplugin/ - cd rmapplugin/ && $(QMAKE) /home/admin/opt/LPPMON_PLUGINS_PLE/rmapplugin/rmapplugin.pro -spec /usr/lib64/qt4/mkspecs/linux-g++ -o $(MAKEFILE) + cd rmapplugin/ && $(QMAKE) /opt/LPPMON_PLUGINS_PAUL/rmapplugin/rmapplugin.pro -spec /usr/lib64/qt4/mkspecs/linux-g++ -o $(MAKEFILE) sub-rmapplugin: rmapplugin/$(MAKEFILE) FORCE cd rmapplugin/ && $(MAKE) -f $(MAKEFILE) sub-rmapplugin-make_default-ordered: rmapplugin/$(MAKEFILE) FORCE diff --git a/PAULs_LPPMON_PLUGINS.pro.user b/PAULs_LPPMON_PLUGINS.pro.user --- a/PAULs_LPPMON_PLUGINS.pro.user +++ b/PAULs_LPPMON_PLUGINS.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -63,7 +63,7 @@ QtProjectManager.QMakeBuildStep false - false + true false @@ -97,15 +97,65 @@ 2 false - Qt 4.8.3 in PATH (System) Release + Qt 4.8.2 in PATH (System) Release Qt4ProjectManager.Qt4BuildConfiguration 0 - /home/admin/opt/LPPMON_PLUGINS_PLE + /opt/LPPMON_PLUGINS_PAUL 1 false - 1 + + ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.2 in PATH (System) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /opt/LPPMON_PLUGINS_PAUL + 1 + false + + 2 0 @@ -196,7 +246,85 @@ false false - 1 + + true + true + + + false + false + false + false + false + false + false + false + true + true + 0.01 + 0.01 + 10 + 10 + true + true + 25 + 25 + + + true + true + valgrind + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + spwtimegenerator + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + spwtimegenerator/spwtimegenerator/spwtimegenerator.pro + false + false + + + 3768 + true + false + true + + 2 @@ -205,7 +333,7 @@ ProjectExplorer.Project.Updater.EnvironmentId - {cdbf9cdc-1e84-406e-889b-c4feef49e75c} + {2e58a81f-9962-4bba-ae6b-760177f0656c} ProjectExplorer.Project.Updater.FileVersion diff --git a/common_PLE/qipdialogbox.cpp b/common_PLE/qipdialogbox.cpp --- a/common_PLE/qipdialogbox.cpp +++ b/common_PLE/qipdialogbox.cpp @@ -59,11 +59,21 @@ void QIPDialogBox::valueChanged() // SLO gresbIP.append(addressPart3->cleanText()); gresbIP.append("."); gresbIP.append(addressPart4->cleanText()); - //labelGRESBIP->setText("IP used for the gresb module: " + gresbIP); } -QString QIPDialogBox::getGRESBIP() +QString QIPDialogBox::getIP() { return(gresbIP); } +void QIPDialogBox::setIP(unsigned char address1, unsigned char address2, unsigned char address3, unsigned char address4) +{ + addressPart1->setValue(address1); + addressPart2->setValue(address2); + addressPart3->setValue(address3); + addressPart4->setValue(address4); + addressPart1->repaint(); + addressPart2->repaint(); + addressPart3->repaint(); + addressPart4->repaint(); +} diff --git a/common_PLE/qipdialogbox.h b/common_PLE/qipdialogbox.h --- a/common_PLE/qipdialogbox.h +++ b/common_PLE/qipdialogbox.h @@ -11,12 +11,13 @@ class QIPDialogBox : public QWidget Q_OBJECT public: explicit QIPDialogBox(QWidget *parent = 0); - QString getGRESBIP(); + void setIP(unsigned char address1, unsigned char address2, unsigned char address3, unsigned char address4); signals: public slots: void valueChanged(); + QString getIP(); private: QSpinBox *addressPart1; diff --git a/rmapplugin/Makefile b/rmapplugin/Makefile --- a/rmapplugin/Makefile +++ b/rmapplugin/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: librmapplugin.so.1.0.0 -# Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Feb 1 12:36:22 2013 +# Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Apr 5 15:41:42 2013 # Project: rmapplugin.pro # Template: lib # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile rmapplugin.pro @@ -10,13 +10,13 @@ CC = gcc CXX = g++ -DEFINES = -DPLUGIN=rmapplugin -DPLUGINHEADER="\"rmapplugin.h\"" -Ddriver_Name="\"RMAPPlugin\"" -Ddriver_Author="\"Paul Leroy paul.leroy@lpp.polytechnique.fr\"" -Ddriver_Version="\"1.1.2\"" -Ddriver_Description="\"AHB bus controler, works with Gaisler's AHB plugn' play bus.\"" -Ddriver_can_be_root=1 -Ddriver_can_be_child=0 -Ddriver_VID=0 -Ddriver_PID=0 -DUNIXTRANSLATIONPATH -DLPPMON_PLUGINS_INSTALL_PATH="QDir::homePath()+\"/.lppmon/plugins\"" -DLPPMON_CONFIG_PATH="QDir::homePath()+\"/.lppmon/config\"" -DLPPMON_TRANSLATION_PATH="\"/etc/lppmon/translations\"" -DLPPMONPLUGIN_LIBRARY -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED +DEFINES = -DPLUGIN=rmapplugin -DPLUGINHEADER="\"rmapplugin.h\"" -Ddriver_Name="\"RMAPPlugin\"" -Ddriver_Author="\"Paul Leroy paul.leroy@lpp.polytechnique.fr\"" -Ddriver_Version="\"1.1.2\"" -Ddriver_Description="\"AHB bus controler, works with Gaisler's AHB plugn' play bus.\"" -Ddriver_can_be_root=1 -Ddriver_can_be_child=0 -Ddriver_VID=0 -Ddriver_PID=0 -DLPPMON_VERSION="\"0.0.1\"" -DUNIXTRANSLATIONPATH -DLPPMON_PLUGINS_INSTALL_PATH="QDir::homePath()+\"/.lppmon/plugins\"" -DLPPMON_CONFIG_PATH="QDir::homePath()+\"/.lppmon/config\"" -DLPPMON_TRANSLATION_PATH="\"/etc/lppmon/translations\"" -DLPPMONPLUGIN_LIBRARY -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED CFLAGS = -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES) CXXFLAGS = -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -O2 -I/usr/include/python2.7 -I/usr/include/python2.7 -Wall -W -D_REENTRANT -fPIC $(DEFINES) INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtNetwork -I/usr/include/QtGui -I/usr/include/QtXml -I/usr/include -I. -I../common_PLE -I../spw_usb_driver_v2.61/inc -I/usr/include/lppmon/common -I/usr/include/lppmon -I/usr/include/lppmon/pluginsInterface -I/usr/include/PythonQt -Imoc LINK = g++ LFLAGS = -Wl,-O1 -Wl,-z,relro -shared -Wl,-soname,librmapplugin.so.1 -LIBS = $(SUBLIBS) -L/usr/lib64 ../spw_usb_driver_v2.61/lib/x86_64/libSpaceWireUSBAPI.so ../spw_usb_driver_v2.61/lib/x86_64/libConfigLibraryUSB.so -ldl -lutil -lm -lpython2.7 -lPythonQt_QtAll -lPythonQt -lQtXml -lQtGui -lQtNetwork -lQtCore -lpthread +LIBS = $(SUBLIBS) -L/usr/lib64 ../spw_usb_driver_v2.62/lib/x86_64/libSpaceWireUSBAPI.so ../spw_usb_driver_v2.62/lib/x86_64/libConfigLibraryUSB.so -ldl -lutil -lm -lpython2.7 -lPythonQt_QtAll -lPythonQt -lQtXml -lQtGui -lQtNetwork -lQtCore -lpthread AR = ar cqs RANLIB = QMAKE = /usr/bin/qmake-qt4 @@ -53,7 +53,8 @@ SOURCES = rmapplugin.cpp \ rmappluginpythonwrapper.cpp \ stardundee.cpp \ gresb.cpp \ - bridge.cpp \ + tcpackettosend.cpp \ + tmpackettoread.cpp \ /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp moc/moc_rmappluginui.cpp \ moc/moc_rmapplugin.cpp \ moc/moc_qipdialogbox.cpp \ @@ -62,7 +63,10 @@ SOURCES = rmapplugin.cpp \ moc/moc_rmappluginpythonwrapper.cpp \ moc/moc_stardundee.cpp \ moc/moc_gresb.cpp \ - moc/moc_bridge.cpp + moc/moc_tcpackettosend.cpp \ + moc/moc_tmpackettoread.cpp \ + moc/moc_genericPySysdriver.cpp \ + moc/moc_lppmonplugin.cpp OBJECTS = obj/rmapplugin.o \ obj/rmappluginui.o \ obj/rmapoperations.o \ @@ -73,7 +77,8 @@ OBJECTS = obj/rmapplugin.o \ obj/rmappluginpythonwrapper.o \ obj/stardundee.o \ obj/gresb.o \ - obj/bridge.o \ + obj/tcpackettosend.o \ + obj/tmpackettoread.o \ obj/lppmonplugininterface.o \ obj/moc_rmappluginui.o \ obj/moc_rmapplugin.o \ @@ -83,7 +88,10 @@ OBJECTS = obj/rmapplugin.o \ obj/moc_rmappluginpythonwrapper.o \ obj/moc_stardundee.o \ obj/moc_gresb.o \ - obj/moc_bridge.o + obj/moc_tcpackettosend.o \ + obj/moc_tmpackettoread.o \ + obj/moc_genericPySysdriver.o \ + obj/moc_lppmonplugin.o DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ /usr/lib64/qt4/mkspecs/common/linux.conf \ /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ @@ -231,7 +239,7 @@ qmake: FORCE dist: @$(CHK_DIR_EXISTS) obj/rmapplugin1.0.0 || $(MKDIR) obj/rmapplugin1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/rmapplugin1.0.0/ && $(COPY_FILE) --parents rmappluginui.h rmapplugin.h rmapoperations.h ccsds.h ../common_PLE/qipdialogbox.h ../common_PLE/gresbstatusenquiry.h spectralmatricesdmasimulator.h rmappluginpythonwrapper.h stardundee.h ../spw_usb_driver_v2.61/inc/spw_usb_api.h ../spw_usb_driver_v2.61/inc/spw_config_library.h gresb.h bridge.h /usr/include/genericPySysdriver.h /usr/include/lppmonplugin.h obj/rmapplugin1.0.0/ && $(COPY_FILE) --parents rmapplugin.cpp rmappluginui.cpp rmapoperations.cpp ccsds.cpp ../common_PLE/qipdialogbox.cpp ../common_PLE/gresbstatusenquiry.cpp spectralmatricesdmasimulator.cpp rmappluginpythonwrapper.cpp stardundee.cpp gresb.cpp bridge.cpp /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp obj/rmapplugin1.0.0/ && (cd `dirname obj/rmapplugin1.0.0` && $(TAR) rmapplugin1.0.0.tar rmapplugin1.0.0 && $(COMPRESS) rmapplugin1.0.0.tar) && $(MOVE) `dirname obj/rmapplugin1.0.0`/rmapplugin1.0.0.tar.gz . && $(DEL_FILE) -r obj/rmapplugin1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/rmapplugin1.0.0/ && $(COPY_FILE) --parents rmappluginui.h rmapplugin.h rmapoperations.h ccsds.h ../common_PLE/qipdialogbox.h ../common_PLE/gresbstatusenquiry.h spectralmatricesdmasimulator.h rmappluginpythonwrapper.h stardundee.h ../spw_usb_driver_v2.61/inc/spw_usb_api.h ../spw_usb_driver_v2.61/inc/spw_config_library.h gresb.h tcpackettosend.h tmpackettoread.h /usr/include/lppmon/genericPySysdriver.h /usr/include/lppmon/lppmonplugin.h obj/rmapplugin1.0.0/ && $(COPY_FILE) --parents rmapplugin.cpp rmappluginui.cpp rmapoperations.cpp ccsds.cpp ../common_PLE/qipdialogbox.cpp ../common_PLE/gresbstatusenquiry.cpp spectralmatricesdmasimulator.cpp rmappluginpythonwrapper.cpp stardundee.cpp gresb.cpp tcpackettosend.cpp tmpackettoread.cpp /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp obj/rmapplugin1.0.0/ && (cd `dirname obj/rmapplugin1.0.0` && $(TAR) rmapplugin1.0.0.tar rmapplugin1.0.0 && $(COMPRESS) rmapplugin1.0.0.tar) && $(MOVE) `dirname obj/rmapplugin1.0.0`/rmapplugin1.0.0.tar.gz . && $(DEL_FILE) -r obj/rmapplugin1.0.0 clean:compiler_clean @@ -253,12 +261,14 @@ mocclean: compiler_moc_header_clean comp mocables: compiler_moc_header_make_all compiler_moc_source_make_all -compiler_moc_header_make_all: moc/moc_rmappluginui.cpp moc/moc_rmapplugin.cpp moc/moc_qipdialogbox.cpp moc/moc_gresbstatusenquiry.cpp moc/moc_spectralmatricesdmasimulator.cpp moc/moc_rmappluginpythonwrapper.cpp moc/moc_stardundee.cpp moc/moc_gresb.cpp moc/moc_bridge.cpp +compiler_moc_header_make_all: moc/moc_rmappluginui.cpp moc/moc_rmapplugin.cpp moc/moc_qipdialogbox.cpp moc/moc_gresbstatusenquiry.cpp moc/moc_spectralmatricesdmasimulator.cpp moc/moc_rmappluginpythonwrapper.cpp moc/moc_stardundee.cpp moc/moc_gresb.cpp moc/moc_tcpackettosend.cpp moc/moc_tmpackettoread.cpp moc/moc_genericPySysdriver.cpp moc/moc_lppmonplugin.cpp compiler_moc_header_clean: - -$(DEL_FILE) moc/moc_rmappluginui.cpp moc/moc_rmapplugin.cpp moc/moc_qipdialogbox.cpp moc/moc_gresbstatusenquiry.cpp moc/moc_spectralmatricesdmasimulator.cpp moc/moc_rmappluginpythonwrapper.cpp moc/moc_stardundee.cpp moc/moc_gresb.cpp moc/moc_bridge.cpp + -$(DEL_FILE) moc/moc_rmappluginui.cpp moc/moc_rmapplugin.cpp moc/moc_qipdialogbox.cpp moc/moc_gresbstatusenquiry.cpp moc/moc_spectralmatricesdmasimulator.cpp moc/moc_rmappluginpythonwrapper.cpp moc/moc_stardundee.cpp moc/moc_gresb.cpp moc/moc_tcpackettosend.cpp moc/moc_tmpackettoread.cpp moc/moc_genericPySysdriver.cpp moc/moc_lppmonplugin.cpp moc/moc_rmappluginui.cpp: rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ + ccsds.h \ + tmpackettoread.h \ gresb.h \ rmappluginui.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmappluginui.h -o moc/moc_rmappluginui.cpp @@ -267,8 +277,9 @@ moc/moc_rmapplugin.cpp: rmappluginui.h \ rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ + ccsds.h \ + tmpackettoread.h \ gresb.h \ - ccsds.h \ rmapplugin.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmapplugin.h -o moc/moc_rmapplugin.cpp @@ -281,20 +292,36 @@ moc/moc_gresbstatusenquiry.cpp: ../commo moc/moc_spectralmatricesdmasimulator.cpp: spectralmatricesdmasimulator.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) spectralmatricesdmasimulator.h -o moc/moc_spectralmatricesdmasimulator.cpp -moc/moc_rmappluginpythonwrapper.cpp: rmappluginpythonwrapper.h +moc/moc_rmappluginpythonwrapper.cpp: rmapoperations.h \ + ccsds.h \ + tcpackettosend.h \ + tmpackettoread.h \ + rmappluginpythonwrapper.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmappluginpythonwrapper.h -o moc/moc_rmappluginpythonwrapper.cpp moc/moc_stardundee.cpp: rmapoperations.h \ + ccsds.h \ + tmpackettoread.h \ stardundee.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) stardundee.h -o moc/moc_stardundee.cpp moc/moc_gresb.cpp: rmapoperations.h \ + ccsds.h \ + tmpackettoread.h \ gresb.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) gresb.h -o moc/moc_gresb.cpp -moc/moc_bridge.cpp: rmapoperations.h \ - bridge.h - /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) bridge.h -o moc/moc_bridge.cpp +moc/moc_tcpackettosend.cpp: tcpackettosend.h + /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) tcpackettosend.h -o moc/moc_tcpackettosend.cpp + +moc/moc_tmpackettoread.cpp: tmpackettoread.h + /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) tmpackettoread.h -o moc/moc_tmpackettoread.cpp + +moc/moc_genericPySysdriver.cpp: /usr/include/lppmon/genericPySysdriver.h + /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) /usr/include/lppmon/genericPySysdriver.h -o moc/moc_genericPySysdriver.cpp + +moc/moc_lppmonplugin.cpp: /usr/include/lppmon/lppmonplugin.h + /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) /usr/include/lppmon/lppmonplugin.h -o moc/moc_lppmonplugin.cpp compiler_rcc_make_all: compiler_rcc_clean: @@ -320,9 +347,11 @@ obj/rmapplugin.o: rmapplugin.cpp rmapplu rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ + ccsds.h \ + tmpackettoread.h \ gresb.h \ - ccsds.h \ - rmappluginpythonwrapper.h + rmappluginpythonwrapper.h \ + tcpackettosend.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmapplugin.o rmapplugin.cpp obj/rmappluginui.o: rmappluginui.cpp rmapplugin.h \ @@ -330,8 +359,9 @@ obj/rmappluginui.o: rmappluginui.cpp rma rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ - gresb.h \ - ccsds.h + ccsds.h \ + tmpackettoread.h \ + gresb.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmappluginui.o rmappluginui.cpp obj/rmapoperations.o: rmapoperations.cpp rmapoperations.h @@ -349,20 +379,30 @@ obj/gresbstatusenquiry.o: ../common_PLE/ obj/spectralmatricesdmasimulator.o: spectralmatricesdmasimulator.cpp spectralmatricesdmasimulator.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/spectralmatricesdmasimulator.o spectralmatricesdmasimulator.cpp -obj/rmappluginpythonwrapper.o: rmappluginpythonwrapper.cpp rmappluginpythonwrapper.h +obj/rmappluginpythonwrapper.o: rmappluginpythonwrapper.cpp rmappluginpythonwrapper.h \ + rmapoperations.h \ + ccsds.h \ + tcpackettosend.h \ + tmpackettoread.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmappluginpythonwrapper.o rmappluginpythonwrapper.cpp obj/stardundee.o: stardundee.cpp stardundee.h \ - rmapoperations.h + rmapoperations.h \ + ccsds.h \ + tmpackettoread.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/stardundee.o stardundee.cpp obj/gresb.o: gresb.cpp gresb.h \ - rmapoperations.h + rmapoperations.h \ + ccsds.h \ + tmpackettoread.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/gresb.o gresb.cpp -obj/bridge.o: bridge.cpp bridge.h \ - rmapoperations.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/bridge.o bridge.cpp +obj/tcpackettosend.o: tcpackettosend.cpp tcpackettosend.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/tcpackettosend.o tcpackettosend.cpp + +obj/tmpackettoread.o: tmpackettoread.cpp tmpackettoread.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/tmpackettoread.o tmpackettoread.cpp obj/lppmonplugininterface.o: /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp /usr/include/lppmon/pluginsInterface/lppmonplugininterface.h \ /usr/include/lppmon/pluginsInterface/lppmonplugininterface_global.h @@ -392,24 +432,33 @@ obj/moc_stardundee.o: moc/moc_stardundee obj/moc_gresb.o: moc/moc_gresb.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_gresb.o moc/moc_gresb.cpp -obj/moc_bridge.o: moc/moc_bridge.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_bridge.o moc/moc_bridge.cpp +obj/moc_tcpackettosend.o: moc/moc_tcpackettosend.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_tcpackettosend.o moc/moc_tcpackettosend.cpp + +obj/moc_tmpackettoread.o: moc/moc_tmpackettoread.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_tmpackettoread.o moc/moc_tmpackettoread.cpp + +obj/moc_genericPySysdriver.o: moc/moc_genericPySysdriver.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_genericPySysdriver.o moc/moc_genericPySysdriver.cpp + +obj/moc_lppmonplugin.o: moc/moc_lppmonplugin.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_lppmonplugin.o moc/moc_lppmonplugin.cpp ####### Install install_target: first FORCE - @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/home/admin/.lppmon/plugins/ || $(MKDIR) $(INSTALL_ROOT)/home/admin/.lppmon/plugins/ - -$(INSTALL_PROGRAM) "bin/$(TARGET)" "$(INSTALL_ROOT)/home/admin/.lppmon/plugins/$(TARGET)" - -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/home/admin/.lppmon/plugins/$(TARGET0)" - -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/home/admin/.lppmon/plugins/$(TARGET1)" - -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/home/admin/.lppmon/plugins/$(TARGET2)" + @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/home/paul/.lppmon/plugins/ || $(MKDIR) $(INSTALL_ROOT)/home/paul/.lppmon/plugins/ + -$(INSTALL_PROGRAM) "bin/$(TARGET)" "$(INSTALL_ROOT)/home/paul/.lppmon/plugins/$(TARGET)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/home/paul/.lppmon/plugins/$(TARGET0)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/home/paul/.lppmon/plugins/$(TARGET1)" + -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/home/paul/.lppmon/plugins/$(TARGET2)" uninstall_target: FORCE - -$(DEL_FILE) "$(INSTALL_ROOT)/home/admin/.lppmon/plugins/$(TARGET)" - -$(DEL_FILE) "$(INSTALL_ROOT)/home/admin/.lppmon/plugins/$(TARGET0)" - -$(DEL_FILE) "$(INSTALL_ROOT)/home/admin/.lppmon/plugins/$(TARGET1)" - -$(DEL_FILE) "$(INSTALL_ROOT)/home/admin/.lppmon/plugins/$(TARGET2)" - -$(DEL_DIR) $(INSTALL_ROOT)/home/admin/.lppmon/plugins/ + -$(DEL_FILE) "$(INSTALL_ROOT)/home/paul/.lppmon/plugins/$(TARGET)" + -$(DEL_FILE) "$(INSTALL_ROOT)/home/paul/.lppmon/plugins/$(TARGET0)" + -$(DEL_FILE) "$(INSTALL_ROOT)/home/paul/.lppmon/plugins/$(TARGET1)" + -$(DEL_FILE) "$(INSTALL_ROOT)/home/paul/.lppmon/plugins/$(TARGET2)" + -$(DEL_DIR) $(INSTALL_ROOT)/home/paul/.lppmon/plugins/ install: install_target FORCE diff --git a/rmapplugin/ccsds.h b/rmapplugin/ccsds.h --- a/rmapplugin/ccsds.h +++ b/rmapplugin/ccsds.h @@ -1,6 +1,15 @@ #ifndef CCSDS_H #define CCSDS_H +#define CCSDS_MAX_PACKET_LENGTH 4412 // in bytes, specified in the LFR Software Requirements Specification + +struct ccsdsPacketToProcess_str +{ + unsigned int size; + unsigned char data[CCSDS_MAX_PACKET_LENGTH]; +}; +typedef ccsdsPacketToProcess_str ccsdsPacketToProcess_t; + struct ccsds_telecommand_source_packet_hdr_str { unsigned char packetId1; diff --git a/rmapplugin/gresb.cpp b/rmapplugin/gresb.cpp --- a/rmapplugin/gresb.cpp +++ b/rmapplugin/gresb.cpp @@ -16,12 +16,13 @@ gresb::gresb(QWidget *parent) : spwPacket = (char*) malloc( qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH) ); commandCode = invalid0; // initialization of the command code for the RMAP transfers + rmapTargetLogicalAddress = DEFAULT_TARGET; + rmapSourceLogicalAddress = DEFAULT_SOURCE; //*** QLABEL ***// gresbBridgeIPLabel = new QLabel(tr("GRESB Bridge IP: ")); gresbVirtualLinkLabel = new QLabel(tr("GRESB Virtual Link: ")); spwLinkLabel = new QLabel(tr("GRESB SPW Link: ")); - rmapSourceLogicalAddressLabel = new QLabel(tr("RMAP Source Logical Address: ")); rmapSendStateLabel = new QLabel(tr("RMAP Send Socket State: waiting for connection")); rmapReceiveStateLabel = new QLabel(tr("RMAP Receive Socket State: waiting for connection")); gresbStatusQueryLabel = new QLabel(tr("GRESB status query socket (port 3010): waiting for connection")); @@ -29,12 +30,9 @@ gresb::gresb(QWidget *parent) : //*** SPINBOX ***// gresbVirtualLinkSpinBox = new QSpinBox; - rmapSourceLogicalAddressSpinBox = new QSpinBox; spwLinkSpinBox = new QSpinBox;; gresbVirtualLinkSpinBox->setRange(0, 4); gresbVirtualLinkSpinBox->setValue(1); - rmapSourceLogicalAddressSpinBox->setRange(0, 255); - rmapSourceLogicalAddressSpinBox->setValue(33); spwLinkSpinBox->setRange(0, 2); spwLinkSpinBox->setValue(0); @@ -56,13 +54,11 @@ gresb::gresb(QWidget *parent) : connectionLayout->addWidget(gresbVirtualLinkSpinBox, 1, 1, 0); connectionLayout->addWidget(spwLinkLabel, 2, 0, 0); connectionLayout->addWidget(spwLinkSpinBox, 2, 1, 0); - connectionLayout->addWidget(rmapSourceLogicalAddressLabel, 3, 0, 0); - connectionLayout->addWidget(rmapSourceLogicalAddressSpinBox, 3, 1, 0); - connectionLayout->addWidget(rmapSendStateLabel, 4, 0, 1, 2); - connectionLayout->addWidget(rmapReceiveStateLabel, 5, 0, 1, 2); - connectionLayout->addWidget(gresbStatusQueryLabel, 6, 0, 1, 2); + connectionLayout->addWidget(rmapSendStateLabel, 3, 0, 1, 2); + connectionLayout->addWidget(rmapReceiveStateLabel, 4, 0, 1, 2); + connectionLayout->addWidget(gresbStatusQueryLabel, 5, 0, 1, 2); - connectionLayout->setRowStretch(7, 1); + connectionLayout->setRowStretch(6, 1); connectionLayout->setColumnStretch(2, 1); // GRESB STATUS QUERY DIALOG @@ -80,7 +76,7 @@ gresb::gresb(QWidget *parent) : connect(gresbStatusQueryRetryButton, SIGNAL(clicked()), this, SLOT(reTestSPWLink())); connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); connect(spwLinkStatusEnquiry->readSPWStatusButton, SIGNAL(clicked()), this, SLOT(GRESBStatusQuery())); - connect(this->RMAPReceive_SOCKET, SIGNAL(readyRead()), this, SLOT(receiveSPWPacket())); + connect(this->RMAPReceive_SOCKET, SIGNAL(readyRead()), this, SLOT(receiveSPWPacketLoop())); } gresb::~gresb() @@ -238,7 +234,7 @@ unsigned int gresb::WriteBLOCK(char *dat RMAPCommand = new RMAP(commandCode, rmapTargetLogicalAddress, - rmapSourceLogicalAddressSpinBox->value(), + rmapSourceLogicalAddress, address, nbBytes, data); @@ -353,7 +349,7 @@ unsigned int gresb::ReadBLOCK(unsigned i { RMAPCommand = new RMAP(read_Inc, rmapTargetLogicalAddress, - rmapSourceLogicalAddressSpinBox->value(), + rmapSourceLogicalAddress, address, nbBytes, NULL); @@ -362,7 +358,7 @@ unsigned int gresb::ReadBLOCK(unsigned i { RMAPCommand = new RMAP(read_Single, rmapTargetLogicalAddress, - rmapSourceLogicalAddressSpinBox->value(), + rmapSourceLogicalAddress, address, nbBytes, NULL); @@ -458,6 +454,20 @@ unsigned int gresb::WriteSPW(char *Value return count; } +int gresb::receiveSPWPacketLoop(unsigned char requestID) +{ + int result = 0; + while (RMAPReceive_SOCKET->bytesAvailable()) + { + result = receiveSPWPacket(requestID); + } + if (!ccsdsPacketStore.isEmpty()) + { + emit packetStoreNotEmpty(); + } + return result; +} + int gresb::receiveSPWPacket(unsigned char requestID) // SLOT { QTime spwPacketReceiverTimeout; @@ -508,31 +518,42 @@ int gresb::receiveSPWPacket(unsigned cha return packetLength; case 2: // 0x02 is the protocole identifier for CCSDS packets - if (ccsdsPacketSEMAPHORE->available()!=0) return -4; // ERROR === previous CCSDS packet not processed yet + /*if (ccsdsPacketSEMAPHORE->available()!=0) + { + emit sendMessage("in function [receiveSPWPacket] === ERROR === previous CCSDS packet not processed yet"); + return -4; // ERROR === previous CCSDS packet not processed yet + }*/ for(unsigned int i=0; irelease(); - emit(ccsdsPacketAvailable(ccsdsPacket, packetLength)); - //emit sendMessage("CCSDS packet of size " + QString::number(packetLength) + " received"); + storeCCSDSPacket(ccsdsPacket, packetLength); return packetLength; } return 0; } +unsigned int gresb::storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) +{ + TMPacketToRead *packet; + + packet = new TMPacketToRead(ccsdsPacket, size); + ccsdsPacketStore.append(packet); + + return 1; +} + void gresb::Open() // SLOT { bool spwRunning = true; - RMAPSend_SOCKET->connectToHost( QHostAddress(gresbBridgeIPDialogBox->getGRESBIP()), + RMAPSend_SOCKET->connectToHost( QHostAddress(gresbBridgeIPDialogBox->getIP()), 3000 + gresbVirtualLinkSpinBox->value()*2, QIODevice::WriteOnly); - RMAPReceive_SOCKET->connectToHost( QHostAddress(gresbBridgeIPDialogBox->getGRESBIP()), + RMAPReceive_SOCKET->connectToHost( QHostAddress(gresbBridgeIPDialogBox->getIP()), 3000 + gresbVirtualLinkSpinBox->value()*2+1, QIODevice::ReadOnly); - GRESBStatusQuery_SOCKET->connectToHost( QHostAddress(gresbBridgeIPDialogBox->getGRESBIP()), + GRESBStatusQuery_SOCKET->connectToHost( QHostAddress(gresbBridgeIPDialogBox->getIP()), 3010, QIODevice::ReadWrite); GRESBStatusQuery_SOCKET->waitForConnected(10000); - RMAPReceive_SOCKET->readAll(); // read all remaining data from the reception socket // initialize SPW packet semaphores while (rmapPacketSEMAPHORE->available()!=0) rmapPacketSEMAPHORE->acquire(); while (ccsdsPacketSEMAPHORE->available()!=0) ccsdsPacketSEMAPHORE->acquire(); @@ -543,7 +564,8 @@ void gresb::Open() // SLOT if (spwRunning == false) this->Close(); else { - emit appendToLog(QString("SpaceWire running on virtual link ")+ QString::number(spwLinkSpinBox->value())); + emit appendToLog(QString("SpaceWire running on link ")+ QString::number(spwLinkSpinBox->value())); + RMAPReceive_SOCKET->readAll(); // read all remaining data from the reception socket emit isOpen(true); } } @@ -764,3 +786,4 @@ void gresb::GRESBConnectionState(QAbstra } gresbStatusQueryLabel->setText(socketMessage); } + diff --git a/rmapplugin/gresb.h b/rmapplugin/gresb.h --- a/rmapplugin/gresb.h +++ b/rmapplugin/gresb.h @@ -13,6 +13,8 @@ #include "gresbstatusenquiry.h" #include "rmapoperations.h" #include "qipdialogbox.h" +#include "ccsds.h" +#include "tmpackettoread.h" class gresb : public QWidget { @@ -23,6 +25,9 @@ public: unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); + + unsigned int storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); + QList ccsdsPacketStore; signals: void sendMessage(QString message); @@ -30,19 +35,25 @@ signals: void RMAP_write_reply_setText(QString); void appendToLog(QString); void ccsdsPacketAvailable(unsigned char*, unsigned int); + void packetStoreNotEmpty(); public slots: void Open(); void Close(); + int receiveSPWPacketLoop(unsigned char requestID=0); int receiveSPWPacket(unsigned char requestID=0); void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} + void sourceHasChanged(int source) {rmapSourceLogicalAddress = (unsigned char) source;} void ccsdsPacketIsProcessed() {ccsdsPacketSEMAPHORE->tryAcquire();} void reTestSPWLink(); // void RMAPSendConnectionState(QAbstractSocket::SocketState socketState); void RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState); void GRESBConnectionState(QAbstractSocket::SocketState socketState); + // + void setIP(unsigned char address1, unsigned char address2, unsigned char address3, unsigned char address4) + {this->gresbBridgeIPDialogBox->setIP(address1, address2, address3, address4);} private slots: int GRESBStatusQuery(); @@ -65,7 +76,6 @@ private: QLabel *gresbBridgeIPLabel; QLabel *gresbVirtualLinkLabel; QLabel *spwLinkLabel; - QLabel *rmapSourceLogicalAddressLabel; QLabel *rmapSendStateLabel; QLabel *rmapReceiveStateLabel; QLabel *gresbStatusQueryLabel; @@ -77,7 +87,6 @@ private: QSpinBox *gresbVirtualLinkSpinBox; QSpinBox *spwLinkSpinBox; - QSpinBox *rmapSourceLogicalAddressSpinBox; QGridLayout *connectionLayout; QGridLayout *gresbStatusQueryDialogLayout; diff --git a/rmapplugin/rmapoperations.cpp b/rmapplugin/rmapoperations.cpp --- a/rmapplugin/rmapoperations.cpp +++ b/rmapplugin/rmapoperations.cpp @@ -1,6 +1,7 @@ #include "rmapoperations.h" -RMAP::RMAP(RMAP_command_codes commandCode, char targetLogicalAddress, char initiatorLogicalAddress, int startAddress, int nbBytes, char* data) +RMAP::RMAP(RMAP_command_codes commandCode, unsigned char targetLogicalAddress, unsigned char initiatorLogicalAddress, + int startAddress, int nbBytes, char* data) { char packetType; // 2 most Significant Bits char command; // 4 bits @@ -37,9 +38,9 @@ RMAP::RMAP(RMAP_command_codes commandCod break; } RMAPHeader.targetLogicalAddress = targetLogicalAddress ; - RMAPHeader.protocolIdentifier = 0x01; // 0x01 is the protocole identifier for RMAP + RMAPHeader.protocolIdentifier = 0x01; // 0x01 is the protocole identifier for RMAP RMAPHeader.instruction = (packetType<<6) + (command<<2) + (replyAddressLength); - RMAPHeader.key = 0; // used for command authorization + RMAPHeader.key = initiatorLogicalAddress; // used for command authorization RMAPHeader.initiatorLogicalAddress = initiatorLogicalAddress; // 0 is the default address for the GRESB module RMAPHeader.transactionIdentifier1 = 0x00; RMAPHeader.transactionIdentifier0 = 0x01; diff --git a/rmapplugin/rmapoperations.h b/rmapplugin/rmapoperations.h --- a/rmapplugin/rmapoperations.h +++ b/rmapplugin/rmapoperations.h @@ -9,7 +9,9 @@ #define RMAP_READ_COMMAND_HEADER_LENGTH 16 // in bytes => ECSS #define RMAP_DATA_CRC_LENGTH 1 // in bytes => ECSS #define RMAP_MAX_PACKET_LENGTH RMAP_READ_REPLY_HEADER_LENGTH + RMAP_MAX_DATA_LENGTH + RMAP_DATA_CRC_LENGTH -#define CCSDS_MAX_PACKET_LENGTH 4412 // in bytes, specified in the LFR Software Requirements Specification + +#define DEFAULT_SOURCE 0 +#define DEFAULT_TARGET 254 static const unsigned char RMAP_CRCTable[] = { 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75, @@ -71,9 +73,9 @@ struct rmap_command_format_str char targetLogicalAddress; char protocolIdentifier; char instruction; - char key; // used for command authorization => check Gaisler GRSPW for compliance + unsigned char key; // used for command authorization => check Gaisler GRSPW for compliance //char replyAddress[]; // not needed if logical addressing is used (replyAddressLength = 0b00) - char initiatorLogicalAddress; + unsigned char initiatorLogicalAddress; char transactionIdentifier1; char transactionIdentifier0; char extendedAddress; @@ -132,8 +134,8 @@ class RMAP { public: RMAP(RMAP_command_codes commandCode, - char targetLogicalAddress, - char initiatorLogicalAddress, + unsigned char targetLogicalAddress, + unsigned char initiatorLogicalAddress, int startAddress, int nbBytes, char *data); diff --git a/rmapplugin/rmapplugin.cpp b/rmapplugin/rmapplugin.cpp --- a/rmapplugin/rmapplugin.cpp +++ b/rmapplugin/rmapplugin.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include rmapplugin::rmapplugin(QWidget *parent) :lppmonplugin(parent,false) @@ -37,11 +39,38 @@ rmapplugin::rmapplugin(QWidget *parent) time_FINE = 0; currentBridge = selectedBridgeIsUnknown; - /*Python wrapper*/ + //************** + //Python wrapper this->pyObject = new rmappluginPythonWrapper(); connect(this->pyObject,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); connect(this->pyObject,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); - /*==============*/ + //** + connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( WriteSPWSig(char*,uint,char,char) ), + this, SLOT( WriteSPW(char*,uint,char,char)), Qt::DirectConnection ); + //** + connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( updateTargetAddress(unsigned char) ), + this, SLOT( setValueTargetAddress(unsigned char)) ); + //** + connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL( updateSourceAddress(unsigned char) ), + this, SLOT( setValueSourceAddress(unsigned char)) ); + //** + connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(sendMessage(QString)), + this, SLOT(displayOnConsole(QString)) ); + //** + connect( (rmappluginPythonWrapper*)this->pyObject, SIGNAL(fetchPacketSig()), + this, SLOT(fetchPacket()), Qt::DirectConnection ); + //************** + + //************** + // get a smart pointer to the __main__ module of the Python interpreter + PythonQtObjectPtr context = PythonQt::self()->getMainModule(); + // add a QObject as variable of name "BUTTON_rmapOpenCommunication" to the namespace of the __main__ module + context.addObject("BUTTON_rmapOpenCommunication", UI->rmapOpenCommunicationButton); + context.addObject("BUTTON_rmapCloseCommunication", UI->rmapCloseCommunicationButton); + context.addObject("BUTTON_selectStarDundee", UI->selectStarDundee_BUTTON); + context.addObject("BUTTON_selectGRESB", UI->selectGRESB_BUTTON); + context.addObject("GRESB_Bridge", UI->gresbBridge); + //************** connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(openBridge())); connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(closeBridge())); @@ -64,6 +93,12 @@ rmapplugin::rmapplugin(QWidget *parent) connect(this->UI->gresbBridge, SIGNAL(ccsdsPacketAvailable(unsigned char*,uint)), this, SLOT(processCCSDSPacket(unsigned char*,uint))); connect(this, SIGNAL(ccsdsPacketIsProcessed()), this->UI->gresbBridge, SLOT(ccsdsPacketIsProcessed())); + connect(this->UI->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), + this->UI->gresbBridge, SLOT(targetHasChanged(int))); + connect(this->UI->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), + this->UI->gresbBridge, SLOT(sourceHasChanged(int))); + connect(this->UI->gresbBridge, SIGNAL(packetStoreNotEmpty()), + this, SLOT(processPacketStore())); // Star Dundee connect(this->UI->starDundee, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); @@ -73,15 +108,32 @@ rmapplugin::rmapplugin(QWidget *parent) connect(this->UI->starDundee, SIGNAL(ccsdsPacketAvailable(unsigned char*,uint)), this, SLOT(processCCSDSPacket(unsigned char*,uint))); connect(this, SIGNAL(ccsdsPacketIsProcessed()), this->UI->starDundee, SLOT(ccsdsPacketIsProcessed())); + connect(this->UI->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), + this->UI->starDundee, SLOT(targetHasChanged(int))); + connect(this->UI->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), + this->UI->starDundee, SLOT(sourceHasChanged(int))); + connect(this->UI->starDundee, SIGNAL(packetStoreNotEmpty()), + this, SLOT(processPacketStore())); connect(this->UI, SIGNAL(bridgeHasChanged(selectedBridge)), this, SLOT(bridgeHasChanged(selectedBridge))); + connect(this->UI, SIGNAL(bridgeHasChanged(selectedBridge)), this, SLOT(updatePacketStore(selectedBridge))); + } rmapplugin::~rmapplugin() { - if (!RMAPSend_SOCKET->isOpen()) RMAPSend_SOCKET->disconnectFromHost(); - if (!RMAPReceive_SOCKET->isOpen()) RMAPReceive_SOCKET->disconnectFromHost(); - if (!GRESBStatusQuery_SOCKET->isOpen()) GRESBStatusQuery_SOCKET->disconnectFromHost(); + switch(currentBridge) + { + case selectedBridgeIsGRESB : + if (RMAPSend_SOCKET->isOpen()) RMAPSend_SOCKET->disconnectFromHost(); + if (RMAPReceive_SOCKET->isOpen()) RMAPReceive_SOCKET->disconnectFromHost(); + if (GRESBStatusQuery_SOCKET->isOpen()) GRESBStatusQuery_SOCKET->disconnectFromHost(); + break; + case selectedBridgeIsStarDundee : + break; + default: + break; + } } unsigned int rmapplugin::Write(unsigned int *Value, unsigned int count, unsigned int address) @@ -279,6 +331,16 @@ void rmapplugin::appendToLog(QString tex APPENDTOLOG(text); } +void rmapplugin::setValueTargetAddress(unsigned char newAddress) +{ + this->UI->rmapTargetLogicalAddressSpinBox->setValue(newAddress); +} + +void rmapplugin::setValueSourceAddress(unsigned char newAddress) +{ + this->UI->rmapSourceLogicalAddressSpinBox->setValue(newAddress); +} + ///////////////////// // INTERNAL FUNCTIONS @@ -311,6 +373,44 @@ void rmapplugin::processCCSDSPacket(unsi //+" " //+ QString::number(ccsdsPacket[7], 16)); displayOnConsole(message); + //((rmappluginPythonWrapper*)this->pyObject)->storeCCSDSPacket(ccsdsPacket, size); emit ccsdsPacketIsProcessed(); } +void rmapplugin::processPacketStore() +{ + ((rmappluginPythonWrapper*)this->pyObject)->processPacketStore(); +} + +void rmapplugin::updatePacketStore(selectedBridge bridge) +{ + switch(bridge) + { + case selectedBridgeIsGRESB : + ((rmappluginPythonWrapper*)this->pyObject)->ccsdsPacketStore = &(this->UI->gresbBridge->ccsdsPacketStore); + break; + case selectedBridgeIsStarDundee : + ((rmappluginPythonWrapper*)this->pyObject)->ccsdsPacketStore = &(this->UI->starDundee->ccsdsPacketStore); + break; + default: + break; + } +} + +int rmapplugin::fetchPacket() +{ + int ret = 0; + + switch(currentBridge) + { + case selectedBridgeIsGRESB : + break; + case selectedBridgeIsStarDundee : + ret = this->UI->starDundee->receiveSPWPacketLoop(); + break; + default: + break; + } + + return ret; +} diff --git a/rmapplugin/rmapplugin.h b/rmapplugin/rmapplugin.h --- a/rmapplugin/rmapplugin.h +++ b/rmapplugin/rmapplugin.h @@ -54,9 +54,14 @@ public slots: unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); + void setValueTargetAddress(unsigned char newAddress); + void setValueSourceAddress(unsigned char newAddress); void openBridge(); void closeBridge(); void processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); + void processPacketStore(); + void updatePacketStore(selectedBridge bridge); + int fetchPacket(); // void sendCCSDS(); void send_TC_LFR_UPDATE_TIME(); diff --git a/rmapplugin/rmapplugin.pro b/rmapplugin/rmapplugin.pro --- a/rmapplugin/rmapplugin.pro +++ b/rmapplugin/rmapplugin.pro @@ -20,8 +20,8 @@ DEFINES += driver_PID=0 QT += network -LIBS += ../spw_usb_driver_v2.61/lib/x86_64/libSpaceWireUSBAPI.so \ - ../spw_usb_driver_v2.61/lib/x86_64/libConfigLibraryUSB.so +LIBS += ../spw_usb_driver_v2.62/lib/x86_64/libSpaceWireUSBAPI.so \ + ../spw_usb_driver_v2.62/lib/x86_64/libConfigLibraryUSB.so INCLUDEPATH += \ @@ -43,7 +43,8 @@ HEADERS += \ ../spw_usb_driver_v2.61/inc/spw_usb_api.h \ ../spw_usb_driver_v2.61/inc/spw_config_library.h \ gresb.h \ - bridge.h + tcpackettosend.h \ + tmpackettoread.h SOURCES += \ @@ -57,7 +58,8 @@ SOURCES += \ rmappluginpythonwrapper.cpp \ stardundee.cpp \ gresb.cpp \ - bridge.cpp + tcpackettosend.cpp \ + tmpackettoread.cpp diff --git a/rmapplugin/rmappluginpythonwrapper.cpp b/rmapplugin/rmappluginpythonwrapper.cpp --- a/rmapplugin/rmappluginpythonwrapper.cpp +++ b/rmapplugin/rmappluginpythonwrapper.cpp @@ -1,19 +1,165 @@ #include "rmappluginpythonwrapper.h" #include +#include rmappluginPythonWrapper::rmappluginPythonWrapper(QObject *parent) : genericPySysdriver(parent) { + timer = new QTimer; + timer->setSingleShot(true); + connect(timer, SIGNAL(timeout()), this, SLOT(sendTC())); + connect(this, SIGNAL(activateTCLoopSig()), this, SLOT(sendTCLoop())); +} + +QList rmappluginPythonWrapper::ReadSPW(unsigned int size) // size is not used +{ + QList result; + TMPacketToRead *ccsdsPacket; + + if (!ccsdsPacketStore->isEmpty()) + { + ccsdsPacket = ccsdsPacketStore->takeFirst(); + for(unsigned int i = 0;isize;i++) + { + result.append((QVariant)ccsdsPacket->Value[i]); + } + delete(ccsdsPacket); + } + + return result; +} + +void rmappluginPythonWrapper::WriteSPW(QList dataList) +{ + char targetLogicalAddress; + char userApplication; + unsigned int count; + char *Value; + + unsigned char data[dataList.count()]; + + for(int i = 0; i dataList, unsigned int delay) +{ + char targetLogicalAddress; + char userApplication; + unsigned int count; + char *Value; + TCPacketToSend *packet; + + unsigned char data[dataList.count()]; + + for(int i = 0; i rmappluginPythonWrapper::getData() +void rmappluginPythonWrapper::sendTCLoop() { - QList data; - for (int i = 0; i<1024; i++) + unsigned int delay; + + if (!timer->isActive()) + { + if (!TCPacketStore.isEmpty()) + { + delay = TCPacketStore.at(0)->delay; + timer->setInterval(delay); + timer->start(); + } + } +} + +void rmappluginPythonWrapper::sendTC() +{ + TCPacketToSend *packet; + unsigned int delay; + + packet = TCPacketStore.takeFirst(); + // the signal is connected with the option Qt::DirectConnection, thus it is processed immediately + emit(WriteSPWSig(packet->Value, packet->count,packet->targetLogicalAddress, packet->userApplication)); + delete(packet); + if (!TCPacketStore.isEmpty()) { - QVariant t(1000*cos(0.1*i)); - data.append(t); + delay = TCPacketStore.at(0)->delay; + timer->setInterval(delay); + timer->start(); + } +} + +/*unsigned int rmappluginPythonWrapper::storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) +{ + unsigned int i; + TMPacketToRead ccsdsPacketToStore; + + ccsdsPacketToStore.size = size; + for(i=0; iappend(ccsdsPacketToStore); + emit ccsdsPacketIsAvailable(size); + return 1; +}*/ + +void rmappluginPythonWrapper::processPacketStore() +{ + while (!ccsdsPacketStore->isEmpty()) + { + emit ccsdsPacketIsAvailable(ccsdsPacketStore->at(0)->size); + } } + +void rmappluginPythonWrapper::setTargetAddressValue(unsigned int address) +{ + unsigned char newAddress; + newAddress = (unsigned char) address; + emit updateTargetAddress(newAddress); +} + +void rmappluginPythonWrapper::setSourceAddressValue(unsigned int address) +{ + unsigned char newAddress; + newAddress = (unsigned char) address; + emit updateSourceAddress(newAddress); +} + +void rmappluginPythonWrapper::ProcessPendingEvents() +{ + QCoreApplication::processEvents(); +} + diff --git a/rmapplugin/rmappluginpythonwrapper.h b/rmapplugin/rmappluginpythonwrapper.h --- a/rmapplugin/rmappluginpythonwrapper.h +++ b/rmapplugin/rmappluginpythonwrapper.h @@ -5,17 +5,52 @@ #include #include #include +#include "rmapoperations.h" +#include "ccsds.h" +#include +#include +#include class rmappluginPythonWrapper : public genericPySysdriver { Q_OBJECT public: explicit rmappluginPythonWrapper(QObject *parent = 0); + + QList *ccsdsPacketStore; + void processPacketStore(); + unsigned int storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); + + QList TCPacketStore; + QTimer *timer; signals: + void ccsdsPacketIsAvailable(unsigned int size); + void wakeUpCallingThread(); + unsigned int WriteSPWSig(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); + void updateTargetAddress(unsigned char newAddress); + void updateSourceAddress(unsigned char newAddress); + void activateTCLoopSig(); + void processPacketStoreNowSig(); + void sendMessage(QString message); + int fetchPacketSig(); public slots: - QList getData(); + QList ReadSPW(unsigned int size=0); + int fetchPacket() {return emit fetchPacketSig();} + void WriteSPW(QList dataList); + void WriteSPWDelay(QList dataList, unsigned int delay=0); + void processPacketStoreLater(unsigned int delay); + void sendProcessPacketStoreNowSig(){emit processPacketStoreNowSig();} + void sendTCLoop(); + void sendTC(); + void reEmitWriteSPWSig(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) + {emit WriteSPWSig(Value, count, targetLogicalAddress, userApplication);} + + void setTargetAddressValue(unsigned int address); + void setSourceAddressValue(unsigned int address); + void ProcessPendingEvents(); + void BlockAllSignals(); }; diff --git a/rmapplugin/rmappluginui.cpp b/rmapplugin/rmappluginui.cpp --- a/rmapplugin/rmappluginui.cpp +++ b/rmapplugin/rmappluginui.cpp @@ -55,6 +55,7 @@ rmapPluginUI::rmapPluginUI(QWidget *pare gresbStatusQueryLabel = new QLabel(tr("Status query socket (port 3010): waiting for connection")); gresbStatusQueryDialogLabel = new QLabel(tr("sockets opened but SpaceWire link not running")); sendCCSDSCommandLabel = new QLabel(tr("Address of the target")); + nbPacketInStore = new QLabel(tr("nb packets in store: -")); //*** QPUSHBUTTON ***// rmapOpenCommunicationButton = new QPushButton(tr("Open selected bridge")); @@ -81,18 +82,18 @@ rmapPluginUI::rmapPluginUI(QWidget *pare gresbVirtualLinkSpinBox->setRange(0, 4); gresbVirtualLinkSpinBox->setValue(1); rmapSourceLogicalAddressSpinBox->setRange(0, 255); - rmapSourceLogicalAddressSpinBox->setValue(33); + rmapSourceLogicalAddressSpinBox->setValue(0); rmapTargetLogicalAddressSpinBox->setRange(0, 255); spwLinkSpinBox->setRange(0, 2); spwLinkSpinBox->setValue(0); CCSDSTargetLogicalAddressSpinBox->setRange(0,255); - CCSDSTargetLogicalAddressSpinBox->setValue(254); + CCSDSTargetLogicalAddressSpinBox->setValue(0); //*** MISC **// starDundee = new StarDundee; gresbBridge = new gresb; console = new QTextEdit; - gresbBridgeIPDialogBox = new QIPDialogBox; + //gresbBridgeIPDialogBox = new QIPDialogBox; gresbStatusQueryDialog = new QDialog; logEnableCheckBox = new QCheckBox(tr("Enable Logs")); RMAP_write_verify = new QCheckBox(tr("data checked before write\nlimited to 4 bytes\nNOT IMPLEMENTED")); @@ -112,13 +113,16 @@ rmapPluginUI::rmapPluginUI(QWidget *pare generalParameters_LAYOUT->addWidget(logEnableCheckBox, 0, 0, 1, 1); generalParameters_LAYOUT->addWidget(logFileChooseButton, 0, 1, 1, 1); - generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressLabel, 1, 0, 0); - generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressSpinBox, 1, 1, 0); - generalParameters_LAYOUT->addWidget(rmapOpenCommunicationButton, 2, 0, 1, 1); - generalParameters_LAYOUT->addWidget(rmapCloseCommunicationButton, 2, 1, 1, 1); - generalParameters_LAYOUT->addWidget(RMAP_write_verify, 3, 0, 1, 2); - generalParameters_LAYOUT->addWidget(RMAP_write_reply, 4, 0, 1, 2); - generalParameters_LAYOUT->setRowStretch(5, 1); + generalParameters_LAYOUT->addWidget(rmapSourceLogicalAddressLabel, 1, 0, 0); + generalParameters_LAYOUT->addWidget(rmapSourceLogicalAddressSpinBox, 1, 1, 0); + generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressLabel, 2, 0, 0); + generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressSpinBox, 2, 1, 0); + generalParameters_LAYOUT->addWidget(rmapOpenCommunicationButton, 3, 0, 1, 1); + generalParameters_LAYOUT->addWidget(rmapCloseCommunicationButton, 3, 1, 1, 1); + generalParameters_LAYOUT->addWidget(RMAP_write_verify, 4, 0, 1, 2); + generalParameters_LAYOUT->addWidget(RMAP_write_reply, 5, 0, 1, 2); + + generalParameters_LAYOUT->setRowStretch(6, 1); generalParameters_LAYOUT->setColumnStretch(2, 1); gresb_GROUPBOX->setLayout(gresbBridge->layout()); @@ -140,6 +144,7 @@ rmapPluginUI::rmapPluginUI(QWidget *pare consoleLayout->addWidget(console); consoleLayout->addWidget(clearConsoleButton); + consoleLayout->addWidget(nbPacketInStore); connect(this->logFileChooseButton, SIGNAL(clicked()), this, SLOT(chooseLogFile())); connect(this, SIGNAL(setLogFileName(QString)), this->logFileName, SLOT(setText(QString))); @@ -168,8 +173,10 @@ rmapPluginUI::rmapPluginUI(QWidget *pare connect(this->starDundee, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool))); connect(this->gresbBridge, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool))); + connect(this->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->gresbBridge, SLOT(sourceHasChanged(int))); + connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->gresbBridge, SLOT(targetHasChanged(int))); + connect(this->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->starDundee, SLOT(sourceHasChanged(int))); connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->starDundee, SLOT(targetHasChanged(int))); - connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->gresbBridge, SLOT(targetHasChanged(int))); // command code connect(this->RMAP_write_reply, SIGNAL(clicked()), this, SLOT(getCommandCode())); @@ -180,7 +187,8 @@ rmapPluginUI::rmapPluginUI(QWidget *pare this->gresbBridge, SLOT(commandCodeHasChanged(RMAP_command_codes))); getCommandCode(); // init the command code value - rmapTargetLogicalAddressSpinBox->setValue(254); + rmapSourceLogicalAddressSpinBox->setValue(DEFAULT_SOURCE); + rmapTargetLogicalAddressSpinBox->setValue(DEFAULT_TARGET); } rmapPluginUI::~rmapPluginUI() diff --git a/rmapplugin/rmappluginui.h b/rmapplugin/rmappluginui.h --- a/rmapplugin/rmappluginui.h +++ b/rmapplugin/rmappluginui.h @@ -81,7 +81,7 @@ public: QSpinBox* rmapTargetLogicalAddressSpinBox; QSpinBox* CCSDSTargetLogicalAddressSpinBox; - QIPDialogBox* gresbBridgeIPDialogBox; + //QIPDialogBox* gresbBridgeIPDialogBox; QCheckBox *logEnableCheckBox; QCheckBox *RMAP_write_verify; @@ -92,6 +92,7 @@ public: QLabel* gresbStatusQueryLabel; QLabel* gresbStatusQueryDialogLabel; QLabel* sendCCSDSCommandLabel; + QLabel* nbPacketInStore; QDialog* gresbStatusQueryDialog; @@ -101,8 +102,8 @@ public: QTextEdit* console; + // SPACEWIRE BRIDGES StarDundee *starDundee; - gresb *gresbBridge; bool islogfileenable(); @@ -124,6 +125,7 @@ signals: void commandCodeHasChanged(RMAP_command_codes commandCode); void bridgeHasChanged(selectedBridge bridge); void targetHasChanged(unsigned char target); + void sourceHasChanged(unsigned char source); private: QLabel *gresbBridgeIPLabel; diff --git a/rmapplugin/stardundee.cpp b/rmapplugin/stardundee.cpp --- a/rmapplugin/stardundee.cpp +++ b/rmapplugin/stardundee.cpp @@ -1,6 +1,7 @@ #include "stardundee.h" #include #include +#include "ccsds.h" StarDundee::StarDundee(QWidget *parent) : QWidget(parent) @@ -16,13 +17,13 @@ StarDundee::StarDundee(QWidget *parent) starDundeeStatusQueryDialog = new QDialog; commandCode = invalid0; // initialization of the cmmand code for the RMAP transfers + rmapTargetLogicalAddress = DEFAULT_TARGET; + rmapSourceLogicalAddress = DEFAULT_SOURCE; - rmapSourceLogicalAddress = 0x20; connection_LAYOUT = new QGridLayout; usbDeviceNumber_LABEL = new QLabel(tr("USB device number: ")); linkNumber_LABEL = new QLabel(tr("SpaceWire link number: ")); - sourceLogicalAddress_LABEL = new QLabel(tr("Source logical address: ")); starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire link not running")); //*** QPUSHBUTTON ***// @@ -35,9 +36,6 @@ StarDundee::StarDundee(QWidget *parent) linkNumber_SPINBOX = new QSpinBox; linkNumber_SPINBOX->setRange(1,2); linkNumber_SPINBOX->setValue(1); - sourceLogicalAddress_SPINBOX = new QSpinBox; - sourceLogicalAddress_SPINBOX->setRange(0,254); - sourceLogicalAddress_SPINBOX->setValue(32); // STAR DUNDEE STATUS QUERY DIALOG starDundeeStatusQueryDialogLayout = new QGridLayout; @@ -50,21 +48,16 @@ StarDundee::StarDundee(QWidget *parent) connection_LAYOUT->addWidget(usbDeviceNumber_SPINBOX, 0, 1, 1, 1); connection_LAYOUT->addWidget(linkNumber_LABEL, 1, 0, 1, 1); connection_LAYOUT->addWidget(linkNumber_SPINBOX, 1, 1, 1, 1); - connection_LAYOUT->addWidget(sourceLogicalAddress_LABEL, 2, 0, 1, 1); - connection_LAYOUT->addWidget(sourceLogicalAddress_SPINBOX, 2, 1, 1, 1); - connection_LAYOUT->setRowStretch(3, 1); + connection_LAYOUT->setRowStretch(2, 1); connection_LAYOUT->setColumnStretch(2, 1); this->setLayout(connection_LAYOUT); - connect(this->sourceLogicalAddress_SPINBOX, SIGNAL(valueChanged(int)), this, SLOT(sourceHasChanged(int))); - connect(starDundeeStatusQueryRetryButton, SIGNAL(clicked()), this, SLOT(reTestSPWLink())); connect(starDundeeStatusQueryAbortButton, SIGNAL(clicked()), starDundeeStatusQueryDialog, SLOT(reject())); connect(this->timer, SIGNAL(timeout()), this, SLOT(receivePollingLoop())); - timer->start(100); // starts the periodical timer, perdio = 100ms } StarDundee::~StarDundee() @@ -82,14 +75,14 @@ void StarDundee::Open() if (!USBSpaceWire_Open(&hDevice, usbDeviceNumber_SPINBOX->value())) // Open the USB device { - emit sendMessage("stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); - return; + emit sendMessage("stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); + return; } emit sendMessage("stardundee *** Open *** USBSpaceWire_Open successful, device number: " + QString::number(usbDeviceNumber_SPINBOX->value())); USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode - CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP + CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices // Set the path and return path to the device @@ -129,15 +122,27 @@ void StarDundee::Open() else emit sendMessage("Set the link status control for link " + QString::number(linkNumber_SPINBOX->value())); } - setRoutingTableEntry(rmapTargetLogicalAddress, (1<value())); - setRoutingTableEntry(sourceLogicalAddress_SPINBOX->value(), (1<<3)); - //setRoutingTableEntry(33, (1<<3)); + if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) + { + emit sendMessage("Could not set the device to be an interface"); + } + else + { + emit sendMessage("Device set to be an interface"); + } - emit sendMessage("The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); + //setRoutingTableEntry(rmapTargetLogicalAddress, (1<value())); + //setRoutingTableEntry(rmapSourceLogicalAddress, (1<<3)); + //GetRoutingTableEntry(rmapTargetLogicalAddress); + //GetRoutingTableEntry(rmapSourceLogicalAddress); USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints + emit sendMessage("The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); + emit sendMessage("The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); + emit sendMessage("USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); + // initialize SPW packet semaphores while (rmapPacketSEMAPHORE->available()!=0) rmapPacketSEMAPHORE->acquire(); while (ccsdsPacketSEMAPHORE->available()!=0) ccsdsPacketSEMAPHORE->acquire(); @@ -145,10 +150,11 @@ void StarDundee::Open() if (getLinkStatus(linkNumber_SPINBOX->value())) { emit isOpen(true); + timer->start(100); // starts the periodical timer, period = 100ms } else { - + starDundeeStatusQueryDialog->exec(); } } @@ -162,21 +168,35 @@ void StarDundee::Close() emit isOpen(false); } -unsigned int StarDundee::GetRoutingTableEntry() +unsigned char StarDundee::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts) +{ + U32 routingTableEntry; + // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber + if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) + { + emit sendMessage("Could not clear routing table entry " + QString::number(tableEntry)); + } + // Build the routing table entry + CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, + dwOutputPorts, // route out of port dwOutputPorts + 0, // header deletion disabled + 0); // priority normal + // Set the routing table entry for logical address tableEntry + if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) + { + emit sendMessage("Could not set routing table entry [" + QString::number(tableEntry) + "]"); + } + else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] set" ); + return 1; +} + +unsigned int StarDundee::GetRoutingTableEntry(int tableEntry) { U32 routingTableEntry, outputPorts; char enabled, delHead, priority; int portNum; - int tableEntry; - tableEntry = rmapTargetLogicalAddress; - - // Set the path and return path to the device - CFGSpaceWire_StackClear(); - CFGSpaceWire_AddrStackPush(0); - CFGSpaceWire_AddrStackPush(254); - CFGSpaceWire_RetAddrStackPush(254); - + emit sendMessage("GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); // Read the routing table entry if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) { @@ -343,8 +363,8 @@ unsigned int StarDundee::WriteBLOCK(char { RMAP *RMAPCommand; char * packet; + char* aux; unsigned char offset, headerSize, CRCSize; - char* aux; unsigned int totalSize; int errorCode; QString console_message; @@ -366,16 +386,17 @@ unsigned int StarDundee::WriteBLOCK(char //************************* // BUILD THE PACKET TO SEND - totalSize = headerSize + nbBytes + CRCSize; + totalSize = headerSize + nbBytes + CRCSize + PATH_ADDRESSING_OFFSET; packet = (char*) malloc( totalSize ); aux = (char*) ((void*) &RMAPCommand->RMAPHeader); - for(unsigned int i = 0; ilinkNumber_SPINBOX->value(); + for(unsigned int i = 0; idataCRC; + packet[nbBytes+offset+PATH_ADDRESSING_OFFSET] = RMAPCommand->dataCRC; //**************** // SEND THE PACKET @@ -480,7 +501,10 @@ unsigned int StarDundee::ReadBLOCK(unsig { int errorCode; RMAP *RMAPCommand; - unsigned int dataLength; + char *packet; + char *aux; + unsigned int dataLength = 0; + unsigned int totalSize = 0; //********************** // Check the link status @@ -511,12 +535,39 @@ unsigned int StarDundee::ReadBLOCK(unsig nbBytes, NULL); } + + //************************* + // BUILD THE PACKET TO SEND + totalSize = sizeof(RMAPCommand->RMAPHeader) + PATH_ADDRESSING_OFFSET; + packet = (char*) malloc( totalSize ); + aux = (char*) ((void*) &RMAPCommand->RMAPHeader); + packet[0] = this->linkNumber_SPINBOX->value(); + for (unsigned int i = 0; iRMAPHeader); i++) + packet[i+PATH_ADDRESSING_OFFSET] = aux[i]; + + //**************** + // SEND THE PACKET result = USBSpaceWire_SendPacket(hDevice, - (unsigned char*) ((void*) &RMAPCommand->RMAPHeader), - sizeof(RMAPCommand->RMAPHeader), + packet, + totalSize, BWAIT_1, &pIdentifier); if (result != TRANSFER_SUCCESS) emit sendMessage("ERR *** ReadStarDundee *** ReadBLOCK *** sending the READ command "); - else emit sendMessage("OK *** ReadStarDundee *** ReadBLOCK *** sending the READ command"); + else + { + emit sendMessage("OK *** ReadStarDundee *** ReadBLOCK *** sending the READ command"); + emit appendToLog("packet sent, B0 = " + QString::number(packet[0], 16) + + " *** B1 = " + QString::number(packet[1], 16) + + " *** B2 = " + QString::number(packet[2], 16) + + " *** B3 = " + QString::number(packet[3], 16) + + " *** B4 = " + QString::number(packet[4], 16) + + " *** B5 = " + QString::number(packet[5], 16) + ); + } + + //************** + // Free the send + USBSpaceWire_FreeSend(hDevice, pIdentifier); + free(packet); //********************************* // RECEIVE THE INCOMING RMAP PACKET @@ -561,20 +612,21 @@ unsigned int StarDundee::WriteSPW(char * return 1; } - totalSize = count + 4; + totalSize = count + 4 + PATH_ADDRESSING_OFFSET; // The StarDundee brick is in PATH addressing SPWData = (char*) malloc(totalSize); // SPW HEADER - SPWData[0] = targetLogicalAddress; - SPWData[1] = protocoleIdentifier; - SPWData[2] = reserved; - SPWData[3] = userApplication; + SPWData[0] = this->linkNumber_SPINBOX->value(); // 1 by default, value can be 1 or 2 + SPWData[0+PATH_ADDRESSING_OFFSET] = targetLogicalAddress; + SPWData[1+PATH_ADDRESSING_OFFSET] = protocoleIdentifier; + SPWData[2+PATH_ADDRESSING_OFFSET] = reserved; + SPWData[3+PATH_ADDRESSING_OFFSET] = userApplication; // CCSDS PACKET for (unsigned int i = 0; irelease(); emit appendToLog("RMAP packet of size " + QString::number(packetLength) + " received"); + emit appendToLog("packet received, B0 = " + QString::number(spwPacket[0], 16) + + " *** B1 = " + QString::number(spwPacket[1], 16) + + " *** B2 = " + QString::number(spwPacket[2], 16) + + " *** B3 = " + QString::number(spwPacket[3], 16) + + " *** B4 = " + QString::number(spwPacket[4], 16) + + " *** B5 = " + QString::number(spwPacket[5], 16) + ); return packetLength; case 2: // 0x02 is the protocole identifier for CCSDS packets - if (ccsdsPacketSEMAPHORE->available()!=0) return -4; // ERROR === previous CCSDS packet not processed yet + if (ccsdsPacketSEMAPHORE->available()!=0) + { + emit sendMessage("in function [receiveSPWPacket] === ERROR === previous CCSDS packet not processed yet"); + return -4; // ERROR === previous CCSDS packet not processed yet + } for(unsigned int i=0; irelease(); + //ccsdsPacketSEMAPHORE->release(); + //emit(ccsdsPacketAvailable(ccsdsPacket, packetLength)); emit appendToLog("CCSDS packet of size " + QString::number(packetLength) + " received"); - emit(ccsdsPacketAvailable(ccsdsPacket, packetLength)); + emit appendToLog("packet received, byte0 " + QString::number(spwPacket[0], 16) + + " *** byte1 " + QString::number(spwPacket[1], 16) + + " *** byte2 " + QString::number(spwPacket[2], 16) + + " *** byte3 " + QString::number(spwPacket[3], 16)); + storeCCSDSPacket(ccsdsPacket, packetLength); return packetLength; + default: + emit appendToLog("packet received, byte0 " + QString::number(spwPacket[0], 16) + + " *** byte1 " + QString::number(spwPacket[1], 16) + + " *** byte2 " + QString::number(spwPacket[2], 16) + + " *** byte3 " + QString::number(spwPacket[3], 16)); + return 0; } return 0; } -void StarDundee::receivePollingLoop() +unsigned int StarDundee::storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) { - timer->blockSignals(true); - if (USBSpaceWire_WaitOnReadPacketAvailable(hDevice, 0)) receiveSPWPacket(0); - timer->blockSignals(false); + TMPacketToRead *packet; + + packet = new TMPacketToRead(ccsdsPacket, size); + ccsdsPacketStore.append(packet); + + return 1; } -unsigned char StarDundee::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts) +void StarDundee::reTestSPWLink() // SLOT { - U32 routingTableEntry; - // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber - if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) + if (getLinkStatus(linkNumber_SPINBOX->value())) { - emit sendMessage("Could not clear routing table entry " + QString::number(tableEntry)); + emit isOpen(true); + starDundeeStatusQueryDialog->accept(); } - // Build the routing table entry - CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, - dwOutputPorts, // route out of port dwOutputPorts - 0, // header deletion disabled - 0); // priority normal - // Set the routing table entry for logical address tableEntry - if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) - { - emit sendMessage("Could not set routing table entry [" + QString::number(tableEntry) + "]"); - } - else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] set" ); - } diff --git a/rmapplugin/stardundee.h b/rmapplugin/stardundee.h --- a/rmapplugin/stardundee.h +++ b/rmapplugin/stardundee.h @@ -13,9 +13,12 @@ #include "rmapoperations.h" #include "spw_usb_api.h" #include "spw_config_library.h" +#include "ccsds.h" +#include "tmpackettoread.h" #define BWAIT_0 0 #define BWAIT_1 1 +#define PATH_ADDRESSING_OFFSET 1 class StarDundee : public QWidget { @@ -27,23 +30,28 @@ public: unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); + unsigned int storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); + QList ccsdsPacketStore; + signals: void sendMessage(QString message); void isOpen(bool); void RMAP_write_reply_setText(QString); void appendToLog(QString); void ccsdsPacketAvailable(unsigned char*, unsigned int); + void packetStoreNotEmpty(); public slots: void Open(); void Close(); - int receiveSPWPacket(unsigned char requestID); + void reTestSPWLink(); + int receiveSPWPacketLoop(unsigned char requestID=0); + int receiveSPWPacket(unsigned char requestID=0); void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} + void sourceHasChanged(int source) {rmapSourceLogicalAddress = (unsigned char) source;} void ccsdsPacketIsProcessed() {ccsdsPacketSEMAPHORE->tryAcquire();} - void reTestSPWLink() {getLinkStatus(linkNumber_SPINBOX->value());} // - void sourceHasChanged(int target) {rmapSourceLogicalAddress = (unsigned char) target;} void receivePollingLoop(); private: @@ -54,7 +62,7 @@ private: unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts); unsigned int getLinkStatus(unsigned char link); - unsigned int GetRoutingTableEntry(); + unsigned int GetRoutingTableEntry(int tableEntry); unsigned char rmapTargetLogicalAddress ; unsigned char rmapSourceLogicalAddress ; @@ -63,12 +71,10 @@ private: QLabel *usbDeviceNumber_LABEL; QLabel *linkNumber_LABEL; - QLabel *sourceLogicalAddress_LABEL; QLabel *starDundeeStatusQueryDialogLabel; QSpinBox *usbDeviceNumber_SPINBOX; QSpinBox *linkNumber_SPINBOX; - QSpinBox *sourceLogicalAddress_SPINBOX; QGridLayout *connection_LAYOUT; QGridLayout *starDundeeStatusQueryDialogLayout; @@ -80,8 +86,9 @@ private: QTimer *timer; - unsigned char pBuffer[10]; // Pointer to the start of the user buffer from which to transmit data - USB_SPACEWIRE_ID pIdentifier; // A pointer to a variable which will be set to contain a unique identifier for the send + unsigned char pBuffer[10]; // Pointer to the start of the user buffer from which to transmit data + USB_SPACEWIRE_ID pIdentifierRead; // A pointer to a variable which will be set to contain a unique identifier for the read + USB_SPACEWIRE_ID pIdentifier; star_device_handle hDevice; // Handle to the SpaceWire device USB_SPACEWIRE_STATUS result; // The result of the send operation