Commit 4752568c authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

Merge branch 'master' of github.com:ASTRO-BO/PacketLib

Some changes to File::fsize() and open
parents a0c1d7e8 fc170118
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
2014-01-10	Andrea Zoli <zoli@iasfbo.inaf.it>
TAG v3.1.0
* InputPacketStream: expose ByteStream instead of byte*.
* Fixed low level buffer (byte*) deallocation.

2013-12-23  Andrea Bulgarelli <bulgarelli@iasfbo.inaf.it>
* PartOfPacket: get set PTC=5 PFC=2 (real double precision) TODO: this does
not work in a 32 bit system
+1 −1
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ makelibdir:

#clean: delete all files from the current directory that are normally created by building the program. 
clean:
	$(DEL_FILE) $(OBJECTS_DIR)/*.o
	$(DEL_FILE) $(OBJECTS_DIR)/*.o test/*.o
	$(DEL_FILE) *~ core *.core
	$(DEL_FILE) $(LIB_DESTDIR)/*.a
	$(DEL_FILE) $(LIB_DESTDIR)/*.so*
+4 −4
Original line number Diff line number Diff line
@@ -49,12 +49,12 @@ public:

    ///It returns the index of the packet type contained in the stream. The stream* contains also the prefix (if present)
    /// \return The index of packet type if it's recognized. 0 if packet isn't recognized.
    /// \param packet A byte* that contains the packet.
    int detPacketType(byte* packet);
    /// \param packet A ByteStream pointer that contains the packet.
    int detPacketType(ByteStreamPtr packet);

	///It returns the total dimension of the packet contained in the stream (without prefix). The stream* contains also the prefix (if present)
	///\param The stream with the prefix (if present)
    dword getPacketDimension(byte* stream);
    dword getPacketDimension(ByteStreamPtr stream);

    /// This method sets the generic input of the stream
    /// \param in An input.
@@ -65,7 +65,7 @@ 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);
    Packet* decodePacket(ByteStreamPtr stream);

protected:

+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ PacketLib::ByteStream::~ByteStream()
    {
        ByteStream::count_object_deleted++;
        //cout << "ByteStream::~ByteStream() delete[] stream;" << endl;
//        delete[] stream;
        delete[] stream;
        stream = 0;
    }
    else
+6 −6
Original line number Diff line number Diff line
@@ -69,14 +69,14 @@ int InputPacketStream::detPacketType(ByteStreamPtr prefix, ByteStreamPtr packet)
}


int InputPacketStream::detPacketType(byte* packet)
int InputPacketStream::detPacketType(ByteStreamPtr packet)
{
    /// Iterate through list and output each element.
    /// The packetType 0 is the packet not recognized
    for (dword i = 1; i<numberOfPacketType; i++)
    {
        Packet* p = getPacketType(i);
        if(p->verifyPacketValue(packet))
        if(p->verifyPacketValue(packet->stream))
            return i;
    }
    return 0;
@@ -158,7 +158,7 @@ Packet* InputPacketStream::readPacket() throw(PacketExceptionIO*)
    }
}

dword InputPacketStream::getPacketDimension(byte* stream) {
dword InputPacketStream::getPacketDimension(ByteStreamPtr stream) {
		dword dimPre = 0;
		if(prefix)
			dimPre += dimPrefix;
@@ -168,18 +168,18 @@ dword InputPacketStream::getPacketDimension(byte* stream) {
		dword dimHeader = headerReference->getDimension();
		dim += dimHeader;
		ByteStreamPtr tempHeader = ByteStreamPtr(new ByteStream());
		tempHeader->setStream(stream+dimPre, dimHeader, bigendian);
		tempHeader->setStream(stream->stream+dimPre, dimHeader, bigendian);
		headerReference->setByteStream(tempHeader);
		dim += headerReference->getPacketLength();
		return dim;
}

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

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