Skip to content

Commit

Permalink
Merge pull request #44 from RI-SE/fix_missing_traj_point
Browse files Browse the repository at this point in the history
Fix missing traj point
  • Loading branch information
Robert108 authored Oct 23, 2023
2 parents 323bcd5 + a49f38f commit 789df73
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
6 changes: 0 additions & 6 deletions iso22133.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ typedef struct {
} timeServer;
} ObjectSettingsType;

/*! ISO message constants */
enum ISOConstantsType {
ISO_TRAJ_HEADER_SIZE = 91,
ISO_TRAJ_WAYPOINT_SIZE = 70
};

typedef enum {
TRAJECTORY_INFO_RELATIVE_TO_OBJECT = 1,
TRAJECTORY_INFO_RELATIVE_TO_ORIGIN = 2,
Expand Down
12 changes: 6 additions & 6 deletions src/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ enum ISOMessageReturnValue decodeISOHeader(

if (debug) {
printf("syncWord = 0x%x\n", HeaderData->syncWord);
printf("messageLength = 0x%x\n", HeaderData->messageLength);
printf("ackReqProtVer = 0x%x\n", HeaderData->ackReqProtVer);
printf("transmitterID = 0x%x\n", HeaderData->transmitterID);
printf("receiverID = 0x%x\n", HeaderData->receiverID);
printf("messageCounter = 0x%x\n", HeaderData->messageCounter);
printf("messageID = 0x%x\n", HeaderData->messageID);
printf("messageLength = %d bytes, [0x%x]\n", HeaderData->messageLength, HeaderData->messageLength);
printf("ackReqProtVer = %d, [0x%x]\n", HeaderData->ackReqProtVer, HeaderData->ackReqProtVer);
printf("transmitterID = %d, [0x%x]\n", HeaderData->transmitterID, HeaderData->transmitterID);
printf("receiverID = %d, [0x%x]\n", HeaderData->receiverID, HeaderData->receiverID);
printf("messageCounter = %d, [0x%x]\n", HeaderData->messageCounter, HeaderData->messageCounter);
printf("messageID = %d, [0x%x]\n", HeaderData->messageID, HeaderData->messageID);
}

return retval;
Expand Down
4 changes: 2 additions & 2 deletions src/traj.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ssize_t decodeTRAJMessageHeader(
printf("\tTrajectory name: %s\n", TRAJHeaderData.trajectoryName);
printf("\tTrajectory info: %u\n", TRAJHeaderData.trajectoryInfo);
printf("\tTRAJ length: %ld bytes\n", TRAJHeaderData.header.messageLength
- sizeof(TRAJHeaderType) - sizeof(TRAJFooterType) + sizeof(FooterType));
- sizeof(TRAJHeaderType) + sizeof(HeaderType) - sizeof(TRAJFooterType) + sizeof(FooterType));
}

// Fill output struct with parsed data
Expand All @@ -244,7 +244,7 @@ enum ISOMessageReturnValue convertTRAJHeaderToHostRepresentation(TRAJHeaderType*
trajectoryHeaderData->trajectoryID = TRAJHeaderData->trajectoryID;
memcpy(trajectoryHeaderData->trajectoryName, TRAJHeaderData->trajectoryName, sizeof(TRAJHeaderData->trajectoryName));
trajectoryHeaderData->trajectoryInfo = TRAJHeaderData->trajectoryInfo;
trajectoryHeaderData->trajectoryLength = trajectoryLength - sizeof(TRAJHeaderType) - sizeof(TRAJFooterType) + sizeof(FooterType);
trajectoryHeaderData->trajectoryLength = trajectoryLength - sizeof(TRAJHeaderType) + sizeof(HeaderType) - sizeof(TRAJFooterType) + sizeof(FooterType);
trajectoryHeaderData->nWaypoints = trajectoryHeaderData->trajectoryLength/sizeof(TRAJPointType);

return MESSAGE_OK;
Expand Down
2 changes: 1 addition & 1 deletion tests/osem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class EncodeOSEM : public ::testing::Test
}
void TearDown() override
{
setTransmitterID(0xFFFF);
setTransmitterID(0xFFFFFFFF);
}

ObjectSettingsType settings;
Expand Down
13 changes: 9 additions & 4 deletions tests/traj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class DecodeTRAJHeader : public ::testing::Test
DecodeTRAJHeader() {
decodeBuffer[0] = 0x7F;
decodeBuffer[1] = 0x7E; // preamble
decodeBuffer[2] = 0x52;
decodeBuffer[3] = 0x00;
decodeBuffer[2] = 0x1E;
decodeBuffer[3] = 0x03;
decodeBuffer[4] = 0x00;
decodeBuffer[5] = 0x00; // TODO Message length
decodeBuffer[5] = 0x00; // Message length 0x31E (sizeof(TRAJHeaderType) + sizeof(TRAJPointType) * 21 + sizeof(TRAJFooterType)) - (sizeof(TRAJHeaderType) + sizeof(HeaderType)) - (sizeof(TRAJFooterType) + sizeof(FooterType));
decodeBuffer[6] = 0x02; // Acknowledge protocol version
decodeBuffer[7] = 0x34;
decodeBuffer[8] = 0x12;
Expand Down Expand Up @@ -145,7 +145,7 @@ class DecodeTRAJHeader : public ::testing::Test
&header,
decodeBuffer,
sizeof(decodeBuffer),
false);
true);
ASSERT_GT(res, 0);
}

Expand All @@ -171,6 +171,11 @@ TEST_F(DecodeTRAJHeader, Name)
}
}

TEST_F(DecodeTRAJHeader, nWaypoints)
{
EXPECT_EQ(header.nWaypoints, 21);
}

class EncodeTRAJPoint : public ::testing::Test
{
protected:
Expand Down

0 comments on commit 789df73

Please sign in to comment.