Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

No need to wait after Wire.requestFrom() and it should not be used together with Wire.beginTransmission(). #3

Copy link
Copy link
@Koepel

Description

@Koepel
Issue body actions

In the file "FOSSASAT-1/Code/FossaSat1/power_control.cpp", in the function "Power_Control_INA2256_Check()", there is Wire.beginTransmission() just before the Wire.requestFrom(). That Wire.beginTransmission() may be removed.
The timeout after the Wire.requestFrom() may be removed as well.

Explanation: Common-mistakes, number 1 and 3.

This section:

  // try to read
  Wire.beginTransmission(INA_ADDR);
  Wire.requestFrom((uint8_t)INA_ADDR, (uint8_t)2);
  uint32_t start = millis();
  while(!Wire.available()) {
    if(millis() - start >= INA_TIMEOUT) {
      // timed out
      return(false);
    }
  }

can be reduced to:

  // try to read
  Wire.requestFrom((uint8_t)INA_ADDR, (uint8_t)2);

If you want to check if the data was received, then you can do this:

  // try to read
  Wire.requestFrom((uint8_t)INA_ADDR, (uint8_t)2);
  if(Wire.available() != 2) {
    return(false);
  }

or this:

  // try to read
  if(Wire.requestFrom((uint8_t)INA_ADDR, (uint8_t)2) != 2)
    return(false);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.