adafruit / adafruit/Adafruit-MCP23017-Arduino-Library

If the I2C-Bus is not available for any reason 32 Bytes of free heap gets consumed each cycle..

Open
#104 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
385
Forks
204
PR merge metrics
No merged PRs in 30d

Description

This method needs to be changed:

bool Adafruit_MCP23XXX::begin_I2C(uint8_t i2c_addr, TwoWire *wire) {
i2c_dev = new Adafruit_I2CDevice(i2c_addr, wire);
return i2c_dev->begin();
}

into:

bool Adafruit_MCP23XXX::begin_I2C(uint8_t i2c_addr, TwoWire *wire) {
if (i2c_dev != nullptr) {
delete i2c_dev;
i2c_dev = nullptr;
}
i2c_dev = new Adafruit_I2CDevice(i2c_addr, wire);
return i2c_dev->begin();
}

Also, this seems to be a general problem of this library.. only a successful run seems to avoid free heap problems..

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at Adafruit_MCP23XXX::begin_I2C and reproduce repeated initialization attempts with the I2C bus unavailable. Verify that failed cycles no longer consume heap, and check whether the same ownership problem appears in other initialization paths in the library.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.