Skip to content

Feat handle open port error#22

Merged
NestorDP merged 24 commits into
mainfrom
feat-handle-open-port-error
Feb 5, 2026
Merged

Feat handle open port error#22
NestorDP merged 24 commits into
mainfrom
feat-handle-open-port-error

Conversation

@NestorDP

@NestorDP NestorDP commented Feb 3, 2026

Copy link
Copy Markdown
Owner

Pull Request

Description

Iplement handle for open and close serial port erros. create new init and mapErros methods

Related Issue(s)

  • NA

Checklist

  • I have tested this code thoroughly.
  • My code follows the project's coding standards.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive error handling for serial port operations in the littlebot_base driver. The changes introduce a new error type system with explicit error codes instead of boolean success/failure indicators, and adds an initialization method to handle port opening separately from object construction.

Changes:

  • Introduces SerialError enum to represent different serial port error conditions
  • Adds init() method to ILittlebotDriver interface for explicit initialization after construction
  • Updates serial port methods (open, close, read, write) to return error codes and be marked noexcept
  • Creates mapSerialError() helper method to translate SerialError to DriverError
  • Adds new DriverError enum values for serial-specific errors
  • Removes early serial port opening from factory, deferring to explicit init() call

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
littlebot_base/include/littlebot_base/i_serial_port.hpp Adds SerialError enum, updates interface methods to return SerialError and be noexcept, fixes spelling errors in comments
littlebot_base/include/littlebot_base/serial_port.hpp Updates method signatures to match new interface (SerialError return types, noexcept)
littlebot_base/include/littlebot_base/i_littlebot_driver.hpp Adds init() pure virtual method, removes constructor from interface, adds protected default constructor
littlebot_base/include/littlebot_base/littlebot_driver.hpp Adds init() method, port/baudrate parameters and member variables, updates documentation
littlebot_base/include/littlebot_base/types.hpp Adds four new DriverError enum values for serial port errors with aligned comments
littlebot_base/src/serial_port.cpp Implements error handling in open/close methods with try-catch blocks and SerialError returns
littlebot_base/src/littlebot_driver.cpp Implements init() and mapSerialError() methods, removes base class constructor call
littlebot_base/src/littlebot_driver_factory.cpp Removes serial port opening from factory, adds port/baudrate to constructor call
littlebot_base/test/mocks/mock_serial_port.hpp Updates mock to match new interface signatures with SerialError and noexcept
littlebot_base/test/test_littlebot_driver.cpp Adds default mock behavior for open() returning SerialError::None, updates constructor call with port/baudrate

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread littlebot_base/include/littlebot_base/littlebot_driver.hpp Outdated
Comment thread littlebot_base/src/littlebot_driver.cpp
Comment on lines 46 to 52
// Set default behavior for open to return true
ON_CALL(*serial_, open(testing::_, testing::_))
.WillByDefault(testing::Return(littlebot_base::SerialError::None));

driver_ = std::make_unique<littlebot_base::LittlebotDriver>(
serial_, state_buffer_, command_buffer_, joint_names_);
serial_, state_buffer_, command_buffer_, joint_names_, "/dev/TEST_PORT", 115200);
}

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR claims to have added tests to cover the changes (as stated in the checklist), but there are no tests for the new init() method. Tests should be added to verify that init() correctly handles various SerialError conditions (None, PortUnavailable, InsufficientPermissions, ConfigBaudrateFailed, AlreadyOpen) and properly maps them to the corresponding DriverError values.

Copilot uses AI. Check for mistakes.
Comment thread littlebot_base/src/serial_port.cpp Outdated
Comment thread littlebot_base/include/littlebot_base/littlebot_driver.hpp Outdated
Comment thread littlebot_base/src/littlebot_driver_factory.cpp
Comment thread littlebot_base/include/littlebot_base/littlebot_driver.hpp Outdated
Comment thread littlebot_base/src/littlebot_driver.cpp Outdated
Comment thread littlebot_base/test/test_littlebot_driver.cpp Outdated
Comment thread littlebot_base/include/littlebot_base/serial_port.hpp Outdated
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@NestorDP NestorDP merged commit 264f605 into main Feb 5, 2026
2 checks passed
@NestorDP NestorDP deleted the feat-handle-open-port-error branch February 5, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants