Skip to content

Commit

Permalink
🐛 (BufferedSerial): Register sigio again after disableDeepSleep
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Jul 10, 2024
1 parent 6ea7c2d commit 24203bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/CoreBufferedSerial/source/CoreBufferedSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ auto CoreBufferedSerial::readable() -> bool
void CoreBufferedSerial::disableDeepSleep()
{
_serial.enable_input(true);

if (_sigio_callback != nullptr) {
_serial.sigio(mbed::Callback<void()> {[this] { _sigio_callback(); }});
}
}

void CoreBufferedSerial::enableDeepSleep()
Expand Down
18 changes: 18 additions & 0 deletions drivers/CoreBufferedSerial/tests/CoreBufferedSerial_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,21 @@ TEST_F(CoreBufferedSerialTest, disableDeepSleep)
coreserial.disableDeepSleep();
ASSERT_TRUE(spy_BufferedSerial_getEnableInput());
}

TEST_F(CoreBufferedSerialTest, sigioAfterDisableDeepSleep)
{
auto mock_function = MockFunction<void()> {};

coreserial.sigio(mock_function.AsStdFunction());

EXPECT_CALL(mock_function, Call);
auto on_sigio_callback = spy_BufferedSerial_getSigioCallback();
on_sigio_callback();

coreserial.enableDeepSleep();
coreserial.disableDeepSleep();

EXPECT_CALL(mock_function, Call);
on_sigio_callback = spy_BufferedSerial_getSigioCallback();
on_sigio_callback();
}

0 comments on commit 24203bb

Please sign in to comment.