Skip to content

Commit

Permalink
Check that the superframe flag is set properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Thealexbarney committed Oct 17, 2018
1 parent 0fb7069 commit 6a9e00f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions C/src/structures.h
Expand Up @@ -130,6 +130,7 @@ struct Block {
};

struct Frame {
int IndexInSuperframe;
ConfigData* Config;
Channel* Channels[MAX_CHANNEL_COUNT];
Block Blocks[MAX_BLOCK_COUNT];
Expand Down
13 changes: 13 additions & 0 deletions C/src/unpack.c
Expand Up @@ -32,7 +32,20 @@ At9Status UnpackFrame(Frame* frame, BitReaderCxt* br)
for (int i = 0; i < blockCount; i++)
{
ERROR_CHECK(UnpackBlock(&frame->Blocks[i], br));

if (frame->Blocks[i].FirstInSuperframe && frame->IndexInSuperframe)
{
return ERR_UNPACK_SUPERFRAME_FLAG_INVALID;
}
}

frame->IndexInSuperframe++;

if (frame->IndexInSuperframe == frame->Config->FramesPerSuperframe)
{
frame->IndexInSuperframe = 0;
}

return ERR_SUCCESS;
}

Expand Down

0 comments on commit 6a9e00f

Please sign in to comment.