15-11-2017
Visit associated GitHub repository
Visit reference documentation page

Troubleshooting IO issues using LoggingIoAbstraction

Within the MockIoAbstraction.h header there is an implementation of BasicIoAbstraction that delegates through a logging layer. If you are having difficulty determining what your code is sending and receiving, this could be useful. You simply introduce the logging abstraction between your regular abstraction and the device you're having trouble with. For example:

LoggingIoAbstraction loggingAbstraction(internalDigitalIo());

ComponentThatNeedsDebugging debugging(internalDigitalIo());
ComponentThatNeedsDebugging debugging(asIoRef(loggingAbstraction));

Mock objects for use with Unit testing

This library itself is quite well tested, and further it makes unit testing your code easier. There is a MockIoAbstraction that provides very easy support for mocking out an IoAbstraction. You just provide how many sync() calls to store in the internal buffer:

MockedIoAbstraction mockIo(numberOfCycles = 6);

There is a simulated version of the EepromAbstraction, this uses a small amount of memory to store the EEPROM state, to avoid writes to ROM during testing.

MockEepromAbstraction myRom(romSize = 128);

There is no need for a mock task manager, just use the regular instance, it has accessors to get hold of tasks if needed. Be sure to call reset() after each test that interacts with it.

These Mock interfaces are fully documented in the reference docs

Go back to the IoAbstraction page

These may be of interest

Want to let us know about something?

We use cookies to analyse traffic and to personalise content. We also embed Twitter and Youtube on some pages, these companies have their own privacy policies.

See the privacy policy and terms of use of this site should you need more information or wish to adjust your settings.