Commit a3bbbd40 authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

bool Packet::createPacketType() bug fix

parent 4ce389fb
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
2013-09-18  bulgarelli  Andrea Bulgarelli <bulgarelli@iasfbo.inaf.it>

	* src/Packet.cpp (Packet::createPacketType): bool Packet::createPacketType(char* fileName, bool isprefix, word dimprefix) bug fix when the configuration files are read more than one time

2013-09-17  Andrea Bulgarelli <bulgarelli@iasfbo.inaf.it>

* include/InputPacketStream.h (InputPacketStream): 
+2 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ public:
    /// \return A pointer telemetry packet. Make attention: the object returned is one of the TM packet object of the array of this object. Don't delete it!
    Packet* readPacket() throw(PacketExceptionIO*);

    Packet* decodePacket(byte* stream);

protected:

    Input* in;
+4 −0
Original line number Diff line number Diff line
@@ -90,6 +90,10 @@ public:
    /// \param stream A pointer to the stream of byte, with prefix and packet
    bool verifyPacketValue(byte* stream);

    /// Sets all the fields of the packet with correct value contained into the input ByteStream.
    /// \param stream A pointer to the stream of byte, with prefix and packet
    bool setPacketValue(byte* stream);

    /// Verifies if within the ByteStream passed with arguments it's present a correct packet.
    ///	\pre The structure of the stream must be loaded.
    /// \param prefix This is the prefix of the packet.
+13 −0
Original line number Diff line number Diff line
@@ -174,3 +174,16 @@ dword InputPacketStream::getPacketDimension(byte* stream) {
		delete tempHeader;
		return dim;
}

Packet* PacketLib::InputPacketStream::decodePacket(byte* stream) {

	int index = detPacketType(stream);
	if(index > 0) {
		Packet* p = getPacketType(index);
		p->setPacketValue(stream);
		return p;
	}
	else
		return 0;

}
+21 −2
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ bool Packet::createPacketType(char* fileName, bool isprefix, word dimprefix) thr
        if(file.open(argv))
        {
            delete[] argv;
            file.setpos(0);
            /// retrieve name of packet header
            name = file.getLine();
            /// find the PacketHeader section
@@ -158,8 +159,8 @@ bool Packet::createPacketType(char* fileName, bool isprefix, word dimprefix) thr
                                if(!section_found)
                                    throw new PacketExceptionFileFormat("It's impossibile to identify the type of source data field. Expected block, noblock or rblock keyword.");

                                delete[] block;
                                delete[] typeOfPacket;
                                //delete[] block;
                                //delete[] typeOfPacket;

                                if(dataField->sourceDataField->loadFields(file))
                                {
@@ -854,3 +855,21 @@ bool Packet::verifyPacketValue(byte* stream) {

	return verifyPacketValue(prefix, packet);
}

bool Packet::setPacketValue(byte* stream) {
	dword dimPre = 0;
	if(thereisprefix)
			dimPre += dimPrefix;
	ByteStream* prefix = new ByteStream(stream, dimPre, bigendian);

	dword dim = 0;
	dword dimHeader = header->getDimension();
	dim += dimHeader;
	tempHeader->setStream(stream+dimPre, dimHeader, bigendian);
	header->setByteStream(tempHeader);
	dim += header->getDimensionOfPacketLenght() + 1;
	ByteStream* packet = new ByteStream(stream+dimPre, dim, bigendian);

	return setPacketValue(prefix, packet);

}