Skip to main content

StaTable

MISRA C:2012-aware state machine design and C code generation for embedded systems.

License Python Tests MISRA

StaTable is a Python-based tool for designing state machines and generating MISRA C:2012-compliant C code for embedded systems. It provides a CLI, a Python SDK, and a PySide6 GUI.


Features

  • MISRA C:2012-aware C code generation — validated with cppcheck + official MISRA addon
  • Multi-layer state machines — Driver / Middleware / Application with priority execution
  • State actions (Entry / Exit / Do) — table-driven dispatch with user-code markers
  • 35 validation rules across 11 categories with AI-assisted diagnostics
  • Marker-based user code preservation — regenerate without losing your custom code
  • CLI + SDK + GUI — integrate into any workflow
  • Pure Python — easy to install and extend
  • i18n: English and Simplified Chinese (简体中文)

Installation

SDK + CLI only:

pip install statable

With GUI (PySide6):

pip install "statable[gui]"

Development:

pip install "statable[dev]"

Quick Start

CLI

statable-cli version
statable-cli generate --xml design.xml --out generated/ --format json
statable-cli validate --xml design.xml --format json --exit-on-error

Python SDK

from statable import State, Event, Transition, StateMachine, StateType, EventKind
from statable.global_defs import GlobalDefinitions
from codegen import CCodeGenerator, CodeGenerationConfig

sm = StateMachine()
sm.add_state(State(name="Idle", type=StateType.INITIAL))
sm.add_state(State(name="Running"))
sm.add_event(Event(name="START", kind=EventKind.SIGNAL))
sm.set_initial("Idle")
sm.add_transition(Transition(source="Idle", event="START", target="Running"))

cfg = CodeGenerationConfig()
gen = CCodeGenerator(config=cfg)
files = gen.generate_all_layers([("Application", sm)], GlobalDefinitions())
gen.save_generated_code(files, "generated/")

GUI

python -m statable

Menu: Language / 语言 → switch between English and 简体中文.


Requirements

  • Python 3.10 or later
  • PySide6 >= 6.0 (for GUI)
  • pycparser (optional, for advanced parsing)


License

Apache License 2.0 — free for commercial and personal use.

See LICENSE for details.


Acknowledgments

  • PySide6 — Qt 6 for Python
  • cppcheck — static analysis
  • All contributors and users

If StaTable helps you, please consider giving it a ⭐ on GitHub.

Metadata

Release files for statable 3.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for statable 3.1.1
File Size Uploaded
statable-3.1.1.tar.gz 333.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for statable 3.1.1
File Interpreter ABI Platform
statable-3.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 630.7 kB

Release files / statable-3.1.1.tar.gz

Download URL statable-3.1.1.tar.gz
Size 333.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5481038cb8fcb05e6216fd3ac21aae6d4d5c7b4433faf8846f856cf3072fae0b
BLAKE2b-256 checksum
How to use checksums
dbd1e3982fdcc257812e3928654f39d0e9c012593d7abad3db3c5c2e1e55daeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / statable-3.1.1-py3-none-any.whl

Download URL statable-3.1.1-py3-none-any.whl
Size 296.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b9576a1d5a434e83fac4564f86e9d28cdecdcf507fb1a756b88f94406139147
BLAKE2b-256 checksum
How to use checksums
ee74ec0a1fbd285cf6dfdd4f811440cffd86d525a62dd4aa54d47ee29f48aa2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release history Release notifications | RSS feed

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

This release

3.1.1 This release

2 release files

3.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page