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

Packet* InputPacketStream::readPacket(int decodeType) and Packet*...

Packet* InputPacketStream::readPacket(int decodeType) and Packet* getPacket(ByteStreamPtr packet, int decodeType = 2)
parent 27f60cb3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -64,9 +64,13 @@ public:
    /// \pre The setInput method must be invocated
    /// \param bDecode if true decode the method will decode the data fields.
    /// \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(bool bDecode = true) throw(PacketExceptionIO*);
    Packet* readPacket(int decodeType = 2) throw(PacketExceptionIO*);

    Packet* decodePacket(ByteStreamPtr stream);
	/// get a Packet* from a ByteStream
	/// \pre the prefix has been removed
	/// \param packet the stream that contains the source packet without the prefix
	/// \param decodeType (0) do not decode anything (1) decode only sections (prefix, header, data field header, source data field fixed part, source data field variable part) (2) decode blocks (all sections + all blocks of the ‘source data field variable part’)
    Packet* getPacket(ByteStreamPtr packet, int decodeType = 2) throw(PacketException*) throw(PacketException*);

protected:

+4 −1
Original line number Diff line number Diff line
@@ -64,9 +64,12 @@ public:
    /// correct value
    virtual bool setAndVerifyPacketValue(ByteStreamPtr prefix, ByteStreamPtr packet);

	/// Set the internal prefix and packet. Decode only the header.
	/// Set the internal prefix and packet. 
	virtual void setByteStreamPointers(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField);
	
	/// Set the internal prefix and packet.
	virtual void setByteStreamPointers(ByteStreamPtr prefix, ByteStreamPtr packet);

    /// Sets all the fields of the packet with correct value contained into the input ByteStream.
    ///	\pre The structure of the stream must be loaded.
    /// \param prefix This is the prefix of the packet
+17 −5
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ void InputPacketStream::setInput(Input* in)



Packet* InputPacketStream::readPacket(bool bDecode) throw(PacketExceptionIO*)
Packet* InputPacketStream::readPacket(int decodeType) throw(PacketExceptionIO*)
{
    unsigned dimHeader = getHeaderDimension();
    unsigned dimPrefix = getPrefixDimension();
@@ -148,9 +148,10 @@ Packet* InputPacketStream::readPacket(bool bDecode) throw(PacketExceptionIO*)

		Packet* p = packetType[pindex];

		if(bDecode)
		if(decodeType > 0)
		{
	        if(!p->setPacketValue(b0, b1, b2)) //gli stream diventano del packet
			bool onlySection = decodeType==1?true:false;
	        if(!p->setPacketValue(b0, b1, b2, onlySection)) //gli stream diventano del packet
	            throw new PacketExceptionIO("it is impossible to resolve the packet.");
		}
		else
@@ -184,13 +185,24 @@ dword InputPacketStream::getPacketDimension(ByteStreamPtr stream) {
		return dim;
}

Packet* PacketLib::InputPacketStream::decodePacket(ByteStreamPtr stream) {
Packet* PacketLib::InputPacketStream::getPacket(ByteStreamPtr stream, int decodeType) throw(PacketException*){

	int index = detPacketType(stream);
	if(index > 0) {
		Packet* p = getPacketType(index);
		p->setPacketValue(stream->stream);
		
		if(decodeType > 0)
		{
			bool onlySection = decodeType==1?true:false;
	        if(!p->setPacketValue(stream->stream, onlySection)) //gli stream diventano del packet
	            throw new PacketExceptionIO("it is impossible to resolve the packet.");
		}
		else
		{
			p->setByteStreamPointers(0, stream);
		}
		return p;
		
	}
	else
		return 0;
+5 −0
Original line number Diff line number Diff line
@@ -299,6 +299,11 @@ void Packet::setByteStreamPointers(ByteStreamPtr prefix, ByteStreamPtr packetHea
    memByteStream(prefix, packet);
}

void Packet::setByteStreamPointers(ByteStreamPtr prefix, ByteStreamPtr packet)
{
    memByteStream(prefix, packet);
}

bool Packet::setPacketValue(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField, bool onlySections)
{
	setByteStreamPointers(prefix, packetHeader, packetDataField);