# HG changeset patch # User Paul LEROY # Date 2012-12-10 12:43:21 # Node ID 7c1589fec151f2e7199a64688b7c02b69ae1430c # Parent fb2c374505d087a69693107643d4e5f086f40f0d changes on the gresb class, object ready for usage in the rmapplugin 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 08:08:24 2012 +# Generated by qmake (2.01a) (Qt 4.8.3) on: Mon Dec 10 09:02:30 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: Mon Dec 10 08:08:25 2012 +# Generated by qmake (2.01a) (Qt 4.8.3) on: Mon Dec 10 09:02:30 2012 # Project: rmapplugin.pro # Template: lib # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile rmapplugin.pro @@ -266,6 +266,7 @@ moc/moc_rmappluginui.cpp: rmapoperations spectralmatricesdmasimulator.h \ stardundee.h \ gresb.h \ + spwpacketreceiver.h \ rmappluginui.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmappluginui.h -o moc/moc_rmappluginui.cpp @@ -274,8 +275,8 @@ moc/moc_rmapplugin.cpp: rmappluginui.h \ spectralmatricesdmasimulator.h \ stardundee.h \ gresb.h \ + spwpacketreceiver.h \ ccsds.h \ - spwpacketreceiver.h \ rmapplugin.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) rmapplugin.h -o moc/moc_rmapplugin.cpp @@ -298,7 +299,9 @@ 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: gresb.h +moc/moc_gresb.cpp: spwpacketreceiver.h \ + rmapoperations.h \ + gresb.h /usr/lib64/qt4/bin/moc $(DEFINES) $(INCPATH) gresb.h -o moc/moc_gresb.cpp moc/moc_bridge.cpp: bridge.h @@ -335,8 +338,8 @@ obj/rmapplugin.o: rmapplugin.cpp rmapplu spectralmatricesdmasimulator.h \ stardundee.h \ gresb.h \ + spwpacketreceiver.h \ ccsds.h \ - spwpacketreceiver.h \ rmappluginpythonwrapper.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmapplugin.o rmapplugin.cpp @@ -346,8 +349,8 @@ obj/rmappluginui.o: rmappluginui.cpp rma spectralmatricesdmasimulator.h \ stardundee.h \ gresb.h \ - ccsds.h \ - spwpacketreceiver.h + spwpacketreceiver.h \ + ccsds.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/rmappluginui.o rmappluginui.cpp obj/rmapoperations.o: rmapoperations.cpp rmapoperations.h @@ -376,7 +379,9 @@ obj/stardundee.o: stardundee.cpp stardun rmapoperations.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/stardundee.o stardundee.cpp -obj/gresb.o: gresb.cpp gresb.h +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 diff --git a/rmapplugin/gresb.cpp b/rmapplugin/gresb.cpp --- a/rmapplugin/gresb.cpp +++ b/rmapplugin/gresb.cpp @@ -8,8 +8,12 @@ gresb::gresb(QWidget *parent) : RMAPSend_SOCKET = new QTcpSocket; RMAPReceive_SOCKET = new QTcpSocket; GRESBStatusQuery_SOCKET = new QTcpSocket; - spwPacketReceiverOBJECT = new spwpacketreceiver; - spwPacketReceiverOBJECT->gresbReceptionSocket = RMAPReceive_SOCKET; + + 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) ); + + commandCode = invalid0; // initialization of the command code for the RMAP transfers //*** QLABEL ***// gresbBridgeIPLabel = new QLabel(tr("GRESB Bridge IP: ")); @@ -69,6 +73,442 @@ gresb::gresb(QWidget *parent) : this->setLayout(connectionLayout); connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); + connect(this->RMAPReceive_SOCKET, SIGNAL(readyRead()), this, SLOT(receiveSPWPacket())); +} + +gresb::~gresb() +{ + free(rmapPacket); + free(ccsdsPacket); + free(spwPacket); +} + +unsigned int gresb::Write(unsigned int *Value, unsigned int count, unsigned int address) +{ + unsigned int remainingCount = count; + unsigned int iOffset = 0; + QString console_message; + char* data; + + if(rmapPacketSEMAPHORE->available()!=0) + { + emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP request already running, WRITE access stopped"); + return 1; + } + + RMAP_write_reply_setText("reply to the write command required\nlast reply status: unavailable"); + + data = (char*) malloc(READ_WRITE_MAX_COUNTS*4); + + emit appendToLog(QString("*** START *** WRITE ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16)); + + while (remainingCount > READ_WRITE_MAX_COUNTS) + { + for (int i = 0; i>8); + data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16); + data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24); + } + + console_message.sprintf("remainingCount: %d => ", remainingCount); + emit appendToLog(console_message + QString("Write ")+ QString::number(READ_WRITE_MAX_COUNTS*4) + QString(" byte(s) @0x")+ QString::number(address,16)); + + if(WriteBLOCK(data, READ_WRITE_MAX_COUNTS*4, address)==0) + { + emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed"); + return 1; + } + + remainingCount = remainingCount - READ_WRITE_MAX_COUNTS; + address = address + READ_WRITE_MAX_COUNTS * 4; + iOffset = iOffset + READ_WRITE_MAX_COUNTS; + } + + if (remainingCount > 0) + { + for (unsigned int i = 0; i>8); + data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16); + data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24); + } + + console_message.sprintf("remainingCount: %d => ", remainingCount); + emit appendToLog(console_message + QString("Write ")+ QString::number(remainingCount*4) + QString(" byte(s) @0x")+ QString::number(address,16)); + + if (WriteBLOCK(data, remainingCount*4, address)==0) + { + emit appendToLog("WARNING === in function WRITE of rmapplugin *** RMAP write command failed"); + return 1; + } + } + + emit appendToLog(QString("*** STOP *** WRITE")); + free(data); + return count; +} + +unsigned int gresb::Read(unsigned int *Value, unsigned int count, unsigned int address) +{ + unsigned int remainingCount = count; + unsigned int iOffset = 0; + QString console_message; + + if(rmapPacketSEMAPHORE->available()!=0) + { + emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP request already running, READ access stopped"); + return 1; + } + emit appendToLog(QString("*** START *** READ ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16)); + + while (remainingCount > READ_WRITE_MAX_COUNTS) + { + console_message.sprintf("remainingCount: %d => ", remainingCount); + emit appendToLog(console_message + QString("Read ")+ QString::number(4*READ_WRITE_MAX_COUNTS) + QString(" byte(s) @0x")+ QString::number(address,16)); + + if (ReadBLOCK(READ_WRITE_MAX_COUNTS*4, address)==0) + { + emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received"); + return 1; + } + + for(int i=0;i 0) + { + console_message.sprintf("remainingCount: %d => ", remainingCount); + emit appendToLog(console_message + QString("Read ")+ QString::number(4*remainingCount) + QString(" byte(s) @0x")+ QString::number(address,16)); + + if (ReadBLOCK(4*remainingCount, address)==0) + { + emit appendToLog("WARNING === in function READ of rmapplugin *** RMAP packet not received"); + return 1; + } + + for(unsigned int i=0;ivalue()) == 1) + { + this->Close(); + return 1; + } + + RMAPCommand = new RMAP(commandCode, + rmapTargetLogicalAddress, + rmapSourceLogicalAddress, + address, + nbBytes, + data); + + // SEND GRESB HEADER + RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->GRESBHeader), 4); + // SEND SPACEWIRE PACKET HEADER + RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->RMAPHeader), sizeof(RMAPCommand->RMAPHeader)); + // SEND DATA + RMAPSend_SOCKET->write( data, nbBytes); + // SEND DATA CRC + RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->dataCRC), 1); + RMAPTimeout.start(); + while(RMAPSend_SOCKET->bytesToWrite() > 0) + { + RMAPSend_SOCKET->waitForBytesWritten(100); + if(RMAPTimeout.elapsed()>1000) + { + emit appendToLog("WARNING === in function WRITE (with reply) of rmapplugin *** sending Write RMAP Command timeout"); + return 0; + } + } + + if ( (commandCode == writeSingle_noVer_Rep) | (commandCode == writeInc_noVer_Rep) | + (commandCode == writeSingle_ver_rep) | (commandCode == writeInc_ver_rep) ) + { + // WAIT FOR THE RMAP REPLY PACKET + errorCode = receiveSPWPacket(1); + if (errorCode<=0) + { + emit appendToLog("WARNING === in function WriteBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode)); + return 0; + } + if(rmapPacketSize != 8) + { + console_message.sprintf("WARNING === in function WRITE (with reply) of rmapplugin *** write reply format not compliant\n"); + emit appendToLog(console_message); + return 0; + } + switch (rmapPacket[3]) // byte 4 is the status byte in the reply + { + case 0: + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + RMAP_write_reply_setText("reply to the write command required\nlast reply status: 12 Invalid target logical address"); + break; + } + acquireRMAPSemaphore(); + } + return nbBytes; +} + +unsigned int gresb::ReadBLOCK(unsigned int nbBytes, unsigned int address) +{ + int errorCode; + RMAP *RMAPCommand; + QTime RMAPTimeout; + unsigned int dataLength; + if (GRESBStatusQueryRequest(LinkStatus, spwLinkSpinBox->value()) == 1) + { + this->Close(); + return 1; + } + + if (nbBytes > 4) + { + RMAPCommand = new RMAP(read_Inc, + rmapTargetLogicalAddress, + rmapSourceLogicalAddress, + address, + nbBytes, + NULL); + } + else + { + RMAPCommand = new RMAP(read_Single, + rmapTargetLogicalAddress, + rmapSourceLogicalAddress, + 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) + { + emit appendToLog("WARNING === in function READ of rmapplugin *** sending Read RMAP Command timeout\n"); + return 0; + } + } + + // RECEIVE THE INCOMING RMAP PACKET + errorCode = receiveSPWPacket(1); // request ID 1 is for RMAP packet + if (errorCode<=0) + { + emit appendToLog("WARNING === in function ReadBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode)); + return 0; + } + dataLength = rmapPacketSize - RMAP_READ_REPLY_HEADER_LENGTH - RMAP_DATA_CRC_LENGTH; + if(dataLength != nbBytes) + { + 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) + +")"); + return 0; + } + return dataLength; +} + +unsigned int gresb::WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) +{ + char protocoleIdentifier = 0x02; + char reserved = 0x00; + char gresbProtocole = 0x00; + unsigned char size[3]; + unsigned int spwPacketSize = count + 4; + QTime SPWTimeout; + + if (count>248) + { + appendToLog("WARNING === in function WRITE of rmapplugin *** CCSDS packet size > 248 bytes\n"); + return 1; + } + + appendToLog(QString("*** START *** Send CCSDS packet of ")+ QString::number(count) + QString(" byte(s)")); + + if (GRESBStatusQueryRequest(LinkStatus, spwLinkSpinBox->value()) == 1) + { + this->Close(); + appendToLog("WARNING === in function WRITE of rmapplugin *** SPW link not running\n"); + return 1; + } + + // SEND GRESB HEADER + size[0] = (unsigned char) ((unsigned int) spwPacketSize>>16); + size[1] = (unsigned char) ((unsigned int) spwPacketSize>>8); + size[2] = (unsigned char) ((unsigned int) spwPacketSize); + RMAPSend_SOCKET->write(&gresbProtocole, 1); + RMAPSend_SOCKET->write((char*) size, 3); + // SEND SPW HEADER + RMAPSend_SOCKET->write(&targetLogicalAddress, 1); + RMAPSend_SOCKET->write(&protocoleIdentifier, 1); + RMAPSend_SOCKET->write(&reserved, 1); + RMAPSend_SOCKET->write(&userApplication, 1); + // SEND CCSDS PACKET + RMAPSend_SOCKET->write(Value, count); + SPWTimeout.start(); + while(RMAPSend_SOCKET->bytesToWrite() > 0) + { + RMAPSend_SOCKET->waitForBytesWritten(100); + if(SPWTimeout.elapsed()>1000) + { + appendToLog("WARNING === in function WRITE of rmapplugin *** sending CCSDS packet timeout\n"); + return 1; + } + } + + appendToLog(QString("*** CCSDS packet sent")); + + return count; +} + +int gresb::receiveSPWPacket(unsigned char requestID) // SLOT +{ + QTime spwPacketReceiverTimeout; + // GRESB HEADER + char RES_TR_EP; // 6 bits REserved + 1 bit TRuncated + 1 bit EP error end of packet + unsigned char packetLength2; + unsigned char packetLength1; + unsigned char packetLength0; + unsigned int packetLength; + + if (requestID==1) + { + if (rmapPacketSEMAPHORE->available()) return rmapPacketSize; + } + + RMAPReceive_SOCKET->blockSignals(1); // block the signals of the socket during packet reception + // READ THE GRESB HEADER OF THE INCOMING PACKET + spwPacketReceiverTimeout.start(); + while(RMAPReceive_SOCKET->bytesAvailable() < 4) + { + RMAPReceive_SOCKET->waitForReadyRead(100); + if(spwPacketReceiverTimeout.elapsed()>1000) return -1; // ERROR === read GRSEB header TIMEOUT + } + RMAPReceive_SOCKET->read(&RES_TR_EP, 1); + RMAPReceive_SOCKET->read( (char*) &packetLength2, 1); + 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) + { + RMAPReceive_SOCKET->waitForReadyRead(100); + if(spwPacketReceiverTimeout.elapsed()>1000) return -2; // ERROR === read SPW packet TIMEOUT + } + RMAPReceive_SOCKET->read( spwPacket, packetLength ); + RMAPReceive_SOCKET->blockSignals(0); + + switch(spwPacket[1]) // byte 1 is the protocole identifier in the SPW packet + { + case 1: // 0x01 is the protocole identifier for RMAP packets + if (rmapPacketSEMAPHORE->available()!=0) return -3; // ERROR === previous RMAP packet not processed yet + for(unsigned int i=0; irelease(); + //emit sendMessage("RMAP packet of size " + QString::number(packetLength) + " received"); + 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 + for(unsigned int i=0; irelease(); + emit(ccsdsPacketAvailable(ccsdsPacket, packetLength)); + return packetLength; + } + return 0; } void gresb::Open() // SLOT @@ -86,8 +526,8 @@ void gresb::Open() // SLOT GRESBStatusQuery_SOCKET->waitForConnected(10000); RMAPReceive_SOCKET->readAll(); // read all remaining data from the reception socket // initialize SPW packet semaphores - while (spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->available()!=0) spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->acquire(); - while (spwPacketReceiverOBJECT->ccsdsPacketSEMAPHORE->available()!=0) spwPacketReceiverOBJECT->ccsdsPacketSEMAPHORE->acquire(); + while (rmapPacketSEMAPHORE->available()!=0) rmapPacketSEMAPHORE->acquire(); + while (ccsdsPacketSEMAPHORE->available()!=0) ccsdsPacketSEMAPHORE->acquire(); if (GRESBStatusQueryRequest(LinkStatus, spwLinkSpinBox->value()) != 0) { spwRunning = gresbStatusQueryDialog->exec(); @@ -213,3 +653,35 @@ 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); +} diff --git a/rmapplugin/gresb.h b/rmapplugin/gresb.h --- a/rmapplugin/gresb.h +++ b/rmapplugin/gresb.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "gresbstatusenquiry.h" #include "spwpacketreceiver.h" @@ -23,7 +24,7 @@ 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 getLinkStatus(unsigned char link); + //unsigned int getLinkStatus(unsigned char link); signals: void sendMessage(QString message); @@ -35,7 +36,8 @@ signals: public slots: void Open(); void Close(); - int receiveSPWPacket(unsigned char requestID); + 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 sourceHasChanged(int target) {rmapSourceLogicalAddress = (unsigned char) target;} @@ -44,6 +46,10 @@ private slots: int GRESBStatusQuery(); 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();} int GRESBStatusQueryRequest(GresbStatusQueryOption option, char link); unsigned char rmapTargetLogicalAddress ; @@ -78,9 +84,16 @@ private: QTcpSocket *RMAPReceive_SOCKET; QTcpSocket *GRESBStatusQuery_SOCKET; - spwpacketreceiver *spwPacketReceiverOBJECT; + gresbStatusEnquiry* spwLinkStatusEnquiry; - gresbStatusEnquiry* spwLinkStatusEnquiry; + // Packet receiver + QSemaphore *rmapPacketSEMAPHORE; + QSemaphore *ccsdsPacketSEMAPHORE; + char* rmapPacket; // The buffer to receive RMAP READ packets + unsigned char *ccsdsPacket; + char *spwPacket; + unsigned int rmapPacketSize; + unsigned int ccsdsPacketSize; }; #endif // GRESB_H diff --git a/rmapplugin/rmappluginui.cpp b/rmapplugin/rmappluginui.cpp --- a/rmapplugin/rmappluginui.cpp +++ b/rmapplugin/rmappluginui.cpp @@ -137,6 +137,7 @@ rmapPluginUI::rmapPluginUI(QWidget *pare generalParameters_LAYOUT->setColumnStretch(2, 1); gresb_GROUPBOX->setLayout(connectionLayout); + //gresb_GROUPBOX->setLayout(gresbBridge->layout()); gresb_GROUPBOX->setVisible(false); stardundee_GROUPBOX->setLayout(starDundee->layout()); stardundee_GROUPBOX->setVisible(false); @@ -199,21 +200,6 @@ rmapPluginUI::rmapPluginUI(QWidget *pare rmapTargetLogicalAddressSpinBox->setValue(254); } -void rmapPluginUI::connectPort() -{ - //emit this->connectPortsig(ui->PortName->text(),ui->PortspeedSlider->value()); -} - -void rmapPluginUI::setConnected(bool connected) -{ - /*if(connected == true) - { - ui->OpenPort->setText(tr("Close port")); - } - else - ui->OpenPort->setText(tr("Open port"));*/ -} - rmapPluginUI::~rmapPluginUI() { //delete ui; diff --git a/rmapplugin/rmappluginui.h b/rmapplugin/rmappluginui.h --- a/rmapplugin/rmappluginui.h +++ b/rmapplugin/rmappluginui.h @@ -110,8 +110,6 @@ public: void closeEvent(QCloseEvent *event); public slots: - void setConnected(bool connected); - void connectPort(); void chooseLogFile(); void logFileEnDisable(int state); RMAP_command_codes getCommandCode(); diff --git a/rmapplugin/spwpacketreceiver.cpp b/rmapplugin/spwpacketreceiver.cpp --- a/rmapplugin/spwpacketreceiver.cpp +++ b/rmapplugin/spwpacketreceiver.cpp @@ -80,23 +80,7 @@ int spwpacketreceiver::receiveSPWPacket( return 0; } -bool spwpacketreceiver::isRMAPPacketSemaphoreAvailable() -{ - if (rmapPacketSEMAPHORE->available()!=0) return true; - return false; -} - -void spwpacketreceiver::acquireRMAPSemaphore() -{ - rmapPacketSEMAPHORE->acquire(); -} - -void spwpacketreceiver::acquireCCSDSSemaphore() -{ - ccsdsPacketSEMAPHORE->acquire(); -} - -void spwpacketreceiver::processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) +void spwpacketreceiver::processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size) // SLOT { QString message; unsigned int fine_time_value = 0; @@ -127,4 +111,3 @@ void spwpacketreceiver::processCCSDSPack ccsdsPacketSEMAPHORE->acquire(); emit sendMessage(message); } - diff --git a/rmapplugin/spwpacketreceiver.h b/rmapplugin/spwpacketreceiver.h --- a/rmapplugin/spwpacketreceiver.h +++ b/rmapplugin/spwpacketreceiver.h @@ -11,9 +11,8 @@ public: explicit spwpacketreceiver(QObject *parent = 0); ~spwpacketreceiver(); int fetchRMAPPacket(); - void acquireRMAPSemaphore(); - void acquireCCSDSSemaphore(); - bool isRMAPPacketSemaphoreAvailable(); + void acquireCCSDSSemaphore() {ccsdsPacketSEMAPHORE->acquire();} + void acquireRMAPSemaphore() {rmapPacketSEMAPHORE->acquire();} unsigned char* ccsdsPacket; char* rmapPacket; diff --git a/rmapplugin/stardundee.h b/rmapplugin/stardundee.h --- a/rmapplugin/stardundee.h +++ b/rmapplugin/stardundee.h @@ -40,13 +40,14 @@ public slots: void sourceHasChanged(int target) {rmapSourceLogicalAddress = (unsigned char) target;} private: - unsigned int getLinkStatus(unsigned char link); - unsigned int GetRoutingTableEntry(); 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();} + unsigned int getLinkStatus(unsigned char link); + unsigned int GetRoutingTableEntry(); + unsigned char rmapTargetLogicalAddress ; unsigned char rmapSourceLogicalAddress ;