Skip to content

Update serial device to support reading functionality - #44

Merged
automas-dev merged 3 commits into
mainfrom
agents/update-serial-device-read-support-68b305b0
Sep 12, 2026
Merged

automas-dev merged 3 commits into
mainfrom
agents/update-serial-device-read-support-68b305b0

Conversation

@automas-dev

Copy link
Copy Markdown
Owner

This pull request enhances the serial device driver to support reading operations, along with several structural improvements. The key changes include:

  • New Read Functionality: Introduced a serial_read function that allows reading a specified number of bytes into a buffer. The previous single-character read function was renamed to serial_read_char.
  • Device Struct: Created a serial_device_t struct to hold the port information, following the pattern used in other device implementations.
  • Function Signature Updates: Modified the serial_write and serial_write_str functions to return the number of bytes written, improving error handling.
  • Parameter Addition: Updated the io_device_serial_open function to accept a port parameter, which is stored in the new device struct.
  • Code Organization: Rearranged static functions to the end of the driver implementation file for better readability and maintenance.
  • Documentation: Added short docstrings to the serial driver header, clarifying function purposes and parameters.

These changes improve the functionality and maintainability of the serial device driver, aligning it with existing patterns in the codebase.

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.

🟡 Changes recommended

Critical write-buffering and blocking-read issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Enhances the serial device driver with buffered reads, per-port state, and updated I/O APIs.

Changes:

  • Adds bulk and single-character read support.
  • Stores the selected serial port in the device structure.
  • Updates write functions to return byte counts.
  • Updates API documentation and signatures.
File summaries
File Summary Findings
src/kernel/src/kernel/device/serial.c Adds port-aware device callbacks and cleanup. Critical: blocking reads can spin in kernel mode without yielding.
src/kernel/src/drivers/serial.c Implements buffered reads and count-returning writes. Critical: writes may lose bytes despite reporting success. Nit: add serial-driver tests.
src/kernel/include/kernel/device/serial.h Updates the device-open signature. None.
src/kernel/include/drivers/serial.h Documents the updated serial APIs. None.
Review details

Suppressed comments (1)

src/kernel/src/drivers/serial.c:46

  • This adds a blocking public read path without corresponding serial-driver tests. The repository already has driver tests and port-I/O fakes, so please cover null/zero-length buffers, the requested byte count, and the port-specific polling/read behavior to prevent regressions that can otherwise hang the test target or read from the wrong UART.
size_t serial_read(uint16_t port, char * buff, size_t count) {
    if (!buff) {
        return 0;
    }

  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/kernel/src/drivers/serial.c
Comment thread src/kernel/src/kernel/device/serial.c
@automas-dev
automas-dev merged commit 7e2dac4 into main Sep 12, 2026
4 checks passed
@automas-dev
automas-dev deleted the agents/update-serial-device-read-support-68b305b0 branch September 12, 2026 20:46
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.

2 participants