Skip to content

Conversation

eternal-echo
Copy link
Contributor

Checklist

  • Component contains License
  • Component contains README.md
  • Component contains idf_component.yml file with url field defined
  • Component was added to upload job
  • Component has an example project
  • Component has a test_app (pytest-based testing)
  • CI passing

Change description

Add ESP-IDF ISO-TP Component

This PR adds the esp_isotp component, providing a complete ISO-TP (ISO 15765-2) protocol implementation for ESP-IDF. ISO-TP is essential for automotive and industrial applications requiring CAN-based diagnostic communication.

Key Features

  • Complete ISO-TP Protocol: Full implementation of ISO 15765-2 standard
  • Multi-Frame Support: Handles both Single Frame (SF) and Multi-Frame (MF) transmission
  • Flow Control: Configurable Block Size and STmin parameters
  • Thread-Safe Design: Safe for use in multi-threaded applications with interrupt context support
  • Memory Efficient: Optimized buffer management for embedded systems
  • QEMU Testing: Complete test suite running in QEMU environment

Component Structure

esp_isotp/
├── LICENSE                   # Apache 2.0 License
├── README.md                # Comprehensive documentation
├── idf_component.yml        # Component manifest with URL
├── include/esp_isotp.h      # Public API
├── src/                     # Implementation files
├── isotp-c/                 # Git submodule for protocol core
└── examples/echo/           # Echo example with pytest

Testing

  • Automated Testing: Comprehensive pytest suite with QEMU integration
  • Test Coverage: Single/Multi-frame, flow control, error scenarios
  • CI Ready: Tests run automatically without hardware requirements
  • Example Project: ISO-TP echo server demonstrating bidirectional communication

Integration Status

  • ✅ Added to upload job workflow
  • ✅ Component auto-discovered by clang-tidy test_app
  • ✅ All required files present and properly configured
  • ✅ Follows ESP-IDF coding standards and best practices

Use Cases

  • Automotive diagnostic systems (UDS over CAN)
  • Industrial CAN communication requiring >8 byte messages
  • IoT gateways with CAN connectivity
  • ESP32-based diagnostic tools and interfaces

This component fills a critical gap for CAN-based applications in the ESP-IDF ecosystem, providing a robust, production-ready ISO-TP implementation with comprehensive testing and documentation.

}

/// isotp-c library stub function: print debug message
/**

Check warning

Code scanning / clang-tidy

Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] Warning

Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
/// isotp-c library stub function: print debug message
/**
* @brief Print a formatted debug message from isotp-c.
*

Check warning

Code scanning / clang-tidy

Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] Warning

Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
#ifdef ISO_TP_TRANSMIT_COMPLETE_CALLBACK
if (config->tx_callback) {
isotp_set_tx_done_cb(&isotp->link, esp_isotp_tx_wrapper, isotp);
}

Check warning

Code scanning / clang-tidy

Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] Warning

Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
@github-actions github-actions bot changed the title feat(esp_isotp): add ISO-TP protocol component's echo example feat(esp_isotp): add ISO-TP protocol component's echo example (IEC-376) Sep 14, 2025
Copy link
Collaborator

@suda-morris suda-morris left a comment

Choose a reason for hiding this comment

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

Please bump the component version.

And this leftover nitpick: #563 (comment)

@eternal-echo eternal-echo force-pushed the features/isotp-doc-echo branch 4 times, most recently from b9a00a4 to 77032d6 Compare September 16, 2025 12:05
@eternal-echo eternal-echo force-pushed the features/isotp-doc-echo branch from 77032d6 to 38aab01 Compare September 16, 2025 12:07
@eternal-echo eternal-echo marked this pull request as ready for review September 16, 2025 12:08
@eternal-echo
Copy link
Contributor Author

Please bump the component version.

And this leftover nitpick: #563 (comment)

Could I get a Copilot reviewer first? :)

@suda-morris suda-morris requested a review from Copilot September 17, 2025 05:41
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a complete ISO-TP (ISO 15765-2) protocol component for ESP-IDF, enabling automotive and industrial CAN communication applications that require multi-frame data transmission.

  • Implements full ISO-TP protocol with single-frame and multi-frame support
  • Provides comprehensive echo example with pytest-based testing
  • Includes QEMU integration for automated testing without hardware

Reviewed Changes

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

Show a summary per file
File Description
esp_isotp/src/esp_isotp.c Moves size validation check earlier in TWAI frame transmission function
esp_isotp/pytest.ini Configures pytest for QEMU-based testing with CAN bus simulation
esp_isotp/examples/echo/sdkconfig.defaults Sets default configuration for echo example
esp_isotp/examples/echo/pytest_isotp_echo.py Comprehensive test suite for ISO-TP echo functionality
esp_isotp/examples/echo/main/isotp_echo_main.c Main application implementing ISO-TP echo server
esp_isotp/examples/echo/main/idf_component.yml Component dependency configuration
esp_isotp/examples/echo/main/Kconfig.projbuild Configuration menu for echo example
esp_isotp/examples/echo/main/CMakeLists.txt Build configuration for main component
esp_isotp/examples/echo/conftest.py Pytest configuration for CAN interface setup
esp_isotp/examples/echo/README.md Documentation for echo example usage
esp_isotp/examples/echo/CMakeLists.txt Top-level build configuration for echo example

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Total 60KB data simulating firmware transmission.
"""
chunk_size = 2048
iterations = 30 # 60KB total
Copy link
Preview

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

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

The comment '60KB total' is inconsistent with the actual calculation. 30 iterations × 2048 bytes = 61440 bytes = 60KB. Consider updating the comment to '30 iterations × 2K = 60KB' to be more precise.

Suggested change
iterations = 30 # 60KB total
iterations = 30 # 30 iterations × 2K = 60KB

Copilot uses AI. Check for mistakes.

ESP_ERROR_CHECK(esp_isotp_poll(isotp_handle));

// Small delay to ensure accurate STmin timing and prevent 100% CPU usage
vTaskDelay(pdMS_TO_TICKS(CONFIG_EXAMPLE_ECHO_POLL_DELAY_MS));
Copy link
Preview

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

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

The configuration symbol CONFIG_EXAMPLE_ECHO_POLL_DELAY_MS is used but not defined in the provided Kconfig file. This should reference CONFIG_EXAMPLE_ECHO_POLL_DELAY_MS which is defined in Kconfig.projbuild.

Copilot uses AI. Check for mistakes.

cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
set(COMPONENTS main)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants