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: Thu Nov 29 09:03:10 2012 +# Generated by qmake (2.01a) (Qt 4.8.3) on: Thu Nov 29 14:02:20 2012 # 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/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: Thu Nov 29 09:38:20 2012 +# Generated by qmake (2.01a) (Qt 4.8.3) on: Mon Dec 3 13:45:43 2012 # Project: rmapplugin.pro # Template: lib # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile rmapplugin.pro @@ -16,7 +16,7 @@ CXXFLAGS = -pipe -O2 -g -pipe -Wall 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 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/libSpaceWireUSBAPI.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 -lQtGui -lQtNetwork -lQtCore -lpthread AR = ar cqs RANLIB = QMAKE = /usr/bin/qmake-qt4 @@ -53,6 +53,7 @@ SOURCES = rmapplugin.cpp \ spectralmatricesdmasimulator.cpp \ rmappluginpythonwrapper.cpp \ stardundee.cpp \ + gresb.cpp \ /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp moc/moc_rmappluginui.cpp \ moc/moc_rmapplugin.cpp \ moc/moc_spwpacketreceiver.cpp \ @@ -61,6 +62,7 @@ SOURCES = rmapplugin.cpp \ moc/moc_spectralmatricesdmasimulator.cpp \ moc/moc_rmappluginpythonwrapper.cpp \ moc/moc_stardundee.cpp \ + moc/moc_gresb.cpp \ moc/moc_genericPySysdriver.cpp \ moc/moc_lppmonplugin.cpp OBJECTS = obj/rmapplugin.o \ @@ -73,6 +75,7 @@ OBJECTS = obj/rmapplugin.o \ obj/spectralmatricesdmasimulator.o \ obj/rmappluginpythonwrapper.o \ obj/stardundee.o \ + obj/gresb.o \ obj/lppmonplugininterface.o \ obj/moc_rmappluginui.o \ obj/moc_rmapplugin.o \ @@ -82,6 +85,7 @@ OBJECTS = obj/rmapplugin.o \ obj/moc_spectralmatricesdmasimulator.o \ obj/moc_rmappluginpythonwrapper.o \ obj/moc_stardundee.o \ + obj/moc_gresb.o \ obj/moc_genericPySysdriver.o \ obj/moc_lppmonplugin.o DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ @@ -229,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 /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 /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 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 /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 /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 @@ -251,17 +255,19 @@ 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_genericPySysdriver.cpp moc/moc_lppmonplugin.cpp +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_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_genericPySysdriver.cpp moc/moc_lppmonplugin.cpp + -$(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_genericPySysdriver.cpp moc/moc_lppmonplugin.cpp moc/moc_rmappluginui.cpp: rmapoperations.h \ spectralmatricesdmasimulator.h \ + stardundee.h \ rmappluginui.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmappluginui.h -o moc/moc_rmappluginui.cpp moc/moc_rmapplugin.cpp: rmappluginui.h \ rmapoperations.h \ spectralmatricesdmasimulator.h \ + stardundee.h \ ccsds.h \ spwpacketreceiver.h \ rmapplugin.h @@ -285,6 +291,9 @@ moc/moc_rmappluginpythonwrapper.cpp: rma moc/moc_stardundee.cpp: stardundee.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) stardundee.h -o moc/moc_stardundee.cpp +moc/moc_gresb.cpp: gresb.h + /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) gresb.h -o moc/moc_gresb.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 @@ -314,6 +323,7 @@ obj/rmapplugin.o: rmapplugin.cpp rmapplu rmappluginui.h \ rmapoperations.h \ spectralmatricesdmasimulator.h \ + stardundee.h \ ccsds.h \ spwpacketreceiver.h \ rmappluginpythonwrapper.h @@ -323,6 +333,7 @@ obj/rmappluginui.o: rmappluginui.cpp rma rmappluginui.h \ rmapoperations.h \ spectralmatricesdmasimulator.h \ + stardundee.h \ ccsds.h \ spwpacketreceiver.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmappluginui.o rmappluginui.cpp @@ -348,9 +359,13 @@ obj/spectralmatricesdmasimulator.o: spec obj/rmappluginpythonwrapper.o: rmappluginpythonwrapper.cpp rmappluginpythonwrapper.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmappluginpythonwrapper.o rmappluginpythonwrapper.cpp -obj/stardundee.o: stardundee.cpp stardundee.h +obj/stardundee.o: stardundee.cpp stardundee.h \ + rmapoperations.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/stardundee.o stardundee.cpp +obj/gresb.o: gresb.cpp gresb.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/gresb.o gresb.cpp + obj/lppmonplugininterface.o: /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp /usr/include/lppmon/pluginsInterface/lppmonplugininterface.h \ /usr/include/lppmon/pluginsInterface/lppmonplugininterface_global.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/lppmonplugininterface.o /usr/include/lppmon/pluginsInterface/lppmonplugininterface.cpp @@ -379,6 +394,9 @@ obj/moc_rmappluginpythonwrapper.o: moc/m obj/moc_stardundee.o: moc/moc_stardundee.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_stardundee.o moc/moc_stardundee.cpp +obj/moc_gresb.o: moc/moc_gresb.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_gresb.o moc/moc_gresb.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/rmapoperations.cpp b/rmapplugin/rmapoperations.cpp --- a/rmapplugin/rmapoperations.cpp +++ b/rmapplugin/rmapoperations.cpp @@ -16,7 +16,7 @@ RMAP::RMAP(RMAP_command_codes commandCod SPWPacketSize = sizeof(RMAPHeader) + nbBytes + 1 ; // SPW Packet = Header + Data + dataCRC dataCRC = RMAPCalculateDataCRC(data, nbBytes); } - GRESBHeader.GRESBProtocoleID = 0x00; // packets with protocole ID 0 have SpaceWire a packet as payload + GRESBHeader.GRESBProtocoleID = 0x00; // packets with protocole ID 0 have a SpaceWire packet as payload GRESBHeader.SPWPacketSize2 = (SPWPacketSize>>16); GRESBHeader.SPWPacketSize1 = (SPWPacketSize>>8); GRESBHeader.SPWPacketSize0 = (SPWPacketSize); diff --git a/rmapplugin/rmapoperations.h b/rmapplugin/rmapoperations.h --- a/rmapplugin/rmapoperations.h +++ b/rmapplugin/rmapoperations.h @@ -3,6 +3,14 @@ #include "qhexspinbox.h" +#define READ_WRITE_MAX_COUNTS 4096 // in words +#define RMAP_MAX_DATA_LENGTH 4*READ_WRITE_MAX_COUNTS // in bytes, shall be lower than the limit size of SPW packet of the GRESB bridge +#define RMAP_READ_REPLY_HEADER_LENGTH 12 // in bytes => ECSS +#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 + static const unsigned char RMAP_CRCTable[] = { 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75, 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b, diff --git a/rmapplugin/rmapplugin.cpp b/rmapplugin/rmapplugin.cpp --- a/rmapplugin/rmapplugin.cpp +++ b/rmapplugin/rmapplugin.cpp @@ -39,6 +39,7 @@ rmapplugin::rmapplugin(QWidget *parent) timeCode = 0; time_COARSE = 0; time_FINE = 0; + currentBridge = selectedBridgeIsUnknown; /*Python wrapper*/ this->pyObject = new rmappluginPythonWrapper(); @@ -46,8 +47,10 @@ rmapplugin::rmapplugin(QWidget *parent) connect(this->pyObject,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); /*==============*/ - connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(RMAP_CONNECT())); - connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(RMAP_DISCONNECT())); + //connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(RMAP_CONNECT())); + //connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(RMAP_DISCONNECT())); + connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(openBridge())); + connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(closeBridge())); connect(RMAPSend_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPSendConnectionState(QAbstractSocket::SocketState))); connect(RMAPReceive_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPReceiveConnectionState(QAbstractSocket::SocketState))); connect(GRESBStatusQuery_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(GRESBConnectionState(QAbstractSocket::SocketState))); @@ -68,6 +71,16 @@ rmapplugin::rmapplugin(QWidget *parent) connect(this->UI->spectralMatricesDMASimulator, SIGNAL(rmapplugginRead(uint*,uint,uint)), this, SLOT(Read(uint*,uint,uint))); connect(this->UI->spectralMatricesDMASimulator, SIGNAL(rmapplugginWrite(uint*,uint,uint)), this, SLOT(Write(uint*,uint,uint))); connect(this->UI->spectralMatricesDMASimulator, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); + + // GRESB + connect(this, SIGNAL(gresbIsOpen(bool)), this, SLOT(gresbSelection(bool))); + + // Star Dundee + connect(this->UI->starDundee, SIGNAL(starDundeeIsOpen(bool)), this, SLOT(activatePluginViaStarDundee(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, SIGNAL(bridgeHasChanged(selectedBridge)), this, SLOT(bridgeHasChanged(selectedBridge))); } rmapplugin::~rmapplugin() @@ -79,20 +92,52 @@ rmapplugin::~rmapplugin() unsigned int rmapplugin::Write(unsigned int *Value, unsigned int count, unsigned int address) { + unsigned int result; + switch(currentBridge) + { + case selectedBridgeIsGRESB : + result = WriteGRESB(Value, count, address); + break; + case selectedBridgeIsStarDundee : + result = this->WriteStarDundee(Value, count, address); + break; + default: + result = 1; + break; + } + return result; +} + +unsigned int rmapplugin::Read(unsigned int *Value, unsigned int count, unsigned int address) +{ + unsigned int result; + switch(currentBridge) + { + case selectedBridgeIsGRESB : + result = ReadGRESB(Value, count, address); + break; + case selectedBridgeIsStarDundee : + result = this->ReadStarDundee(Value, count, address); + break; + default: + result = 1; + break; + } + return result; +} + +unsigned int rmapplugin::WriteGRESB(unsigned int *Value, unsigned int count, unsigned int address) +{ unsigned int remainingCount = count; unsigned int iOffset = 0; QString console_message; char* data; - unsigned char command = 0x08; // initialize command at 0b00001000 for write - if(spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->available()!=0) { APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** RMAP request already running, WRITE access stopped"); return 1; } - if (UI->RMAP_write_verify->isChecked()) command = command + (1<<2); - if (UI->RMAP_write_reply->isChecked()) command = command + (1<<1); UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: unavailable"); @@ -149,7 +194,7 @@ unsigned int rmapplugin::Write(unsigned return count; } -unsigned int rmapplugin::Read(unsigned int *Value, unsigned int count, unsigned int address) +unsigned int rmapplugin::ReadGRESB(unsigned int *Value, unsigned int count, unsigned int address) { unsigned int remainingCount = count; unsigned int iOffset = 0; @@ -214,74 +259,6 @@ unsigned int rmapplugin::Read(unsigned i return count; } -unsigned int rmapplugin::ReadBLOCK(unsigned int nbBytes, unsigned int address) -{ - int errorCode; - RMAP *RMAPCommand; - QTime RMAPTimeout; - unsigned int dataLength; - if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 1) - { - RMAP_DISCONNECT(); - return 1; - } - - if (nbBytes > 4) - { - RMAPCommand = new RMAP(read_Inc, - UI->rmapTargetLogicalAddressSpinBox->value(), - UI->rmapSourceLogicalAddressSpinBox->value(), - address, - nbBytes, - NULL); - } - else - { - RMAPCommand = new RMAP(read_Single, - UI->rmapTargetLogicalAddressSpinBox->value(), - UI->rmapSourceLogicalAddressSpinBox->value(), - address, - nbBytes, - NULL); - } - - // SEND THE GRESB HEADER FOR THE RMAP READ COMMAND - RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->GRESBHeader), 4); - // SEND THE SPACEWIRE PACKET FOR THE RMAP READ COMMAND - RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->RMAPHeader), sizeof(RMAPCommand->RMAPHeader)); - RMAPSend_SOCKET->waitForBytesWritten(100); - RMAPTimeout.start(); - // write timeout - while(RMAPSend_SOCKET->bytesToWrite() > 0) - { - RMAPSend_SOCKET->waitForBytesWritten(100); - if(RMAPTimeout.elapsed()>1000) - { - APPENDTOLOG("WARNING === in function READ of rmapplugin *** sending Read RMAP Command timeout\n"); - return 0; - } - } - - // RECEIVE THE INCOMING RMAP PACKET - errorCode = spwPacketReceiverOBJECT->receiveSPWPacket(1); // request ID 1 is for RMAP packet - if (errorCode<=0) - { - APPENDTOLOG("WARNING === in function ReadBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode)); - return 0; - } - dataLength = spwPacketReceiverOBJECT->rmapPacketSize - RMAP_READ_REPLY_HEADER_LENGTH - RMAP_DATA_CRC_LENGTH; - if(dataLength != nbBytes) - { - 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) - +")"); - return 0; - } - return dataLength; -} - unsigned int rmapplugin::WriteBLOCK(char *data, unsigned int nbBytes, unsigned int address) { QTime RMAPTimeout; @@ -395,6 +372,88 @@ unsigned int rmapplugin::WriteBLOCK(char return nbBytes; } +unsigned int rmapplugin::ReadBLOCK(unsigned int nbBytes, unsigned int address) +{ + int errorCode; + RMAP *RMAPCommand; + QTime RMAPTimeout; + unsigned int dataLength; + if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 1) + { + RMAP_DISCONNECT(); + return 1; + } + + if (nbBytes > 4) + { + RMAPCommand = new RMAP(read_Inc, + UI->rmapTargetLogicalAddressSpinBox->value(), + UI->rmapSourceLogicalAddressSpinBox->value(), + address, + nbBytes, + NULL); + } + else + { + RMAPCommand = new RMAP(read_Single, + UI->rmapTargetLogicalAddressSpinBox->value(), + UI->rmapSourceLogicalAddressSpinBox->value(), + address, + nbBytes, + NULL); + } + + // SEND THE GRESB HEADER FOR THE RMAP READ COMMAND + RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->GRESBHeader), 4); + // SEND THE SPACEWIRE PACKET FOR THE RMAP READ COMMAND + RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->RMAPHeader), sizeof(RMAPCommand->RMAPHeader)); + RMAPSend_SOCKET->waitForBytesWritten(100); + RMAPTimeout.start(); + // write timeout + while(RMAPSend_SOCKET->bytesToWrite() > 0) + { + RMAPSend_SOCKET->waitForBytesWritten(100); + if(RMAPTimeout.elapsed()>1000) + { + APPENDTOLOG("WARNING === in function READ of rmapplugin *** sending Read RMAP Command timeout\n"); + return 0; + } + } + + // RECEIVE THE INCOMING RMAP PACKET + errorCode = spwPacketReceiverOBJECT->receiveSPWPacket(1); // request ID 1 is for RMAP packet + if (errorCode<=0) + { + APPENDTOLOG("WARNING === in function ReadBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode)); + return 0; + } + dataLength = spwPacketReceiverOBJECT->rmapPacketSize - RMAP_READ_REPLY_HEADER_LENGTH - RMAP_DATA_CRC_LENGTH; + if(dataLength != nbBytes) + { + 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) + +")"); + return 0; + } + return dataLength; +} + +unsigned int rmapplugin::WriteStarDundee(unsigned int *Value, unsigned int count, unsigned int address) +{ + unsigned int result; + result = UI->starDundee->WriteStarDundee(Value, count, address); + return result; +} + +unsigned int rmapplugin::ReadStarDundee(unsigned int *Value, unsigned int count, unsigned int address) +{ + unsigned int result; + result = UI->starDundee->ReadStarDundee(Value, count, address); + return result; +} + //////// // SLOTS @@ -549,6 +608,36 @@ void rmapplugin::reset_TC_LFR_UPDATE_TIM time_FINE = 0; } +void rmapplugin::openBridge() +{ + switch(currentBridge) + { + case selectedBridgeIsGRESB : + RMAP_CONNECT(); + break; + case selectedBridgeIsStarDundee : + this->UI->starDundee->OpenStarDundee(); + break; + default: + break; + } +} + +void rmapplugin::closeBridge() +{ + switch(currentBridge) + { + case selectedBridgeIsGRESB : + RMAP_DISCONNECT(); + break; + case selectedBridgeIsStarDundee : + this->UI->starDundee->CloseStarDundee(); + break; + default: + break; + } +} + void rmapplugin::RMAP_CONNECT() // SLOT { bool spwRunning = true; @@ -575,6 +664,7 @@ void rmapplugin::RMAP_CONNECT() // SLOT { APPENDTOLOG(QString("SpaceWire running on virtual link ")+ QString::number(UI->spwLinkSpinBox->value())); emit this->activateSig(true); + emit gresbIsOpen(true); } } @@ -584,6 +674,7 @@ void rmapplugin::RMAP_DISCONNECT() // SL RMAPReceive_SOCKET->disconnectFromHost(); GRESBStatusQuery_SOCKET->disconnectFromHost(); emit this->activateSig(false); + emit gresbIsOpen(false); } void rmapplugin::RMAPSendConnectionState(QAbstractSocket::SocketState socketState) // SLOT @@ -710,6 +801,21 @@ void rmapplugin::displayOnConsole(QStrin this->UI->console->append(message); } +void rmapplugin::activatePluginViaStarDundee(bool flag) +{ + emit activateSig(flag); +} + +void rmapplugin::RMAP_write_reply_setText(QString text) +{ + this->UI->RMAP_write_reply->setText(text); +} + +void rmapplugin::appendToLog(QString text) +{ + APPENDTOLOG(text); +} + ///////////////////// // INTERNAL FUNCTIONS @@ -815,3 +921,16 @@ int rmapplugin::charTab_TO_int(char *cha return result; } +void rmapplugin::gresbSelection(bool flag) +{ + if (flag == true) UI->selection_GROUPBOX->setEnabled(false); + if (flag == false) UI->selection_GROUPBOX->setEnabled(true); +} + +// SLOTS +void rmapplugin::bridgeHasChanged(selectedBridge bridge) +{ + currentBridge = bridge; +} + + diff --git a/rmapplugin/rmapplugin.h b/rmapplugin/rmapplugin.h --- a/rmapplugin/rmapplugin.h +++ b/rmapplugin/rmapplugin.h @@ -52,6 +52,10 @@ public: ~rmapplugin(); int GRESBStatusQueryRequest(GresbStatusQueryOption option, char link); int charTab_TO_int(char *charTab); + unsigned int ReadGRESB(unsigned int *Value,unsigned int count,unsigned int address=0); + unsigned int WriteGRESB(unsigned int *Value,unsigned int count,unsigned int address=0); + unsigned int ReadStarDundee(unsigned int *Value, unsigned int count, unsigned int address=0); + unsigned int WriteStarDundee(unsigned int *Value, unsigned int count, unsigned int address=0); public slots: unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); @@ -66,6 +70,8 @@ public slots: // void RMAP_CONNECT(); void RMAP_DISCONNECT(); + void openBridge(); + void closeBridge(); int RMAPSendReadCommand(); int RMAPSendWriteCommand(); void reTestSPWLink(); @@ -73,11 +79,19 @@ public slots: void RMAPSendConnectionState(QAbstractSocket::SocketState socketState); void RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState); void GRESBConnectionState(QAbstractSocket::SocketState socketState); + // + void gresbSelection(bool flag); + void activatePluginViaStarDundee(bool flag); + void RMAP_write_reply_setText(QString text); + void appendToLog(QString text); + void bridgeHasChanged(selectedBridge bridge); signals: void ccsdsPacketReadyRead(char *ccsdsPacket, unsigned int size); + void gresbIsOpen(bool); private: + selectedBridge currentBridge; rmapPluginUI* UI; QTcpSocket* GRESBStatusQuery_SOCKET; QTcpSocket* RMAPSend_SOCKET; diff --git a/rmapplugin/rmapplugin.pro b/rmapplugin/rmapplugin.pro --- a/rmapplugin/rmapplugin.pro +++ b/rmapplugin/rmapplugin.pro @@ -22,7 +22,8 @@ DEFINES += driver_PID=0 QT += network -LIBS += ../spw_usb_driver_v2.61/lib/libSpaceWireUSBAPI.so +LIBS += ../spw_usb_driver_v2.61/lib/x86_64/libSpaceWireUSBAPI.so \ + ../spw_usb_driver_v2.61/lib/x86_64/libConfigLibraryUSB.so INCLUDEPATH += \ @@ -42,7 +43,9 @@ HEADERS += \ spectralmatricesdmasimulator.h \ rmappluginpythonwrapper.h \ stardundee.h \ - ../spw_usb_driver_v2.61/inc/spw_usb_api.h + ../spw_usb_driver_v2.61/inc/spw_usb_api.h \ + ../spw_usb_driver_v2.61/inc/spw_config_library.h \ + gresb.h SOURCES += \ @@ -55,7 +58,8 @@ SOURCES += \ ../common_PLE/gresbstatusenquiry.cpp \ spectralmatricesdmasimulator.cpp \ rmappluginpythonwrapper.cpp \ - stardundee.cpp + stardundee.cpp \ + gresb.cpp diff --git a/rmapplugin/rmappluginui.cpp b/rmapplugin/rmappluginui.cpp --- a/rmapplugin/rmappluginui.cpp +++ b/rmapplugin/rmappluginui.cpp @@ -32,10 +32,19 @@ rmapPluginUI::rmapPluginUI(QWidget *pare QWidget* spwTabWidgetPage3 = new QWidget; QWidget* spwTabWidgetPage4 = new QWidget; QWidget* spwTabWidgetPage5 = new QWidget; + bridgeWidget = new QWidget; mainLayout = new QVBoxLayout; connectionLayout = new QGridLayout; ccsdsLayout = new QVBoxLayout; consoleLayout = new QVBoxLayout; + selectionLayout = new QVBoxLayout; + bridgeSelection_LAYOUT = new QGridLayout; + generalParameters_LAYOUT = new QGridLayout; + + gresb_GROUPBOX = new QGroupBox(tr("GRESB bridge parameters")); + stardundee_GROUPBOX = new QGroupBox(tr("Star Dundee brick parameters")); + selection_GROUPBOX = new QGroupBox(tr("Bridge selection")); + generalParameters_GROUPBOX = new QGroupBox(tr("General parameters")); //*** QLABEL ***// gresbBridgeIPLabel = new QLabel(tr("GRESB Bridge IP: ")); @@ -53,6 +62,7 @@ rmapPluginUI::rmapPluginUI(QWidget *pare //*** QPUSHBUTTON ***// rmapOpenCommunicationButton = new QPushButton(tr("Open RMAP Communication")); rmapCloseCommunicationButton = new QPushButton(tr("Close RMAP Communication")); + rmapOpenCommunicationButton->setEnabled(false); rmapCloseCommunicationButton->setEnabled(false); logFileChooseButton = new QPushButton(tr("Choose file")); gresbStatusQueryRetryButton = new QPushButton(tr("Retry")); @@ -62,6 +72,9 @@ rmapPluginUI::rmapPluginUI(QWidget *pare reset_TC_LFR_UPDATE_TIME_Button = new QPushButton(tr("reset the TC_LFR_UPDATE_TIME Packet coarse and fine times")); clearConsoleButton = new QPushButton(tr("Clear")); + selectGRESB_BUTTON = new QRadioButton(tr("GRESB")); + selectStarDundee_BUTTON = new QRadioButton(tr("Star Dundee")); + //*** SPINBOX ***// gresbVirtualLinkSpinBox = new QSpinBox; rmapSourceLogicalAddressSpinBox = new QSpinBox; @@ -81,6 +94,7 @@ rmapPluginUI::rmapPluginUI(QWidget *pare //*** MISC **// starDundee = new StarDundee; + gresbBridge = new gresb; console = new QTextEdit; gresbBridgeIPDialogBox = new QIPDialogBox; gresbStatusQueryDialog = new QDialog; @@ -96,24 +110,43 @@ rmapPluginUI::rmapPluginUI(QWidget *pare connectionLayout->addWidget(gresbBridgeIPDialogBox, 0, 1, 0); connectionLayout->addWidget(gresbVirtualLinkLabel, 1, 0, 0); connectionLayout->addWidget(gresbVirtualLinkSpinBox, 1, 1, 0); - connectionLayout->addWidget(rmapSourceLogicalAddressLabel, 2, 0, 0); - connectionLayout->addWidget(rmapSourceLogicalAddressSpinBox, 2, 1, 0); - connectionLayout->addWidget(spwLinkLabel, 3, 0, 0); - connectionLayout->addWidget(spwLinkSpinBox, 3, 1, 0); - connectionLayout->addWidget(rmapTargetLogicalAddressLabel, 4, 0, 0); - connectionLayout->addWidget(rmapTargetLogicalAddressSpinBox, 4, 1, 0); - connectionLayout->addWidget(rmapOpenCommunicationButton, 5, 0, 1, 2); - connectionLayout->addWidget(rmapCloseCommunicationButton, 6, 0, 1, 2); - connectionLayout->addWidget(rmapSendStateLabel, 7, 0, 1, 2); - connectionLayout->addWidget(rmapReceiveStateLabel, 8, 0, 1, 2); - connectionLayout->addWidget(gresbStatusQueryLabel, 9, 0, 1, 2); - connectionLayout->addWidget(logEnableCheckBox, 10, 0, 0); - connectionLayout->addWidget(logFileChooseButton, 10, 1, 0); - connectionLayout->addWidget(RMAP_write_verify, 11, 0, 1, 2); - connectionLayout->addWidget(RMAP_write_reply, 12, 0, 1, 2); + 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->setRowStretch(7, 1); + connectionLayout->setColumnStretch(2, 1); + + bridgeSelection_LAYOUT->addWidget(selectGRESB_BUTTON, 0, 0, 1, 1); + bridgeSelection_LAYOUT->addWidget(selectStarDundee_BUTTON, 0, 1, 1, 1); + bridgeSelection_LAYOUT->setRowStretch(1, 1); + bridgeSelection_LAYOUT->setColumnStretch(2, 1); - connectionLayout->setRowStretch(13, 1); - connectionLayout->setColumnStretch(2, 1); + 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, 2); + generalParameters_LAYOUT->addWidget(rmapCloseCommunicationButton, 3, 0, 1, 2); + 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(connectionLayout); + gresb_GROUPBOX->setVisible(false); + stardundee_GROUPBOX->setLayout(starDundee->layout()); + stardundee_GROUPBOX->setVisible(false); + selection_GROUPBOX->setLayout(bridgeSelection_LAYOUT); + generalParameters_GROUPBOX->setLayout(generalParameters_LAYOUT); + selectionLayout->addWidget(selection_GROUPBOX); + selectionLayout->addWidget(generalParameters_GROUPBOX); + selectionLayout->addWidget(gresb_GROUPBOX); + selectionLayout->addWidget(stardundee_GROUPBOX); ccsdsLayout->addWidget(sendCCSDSCommandButton); ccsdsLayout->addWidget(send_TC_LFR_UPDATE_TIME_Button); @@ -133,13 +166,14 @@ rmapPluginUI::rmapPluginUI(QWidget *pare spwTabWidget->addTab(spwTabWidgetPage2, tr("status")); spwTabWidget->addTab(spwTabWidgetPage3, tr("console")); spwTabWidget->addTab(spwTabWidgetPage4, tr("DMA")); - spwTabWidget->addTab(spwTabWidgetPage5, tr("Star Dundee")); - spwTabWidgetPage0->setLayout(connectionLayout); + spwTabWidget->addTab(spwTabWidgetPage5, tr("gresb")); + + spwTabWidgetPage0->setLayout(selectionLayout); spwTabWidgetPage1->setLayout(ccsdsLayout); spwTabWidgetPage2->setLayout(this->spwLinkStatusEnquiry->mainLayout); spwTabWidgetPage3->setLayout(consoleLayout); spwTabWidgetPage4->setLayout(spectralMatricesDMASimulator->mainLayout); - spwTabWidgetPage5->setLayout(starDundee->layout()); + spwTabWidgetPage5->setLayout(gresbBridge->layout()); mainLayout->addWidget(spwTabWidget); setLayout(mainLayout); @@ -152,6 +186,16 @@ rmapPluginUI::rmapPluginUI(QWidget *pare connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); connect(this->clearConsoleButton, SIGNAL(clicked()), this->console, SLOT(clear())); + connect(this->selectGRESB_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee())); + connect(this->selectStarDundee_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee())); + connect(this->starDundee, SIGNAL(starDundeeIsOpen(bool)), this, SLOT(starDundeeIsOpen(bool))); + + // command code + connect(this->RMAP_write_reply, SIGNAL(clicked()), this, SLOT(getCommandCode())); + connect(this->RMAP_write_verify, SIGNAL(clicked()), this, SLOT(getCommandCode())); + connect(this, SIGNAL(commandCodeHasChanged(RMAP_command_codes)), this->starDundee, SLOT(updateCommandCode(RMAP_command_codes))); + + getCommandCode(); // init the command code value } void rmapPluginUI::connectPort() @@ -169,7 +213,6 @@ void rmapPluginUI::setConnected(bool con ui->OpenPort->setText(tr("Open port"));*/ } - rmapPluginUI::~rmapPluginUI() { //delete ui; @@ -232,9 +275,49 @@ void rmapPluginUI::closeEvent(QCloseEven RMAP_command_codes rmapPluginUI::getCommandCode() { - if (RMAP_write_verify->isChecked() and RMAP_write_reply->isChecked()) return writeSingle_ver_rep; - if (RMAP_write_verify->isChecked() and !RMAP_write_reply->isChecked()) return writeSingle_ver_noRep; - if (!RMAP_write_verify->isChecked() and RMAP_write_reply->isChecked()) return writeSingle_noVer_Rep; - if (!RMAP_write_verify->isChecked() and !RMAP_write_reply->isChecked()) return writeSingle_noVer_noRep; - else return invalid0; + RMAP_command_codes commandCode = invalid0; + if (RMAP_write_verify->isChecked() and RMAP_write_reply->isChecked()) commandCode = writeSingle_ver_rep; + if (RMAP_write_verify->isChecked() and !RMAP_write_reply->isChecked()) commandCode = writeSingle_ver_noRep; + if (!RMAP_write_verify->isChecked() and RMAP_write_reply->isChecked()) commandCode = writeSingle_noVer_Rep; + if (!RMAP_write_verify->isChecked() and !RMAP_write_reply->isChecked()) commandCode = writeSingle_noVer_noRep; + emit commandCodeHasChanged(commandCode); + return commandCode; } + +// SLOT + +void rmapPluginUI::selectionBetweenGresbAndStarDundee() //SLOT +{ + if (selectGRESB_BUTTON->isChecked()) + { + gresb_GROUPBOX->setVisible(true); + stardundee_GROUPBOX->setVisible(false); + rmapOpenCommunicationButton->setEnabled(true); + emit bridgeHasChanged(selectedBridgeIsGRESB); + } + if (selectStarDundee_BUTTON->isChecked()) + { + stardundee_GROUPBOX->setVisible(true); + gresb_GROUPBOX->setVisible(false); + rmapOpenCommunicationButton->setEnabled(true); + emit bridgeHasChanged(selectedBridgeIsStarDundee); + } +} + +void rmapPluginUI::starDundeeIsOpen(bool flag) +{ + if (flag == true) + { + selection_GROUPBOX->setEnabled(false); + this->rmapOpenCommunicationButton->setEnabled(false); + this->rmapCloseCommunicationButton->setEnabled(true); + } + if (flag == false) + { + selection_GROUPBOX->setEnabled(true); + this->rmapOpenCommunicationButton->setEnabled(true); + this->rmapCloseCommunicationButton->setEnabled(false); + } +} + + diff --git a/rmapplugin/rmappluginui.h b/rmapplugin/rmappluginui.h --- a/rmapplugin/rmappluginui.h +++ b/rmapplugin/rmappluginui.h @@ -42,6 +42,15 @@ #include #include "spectralmatricesdmasimulator.h" #include +#include +#include +#include + +enum selectedBridge{ + selectedBridgeIsUnknown, + selectedBridgeIsGRESB, + selectedBridgeIsStarDundee +}; class rmapPluginUI : public QWidget { @@ -61,6 +70,11 @@ public: QPushButton* reset_TC_LFR_UPDATE_TIME_Button; QPushButton* clearConsoleButton; + QRadioButton* selectGRESB_BUTTON; + QRadioButton* selectStarDundee_BUTTON; + + QGroupBox *selection_GROUPBOX; + QSpinBox* gresbVirtualLinkSpinBox; QSpinBox* spwLinkSpinBox; QSpinBox* rmapSourceLogicalAddressSpinBox; @@ -89,39 +103,56 @@ public: StarDundee *starDundee; + gresb *gresbBridge; + bool islogfileenable(); void appendToLogFile(const QString & text); void closeEvent(QCloseEvent *event); - RMAP_command_codes getCommandCode(); public slots: void setConnected(bool connected); void connectPort(); void chooseLogFile(); void logFileEnDisable(int state); + RMAP_command_codes getCommandCode(); + +private slots: + void selectionBetweenGresbAndStarDundee(); + void starDundeeIsOpen(bool flag); signals: void connectPortsig(QString PortName,int baudrate); void setLogFileName(QString FileName); + void commandCodeHasChanged(RMAP_command_codes commandCode); + void bridgeHasChanged(selectedBridge bridge); private: - QLabel* gresbBridgeIPLabel; - QLabel* gresbVirtualLinkLabel; - QLabel* spwLinkLabel; - QLabel* rmapSourceLogicalAddressLabel; - QLabel* rmapTargetLogicalAddressLabel; + QLabel *gresbBridgeIPLabel; + QLabel *gresbVirtualLinkLabel; + QLabel *spwLinkLabel; + QLabel *rmapSourceLogicalAddressLabel; + QLabel *rmapTargetLogicalAddressLabel; QLabel *logFileName; - QVBoxLayout* mainLayout; - QGridLayout* connectionLayout; - QVBoxLayout* ccsdsLayout; - QVBoxLayout* consoleLayout; - QGridLayout* gresbStatusQueryDialogLayout; + QGridLayout *bridgeSelection_LAYOUT; + QVBoxLayout *selectionLayout; + QVBoxLayout *mainLayout; + QGridLayout *connectionLayout; + QVBoxLayout *ccsdsLayout; + QVBoxLayout *consoleLayout; + QGridLayout *gresbStatusQueryDialogLayout; + QGridLayout *generalParameters_LAYOUT; - QTabWidget* spwTabWidget; + QTabWidget *spwTabWidget; + + QWidget* bridgeWidget; - QFile* logFile; - QTextStream* logFileStrm; + QGroupBox *gresb_GROUPBOX; + QGroupBox *stardundee_GROUPBOX; + QGroupBox *generalParameters_GROUPBOX; + + QFile *logFile; + QTextStream *logFileStrm; bool logFileEn; }; diff --git a/rmapplugin/spwpacketreceiver.cpp b/rmapplugin/spwpacketreceiver.cpp --- a/rmapplugin/spwpacketreceiver.cpp +++ b/rmapplugin/spwpacketreceiver.cpp @@ -1,5 +1,6 @@ #include "spwpacketreceiver.h" #include +#include "rmapoperations.h" spwpacketreceiver::spwpacketreceiver(QObject *parent) : QObject(parent) diff --git a/rmapplugin/spwpacketreceiver.h b/rmapplugin/spwpacketreceiver.h --- a/rmapplugin/spwpacketreceiver.h +++ b/rmapplugin/spwpacketreceiver.h @@ -4,14 +4,6 @@ #include #include -#define READ_WRITE_MAX_COUNTS 4096 // in words -#define RMAP_MAX_DATA_LENGTH 4*READ_WRITE_MAX_COUNTS // in bytes, shall be lower than the limit size of SPW packet of the GRESB bridge -#define RMAP_READ_REPLY_HEADER_LENGTH 12 // in bytes => ECSS -#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 - class spwpacketreceiver : public QObject { Q_OBJECT diff --git a/rmapplugin/stardundee.cpp b/rmapplugin/stardundee.cpp --- a/rmapplugin/stardundee.cpp +++ b/rmapplugin/stardundee.cpp @@ -1,30 +1,67 @@ #include "stardundee.h" +#include +#include StarDundee::StarDundee(QWidget *parent) : QWidget(parent) { + commandCode = invalid0; // initialization of the cmmand code for the RMAP transfers + rmapPacket = (unsigned char*) malloc(RMAP_MAX_PACKET_LENGTH); + + rmapTargetLogicalAddress = 0xfe; + rmapSourceLogicalAddress = 0x20; connection_LAYOUT = new QGridLayout; - openCommunication_BUTTON = new QPushButton(tr("Open communication link")); - closeCommunication_BUTTON = new QPushButton(tr("Close communication link")); + sendPacket_BUTTON = new QPushButton(tr("Send a packet")); + sendRMAPPacket_BUTTON = new QPushButton(tr("Write RMAP packet to the specified target")); + readRMAPPacket_BUTTON = new QPushButton(tr("Read RMAP packet from the specified target")); + getRoutingTableEntry_BUTTON = new QPushButton(tr("Get routing table entry (target logical address)")); usbDeviceNumber_LABEL = new QLabel(tr("USB device number: ")); + linkNumber_LABEL = new QLabel(tr("SpaceWire link number: ")); + routingTableEntry_LABEL = new QLabel(tr("Target logical address: ")); + sourceLogicalAddress_LABEL = new QLabel(tr("Source logical address: ")); usbDeviceNumber_SPINBOX = new QSpinBox; usbDeviceNumber_SPINBOX->setRange(0,32); usbDeviceNumber_SPINBOX->setValue(0); + linkNumber_SPINBOX = new QSpinBox; + linkNumber_SPINBOX->setRange(1,2); + linkNumber_SPINBOX->setValue(1); + routingTableEntry_SPINBOX = new QSpinBox; + routingTableEntry_SPINBOX->setRange(0, 254); + routingTableEntry_SPINBOX->setValue(254); + sourceLogicalAddress_SPINBOX = new QSpinBox; + sourceLogicalAddress_SPINBOX->setRange(0,254); + sourceLogicalAddress_SPINBOX->setValue(32); - closeCommunication_BUTTON->setEnabled(false); + sendPacket_BUTTON->setEnabled(false); + sendRMAPPacket_BUTTON->setEnabled(false); + readRMAPPacket_BUTTON->setEnabled(false); + getRoutingTableEntry_BUTTON->setEnabled(false); - connection_LAYOUT->addWidget(openCommunication_BUTTON, 0, 0, 1, 2); - connection_LAYOUT->addWidget(closeCommunication_BUTTON, 1, 0, 1, 2); - connection_LAYOUT->addWidget(usbDeviceNumber_LABEL, 2, 0, 1, 1); - connection_LAYOUT->addWidget(usbDeviceNumber_SPINBOX, 2, 1, 1, 1); + connection_LAYOUT->addWidget(usbDeviceNumber_LABEL, 0, 0, 1, 1); + connection_LAYOUT->addWidget(usbDeviceNumber_SPINBOX, 0, 1, 1, 1); + connection_LAYOUT->addWidget(sendPacket_BUTTON, 1, 0, 1, 2); + connection_LAYOUT->addWidget(linkNumber_LABEL, 2, 0, 1, 1); + connection_LAYOUT->addWidget(linkNumber_SPINBOX, 2, 1, 1, 1); + connection_LAYOUT->addWidget(sourceLogicalAddress_LABEL, 3, 0, 1, 1); + connection_LAYOUT->addWidget(sourceLogicalAddress_SPINBOX, 3, 1, 1, 1); + connection_LAYOUT->addWidget(routingTableEntry_LABEL, 4, 0, 1, 1); + connection_LAYOUT->addWidget(routingTableEntry_SPINBOX, 4, 1, 1, 1); + connection_LAYOUT->addWidget(sendRMAPPacket_BUTTON, 5, 0, 1, 2); + connection_LAYOUT->addWidget(readRMAPPacket_BUTTON, 6, 0, 1, 2); + connection_LAYOUT->addWidget(getRoutingTableEntry_BUTTON, 7, 0, 1, 2); + + connection_LAYOUT->setRowStretch(8, 1); + connection_LAYOUT->setColumnStretch(2, 1); this->setLayout(connection_LAYOUT); - connect(this->openCommunication_BUTTON, SIGNAL(clicked()), this, SLOT(OpenStarDundee())); - connect(this->closeCommunication_BUTTON, SIGNAL(clicked()), this, SLOT(CloseStarDundee())); + connect(this->sendPacket_BUTTON, SIGNAL(clicked()), this, SLOT(SendPacket())); + connect(this->readRMAPPacket_BUTTON, SIGNAL(clicked()),this, SLOT(ReadRMAP())); + connect(this->sendRMAPPacket_BUTTON, SIGNAL(clicked()), this, SLOT(SendRMAP())); + connect(this->getRoutingTableEntry_BUTTON, SIGNAL(clicked()), this, SLOT(GetRoutingTableEntry())); } StarDundee::~StarDundee() @@ -34,22 +71,459 @@ StarDundee::~StarDundee() unsigned int StarDundee::OpenStarDundee() { - if (!USBSpaceWire_Open(&hDevice, 0)) // Open the first device + int status; + U32 statusControl; + U32 routingTableEntry; + int tableEntry; + + if (!USBSpaceWire_Open(&hDevice, usbDeviceNumber_SPINBOX->value())) // Open the USB device { emit sendMessage("stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); return -1; } - openCommunication_BUTTON->setEnabled(false); - closeCommunication_BUTTON->setEnabled(true); - emit sendMessage("stardundee *** Open *** USBSpaceWire_Open(&hDevice, 0)) successful"); + 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_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices + + // Set the path and return path to the device + CFGSpaceWire_StackClear(); + CFGSpaceWire_AddrStackPush(0); + CFGSpaceWire_AddrStackPush(254); + CFGSpaceWire_RetAddrStackPush(254); + + // set the base transmit rate to 100 MHz + status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); + if (status != CFG_TRANSFER_SUCCESS) + { + emit sendMessage("ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); + } + else emit sendMessage("OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); + // read the link status + if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber_SPINBOX->value(), &statusControl) != CFG_TRANSFER_SUCCESS) + { + emit sendMessage("Could not read link status control for link " + QString::number(linkNumber_SPINBOX->value())); + } + else + { + emit sendMessage("OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber_SPINBOX->value())); + + // Set the link status control register properties + CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); + CFGSpaceWire_LSEnableStart(&statusControl, 1); + CFGSpaceWire_LSEnableDisabled(&statusControl, 0); + CFGSpaceWire_LSEnableTristate(&statusControl, 0); + CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz + + // Set the link status control register + if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber_SPINBOX->value(), statusControl) != CFG_TRANSFER_SUCCESS) + { + emit sendMessage("Could not set the link status control for link " + QString::number(linkNumber_SPINBOX->value())); + } + 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 = routingTableEntry_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 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" ); + + emit sendMessage("The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); + + sendPacket_BUTTON->setEnabled(true); + sendRMAPPacket_BUTTON->setEnabled(true); + readRMAPPacket_BUTTON->setEnabled(true); + getRoutingTableEntry_BUTTON->setEnabled(true); + + USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports + + emit starDundeeIsOpen(true); + + emit sendMessage("command code: " + QString::number(commandCode,16) ); + return 1; } unsigned int StarDundee::CloseStarDundee() { USBSpaceWire_Close(hDevice); // Close the device - emit sendMessage("stardundee *** Close *** USBSpaceWire_Close(hDevice)"); - openCommunication_BUTTON->setEnabled(true); - closeCommunication_BUTTON->setEnabled(false); + emit sendMessage("stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(usbDeviceNumber_SPINBOX->value())); + sendPacket_BUTTON->setEnabled(false); + sendRMAPPacket_BUTTON->setEnabled(false); + readRMAPPacket_BUTTON->setEnabled(false); + getRoutingTableEntry_BUTTON->setEnabled(false); + + USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports + + emit starDundeeIsOpen(false); + + return 1; +} + +unsigned int StarDundee::GetRoutingTableEntry() +{ + U32 routingTableEntry, outputPorts; + char enabled, delHead, priority; + int portNum; + int tableEntry; + + tableEntry = routingTableEntry_SPINBOX->value(); + + // Set the path and return path to the device + CFGSpaceWire_StackClear(); + CFGSpaceWire_AddrStackPush(0); + CFGSpaceWire_AddrStackPush(254); + CFGSpaceWire_RetAddrStackPush(254); + + // Read the routing table entry + if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) + { + emit sendMessage("Could not read routing table entry [" + QString::number(tableEntry) + "]"); + } + else + { + // Display the routing table entry properties + CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); + CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); + CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); + CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); + emit sendMessage("CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); + emit sendMessage("CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); + emit sendMessage("CFGSpaceWire_RTIsPriority : " + QString::number(priority)); + emit sendMessage("CFGSpaceWire_RTGetOutputPorts : "); + for (portNum = 0; portNum < 32; portNum++) + { + if (outputPorts & (1 << portNum)) + { + emit sendMessage(QString::number(portNum)); + } + } + } + + return 1; +} + +unsigned int StarDundee::SendPacket() +{ + U32 nBufferSize; // The amount of data, in bytes, to be transmitted. + char bWait; // If bWait is 0 then the transfer is started and the function returns immediately. + // If bWait is not 0 then the function will return only when the transfer is completed or an error is detected. + + nBufferSize = 10; + bWait = 1; + // Send the packet and wait on it completing + result = USBSpaceWire_SendPacket(hDevice, pBuffer, nBufferSize, bWait, &pIdentifier); + if (result != TRANSFER_SUCCESS) + { + emit sendMessage("Error: Could not send the packet"); + } + else emit sendMessage("The packet has been successfully sent"); + + // Free the send + USBSpaceWire_FreeSend(hDevice, pIdentifier); + + return 1; +} + +unsigned int StarDundee::SendRMAP() +{ + unsigned int Value[4]; + unsigned int count = 4; + unsigned int address = 0x40000000; + Value[0] = 0xabcd1234; + Value[1] = 0xbb; + Value[2] = 0xab; + Value[3] = 0xcd; + WriteStarDundee(Value, count, address); + return 1; +} + +unsigned int StarDundee::ReadRMAP() +{ + unsigned int Value[100000]; + unsigned int count = 100000; + unsigned int address = 0x40000000; + unsigned int result; + result = ReadStarDundee(Value, count, address); + emit sendMessage("ReadRMAP, nbBytes: " + QString::number(result)); + emit sendMessage("Value[0]: " + QString::number(Value[0], 16)); + emit sendMessage("Value[1]: " + QString::number(Value[1], 16)); + emit sendMessage("Value[2]: " + QString::number(Value[2], 16)); + emit sendMessage("Value[3]: " + QString::number(Value[3], 16)); return 1; } + +unsigned int StarDundee::ReadStarDundee(unsigned int *Value, unsigned int count, unsigned int address) +{ + RMAP *RMAPCommand; + rmap_read_reply_PcktHdr_t rmapReplyHeader; + USB_SPACEWIRE_STATUS result; // The result of the receive operation + USB_SPACEWIRE_PACKET_PROPERTIES properties; // The properties of the read + unsigned int nbBytes; + unsigned char* packet; + U32 nPacketNum; + unsigned int offset; + unsigned int i; + + //********************** + // SEND THE READ COMMAND + nbBytes = 4 * count; + if (nbBytes > 4) + { + RMAPCommand = new RMAP(read_Inc, // build the command + rmapTargetLogicalAddress, + rmapSourceLogicalAddress, + address, + nbBytes, + NULL); + } + else + { + RMAPCommand = new RMAP(read_Single, // build the command + rmapTargetLogicalAddress, + rmapSourceLogicalAddress, + address, + nbBytes, + NULL); + } + + result = USBSpaceWire_SendPacket(hDevice, + (unsigned char*) ((void*) &RMAPCommand->RMAPHeader), + sizeof(RMAPCommand->RMAPHeader), + BWAIT_1, &pIdentifier); + if (result != TRANSFER_SUCCESS) emit sendMessage("ERROR *** ReadStarDundee when sending the READ command "); + else emit sendMessage("OK *** ReadStarDundee when sending the READ command"); + + //***************** + // RECEIVE THE DATA + nbBytes = sizeof(rmapReplyHeader) + 4 * count + 1; // 1 is for the data CRC + packet = (unsigned char *) malloc(nbBytes); + nPacketNum = 1; + result = USBSpaceWire_ReadPackets(hDevice, packet, nbBytes, nPacketNum, BWAIT_1, &properties, &pIdentifier); + if (result != TRANSFER_SUCCESS) emit sendMessage("Error: Could not receive the packet"); + else + { + emit sendMessage("A packet of length " + QString::number(properties.len) + " has been successfully received"); + offset = sizeof(rmapReplyHeader); + for(i=0; i>8); + dataCHAR[i*4+1] = (char) ((unsigned int) Value[i]>>16); + dataCHAR[i*4+0] = (char) ((unsigned int) Value[i]>>24); + } + + RMAPCommand = new RMAP(commandCode, + rmapTargetLogicalAddress, + rmapSourceLogicalAddress, + address, + dataSize, + dataCHAR); + free(dataCHAR); + headerSize = sizeof(RMAPCommand->RMAPHeader); + CRCSize = 1; + + //************************* + // BUILD THE PACKET TO SEND + totalSize = headerSize + dataSize + CRCSize; + data = (unsigned char*) malloc( totalSize ); + aux = (unsigned char*) ((void*) &RMAPCommand->RMAPHeader); + for(unsigned int i = 0; i>8); + data[offset+1] = (unsigned char) (Value[i]>>16); + data[offset] = (unsigned char) (Value[i]>>24); + offset = offset + 4; + } + data[offset] = RMAPCommand->dataCRC; + + //************ + // SEND THE PACKET + result = USBSpaceWire_SendPacket(hDevice, + data, + totalSize, + BWAIT_1, &pIdentifier); + if (result != TRANSFER_SUCCESS) + { + emit sendMessage("ERROR *** WriteStarDundee when sending packet of size " + + QString::number(totalSize) +", with code: " + QString::number(result)); + USBSpaceWire_FreeSend(hDevice, pIdentifier); + free(data); + return 1; + } + else emit sendMessage("OK *** WriteStarDundee when sending packet of size " + QString::number(totalSize)); + + //************** + // Free the send + USBSpaceWire_FreeSend(hDevice, pIdentifier); + free(data); + + if ( (commandCode == writeSingle_noVer_Rep) | (commandCode == writeInc_noVer_Rep) | + (commandCode == writeSingle_ver_rep) | (commandCode == writeInc_ver_rep) ) + { + //*********************** + // RECEIVE THE RMAP REPLY + totalSize = sizeof(rmapReplyHeader); + nPacketNum = 1; + result = USBSpaceWire_ReadPackets(hDevice, (char *) &rmapReplyHeader, totalSize, nPacketNum, BWAIT_1, &properties, &pIdentifier); + if (result != TRANSFER_SUCCESS) + { + emit sendMessage("Error: Could not receive the RMAP reply"); + USBSpaceWire_FreeRead(hDevice, pIdentifier); // Free the receive + return 1; + } + else + { + emit sendMessage("An RMAP reply of length " + QString::number(properties.len) + " has been successfully received"); + USBSpaceWire_FreeRead(hDevice, pIdentifier); // Free the receive + } + if(properties.len != 8) + { + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** write reply format not compliant\n"); + return 1; + } + emit sendMessage("data CRC " + QString::number(RMAPCommand->dataCRC, 16) ); + emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.initiatorLogicalAddress, 16) ); + emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.protocolIdentifier, 16) ); + emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.instruction, 16) ); + emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.status, 16) ); + emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.targetLogicalAddress, 16) ); + emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.transactionIdentifier1, 16) ); + emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.transactionIdentifier2, 16) ); + emit sendMessage("rmapReplyHeader " + QString::number(rmapReplyHeader.headerCRC, 16) ); + switch (rmapReplyHeader.status) // byte 4 is the status byte in the reply + { + case 0: + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 0 Successfull"); + break; + case 1: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** General error code"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 1 General error code"); + break; + case 2: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Unused RMAP packet type or command code"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 2 Unused RMAP packet type or command code"); + break; + case 3: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid key"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 3 Invalid key"); + break; + case 4: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid data CRC"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 4 Invalid data CRC"); + break; + case 5: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Early EOP"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 5 Early EOP"); + break; + case 6: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Too much data"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 6 Too much data"); + break; + case 7: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** EEP"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 7 EEP"); + break; + case 8: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Reserved"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 8 Reserved"); + break; + case 9: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Verify buffer overrun"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 9 Verify buffer overrun"); + break; + case 10: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** RMAP command not implemented or not authorised"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 10 RMAP command not implemented or not authorised"); + break; + case 11: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** RMW data length error"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 11 RMAP RMW data length error"); + break; + case 12: + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid target logical address"); + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: 12 Invalid target logical address"); + break; + } + } + else + emit RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable"); + return count; +} + +//****** +// SLOTS + +void StarDundee::updateCommandCode(RMAP_command_codes code) +{ + this->commandCode = code; +} diff --git a/rmapplugin/stardundee.h b/rmapplugin/stardundee.h --- a/rmapplugin/stardundee.h +++ b/rmapplugin/stardundee.h @@ -3,10 +3,15 @@ #include #include "spw_usb_api.h" +#include "spw_config_library.h" #include #include #include #include +#include "rmapoperations.h" + +#define BWAIT_0 0 +#define BWAIT_1 1 class StarDundee : public QWidget { @@ -14,24 +19,53 @@ class StarDundee : public QWidget public: explicit StarDundee(QWidget *parent = 0); ~StarDundee(); - star_device_handle hDevice;// Handle to the SpaceWire device - QGridLayout *connection_LAYOUT; + unsigned int WriteStarDundee(unsigned int *Value,unsigned int count,unsigned int address=0); + unsigned int ReadStarDundee(unsigned int *Value,unsigned int count,unsigned int address=0); signals: void sendMessage(QString message); + void starDundeeIsOpen(bool); + void RMAP_write_reply_setText(QString); + void appendToLog(QString); public slots: unsigned int OpenStarDundee(); unsigned int CloseStarDundee(); + unsigned int SendPacket(); + unsigned int SendRMAP(); + unsigned int ReadRMAP(); + unsigned int GetRoutingTableEntry(); + void updateCommandCode(RMAP_command_codes code); private: + char rmapTargetLogicalAddress ; + char rmapSourceLogicalAddress ; - QPushButton *openCommunication_BUTTON; - QPushButton *closeCommunication_BUTTON; + QPushButton *sendPacket_BUTTON; + QPushButton *sendRMAPPacket_BUTTON; + QPushButton *readRMAPPacket_BUTTON; + QPushButton *getRoutingTableEntry_BUTTON; QLabel *usbDeviceNumber_LABEL; + QLabel *linkNumber_LABEL; + QLabel *routingTableEntry_LABEL; + QLabel *sourceLogicalAddress_LABEL; QSpinBox *usbDeviceNumber_SPINBOX; + QSpinBox *linkNumber_SPINBOX; + QSpinBox *routingTableEntry_SPINBOX; + QSpinBox *sourceLogicalAddress_SPINBOX; + + QGridLayout *connection_LAYOUT; + + unsigned char pBuffer[10]; // Pointer to the start of the user buffer from which to transmit data + unsigned char* rmapPacket; // The buffer to receive RMAP READ packets + USB_SPACEWIRE_ID pIdentifier; // A pointer to a variable which will be set to contain a unique identifier for the send + + RMAP_command_codes commandCode; + + star_device_handle hDevice; // Handle to the SpaceWire device + USB_SPACEWIRE_STATUS result; // The result of the send operation };