Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calcOverhead Function Incorrect? #18

Closed
gfvalvo opened this issue Apr 15, 2020 · 3 comments
Closed

calcOverhead Function Incorrect? #18

gfvalvo opened this issue Apr 15, 2020 · 3 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@gfvalvo
Copy link

gfvalvo commented Apr 15, 2020

It looks to me like the calcOverhead function actually finds the LAST occurrence of START_BYTE in the payload, not the first one as stated in the comments (and assumed by the unpackPacket function).

To find the FIRST occurrence, do:

void SerialTransfer::calcOverhead(uint8_t arr[], const uint8_t &len) {
  overheadByte = 0xFF;

  for (uint8_t i = 0; i < len; i++) {
    if (arr[i] == START_BYTE) {
      overheadByte = i;
      break;
    }
  }
}

Or, run the existing loop backwards.

@PowerBroker2 PowerBroker2 self-assigned this Apr 15, 2020
@PowerBroker2 PowerBroker2 added the question Further information is requested label Apr 15, 2020
@PowerBroker2
Copy link
Owner

The documentation might be off. I originally tried a different way of doing COBS before settling on the design I have now. Let me do some testing to see if there is truly a bug.

@PowerBroker2 PowerBroker2 added the bug Something isn't working label Apr 15, 2020
@PowerBroker2
Copy link
Owner

Yup, it's a bug. I'll fix it asap - thank you so much for bringing this to my attention!

PowerBroker2 added a commit that referenced this issue Apr 15, 2020
@PowerBroker2
Copy link
Owner

Should be fixed in release 1.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants