# timka/watchdogdev architecture

> Architecture diagram of the GitHub repository timka/watchdogdev, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/timka/watchdogdev
- Repository: https://github.com/timka/watchdogdev

## Overview

##### Main Components

a) Core Components:
- Python Application Layer
- Watchdogdev Extension Module (C Implementation)
- Linux Kernel Watchdog Interface
- Hardware/Software Watchdog Device

b) Key Interactions:
- System Calls (ioctl)
- Device File Operations (/dev/watchdog)

**Top Layer: Python Application**
**↓**
**Middle Layer: Watchdogdev Extension Module**
**↓**
**Bottom Layer: Linux Kernel & Hardware**

##### Specific Elements

- Rectangle: Python Application (User Code)
- Hexagon: Watchdogdev Extension Module (src/watchdogdev.c)
- Rectangle with rounded corners: Linux Kernel Watchdog API
- Circle: Hardware/Software Watchdog Device

- Double lines: Device file operations

##### Important Details to Highlight

a) API Methods (in a side panel):
- get_support()
- identity
- magic_close()
- Other ioctl wrapper methods

b) Configuration Options:
- WDIOF_MAGICCLOSE flag
- Other watchdog flags and options

##### Implementation Details

- File paths (/dev/watchdog)
- Support for both hardware and software (softdog) watchdog implementations
- ioctl command mappings

##### Flow Description
Typical usage flow:
1. Module import
2. Device opening
3. Command execution
4. Device closing (with magic_close support)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Python Layer"
        PythonApp["Python Application"]:::python
        TestApp["Test Application"]:::python
    end

    subgraph "Extension Layer"
        WatchdogDev["Watchdogdev Extension Module"]:::extension
        BuildConfig["Build Configuration"]:::config
    end

    subgraph "System Layer"
        KernelAPI["Linux Kernel Watchdog API"]:::kernel
        WatchdogDevice[("Hardware/Software\nWatchdog Device")]:::device
        DevFile["/dev/watchdog"]:::file
    end

    subgraph "Documentation"
        Docs["Project Documentation"]:::docs
        Changes["Change History"]:::docs
        Pipeline["Deployment Pipeline"]:::pipeline
    end

    subgraph "API Methods"
        Methods["Available Methods"]:::api
        Methods --> |Includes| get_support["get_support()"]:::method
        Methods --> |Includes| identity["identity()"]:::method
        Methods --> |Includes| magic_close["magic_close()"]:::method
        Methods --> |Includes| ioctl["ioctl commands"]:::method
    end

    PythonApp --> |Uses| WatchdogDev
    TestApp --> |Tests| WatchdogDev
    WatchdogDev --> |System Calls| KernelAPI
    KernelAPI --> |Controls| WatchdogDevice
    KernelAPI --> |Operates| DevFile
    DevFile --> WatchdogDevice

    %% Click events for component mapping
    click PythonApp "https://github.com/timka/watchdogdev/blob/master/watchdogdev_test.py"
    click WatchdogDev "https://github.com/timka/watchdogdev/blob/master/src/watchdogdev.c"
    click BuildConfig "https://github.com/timka/watchdogdev/blob/master/setup.py"
    click Docs "https://github.com/timka/watchdogdev/blob/master/README.txt"
    click Changes "https://github.com/timka/watchdogdev/blob/master/CHANGES.txt"
    click Pipeline "https://github.com/timka/watchdogdev/blob/master/.github/workflows/pythonpublish.yml"

    %% Styling
    classDef python fill:#3776AB,color:white
    classDef extension fill:#6BBF47,color:white
    classDef kernel fill:#808080,color:white
    classDef device fill:#FF4B4B,color:white
    classDef file fill:#FFA500,color:white
    classDef docs fill:#4B0082,color:white
    classDef pipeline fill:#2088FF,color:white
    classDef api fill:#DEB887,color:black
    classDef method fill:#F0E68C,color:black
    classDef config fill:#20B2AA,color:white

    %% Legend
    subgraph Legend
        L1["Python Component"]:::python
        L2["Extension Module"]:::extension
        L3["Kernel Component"]:::kernel
        L4["Hardware Device"]:::device
        L5["Documentation"]:::docs
    end
```
