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/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 09:02:30 2012 +# Generated by qmake (2.01a) (Qt 4.8.3) on: Mon Dec 10 16:03:39 2012 # Project: rmapplugin.pro # Template: lib # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile rmapplugin.pro @@ -47,7 +47,6 @@ SOURCES = rmapplugin.cpp \ rmappluginui.cpp \ rmapoperations.cpp \ ccsds.cpp \ - spwpacketreceiver.cpp \ ../common_PLE/qipdialogbox.cpp \ ../common_PLE/gresbstatusenquiry.cpp \ spectralmatricesdmasimulator.cpp \ @@ -57,7 +56,6 @@ SOURCES = rmapplugin.cpp \ bridge.cpp \ /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp moc/moc_rmappluginui.cpp \ moc/moc_rmapplugin.cpp \ - moc/moc_spwpacketreceiver.cpp \ moc/moc_qipdialogbox.cpp \ moc/moc_gresbstatusenquiry.cpp \ moc/moc_spectralmatricesdmasimulator.cpp \ @@ -71,7 +69,6 @@ OBJECTS = obj/rmapplugin.o \ obj/rmappluginui.o \ obj/rmapoperations.o \ obj/ccsds.o \ - obj/spwpacketreceiver.o \ obj/qipdialogbox.o \ obj/gresbstatusenquiry.o \ obj/spectralmatricesdmasimulator.o \ @@ -82,7 +79,6 @@ OBJECTS = obj/rmapplugin.o \ obj/lppmonplugininterface.o \ obj/moc_rmappluginui.o \ obj/moc_rmapplugin.o \ - obj/moc_spwpacketreceiver.o \ obj/moc_qipdialogbox.o \ obj/moc_gresbstatusenquiry.o \ obj/moc_spectralmatricesdmasimulator.o \ @@ -237,7 +233,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 spwpacketreceiver.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 spwpacketreceiver.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 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 clean:compiler_clean @@ -259,14 +255,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_spwpacketreceiver.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_bridge.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_spwpacketreceiver.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_bridge.cpp moc/moc_genericPySysdriver.cpp moc/moc_lppmonplugin.cpp moc/moc_rmappluginui.cpp: rmapoperations.h \ spectralmatricesdmasimulator.h \ stardundee.h \ gresb.h \ - spwpacketreceiver.h \ rmappluginui.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmappluginui.h -o moc/moc_rmappluginui.cpp @@ -275,14 +270,10 @@ moc/moc_rmapplugin.cpp: rmappluginui.h \ spectralmatricesdmasimulator.h \ stardundee.h \ gresb.h \ - spwpacketreceiver.h \ ccsds.h \ rmapplugin.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmapplugin.h -o moc/moc_rmapplugin.cpp -moc/moc_spwpacketreceiver.cpp: spwpacketreceiver.h - /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) spwpacketreceiver.h -o moc/moc_spwpacketreceiver.cpp - moc/moc_qipdialogbox.cpp: ../common_PLE/qipdialogbox.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) ../common_PLE/qipdialogbox.h -o moc/moc_qipdialogbox.cpp @@ -299,12 +290,12 @@ moc/moc_stardundee.cpp: rmapoperations.h stardundee.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) stardundee.h -o moc/moc_stardundee.cpp -moc/moc_gresb.cpp: spwpacketreceiver.h \ - rmapoperations.h \ +moc/moc_gresb.cpp: rmapoperations.h \ gresb.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) gresb.h -o moc/moc_gresb.cpp -moc/moc_bridge.cpp: bridge.h +moc/moc_bridge.cpp: rmapoperations.h \ + bridge.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) bridge.h -o moc/moc_bridge.cpp moc/moc_genericPySysdriver.cpp: /usr/include/genericPySysdriver.h @@ -338,7 +329,6 @@ obj/rmapplugin.o: rmapplugin.cpp rmapplu spectralmatricesdmasimulator.h \ stardundee.h \ gresb.h \ - spwpacketreceiver.h \ ccsds.h \ rmappluginpythonwrapper.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmapplugin.o rmapplugin.cpp @@ -349,7 +339,6 @@ obj/rmappluginui.o: rmappluginui.cpp rma spectralmatricesdmasimulator.h \ stardundee.h \ gresb.h \ - spwpacketreceiver.h \ ccsds.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmappluginui.o rmappluginui.cpp @@ -359,10 +348,6 @@ obj/rmapoperations.o: rmapoperations.cpp obj/ccsds.o: ccsds.cpp ccsds.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/ccsds.o ccsds.cpp -obj/spwpacketreceiver.o: spwpacketreceiver.cpp spwpacketreceiver.h \ - rmapoperations.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/spwpacketreceiver.o spwpacketreceiver.cpp - obj/qipdialogbox.o: ../common_PLE/qipdialogbox.cpp ../common_PLE/qipdialogbox.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/qipdialogbox.o ../common_PLE/qipdialogbox.cpp @@ -380,11 +365,11 @@ obj/stardundee.o: stardundee.cpp stardun $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/stardundee.o stardundee.cpp obj/gresb.o: gresb.cpp gresb.h \ - spwpacketreceiver.h \ rmapoperations.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/gresb.o gresb.cpp -obj/bridge.o: bridge.cpp bridge.h +obj/bridge.o: bridge.cpp bridge.h \ + rmapoperations.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/bridge.o bridge.cpp obj/lppmonplugininterface.o: /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp /usr/include/lppmon/pluginsInterface/lppmonplugininterface.h \ @@ -397,9 +382,6 @@ obj/moc_rmappluginui.o: moc/moc_rmapplug obj/moc_rmapplugin.o: moc/moc_rmapplugin.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_rmapplugin.o moc/moc_rmapplugin.cpp -obj/moc_spwpacketreceiver.o: moc/moc_spwpacketreceiver.cpp - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_spwpacketreceiver.o moc/moc_spwpacketreceiver.cpp - obj/moc_qipdialogbox.o: moc/moc_qipdialogbox.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_qipdialogbox.o moc/moc_qipdialogbox.cpp diff --git a/rmapplugin/gresb.cpp b/rmapplugin/gresb.cpp --- a/rmapplugin/gresb.cpp +++ b/rmapplugin/gresb.cpp @@ -78,11 +78,9 @@ gresb::gresb(QWidget *parent) : connect(RMAPReceive_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPReceiveConnectionState(QAbstractSocket::SocketState))); connect(GRESBStatusQuery_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(GRESBConnectionState(QAbstractSocket::SocketState))); 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(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); - connect(this->RMAPReceive_SOCKET, SIGNAL(readyRead()), this, SLOT(receiveSPWPacket())); } gresb::~gresb() @@ -196,7 +194,7 @@ unsigned int gresb::Read(unsigned int *V remainingCount = remainingCount - READ_WRITE_MAX_COUNTS; address = address + READ_WRITE_MAX_COUNTS * 4; iOffset = iOffset + READ_WRITE_MAX_COUNTS; - acquireRMAPSemaphore(); + rmapPacketSEMAPHORE->acquire(); } if (remainingCount > 0) @@ -218,7 +216,7 @@ unsigned int gresb::Read(unsigned int *V Value[i+iOffset]= ((unsigned char)(rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256; } } - acquireRMAPSemaphore(); + rmapPacketSEMAPHORE->acquire(); } emit appendToLog(QString("*** STOP *** READ ")); @@ -400,7 +398,7 @@ unsigned int gresb::ReadBLOCK(unsigned i emit appendToLog("WARNING === in function READ of rmapplugin *** number of data received (" +QString::number(dataLength) +") not equal to number of data requested (" - +QString::number(READ_WRITE_MAX_COUNTS*4) + +QString::number(nbBytes) +")"); return 0; } @@ -488,7 +486,6 @@ int gresb::receiveSPWPacket(unsigned cha RMAPReceive_SOCKET->read( (char*) &packetLength1, 1); RMAPReceive_SOCKET->read( (char*) &packetLength0, 1); packetLength = (packetLength2<<16) + (packetLength1<<8) + (packetLength0); - spwPacket = (char*) malloc(packetLength); // READ THE SPW PACKET while(RMAPReceive_SOCKET->bytesAvailable() < packetLength) @@ -498,6 +495,7 @@ int gresb::receiveSPWPacket(unsigned cha } RMAPReceive_SOCKET->read( spwPacket, packetLength ); RMAPReceive_SOCKET->blockSignals(0); + //emit sendMessage("Packet of size " + QString::number(packetLength) + " received"); switch(spwPacket[1]) // byte 1 is the protocole identifier in the SPW packet { @@ -506,7 +504,7 @@ int gresb::receiveSPWPacket(unsigned cha for(unsigned int i=0; irelease(); - //emit sendMessage("RMAP packet of size " + QString::number(packetLength) + " received"); + emit sendMessage("RMAP packet of size " + QString::number(packetLength) + " received"); return packetLength; case 2: // 0x02 is the protocole identifier for CCSDS packets @@ -515,6 +513,7 @@ int gresb::receiveSPWPacket(unsigned cha ccsdsPacketSize = packetLength; ccsdsPacketSEMAPHORE->release(); emit(ccsdsPacketAvailable(ccsdsPacket, packetLength)); + //emit sendMessage("CCSDS packet of size " + QString::number(packetLength) + " received"); return packetLength; } return 0; @@ -663,38 +662,6 @@ int gresb::GRESBStatusQueryRequest(Gresb return 0; } -void gresb::processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) // SLOT -{ - QString message; - unsigned int fine_time_value = 0; - fine_time_value = ((unsigned int) ccsdsPacket[7]<<24) - + ((unsigned int) ccsdsPacket[6]<<16) - + ((unsigned int) ccsdsPacket[5]<<8) - + ((unsigned int) ccsdsPacket[4]); - message.append(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": "); - message.append("size " - + QString::number(size) - +" *** header " - + QString::number(ccsdsPacket[0], 16) - + " " - + QString::number(ccsdsPacket[1], 16) - + " " - + QString::number(ccsdsPacket[2], 16) - + " " - + QString::number(ccsdsPacket[3], 16) - + " *** coarse time " - + QString::number(fine_time_value)); - //+ QString::number(ccsdsPacket[4], 16) - //+" " - //+ QString::number(ccsdsPacket[5], 16) - //+" " - //+ QString::number(ccsdsPacket[6], 16) - //+" " - //+ QString::number(ccsdsPacket[7], 16)); - ccsdsPacketSEMAPHORE->acquire(); - emit sendMessage(message); -} - void gresb::reTestSPWLink() // SLOT { if (GRESBStatusQueryRequest(LinkStatus, spwLinkSpinBox->value()) == 0) diff --git a/rmapplugin/gresb.h b/rmapplugin/gresb.h --- a/rmapplugin/gresb.h +++ b/rmapplugin/gresb.h @@ -11,7 +11,6 @@ #include #include "gresbstatusenquiry.h" -#include "spwpacketreceiver.h" #include "rmapoperations.h" #include "qipdialogbox.h" @@ -36,13 +35,14 @@ public slots: void Open(); void Close(); int receiveSPWPacket(unsigned char requestID=0); - void processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); + void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} + void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} + void ccsdsPacketIsProcessed() {ccsdsPacketSEMAPHORE->tryAcquire();} void reTestSPWLink(); + // void RMAPSendConnectionState(QAbstractSocket::SocketState socketState); void RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState); void GRESBConnectionState(QAbstractSocket::SocketState socketState); - void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} - void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} private slots: int GRESBStatusQuery(); @@ -50,8 +50,8 @@ private slots: private: unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0); unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0); - void acquireRMAPSemaphore() {rmapPacketSEMAPHORE->acquire();} - void acquireCCSDSSemaphore() {ccsdsPacketSEMAPHORE->acquire();} + void acquireRMAPSemaphore() {rmapPacketSEMAPHORE->tryAcquire();} + void acquireCCSDSSemaphore() {ccsdsPacketSEMAPHORE->tryAcquire();} int GRESBStatusQueryRequest(GresbStatusQueryOption option, char link); unsigned char rmapTargetLogicalAddress ; diff --git a/rmapplugin/rmapplugin.cpp b/rmapplugin/rmapplugin.cpp --- a/rmapplugin/rmapplugin.cpp +++ b/rmapplugin/rmapplugin.cpp @@ -61,12 +61,18 @@ rmapplugin::rmapplugin(QWidget *parent) connect(this->UI->gresbBridge, SIGNAL(isOpen(bool)), this, SLOT(activatePlugin(bool))); connect(this->UI->gresbBridge, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString))); connect(this->UI->gresbBridge, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString))); + connect(this->UI->gresbBridge, SIGNAL(ccsdsPacketAvailable(unsigned char*,uint)), + this, SLOT(processCCSDSPacket(unsigned char*,uint))); + connect(this, SIGNAL(ccsdsPacketIsProcessed()), this->UI->gresbBridge, SLOT(ccsdsPacketIsProcessed())); // Star Dundee connect(this->UI->starDundee, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); connect(this->UI->starDundee, SIGNAL(isOpen(bool)), this, SLOT(activatePlugin(bool))); connect(this->UI->starDundee, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString))); connect(this->UI->starDundee, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString))); + 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, SIGNAL(bridgeHasChanged(selectedBridge)), this, SLOT(bridgeHasChanged(selectedBridge))); } @@ -276,11 +282,35 @@ void rmapplugin::appendToLog(QString tex ///////////////////// // INTERNAL FUNCTIONS -void rmapplugin::gresbSelection(bool flag) +void rmapplugin::processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) // SLOT { - if (flag == true) UI->selection_GROUPBOX->setEnabled(false); - if (flag == false) UI->selection_GROUPBOX->setEnabled(true); + QString message; + unsigned int fine_time_value = 0; + fine_time_value = ((unsigned int) ccsdsPacket[7]<<24) + + ((unsigned int) ccsdsPacket[6]<<16) + + ((unsigned int) ccsdsPacket[5]<<8) + + ((unsigned int) ccsdsPacket[4]); + message.append(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": "); + message.append("size " + + QString::number(size) + +" *** header " + + QString::number(ccsdsPacket[0], 16) + + " " + + QString::number(ccsdsPacket[1], 16) + + " " + + QString::number(ccsdsPacket[2], 16) + + " " + + QString::number(ccsdsPacket[3], 16) + + " *** coarse time " + + QString::number(fine_time_value)); + //+ QString::number(ccsdsPacket[4], 16) + //+" " + //+ QString::number(ccsdsPacket[5], 16) + //+" " + //+ QString::number(ccsdsPacket[6], 16) + //+" " + //+ QString::number(ccsdsPacket[7], 16)); + displayOnConsole(message); + emit ccsdsPacketIsProcessed(); } - - diff --git a/rmapplugin/rmapplugin.h b/rmapplugin/rmapplugin.h --- a/rmapplugin/rmapplugin.h +++ b/rmapplugin/rmapplugin.h @@ -31,7 +31,6 @@ #include #include #include -#include #include @@ -57,13 +56,13 @@ public slots: unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); void openBridge(); void closeBridge(); + void processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); // void sendCCSDS(); void send_TC_LFR_UPDATE_TIME(); void reset_TC_LFR_UPDATE_TIME(); void displayOnConsole(QString message) {this->UI->console->append(message);} // - void gresbSelection(bool flag); void RMAP_write_reply_setText(QString text); void appendToLog(QString text); // @@ -71,6 +70,7 @@ public slots: void bridgeHasChanged(selectedBridge bridge) {currentBridge = bridge;} signals: + void ccsdsPacketIsProcessed(); private: selectedBridge currentBridge; @@ -82,7 +82,6 @@ private: unsigned int rmapPacketSize; unsigned int time_COARSE; unsigned int time_FINE; - spwpacketreceiver* spwPacketReceiverOBJECT; char timeCode; }; diff --git a/rmapplugin/rmapplugin.pro b/rmapplugin/rmapplugin.pro --- a/rmapplugin/rmapplugin.pro +++ b/rmapplugin/rmapplugin.pro @@ -35,7 +35,6 @@ HEADERS += \ rmapplugin.h \ rmapoperations.h \ ccsds.h \ - spwpacketreceiver.h \ ../common_PLE/qipdialogbox.h \ ../common_PLE/gresbstatusenquiry.h \ spectralmatricesdmasimulator.h \ @@ -52,7 +51,6 @@ SOURCES += \ rmappluginui.cpp \ rmapoperations.cpp \ ccsds.cpp \ - spwpacketreceiver.cpp \ ../common_PLE/qipdialogbox.cpp \ ../common_PLE/gresbstatusenquiry.cpp \ spectralmatricesdmasimulator.cpp \ diff --git a/rmapplugin/rmappluginui.cpp b/rmapplugin/rmappluginui.cpp --- a/rmapplugin/rmappluginui.cpp +++ b/rmapplugin/rmappluginui.cpp @@ -160,8 +160,8 @@ rmapPluginUI::rmapPluginUI(QWidget *pare mainLayout->addWidget(spwTabWidget); setLayout(mainLayout); - //connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); connect(this->clearConsoleButton, SIGNAL(clicked()), this->console, SLOT(clear())); + // briges connect(this->selectGRESB_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee())); connect(this->selectStarDundee_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee())); diff --git a/rmapplugin/stardundee.cpp b/rmapplugin/stardundee.cpp --- a/rmapplugin/stardundee.cpp +++ b/rmapplugin/stardundee.cpp @@ -6,12 +6,15 @@ StarDundee::StarDundee(QWidget *parent) QWidget(parent) { // Packet receiver + timer = new QTimer; rmapPacketSEMAPHORE = new QSemaphore; ccsdsPacketSEMAPHORE = new QSemaphore; rmapPacket = (char*) malloc(RMAP_MAX_PACKET_LENGTH); ccsdsPacket = (unsigned char*) malloc(CCSDS_MAX_PACKET_LENGTH); spwPacket = (char*) malloc( qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH) ); + starDundeeStatusQueryDialog = new QDialog; + commandCode = invalid0; // initialization of the cmmand code for the RMAP transfers rmapSourceLogicalAddress = 0x20; @@ -20,6 +23,11 @@ StarDundee::StarDundee(QWidget *parent) 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 ***// + starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); + starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); usbDeviceNumber_SPINBOX = new QSpinBox; usbDeviceNumber_SPINBOX->setRange(0,32); @@ -31,6 +39,13 @@ StarDundee::StarDundee(QWidget *parent) sourceLogicalAddress_SPINBOX->setRange(0,254); sourceLogicalAddress_SPINBOX->setValue(32); + // STAR DUNDEE STATUS QUERY DIALOG + starDundeeStatusQueryDialogLayout = new QGridLayout; + starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); + starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 0, 0); + starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 1, 0); + starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); + connection_LAYOUT->addWidget(usbDeviceNumber_LABEL, 0, 0, 1, 1); connection_LAYOUT->addWidget(usbDeviceNumber_SPINBOX, 0, 1, 1, 1); connection_LAYOUT->addWidget(linkNumber_LABEL, 1, 0, 1, 1); @@ -44,6 +59,12 @@ StarDundee::StarDundee(QWidget *parent) 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() @@ -58,8 +79,6 @@ void StarDundee::Open() { int status; U32 statusControl; - U32 routingTableEntry; - int tableEntry; if (!USBSpaceWire_Open(&hDevice, usbDeviceNumber_SPINBOX->value())) // Open the USB device { @@ -110,44 +129,9 @@ void StarDundee::Open() else emit sendMessage("Set the link status control for link " + QString::number(linkNumber_SPINBOX->value())); } - // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET 254 <=> 0xfe - tableEntry = rmapTargetLogicalAddress; - if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) - { - emit sendMessage("Could not clear routing table entry " + QString::number(tableEntry)); - } - else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] cleared"); - // Build the routing table entry to route out of port 1 with header deletion disabled and priority normal - CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, - (1<value()), // 0x02 = 0000 0010 - 0, - 0); - // 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" ); - - // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET 32 <=> 0x20 - tableEntry = sourceLogicalAddress_SPINBOX->value(); - if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) - { - emit sendMessage("Could not clear routing table entry " + QString::number(tableEntry)); - } - else emit sendMessage("Routing table entry [" + QString::number(tableEntry) + "] cleared"); - - // Build the routing table entry to route out of port 3 with header deletion disabled and priority normal - CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, - (1<<3), // 0x02 = 0000 0010 - 0, - 0); - // 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" ); + setRoutingTableEntry(rmapTargetLogicalAddress, (1<value())); + setRoutingTableEntry(sourceLogicalAddress_SPINBOX->value(), (1<<3)); + //setRoutingTableEntry(33, (1<<3)); emit sendMessage("The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); @@ -158,7 +142,14 @@ void StarDundee::Open() while (rmapPacketSEMAPHORE->available()!=0) rmapPacketSEMAPHORE->acquire(); while (ccsdsPacketSEMAPHORE->available()!=0) ccsdsPacketSEMAPHORE->acquire(); - emit isOpen(true); + if (getLinkStatus(linkNumber_SPINBOX->value())) + { + emit isOpen(true); + } + else + { + + } } void StarDundee::Close() @@ -669,7 +660,10 @@ int StarDundee::receiveSPWPacket(unsigne if (requestID==1) { - if (rmapPacketSEMAPHORE->available()) return rmapPacketSize; + if (rmapPacketSEMAPHORE->available()) + { + return rmapPacketSize; + } } //******************** @@ -677,13 +671,16 @@ int StarDundee::receiveSPWPacket(unsigne nbBytes = qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH); // maximum size of the packet to receive nPacketNum = 1; result = USBSpaceWire_ReadPackets(hDevice, spwPacket, nbBytes, nPacketNum, BWAIT_1, &properties, &pIdentifier); - if (result != TRANSFER_SUCCESS) emit sendMessage("Error: Could not receive the packet"); + if (result != TRANSFER_SUCCESS) + { + emit sendMessage("Error: Could not receive the packet"); + return 0; + } else { - emit sendMessage("A packet of length " + QString::number(properties.len) + " has been successfully received"); + packetLength = properties.len; USBSpaceWire_FreeRead(hDevice, pIdentifier); // Free the receive } - packetLength = properties.len; switch(spwPacket[1]) // byte 1 is the protocole identifier in the SPW packet { @@ -692,7 +689,7 @@ int StarDundee::receiveSPWPacket(unsigne for(unsigned int i=0; irelease(); - emit sendMessage("RMAP packet of size " + QString::number(packetLength) + " received"); + emit appendToLog("RMAP packet of size " + QString::number(packetLength) + " received"); return packetLength; case 2: // 0x02 is the protocole identifier for CCSDS packets @@ -700,10 +697,38 @@ int StarDundee::receiveSPWPacket(unsigne for(unsigned int i=0; irelease(); + emit appendToLog("CCSDS packet of size " + QString::number(packetLength) + " received"); emit(ccsdsPacketAvailable(ccsdsPacket, packetLength)); return packetLength; } return 0; } +void StarDundee::receivePollingLoop() +{ + timer->blockSignals(true); + if (USBSpaceWire_WaitOnReadPacketAvailable(hDevice, 0)) receiveSPWPacket(0); + timer->blockSignals(false); +} +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" ); + +} diff --git a/rmapplugin/stardundee.h b/rmapplugin/stardundee.h --- a/rmapplugin/stardundee.h +++ b/rmapplugin/stardundee.h @@ -2,14 +2,17 @@ #define STARDUNDEE_H #include -#include "spw_usb_api.h" -#include "spw_config_library.h" #include #include #include #include #include +#include +#include + #include "rmapoperations.h" +#include "spw_usb_api.h" +#include "spw_config_library.h" #define BWAIT_0 0 #define BWAIT_1 1 @@ -37,13 +40,18 @@ public slots: int receiveSPWPacket(unsigned char requestID); void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} + void ccsdsPacketIsProcessed() {ccsdsPacketSEMAPHORE->tryAcquire();} + void reTestSPWLink() {getLinkStatus(linkNumber_SPINBOX->value());} + // void sourceHasChanged(int target) {rmapSourceLogicalAddress = (unsigned char) target;} + void receivePollingLoop(); private: unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0); unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0); - void acquireRMAPSemaphore() {rmapPacketSEMAPHORE->acquire();} - void acquireCCSDSSemaphore() {ccsdsPacketSEMAPHORE->acquire();} + void acquireRMAPSemaphore() {rmapPacketSEMAPHORE->tryAcquire();} + void acquireCCSDSSemaphore() {ccsdsPacketSEMAPHORE->tryAcquire();} + unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts); unsigned int getLinkStatus(unsigned char link); unsigned int GetRoutingTableEntry(); @@ -56,12 +64,21 @@ 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; + + QDialog *starDundeeStatusQueryDialog; + + QPushButton *starDundeeStatusQueryRetryButton; + QPushButton *starDundeeStatusQueryAbortButton; + + 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