ataraxis-communication-interface 4.2.0__tar.gz → 6.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.claude/settings.local.json +7 -1
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/inspectionProfiles/profiles_settings.xml +1 -0
- ataraxis_communication_interface-6.0.0/.idea/jsonSchemas.xml +27 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/misc.xml +1 -1
- ataraxis_communication_interface-6.0.0/CLAUDE.md +292 -0
- ataraxis_communication_interface-6.0.0/LICENSE +198 -0
- ataraxis_communication_interface-6.0.0/PKG-INFO +726 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/README.md +266 -181
- ataraxis_communication_interface-6.0.0/docs/source/api.rst +58 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/docs/source/conf.py +5 -11
- ataraxis_communication_interface-6.0.0/docs/source/welcome.rst +19 -0
- ataraxis_communication_interface-6.0.0/envs/axci_dev_lin.yml +51 -0
- ataraxis_communication_interface-6.0.0/envs/axci_dev_lin_spec.txt +47 -0
- ataraxis_communication_interface-6.0.0/envs/axci_dev_osx.yml +158 -0
- ataraxis_communication_interface-6.0.0/envs/axci_dev_osx_spec.txt +154 -0
- ataraxis_communication_interface-6.0.0/envs/axci_dev_win.yml +161 -0
- ataraxis_communication_interface-6.0.0/envs/axci_dev_win_spec.txt +157 -0
- ataraxis_communication_interface-6.0.0/examples/example_interface.py +147 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/examples/example_runtime.py +68 -49
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/pyproject.toml +54 -45
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/__init__.py +51 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/communication/__init__.py +41 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/communication/messages.py +434 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/communication/mqtt.py +190 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/communication/protocols.py +1060 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/communication/serial.py +299 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/__init__.py +3 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/cli.py +295 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/config_tools.py +272 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/discovery_tools.py +442 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/mcp_execution.py +314 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/mcp_instance.py +61 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/mcp_server.py +40 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/output_tools.py +355 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/interfaces/processing_tools.py +711 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/microcontroller/__init__.py +63 -0
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/microcontroller/dataclasses.py +251 -0
- ataraxis_communication_interface-4.2.0/src/ataraxis_communication_interface/microcontroller_interface.py → ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/microcontroller/interface.py +252 -548
- ataraxis_communication_interface-6.0.0/src/ataraxis_communication_interface/microcontroller/log_processing.py +914 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/tests/communication_test.py +314 -257
- ataraxis_communication_interface-6.0.0/tests/dataclasses_test.py +305 -0
- ataraxis_communication_interface-6.0.0/tests/log_processing_test.py +1509 -0
- ataraxis_communication_interface-6.0.0/tox.ini +181 -0
- ataraxis_communication_interface-4.2.0/.claude/skills/explore-codebase/SKILL.md +0 -77
- ataraxis_communication_interface-4.2.0/.claude/skills/sun-lab-style/SKILL.md +0 -26
- ataraxis_communication_interface-4.2.0/.claude/skills/sun-lab-style/SUN_LAB_STYLE_GUIDE.md +0 -1072
- ataraxis_communication_interface-4.2.0/.mcp.json +0 -8
- ataraxis_communication_interface-4.2.0/CLAUDE.md +0 -135
- ataraxis_communication_interface-4.2.0/LICENSE +0 -674
- ataraxis_communication_interface-4.2.0/PKG-INFO +0 -1322
- ataraxis_communication_interface-4.2.0/docs/source/api.rst +0 -23
- ataraxis_communication_interface-4.2.0/docs/source/welcome.rst +0 -18
- ataraxis_communication_interface-4.2.0/envs/axci_dev_lin.yml +0 -45
- ataraxis_communication_interface-4.2.0/envs/axci_dev_lin_spec.txt +0 -42
- ataraxis_communication_interface-4.2.0/envs/axci_dev_osx.yml +0 -39
- ataraxis_communication_interface-4.2.0/envs/axci_dev_osx_spec.txt +0 -36
- ataraxis_communication_interface-4.2.0/envs/axci_dev_win.yml +0 -39
- ataraxis_communication_interface-4.2.0/envs/axci_dev_win_spec.txt +0 -36
- ataraxis_communication_interface-4.2.0/examples/example_interface.py +0 -137
- ataraxis_communication_interface-4.2.0/src/ataraxis_communication_interface/__init__.py +0 -41
- ataraxis_communication_interface-4.2.0/src/ataraxis_communication_interface/communication.py +0 -1624
- ataraxis_communication_interface-4.2.0/src/ataraxis_communication_interface/mcp_server.py +0 -131
- ataraxis_communication_interface-4.2.0/tox.ini +0 -197
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.gitattributes +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.gitignore +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/.gitignore +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/ataraxis-communication-interface.iml +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/dictionaries/project.xml +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/inspectionProfiles/Project_Default.xml +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/modules.xml +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/vcs.xml +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/docs/Makefile +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/docs/make.bat +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/docs/source/index.rst +0 -0
- {ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/src/ataraxis_communication_interface/py.typed +0 -0
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
"Bash(axci-mcp)",
|
|
5
5
|
"Bash(echo:*)",
|
|
6
6
|
"mcp__ataraxis-communication-interface__check_mqtt_broker",
|
|
7
|
-
"mcp__ataraxis-communication-interface__list_microcontrollers"
|
|
7
|
+
"mcp__ataraxis-communication-interface__list_microcontrollers",
|
|
8
|
+
"Bash(pip index:*)",
|
|
9
|
+
"Bash(pip install:*)",
|
|
10
|
+
"Bash(pip list:*)",
|
|
11
|
+
"Bash(python:*)",
|
|
12
|
+
"Bash(git stash:*)",
|
|
13
|
+
"Bash(tox:*)"
|
|
8
14
|
]
|
|
9
15
|
},
|
|
10
16
|
"enableAllProjectMcpServers": true,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="JsonSchemaMappingsProjectConfiguration">
|
|
4
|
+
<state>
|
|
5
|
+
<map>
|
|
6
|
+
<entry key="No JSON schema">
|
|
7
|
+
<value>
|
|
8
|
+
<SchemaInfo>
|
|
9
|
+
<option name="ignoredFile" value="true" />
|
|
10
|
+
<option name="name" value="No JSON schema" />
|
|
11
|
+
<option name="relativePathToSchema" value="" />
|
|
12
|
+
<option name="applicationDefined" value="true" />
|
|
13
|
+
<option name="patterns">
|
|
14
|
+
<list>
|
|
15
|
+
<Item>
|
|
16
|
+
<option name="path" value="file://$PROJECT_DIR$/pyproject.toml" />
|
|
17
|
+
</Item>
|
|
18
|
+
</list>
|
|
19
|
+
</option>
|
|
20
|
+
<option name="isIgnoredFile" value="true" />
|
|
21
|
+
</SchemaInfo>
|
|
22
|
+
</value>
|
|
23
|
+
</entry>
|
|
24
|
+
</map>
|
|
25
|
+
</state>
|
|
26
|
+
</component>
|
|
27
|
+
</project>
|
{ataraxis_communication_interface-4.2.0 → ataraxis_communication_interface-6.0.0}/.idea/misc.xml
RENAMED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
<component name="Black">
|
|
4
4
|
<option name="sdkName" value="Python 3.13" />
|
|
5
5
|
</component>
|
|
6
|
-
<component name="ProjectRootManager" version="2" project-jdk-name="
|
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="C:\Users\ikond\miniforge3\envs\axci_dev_win" project-jdk-type="Python SDK" />
|
|
7
7
|
</project>
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Claude Code Instructions
|
|
2
|
+
|
|
3
|
+
## Session start behavior
|
|
4
|
+
|
|
5
|
+
At the beginning of each coding session, before making any code changes, you should build a comprehensive
|
|
6
|
+
understanding of the codebase by invoking the `/explore-codebase` skill.
|
|
7
|
+
|
|
8
|
+
This ensures you:
|
|
9
|
+
- Understand the project architecture before modifying code
|
|
10
|
+
- Follow existing patterns and conventions
|
|
11
|
+
- Don't introduce inconsistencies or break integrations
|
|
12
|
+
|
|
13
|
+
## Style guide compliance
|
|
14
|
+
|
|
15
|
+
Before writing, modifying, or reviewing any code or documentation, you MUST invoke the appropriate skill to load
|
|
16
|
+
Ataraxis framework conventions. This applies to ALL file types:
|
|
17
|
+
|
|
18
|
+
| Task | Skill to Invoke |
|
|
19
|
+
|-------------------------------------|--------------------|
|
|
20
|
+
| Writing or modifying Python code | `/python-style` |
|
|
21
|
+
| Writing or modifying README files | `/readme-style` |
|
|
22
|
+
| Writing git commit messages | `/commit` |
|
|
23
|
+
| Writing or modifying pyproject.toml | `/pyproject-style` |
|
|
24
|
+
| Configuring tox.ini | `/tox-config` |
|
|
25
|
+
|
|
26
|
+
All contributions must strictly follow these conventions. Key conventions include:
|
|
27
|
+
- Google-style docstrings with proper sections
|
|
28
|
+
- Full type annotations with explicit array dtypes
|
|
29
|
+
- Keyword arguments for function calls
|
|
30
|
+
- Third person imperative mood for comments and documentation
|
|
31
|
+
- Proper error handling with `console.error()`
|
|
32
|
+
- 120 character line limit
|
|
33
|
+
|
|
34
|
+
## Cross-referenced library verification
|
|
35
|
+
|
|
36
|
+
Ataraxis framework projects often depend on other `ataraxis-*` or `sl-*` libraries. These libraries may be stored
|
|
37
|
+
locally in the same parent directory as this project (`/home/cyberaxolotl/Desktop/GitHubRepos/`).
|
|
38
|
+
|
|
39
|
+
**Before writing code that interacts with a cross-referenced library, you MUST:**
|
|
40
|
+
|
|
41
|
+
1. **Check for local version**: Look for the library in the parent directory (e.g., `../ataraxis-time/`,
|
|
42
|
+
`../ataraxis-base-utilities/`).
|
|
43
|
+
|
|
44
|
+
2. **Compare versions**: If a local copy exists, compare its version against the latest release or main branch on
|
|
45
|
+
GitHub:
|
|
46
|
+
- Read the local `pyproject.toml` to get the current version
|
|
47
|
+
- Use `gh api repos/Sun-Lab-NBB/{repo-name}/releases/latest` to check the latest release
|
|
48
|
+
- Alternatively, check the main branch version on GitHub
|
|
49
|
+
|
|
50
|
+
3. **Handle version mismatches**: If the local version differs from the latest release or main branch, notify the user
|
|
51
|
+
with the following options:
|
|
52
|
+
- **Use online version**: Fetch documentation and API details from the GitHub repository
|
|
53
|
+
- **Update local copy**: The user will pull the latest changes locally before proceeding
|
|
54
|
+
|
|
55
|
+
4. **Proceed with correct source**: Use whichever version the user selects as the authoritative reference for API
|
|
56
|
+
usage, patterns, and documentation.
|
|
57
|
+
|
|
58
|
+
**Why this matters**: Skills and documentation may reference outdated APIs. Always verify against the actual library
|
|
59
|
+
state to prevent integration errors.
|
|
60
|
+
|
|
61
|
+
## Available skills
|
|
62
|
+
|
|
63
|
+
Skills are distributed through the ataraxis marketplace and are loaded into Claude Code via the plugin system. They are
|
|
64
|
+
**not** stored in this repository.
|
|
65
|
+
|
|
66
|
+
### Communication plugin skills (ataraxis/plugins/communication/)
|
|
67
|
+
|
|
68
|
+
| Skill | Description |
|
|
69
|
+
|----------------------------------------|-----------------------------------------------------------------------|
|
|
70
|
+
| `/microcontroller-setup` | MCP-based microcontroller discovery, MQTT verification, and manifests |
|
|
71
|
+
| `/microcontroller-interface` | MicroControllerInterface and ModuleInterface API usage and lifecycle |
|
|
72
|
+
| `/communication-mcp-environment-setup` | MCP server connectivity diagnostics and environment verification |
|
|
73
|
+
| `/pipeline` | End-to-end pipeline orchestration and multi-controller planning |
|
|
74
|
+
| `/extraction-configuration` | ExtractionConfig parameters, generation, validation, and lifecycle |
|
|
75
|
+
| `/log-input-format` | Reference for NPZ archive format, source IDs, and DataLogger output |
|
|
76
|
+
| `/log-processing` | Orchestrate log archive processing workflow via MCP tools |
|
|
77
|
+
| `/log-processing-results` | Reference for output data formats and event distribution analysis |
|
|
78
|
+
|
|
79
|
+
### Microcontroller plugin skills (ataraxis/plugins/microcontroller/)
|
|
80
|
+
|
|
81
|
+
| Skill | Description |
|
|
82
|
+
|--------------------|-------------------------------------------------------------------------------|
|
|
83
|
+
| `/firmware-module` | Firmware-side Module subclass implementation, command execution, and SendData |
|
|
84
|
+
|
|
85
|
+
### Automation plugin skills (ataraxis/plugins/automation/)
|
|
86
|
+
|
|
87
|
+
The automation plugin provides cross-cutting development skills; this table lists those relevant to this Python
|
|
88
|
+
library. Language-specific style skills (C++, C#) are omitted because they do not apply here.
|
|
89
|
+
|
|
90
|
+
| Skill | Description |
|
|
91
|
+
|----------------------------|--------------------------------------------------------------------------------|
|
|
92
|
+
| `/explore-codebase` | Perform in-depth codebase exploration at session start |
|
|
93
|
+
| `/explore-dependencies` | Explore installed ataraxis dependency APIs for reuse opportunities |
|
|
94
|
+
| `/python-style` | Apply Ataraxis framework Python coding conventions (REQUIRED for code changes) |
|
|
95
|
+
| `/readme-style` | Apply Ataraxis framework README conventions |
|
|
96
|
+
| `/pyproject-style` | Apply Ataraxis framework pyproject.toml conventions |
|
|
97
|
+
| `/tox-config` | Apply Ataraxis framework tox.ini conventions |
|
|
98
|
+
| `/api-docs` | Apply Ataraxis framework Sphinx API documentation conventions |
|
|
99
|
+
| `/project-layout` | Apply Ataraxis framework project directory structure conventions |
|
|
100
|
+
| `/commit` | Draft Ataraxis framework style-compliant git commit messages |
|
|
101
|
+
| `/pr` | Draft a style-compliant pull request summary for the active branch |
|
|
102
|
+
| `/release` | Draft style-compliant release notes from merged pull requests |
|
|
103
|
+
| `/skill-design` | Generate and verify Claude Code skill files |
|
|
104
|
+
| `/audit-facts` | Audit documentation for factual accuracy against source code |
|
|
105
|
+
| `/audit-style` | Audit files for style and convention compliance against framework checklists |
|
|
106
|
+
|
|
107
|
+
## MCP server integration
|
|
108
|
+
|
|
109
|
+
This library provides an MCP server (`axci mcp`) that exposes microcontroller discovery, MQTT broker checking,
|
|
110
|
+
manifest management, extraction configuration management, and log data processing tools. When working with this project
|
|
111
|
+
or its dependencies, prefer using available MCP tools over direct code execution when appropriate.
|
|
112
|
+
|
|
113
|
+
**Guidelines for MCP usage:**
|
|
114
|
+
|
|
115
|
+
1. **Discover available tools**: At the start of a session, check which MCP servers are connected and what tools
|
|
116
|
+
they provide. Use these tools when they offer functionality relevant to the current task.
|
|
117
|
+
|
|
118
|
+
2. **Prefer MCP for runtime operations**: For operations like microcontroller discovery, MQTT broker verification,
|
|
119
|
+
log archive assembly, extraction configuration management, and batch log processing workflows, use MCP tools
|
|
120
|
+
rather than writing and executing Python code directly. MCP tools provide:
|
|
121
|
+
- Consistent, tested interfaces
|
|
122
|
+
- Proper resource management and cleanup
|
|
123
|
+
- Formatted output designed for user display
|
|
124
|
+
|
|
125
|
+
3. **Use MCP for cross-library operations**: When dependency libraries (e.g., `ataraxis-data-structures`,
|
|
126
|
+
`ataraxis-time`) provide MCP servers, explore and use their tools for interacting with those libraries.
|
|
127
|
+
|
|
128
|
+
4. **Fall back to code when necessary**: Use direct code execution when:
|
|
129
|
+
- No MCP tool exists for the required functionality
|
|
130
|
+
- The task requires custom logic not covered by available tools
|
|
131
|
+
- Writing or modifying library source code
|
|
132
|
+
|
|
133
|
+
## Distribution model
|
|
134
|
+
|
|
135
|
+
This project follows a dual distribution model. The library source code, tests, CLI, and MCP server implementation live
|
|
136
|
+
in this repository (`ataraxis-communication-interface`) and are distributed via PyPI. Claude Code skills and MCP server
|
|
137
|
+
registration are distributed separately through the [ataraxis](https://github.com/Sun-Lab-NBB/ataraxis) marketplace as
|
|
138
|
+
plugins:
|
|
139
|
+
|
|
140
|
+
- **communication** plugin (`ataraxis/plugins/communication/`): Registers the `axci mcp` server with compatible MCP
|
|
141
|
+
clients and provides communication-specific skills for microcontroller setup, pipeline orchestration, log processing,
|
|
142
|
+
extraction configuration, and post-processing verification.
|
|
143
|
+
- **microcontroller** plugin (`ataraxis/plugins/microcontroller/`): Provides firmware-side skills for implementing
|
|
144
|
+
custom hardware Module subclasses in the companion
|
|
145
|
+
[ataraxis-micro-controller](https://github.com/Sun-Lab-NBB/ataraxis-micro-controller) C++ library. The
|
|
146
|
+
`/firmware-module` skill complements the `/microcontroller-interface` skill from the communication plugin, covering
|
|
147
|
+
the firmware counterpart to the PC-side ModuleInterface.
|
|
148
|
+
- **automation** plugin (`ataraxis/plugins/automation/`): Provides shared development skills that enforce Ataraxis
|
|
149
|
+
framework coding conventions (Python style, README style, commit messages, pyproject.toml, tox configuration) and
|
|
150
|
+
general-purpose codebase exploration tools.
|
|
151
|
+
|
|
152
|
+
When modifying skills, edit the SKILL.md files in the ataraxis marketplace repository, not in this repository.
|
|
153
|
+
When modifying the MCP server implementation or library code, edit the source files in this repository.
|
|
154
|
+
|
|
155
|
+
## Project context
|
|
156
|
+
|
|
157
|
+
This is **ataraxis-communication-interface**, a Python library that provides the centralized interface for exchanging
|
|
158
|
+
commands and data between Arduino and Teensy microcontrollers and host computers. It abstracts hardware module
|
|
159
|
+
management, serial/USB communication, MQTT data exchange, and provides log processing for extracting hardware event
|
|
160
|
+
data from DataLogger archives.
|
|
161
|
+
|
|
162
|
+
### Key areas
|
|
163
|
+
|
|
164
|
+
| Directory | Purpose |
|
|
165
|
+
|---------------------------------------------|-------------------------------------------------------------------------------|
|
|
166
|
+
| `src/ataraxis_communication_interface/` | Main library source code |
|
|
167
|
+
| `src/.../communication/` | Serial/MQTT communication package (`protocols`, `messages`, `serial`, `mqtt`) |
|
|
168
|
+
| `src/.../microcontroller/interface.py` | Core MicroControllerInterface and ModuleInterface ABC |
|
|
169
|
+
| `src/.../microcontroller/dataclasses.py` | Manifest and extraction configuration data structures |
|
|
170
|
+
| `src/.../microcontroller/log_processing.py` | Log data processing pipeline for extracting module/kernel events |
|
|
171
|
+
| `src/.../interfaces/` | CLI (`axci`), MCP server entry point, shared instance, and MCP tool groups |
|
|
172
|
+
| `tests/` | Test suite (dataclasses, communication, log_processing) |
|
|
173
|
+
| `examples/` | Example ModuleInterface subclass and runtime usage |
|
|
174
|
+
| `docs/` | Sphinx API documentation source |
|
|
175
|
+
|
|
176
|
+
### Architecture
|
|
177
|
+
|
|
178
|
+
- **MicroControllerInterface**: Multiprocessing architecture for bidirectional microcontroller communication.
|
|
179
|
+
Constructor requires `controller_id`, `data_logger`, `module_interfaces`, `buffer_size`, `port`, and `name` as
|
|
180
|
+
positional arguments; `__init__` writes a microcontroller manifest entry associating the controller_id with the
|
|
181
|
+
human-readable name and its module list. A dedicated communication process handles serial I/O via
|
|
182
|
+
`SerialCommunication` and dispatches received messages to the appropriate `ModuleInterface` based on
|
|
183
|
+
`(module_type, module_id)` routing. A watchdog thread monitors process health. Commands and parameters flow from
|
|
184
|
+
the main process through an `MPQueue` to the communication process.
|
|
185
|
+
- **ModuleInterface**: Abstract base class that users subclass to define hardware module behavior. Requires
|
|
186
|
+
`module_type`, `module_id`, and `name` as positional arguments; optional `error_codes` and `data_codes` sets
|
|
187
|
+
control message routing. Three abstract methods: `initialize_remote_assets()`, `terminate_remote_assets()`, and
|
|
188
|
+
`process_received_data()`. Public methods `send_command()` and `send_parameters()` use LRU-cached message
|
|
189
|
+
construction for performance. `reset_command_queue()` sends a dequeue command to the microcontroller. The
|
|
190
|
+
`type_id` property combines `(type << 8) | id` for dispatch lookups.
|
|
191
|
+
- **Serial Communication**: `SerialCommunication` wraps `TransportLayer` from `ataraxis-transport-layer-pc` for
|
|
192
|
+
CRC16-CCITT checksummed serial I/O. Supports 12 message protocols (`SerialProtocols` enum) and 252 numpy data
|
|
193
|
+
prototypes (`SerialPrototypes` enum) covering all numpy scalar and array types. `send_message()` accepts
|
|
194
|
+
command and parameter message objects; `receive_message()` returns typed message objects (`ModuleData`,
|
|
195
|
+
`ModuleState`, `KernelData`, `KernelState`, `ReceptionCode`, `ControllerIdentification`,
|
|
196
|
+
`ModuleIdentification`). All received data is timestamped via `PrecisionTimer` and logged to `DataLogger` through
|
|
197
|
+
an `MPQueue`.
|
|
198
|
+
- **MQTT Communication**: `MQTTCommunication` provides publish/subscribe messaging over MQTT via `paho-mqtt`.
|
|
199
|
+
Constructor takes `ip`, `port`, and optional `monitored_topics`. `get_data()` returns `(topic, message)`
|
|
200
|
+
tuples from an internal `Queue` populated by the on_message callback.
|
|
201
|
+
- **Microcontroller Manifest**: `MicroControllerManifest` (`YamlConfig` subclass) associates controller IDs with
|
|
202
|
+
human-readable names and their module lists in a `microcontroller_manifest.yaml` file alongside DataLogger
|
|
203
|
+
archives. `MicroControllerSourceData` stores per-controller entries with a tuple of `ModuleSourceData` objects.
|
|
204
|
+
`write_microcontroller_manifest()` creates or updates the manifest. Used by log processing discovery to identify
|
|
205
|
+
which archives were produced by ataraxis-communication-interface and to route processing by source ID.
|
|
206
|
+
- **Extraction Configuration**: `ExtractionConfig` (`YamlConfig` subclass) specifies which controllers, modules,
|
|
207
|
+
and event codes to extract from log archives. `ControllerExtractionConfig` contains per-controller settings with
|
|
208
|
+
`ModuleExtractionConfig` (module_type, module_id, event_codes) and optional `KernelExtractionConfig`.
|
|
209
|
+
`create_extraction_config()` generates a precursor config from a manifest with empty event codes.
|
|
210
|
+
- **Log Processing**: Pipeline for extracting hardware module and kernel event data from DataLogger `.npz` archives.
|
|
211
|
+
Requires a `microcontroller_manifest.yaml` in the log directory for source ID resolution and validation. Supports
|
|
212
|
+
sequential and parallel (`ProcessPoolExecutor`) processing with a 2000-message threshold for parallelization.
|
|
213
|
+
Uses `LogArchiveReader` for archive access and `ProcessingTracker` for job lifecycle management.
|
|
214
|
+
`run_log_processing_pipeline()` orchestrates local (all jobs) and remote (single job by ID) execution modes.
|
|
215
|
+
Outputs Polars DataFrames as Feather (Arrow IPC) files in a `microcontroller_data/` subdirectory.
|
|
216
|
+
- **MCP Server**: `FastMCP` instance (`name="ataraxis-communication-interface"`, `json_response=True`) defined in
|
|
217
|
+
`interfaces/mcp_instance.py`, with 19 tools split across `interfaces/discovery_tools.py`, `config_tools.py`,
|
|
218
|
+
`processing_tools.py`, and `output_tools.py`. The tool modules register on the shared instance via `@mcp.tool()`
|
|
219
|
+
decorators and are imported for their side effects by the thin `interfaces/mcp_server.py`, which also exposes
|
|
220
|
+
`run_server()`. Tool categories: microcontroller discovery (2), log archive management (1), manifest management (2),
|
|
221
|
+
recording discovery (1), extraction config management (3), batch processing execution (2), processing status and
|
|
222
|
+
management (5), and output verification and cleanup (3). Batch log processing uses `JobExecutionState` (in
|
|
223
|
+
`interfaces/mcp_execution.py`, accessed via `get_execution_state()` / `set_execution_state()`) with budget-based
|
|
224
|
+
worker allocation: the execution manager divides the CPU budget evenly among concurrent parallel jobs (snapped to
|
|
225
|
+
multiples of 5) with a sqrt-derived saturation floor. The MCP server is registered with MCP clients via the
|
|
226
|
+
**communication** plugin in the ataraxis marketplace, not directly from this repository.
|
|
227
|
+
- **CLI**: Click command group (`axci`) with `id` for microcontroller discovery, `mqtt` for broker verification,
|
|
228
|
+
`config` subgroup (`create`, `show`) for extraction configuration management, `process` for log data processing,
|
|
229
|
+
and `mcp` for starting the MCP server.
|
|
230
|
+
|
|
231
|
+
### Key patterns
|
|
232
|
+
|
|
233
|
+
- **Daemon Communication Process**: The communication process is a daemon process requiring an explicit `stop()`
|
|
234
|
+
call. Callers are responsible for setting an appropriate multiprocessing start method if needed.
|
|
235
|
+
- **Message Protocol Stack**: Four levels — `SerialCommunication` (USB/UART), `TransportLayer` (CRC checksums,
|
|
236
|
+
frame encoding), message protocols (12 types via `SerialProtocols` enum), and data prototypes (252 numpy types
|
|
237
|
+
via `SerialPrototypes` enum).
|
|
238
|
+
- **LRU Caching**: `ModuleInterface` caches command messages (`maxsize=32`) and parameter messages (`maxsize=16`)
|
|
239
|
+
to avoid redundant serialization during repeated operations.
|
|
240
|
+
- **Type-ID Dispatch**: Received messages are routed to `ModuleInterface` instances via a `(module_type, module_id)`
|
|
241
|
+
→ `type_id` (`uint16`) lookup, where `type_id = (type << 8) | id`.
|
|
242
|
+
- **Manifest-Based Log Discovery**: `microcontroller_manifest.yaml` files tag DataLogger output directories with
|
|
243
|
+
source-to-name mappings. Log processing discovery and batch preparation use manifests to identify which archives
|
|
244
|
+
were produced by ataraxis-communication-interface and to route jobs by source ID.
|
|
245
|
+
- **Columnar Data Extraction**: Log processing accumulates data in parallel lists via `_ColumnAccumulator`, converts
|
|
246
|
+
to numpy arrays, then builds Polars DataFrames for efficient Feather output.
|
|
247
|
+
- **Budget-Based Worker Allocation**: The MCP execution manager computes a worker budget as `available_cores - 2`,
|
|
248
|
+
divides it among concurrent jobs snapped to multiples of 5, with a sqrt-derived saturation floor based on message
|
|
249
|
+
count (`ceil(sqrt(messages / 1000))`).
|
|
250
|
+
- **Frozen Dataclasses**: Inner data classes (`ModuleSourceData`, `MicroControllerSourceData`,
|
|
251
|
+
`ModuleExtractionConfig`, `KernelExtractionConfig`, `ControllerExtractionConfig`) use `frozen=True` for
|
|
252
|
+
immutability and `slots=True` for performance. The top-level `MicroControllerManifest` and `ExtractionConfig`
|
|
253
|
+
classes extend `YamlConfig` and are mutable (not frozen).
|
|
254
|
+
|
|
255
|
+
### Code standards
|
|
256
|
+
|
|
257
|
+
- MyPy strict mode with full type annotations
|
|
258
|
+
- Google-style docstrings
|
|
259
|
+
- 120 character line limit
|
|
260
|
+
- Ruff for formatting and linting
|
|
261
|
+
- Python 3.12, 3.13, 3.14 support
|
|
262
|
+
- See style skills for complete conventions
|
|
263
|
+
|
|
264
|
+
### Workflow guidance
|
|
265
|
+
|
|
266
|
+
Non-obvious facts for the most common modifications. Read the cited files for full context.
|
|
267
|
+
|
|
268
|
+
- **MicroControllerInterface** (`microcontroller/interface.py`): the communication loop runs in `_runtime_cycle()`,
|
|
269
|
+
a static method executed in a spawned daemon process; a watchdog thread in the main process monitors liveness.
|
|
270
|
+
Commands flow from the main process through an `MPQueue` to the communication process, which requires an explicit
|
|
271
|
+
`stop()` call. Test against microcontroller hardware or in test mode.
|
|
272
|
+
- **ModuleInterface** (`microcontroller/interface.py`): subclasses must implement `initialize_remote_assets()`,
|
|
273
|
+
`terminate_remote_assets()`, and `process_received_data()`. `send_command()` and `send_parameters()` use
|
|
274
|
+
LRU-cached message construction; `reset_command_queue()` sends a dequeue command. See
|
|
275
|
+
`examples/example_interface.py` for a reference subclass.
|
|
276
|
+
- **Serial communication** (`communication/protocols.py`, `messages.py`, `serial.py`): `SerialProtocols`
|
|
277
|
+
(12 protocols) and `SerialPrototypes` (252 prototypes) define the protocol layer. Command classes pack bytes via
|
|
278
|
+
the `packed_data` property; reception classes parse header bytes via properties.
|
|
279
|
+
- **MQTT communication** (`communication/mqtt.py`): `paho-mqtt` v2 client with callback reception into a `Queue`;
|
|
280
|
+
`get_data()` returns `(topic, message)` tuples or `None`, and the `has_data` property checks queue state.
|
|
281
|
+
- **Data classes and manifests** (`microcontroller/dataclasses.py`): inner classes are frozen — create new instances
|
|
282
|
+
rather than mutating; `MicroControllerManifest` and `ExtractionConfig` are mutable `YamlConfig` subclasses.
|
|
283
|
+
`create_extraction_config()` builds a precursor config with empty event codes.
|
|
284
|
+
- **Log processing** (`microcontroller/log_processing.py`): `run_log_processing_pipeline()` supports local (all jobs)
|
|
285
|
+
and remote (single job by ID) modes; the `config` parameter is a `Path` loaded internally; the parallelization
|
|
286
|
+
threshold is 2000 messages; `ProcessingTracker` manages job lifecycle via YAML state files.
|
|
287
|
+
- **CLI** (`interfaces/cli.py`): use `console.echo()` for output and `console.error()` for errors; the `config`
|
|
288
|
+
subgroup demonstrates nested Click command groups.
|
|
289
|
+
- **MCP tools** (`interfaces/*_tools.py`): register on the shared instance from `interfaces/mcp_instance.py` via
|
|
290
|
+
`@mcp.tool()`, add new tool modules to the side-effect import list in `interfaces/mcp_server.py`, and return
|
|
291
|
+
JSON-serializable `dict[str, Any]`. Execution uses `JobExecutionState` (`interfaces/mcp_execution.py`) with
|
|
292
|
+
budget-based worker allocation.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format.
|
|
185
|
+
|
|
186
|
+
Copyright 2024 Sun Lab, Cornell University
|
|
187
|
+
|
|
188
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
189
|
+
you may not use this file except in compliance with the License.
|
|
190
|
+
You may obtain a copy of the License at
|
|
191
|
+
|
|
192
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
193
|
+
|
|
194
|
+
Unless required by applicable law or agreed to in writing, software
|
|
195
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
196
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
197
|
+
See the License for the specific language governing permissions and
|
|
198
|
+
limitations under the License.
|