Loading include/InputPacketStream.h +2 −1 Original line number Diff line number Diff line Loading @@ -62,8 +62,9 @@ public: /// This method read a telemetry packet /// \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() throw(PacketExceptionIO*); Packet* readPacket(bool bDecode = true) throw(PacketExceptionIO*); Packet* decodePacket(ByteStreamPtr stream); Loading include/Packet.h +3 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,9 @@ public: /// correct value virtual bool setAndVerifyPacketValue(ByteStreamPtr prefix, ByteStreamPtr packet); /// Set the internal prefix and packet. Decode only the header. virtual void setByteStreamPointers(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField); /// 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 Loading include/SourceDataField.h +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ public: virtual ~SourceDataField(); /// Sets the stream of byte. This method assigns the value of stream for each field of part of packet virtual bool setByteStream(ByteStreamPtr s, bool onlySections = false) { PartOfPacket::setByteStream(s); }; virtual bool setByteStream(ByteStreamPtr s, bool onlySections = false) { PartOfPacket::setByteStream(s); return true; }; /// Gets the total max dimension in bytes of source data field virtual dword getMaxDimension() = 0; Loading src/ByteStream.cpp +16 −30 Original line number Diff line number Diff line Loading @@ -97,7 +97,6 @@ PacketLib::ByteStream::ByteStream(ByteStreamPtr b0, ByteStreamPtr b1, ByteStream mem_allocation_constructor = true; /// Streams are swapped dword i = 0; dword dim = 0; if(b0 == 0 && b1 == 0 && b2 == 0) { Loading @@ -113,33 +112,20 @@ PacketLib::ByteStream::ByteStream(ByteStreamPtr b0, ByteStreamPtr b1, ByteStream stream = (byte*) new byte[byteInTheStream]; this->bigendian = (b0!=0?b0->isBigendian():(b1!=0?b1->isBigendian():(b2!=0?b2->isBigendian():false))); //TODO AZ: fare il memcpy if(b0 != 0) { dim = b0->getDimension(); for(; i<b0->getDimension(); i++) stream[i] = b0->stream[i]; memcpy(stream, b0->stream, b0->getDimension()); dim += b0->getDimension(); } if(b1 != 0) { memcpy(stream+dim, b1->stream, b1->getDimension()); dim += b1->getDimension(); dword istart = i; for(; i<dim; i++) { dword pos = i-istart; stream[i] = b1->stream[pos]; } } if(b2 != 0) { memcpy(stream+dim, b2->stream, b2->getDimension()); dim += b2->getDimension(); dword istart = i; for(; i<dim; i++) { dword pos = i-istart; stream[i] = b2->stream[pos]; } } setMemoryAllocated(true); mem_allocation_constructor = false; Loading src/File.cpp +7 −40 Original line number Diff line number Diff line Loading @@ -108,49 +108,16 @@ int File::getByte() ByteStreamPtr File::getNByte(dword N) { dword i = 0; int c1, c2; if(N == 0) return ByteStreamPtr(new ByteStream(0, bigendian)); //solo un numero pari di byte //if(N%2 != 0 || !fileOpened) return NULL; if(closed) return NULL; //ByteStreamPtr b = new ByteStream(N, bigendian); byte* stream = (byte*) new byte[N]; size_t result = fread(stream, 1, N, fp); byte_read += result; if(result != N) eof = true; for(i = 0; i<N && (c1 = getByte()) != EOI && (c2 = getByte()) != EOI; i+=2) { //File::byte_read += 2; stream[i] = c1; stream[i+1] = c2; /* if(bigendian) { //se la macchina e' bigendian, non e' necessario effettuare scambi di byte b->stream[i] = c1; b->stream[i+1] = c2; } else //little endian { //se la macchina lavora in little endian, per "far tornare i conti" e' necessario //invertire i byte letti b->stream[i] = c2; b->stream[i+1] = c1; }*/ } /*if(i != N) { ByteStreamPtr b1 = new ByteStream(i, bigendian); for(int j = 0; j<i; j++) b1->stream[j] = b->stream[j]; delete b; b = b1; } */ //for(; i<N; i++) // b->stream[i] = 0; //return b; return ByteStreamPtr(new ByteStream(stream, i, bigendian, false)); return ByteStreamPtr(new ByteStream(stream, result, bigendian, false)); } Loading Loading
include/InputPacketStream.h +2 −1 Original line number Diff line number Diff line Loading @@ -62,8 +62,9 @@ public: /// This method read a telemetry packet /// \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() throw(PacketExceptionIO*); Packet* readPacket(bool bDecode = true) throw(PacketExceptionIO*); Packet* decodePacket(ByteStreamPtr stream); Loading
include/Packet.h +3 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,9 @@ public: /// correct value virtual bool setAndVerifyPacketValue(ByteStreamPtr prefix, ByteStreamPtr packet); /// Set the internal prefix and packet. Decode only the header. virtual void setByteStreamPointers(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField); /// 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 Loading
include/SourceDataField.h +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ public: virtual ~SourceDataField(); /// Sets the stream of byte. This method assigns the value of stream for each field of part of packet virtual bool setByteStream(ByteStreamPtr s, bool onlySections = false) { PartOfPacket::setByteStream(s); }; virtual bool setByteStream(ByteStreamPtr s, bool onlySections = false) { PartOfPacket::setByteStream(s); return true; }; /// Gets the total max dimension in bytes of source data field virtual dword getMaxDimension() = 0; Loading
src/ByteStream.cpp +16 −30 Original line number Diff line number Diff line Loading @@ -97,7 +97,6 @@ PacketLib::ByteStream::ByteStream(ByteStreamPtr b0, ByteStreamPtr b1, ByteStream mem_allocation_constructor = true; /// Streams are swapped dword i = 0; dword dim = 0; if(b0 == 0 && b1 == 0 && b2 == 0) { Loading @@ -113,33 +112,20 @@ PacketLib::ByteStream::ByteStream(ByteStreamPtr b0, ByteStreamPtr b1, ByteStream stream = (byte*) new byte[byteInTheStream]; this->bigendian = (b0!=0?b0->isBigendian():(b1!=0?b1->isBigendian():(b2!=0?b2->isBigendian():false))); //TODO AZ: fare il memcpy if(b0 != 0) { dim = b0->getDimension(); for(; i<b0->getDimension(); i++) stream[i] = b0->stream[i]; memcpy(stream, b0->stream, b0->getDimension()); dim += b0->getDimension(); } if(b1 != 0) { memcpy(stream+dim, b1->stream, b1->getDimension()); dim += b1->getDimension(); dword istart = i; for(; i<dim; i++) { dword pos = i-istart; stream[i] = b1->stream[pos]; } } if(b2 != 0) { memcpy(stream+dim, b2->stream, b2->getDimension()); dim += b2->getDimension(); dword istart = i; for(; i<dim; i++) { dword pos = i-istart; stream[i] = b2->stream[pos]; } } setMemoryAllocated(true); mem_allocation_constructor = false; Loading
src/File.cpp +7 −40 Original line number Diff line number Diff line Loading @@ -108,49 +108,16 @@ int File::getByte() ByteStreamPtr File::getNByte(dword N) { dword i = 0; int c1, c2; if(N == 0) return ByteStreamPtr(new ByteStream(0, bigendian)); //solo un numero pari di byte //if(N%2 != 0 || !fileOpened) return NULL; if(closed) return NULL; //ByteStreamPtr b = new ByteStream(N, bigendian); byte* stream = (byte*) new byte[N]; size_t result = fread(stream, 1, N, fp); byte_read += result; if(result != N) eof = true; for(i = 0; i<N && (c1 = getByte()) != EOI && (c2 = getByte()) != EOI; i+=2) { //File::byte_read += 2; stream[i] = c1; stream[i+1] = c2; /* if(bigendian) { //se la macchina e' bigendian, non e' necessario effettuare scambi di byte b->stream[i] = c1; b->stream[i+1] = c2; } else //little endian { //se la macchina lavora in little endian, per "far tornare i conti" e' necessario //invertire i byte letti b->stream[i] = c2; b->stream[i+1] = c1; }*/ } /*if(i != N) { ByteStreamPtr b1 = new ByteStream(i, bigendian); for(int j = 0; j<i; j++) b1->stream[j] = b->stream[j]; delete b; b = b1; } */ //for(; i<N; i++) // b->stream[i] = 0; //return b; return ByteStreamPtr(new ByteStream(stream, i, bigendian, false)); return ByteStreamPtr(new ByteStream(stream, result, bigendian, false)); } Loading