Skip to content

No need to remove unused data after a Wire.requestFrom(). #8

Closed
@Koepel

Description

@Koepel

In the file "IridiumSBD.cpp", currently at line 1403, there is this code:

while (wireport->available())
{
  wireport->read(); // Mop up any unexpected bytes
}

That code can be removed, since the Wire library uses packages of data and not a stream of data. There is no need to remove unused data.

Explanation: Common-mistakes#4

In the code above that, is this:

wireport->requestFrom((uint8_t)deviceaddress, 2); // Request two bytes
if (wireport->available() >= 2)

The peripheral can not send less or more. There is no need to allow that it is higher than 2.
If two bytes are requested, then test for two bytes:

if (wireport->available() == 2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions