From 45ae10565b7cdd8193a9bdbf2e53535be25c45c2 Mon Sep 17 00:00:00 2001 From: Matt Scalzo Date: Sun, 10 May 2020 17:39:00 -0400 Subject: [PATCH] Fix Comments More I further clarified my comments and also renamed index to dataStart to make it more clear what it was. --- .../io_procs/AHRSInputIOProcessor.cpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/bfs/implementations/breadcrumbs/io_procs/AHRSInputIOProcessor.cpp b/bfs/implementations/breadcrumbs/io_procs/AHRSInputIOProcessor.cpp index 970d6af..f507517 100644 --- a/bfs/implementations/breadcrumbs/io_procs/AHRSInputIOProcessor.cpp +++ b/bfs/implementations/breadcrumbs/io_procs/AHRSInputIOProcessor.cpp @@ -120,14 +120,15 @@ void AHRSInputIOProcessor::loop() std::cerr << "Error occured while trying to read bytes." << std::endl; } - /* This gets the index of the bytes for the Euler angles in the captured buffer - * szBuff. The 14 index of the message is where the last byte of the roll angle is. - * It finds the first byte of the message and then finds where the data is. This - * allows me loop backward through each group of bytes since the order needs to - * be reversed because the AHRS is in Big Endian. + /* This gets the index of the bytes for the Euler angles in the captured + * buffer (szBuff). First, it finds the first byte of the message (i). Then, + * it finds the 14th index of the message (dataStart). This is where the last + * byte of the roll angle is. This allows me loop backward through each group + * of bytes, since the order needs to be reversed because the AHRS is in Big + * Endian. * i is where the message starts in the buffer. - * index = i + 14, which is where the data we want starts (for Roll). + * dataStart = i + 14, which is where the data we want starts (for Roll). * To find Pitch and Yaw, we add 8 and 16 respectivly. * * MESSAGE STRUCTURE: @@ -142,12 +143,12 @@ void AHRSInputIOProcessor::loop() * | index| index + 8| index + 16| * +-------------------------+-------------------------+-------------------------+ */ - int index = -1; + int dataStart = -1; for (int i=0; i < 32; i++) { if (szBuff[i] == 0xFA && szBuff[i+1] == 0xFF && szBuff[i+2] == 0x36) { - index = i + 14; + dataStart = i + 14; break; } } @@ -156,13 +157,13 @@ void AHRSInputIOProcessor::loop() unsigned char pitchArray[8]; unsigned char yawArray[8]; // Puts the bytes for each angle in their own array backwards, since they are sent in big endian - if (index != -1) + if (dataStart != -1) { for (int i = 0; i < 8; i++) { - rollArray[i] = szBuff[index - i]; - pitchArray[i] = szBuff[index - i + 8]; - yawArray[i] = szBuff[index - i + 16]; + rollArray[i] = szBuff[dataStart - i]; + pitchArray[i] = szBuff[dataStart - i + 8]; + yawArray[i] = szBuff[dataStart - i + 16]; } }