Skip to content
Snippets Groups Projects
Commit 2f7f6f61 authored by Andrea Zoli's avatar Andrea Zoli
Browse files

Expose ByteStream instead of byte* in InputPacketStream.

parent b7b41ae7
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment