# HG changeset patch # User Paul LEROY # Date 2013-03-21 09:03:52 # Node ID 0c9852fa341b15a2ab30cbad06e5eced8c5d4941 # Parent 74729fe4997935879d08505ccee74eca8b1bbee6 Plugin modified to allow the launch of interactiv tests from the python interpreter the signal processPacketStoreNowSig is sent by the SLOT processPacketStoreLater(unsigned int delay) the SLOT WriteSPWDelay(QList dataList, unsigned int delay) allows the storage of a TC for a sending after "delay" ms 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.3) on: Mon Dec 10 09:02:30 2012 +# Generated by qmake (2.01a) (Qt 4.8.4) on: Tue Mar 5 08:11:23 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 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 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.3) on: Mon Dec 10 16:03:39 2012 +# Generated by qmake (2.01a) (Qt 4.8.4) on: Tue Mar 19 07:43:19 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_TRANSLATION_PATH="\"/etc/lppmon/translations\"" -DLPPMONPLUGIN_LIBRARY -DQT_NO_DEBUG -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 -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 -I. -I../common_PLE -I../spw_usb_driver_v2.61/inc -I/usr/include/lppmon/pluginsInterface -I/usr/include/PythonQt -Imoc +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 -lQtGui -lQtNetwork -lQtCore -lpthread +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 AR = ar cqs RANLIB = QMAKE = /usr/bin/qmake-qt4 @@ -53,7 +53,7 @@ SOURCES = rmapplugin.cpp \ rmappluginpythonwrapper.cpp \ stardundee.cpp \ gresb.cpp \ - bridge.cpp \ + tcpackettosend.cpp \ /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp moc/moc_rmappluginui.cpp \ moc/moc_rmapplugin.cpp \ moc/moc_qipdialogbox.cpp \ @@ -62,7 +62,7 @@ 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_genericPySysdriver.cpp \ moc/moc_lppmonplugin.cpp OBJECTS = obj/rmapplugin.o \ @@ -75,7 +75,7 @@ OBJECTS = obj/rmapplugin.o \ obj/rmappluginpythonwrapper.o \ obj/stardundee.o \ obj/gresb.o \ - obj/bridge.o \ + obj/tcpackettosend.o \ obj/lppmonplugininterface.o \ obj/moc_rmappluginui.o \ obj/moc_rmapplugin.o \ @@ -85,7 +85,7 @@ 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_genericPySysdriver.o \ obj/moc_lppmonplugin.o DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ @@ -195,8 +195,9 @@ Makefile: rmapplugin.pro /usr/lib64/qt4 /usr/lib64/qt4/mkspecs/features/yacc.prf \ /usr/lib64/qt4/mkspecs/features/lex.prf \ /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib64/libQtXml.prl \ + /usr/lib64/libQtCore.prl \ /usr/lib64/libQtGui.prl \ - /usr/lib64/libQtCore.prl \ /usr/lib64/libQtNetwork.prl $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile rmapplugin.pro /usr/lib64/qt4/mkspecs/common/unix.conf: @@ -225,15 +226,16 @@ Makefile: rmapplugin.pro /usr/lib64/qt4 /usr/lib64/qt4/mkspecs/features/yacc.prf: /usr/lib64/qt4/mkspecs/features/lex.prf: /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib64/libQtXml.prl: +/usr/lib64/libQtCore.prl: /usr/lib64/libQtGui.prl: -/usr/lib64/libQtCore.prl: /usr/lib64/libQtNetwork.prl: qmake: FORCE @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile rmapplugin.pro 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 /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 tcpackettosend.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 @@ -255,12 +257,13 @@ 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 moc/moc_genericPySysdriver.cpp moc/moc_lppmonplugin.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_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 moc/moc_genericPySysdriver.cpp moc/moc_lppmonplugin.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_genericPySysdriver.cpp moc/moc_lppmonplugin.cpp moc/moc_rmappluginui.cpp: rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ + ccsds.h \ gresb.h \ rmappluginui.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmappluginui.h -o moc/moc_rmappluginui.cpp @@ -269,8 +272,8 @@ moc/moc_rmapplugin.cpp: rmappluginui.h \ rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ + ccsds.h \ gresb.h \ - ccsds.h \ rmapplugin.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmapplugin.h -o moc/moc_rmapplugin.cpp @@ -283,20 +286,23 @@ 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 \ + rmappluginpythonwrapper.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmappluginpythonwrapper.h -o moc/moc_rmappluginpythonwrapper.cpp moc/moc_stardundee.cpp: rmapoperations.h \ + ccsds.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 \ 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_genericPySysdriver.cpp: /usr/include/genericPySysdriver.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) /usr/include/genericPySysdriver.h -o moc/moc_genericPySysdriver.cpp @@ -328,8 +334,8 @@ obj/rmapplugin.o: rmapplugin.cpp rmapplu rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ + ccsds.h \ gresb.h \ - ccsds.h \ rmappluginpythonwrapper.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmapplugin.o rmapplugin.cpp @@ -338,8 +344,8 @@ obj/rmappluginui.o: rmappluginui.cpp rma rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ - gresb.h \ - ccsds.h + ccsds.h \ + gresb.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmappluginui.o rmappluginui.cpp obj/rmapoperations.o: rmapoperations.cpp rmapoperations.h @@ -357,20 +363,24 @@ 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 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmappluginpythonwrapper.o rmappluginpythonwrapper.cpp obj/stardundee.o: stardundee.cpp stardundee.h \ - rmapoperations.h + rmapoperations.h \ + ccsds.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/stardundee.o stardundee.cpp obj/gresb.o: gresb.cpp gresb.h \ - rmapoperations.h + rmapoperations.h \ + ccsds.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/lppmonplugininterface.o: /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp /usr/include/lppmon/pluginsInterface/lppmonplugininterface.h \ /usr/include/lppmon/pluginsInterface/lppmonplugininterface_global.h @@ -400,8 +410,8 @@ 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_genericPySysdriver.o: moc/moc_genericPySysdriver.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_genericPySysdriver.o moc/moc_genericPySysdriver.cpp 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,51 @@ 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)); + //ccsdsPacketSEMAPHORE->release(); + //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) +{ + unsigned int i; + ccsdsPacketToProcess_t ccsdsPacketToStore; + + ccsdsPacketToStore.size = size; + for(i=0; iconnectToHost( 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 +573,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 +795,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,7 @@ #include "gresbstatusenquiry.h" #include "rmapoperations.h" #include "qipdialogbox.h" +#include "ccsds.h" class gresb : public QWidget { @@ -23,6 +24,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 +34,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 +75,6 @@ private: QLabel *gresbBridgeIPLabel; QLabel *gresbVirtualLinkLabel; QLabel *spwLinkLabel; - QLabel *rmapSourceLogicalAddressLabel; QLabel *rmapSendStateLabel; QLabel *rmapReceiveStateLabel; QLabel *gresbStatusQueryLabel; @@ -77,7 +86,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,35 @@ 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)) ); + //************** + + //************** + // 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 +90,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 +105,31 @@ 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))); + } 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 +327,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 +369,22 @@ void rmapplugin::processCCSDSPacket(unsi //+" " //+ QString::number(ccsdsPacket[7], 16)); displayOnConsole(message); + ((rmappluginPythonWrapper*)this->pyObject)->storeCCSDSPacket(ccsdsPacket, size); emit ccsdsPacketIsProcessed(); } +void rmapplugin::processPacketStore() +{ + switch(currentBridge) + { + case selectedBridgeIsGRESB : + ((rmappluginPythonWrapper*)this->pyObject)->ccsdsPacketStore = &(this->UI->gresbBridge->ccsdsPacketStore); + break; + case selectedBridgeIsStarDundee : + ((rmappluginPythonWrapper*)this->pyObject)->ccsdsPacketStore = &(this->UI->starDundee->ccsdsPacketStore); + break; + default: + break; + } + ((rmappluginPythonWrapper*)this->pyObject)->processPacketStore(); +} diff --git a/rmapplugin/rmapplugin.h b/rmapplugin/rmapplugin.h --- a/rmapplugin/rmapplugin.h +++ b/rmapplugin/rmapplugin.h @@ -54,9 +54,12 @@ 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 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 @@ -43,7 +43,7 @@ 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 SOURCES += \ @@ -57,7 +57,7 @@ SOURCES += \ rmappluginpythonwrapper.cpp \ stardundee.cpp \ gresb.cpp \ - bridge.cpp + tcpackettosend.cpp diff --git a/rmapplugin/rmappluginpythonwrapper.cpp b/rmapplugin/rmappluginpythonwrapper.cpp --- a/rmapplugin/rmappluginpythonwrapper.cpp +++ b/rmapplugin/rmappluginpythonwrapper.cpp @@ -1,12 +1,16 @@ #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::getData() { QList data; @@ -17,3 +21,154 @@ QList rmappluginPythonWrapper: } return data; } + +QList rmappluginPythonWrapper::ReadSPW(unsigned int size) +{ + QList result; + ccsdsPacketToProcess_t ccsdsPacket; + + if (!ccsdsPacketStore->isEmpty()) + { + ccsdsPacket = ccsdsPacketStore->takeFirst(); + for(unsigned int i = 0;i 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; iisActive()) + { + 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()) + { + delay = TCPacketStore.at(0)->delay; + timer->setInterval(delay); + timer->start(); + } +} + +unsigned int rmappluginPythonWrapper::storeCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) +{ + unsigned int i; + ccsdsPacketToProcess_t 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); + ProcessPendingEvents(); + } +} + +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,50 @@ #include #include #include +#include "rmapoperations.h" +#include "ccsds.h" +#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); public slots: QList getData(); + + QList ReadSPW(unsigned int size); + 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(); }; diff --git a/rmapplugin/rmappluginui.cpp b/rmapplugin/rmappluginui.cpp --- a/rmapplugin/rmappluginui.cpp +++ b/rmapplugin/rmappluginui.cpp @@ -81,18 +81,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 +112,15 @@ 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()); @@ -168,8 +170,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 +184,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; @@ -101,8 +101,8 @@ public: QTextEdit* console; + // SPACEWIRE BRIDGES StarDundee *starDundee; - gresb *gresbBridge; bool islogfileenable(); @@ -124,6 +124,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,17 @@ 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 + timer->start(100); // starts the periodical timer, period = 100ms } StarDundee::~StarDundee() @@ -82,14 +76,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 +123,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(); @@ -148,7 +154,7 @@ void StarDundee::Open() } 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; } -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); + unsigned int i; + ccsdsPacketToProcess_t ccsdsPacketToStore; + + ccsdsPacketToStore.size = size; + for(i=0; ivalue())) { - 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,11 @@ #include "rmapoperations.h" #include "spw_usb_api.h" #include "spw_config_library.h" +#include "ccsds.h" #define BWAIT_0 0 #define BWAIT_1 1 +#define PATH_ADDRESSING_OFFSET 1 class StarDundee : public QWidget { @@ -27,23 +29,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 +61,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 +70,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 +85,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