XDM1000 (FastAPI / ese774_frame Integration)
server_fastapi provides a way to expose Xdm1000Ctrl through FastAPI using ese774_frame.
The SCPI driver is not exposed directly.
The control class instantiated on the server is Xdm1000Ctrl.
Requirements
- ese774_frame: A framework developed for the Susanoo Project.
- x_logger: Any logger may be used, but the logger developed for the Susanoo Project is recommended.
Basic Structure of XDM1000 Control
xdm1000/server_fastapi/
├── xdm1000_ctrl.py
├── xdm1000_scpi.py
└── xdm1000_worker.py:
Basic Structure of the XDM1000 Server
xdm1000/server_fastapi/
├── spec.py
├── make.py
├── models/
│ └── common.py
├── routers/
│ ├── __init__.py
│ └── xdm1000_router.py
└── clients/
├── __init__.py
├── sync_xdm1000_client.py
└── async_xdm1000_client.py
spec.py
spec.py defines the APIs exposed through FastAPI.
Rather than exposing every method of Xdm1000Ctrl, only APIs that are meaningful for external use are exposed.
These mainly include:
- Retrieving device state
- One-shot measurements
- Continuous measurements
- Statistics measurements
- Retrieving results
- Stop requests
Low-level SCPI APIs are not exposed.
response_model
Use response_model=None for APIs that directly return a dictionary, such as measurement results.
Because ese774_frame includes logic that wraps return values in value, specifying DictResponse may cause FastAPI
response validation to fail.
Therefore, APIs returning dictionaries, such as meas_one_shot(), should use response_model=None.
Router
The router inherits from ese774_frame's DeviceRouter.
from ese774_frame.routers.device_router import DeviceRouter
class Xdm1000Router(DeviceRouter):
pass
Do not implement device-specific operations in the router.
The actual operations belong in Xdm1000Ctrl.
Client
The clients provided by ese774_frame are used.
The synchronous client is imported as follows:
from xdm1000.server_fastapi.clients.sync_xdm1000_client import SyncXdm1000Client
The asynchronous client is imported as follows:
from xdm1000.server_fastapi.clients.async_xdm1000_client import AsyncXdm1000Client
Use absolute imports.
make.py
make.py is a script for generating .pyi files.
It generates the following three files:
clients/async_xdm1000_client.pyi
clients/sync_xdm1000_client.pyi
routers/xdm1000_router.pyi
Do not add unnecessary discovery logic or fallback imports.
Import and use the generators from ese774_frame directly.
Starting the Server
A representative startup script is examples/serve_start.py.
#!/usr/bin/env python3
"""Example of starting the XDM1000 FastAPI server."""
from types import SimpleNamespace
from ese774_frame.api_server import FastApiServer
from x_logger import XLogger
from xdm1000.xdm1000_ctrl import Xdm1000Ctrl
from xdm1000.server_fastapi.spec import xdm1000_api_spec
from xdm1000.server_fastapi.routers.xdm1000_router import Xdm1000Router
PORT = "/dev/cu.usbserial-10"
SERVER_HOST = "127.0.0.1"
SERVER_PORT = 8000
def main() -> None:
logger = XLogger(
log_level="debug",
logger_name="xdm1000.server",
log_mode="rotate",
log_name="xdm1000_server.log",
)
config = SimpleNamespace(
PORT=PORT,
SERVER_HOST=SERVER_HOST,
SERVER_PORT=SERVER_PORT,
)
server = FastApiServer(
device_cls=Xdm1000Ctrl,
router_cls=Xdm1000Router,
config=config,
api_spec=xdm1000_api_spec,
device_kwargs={"port": PORT},
logger=logger,
logger_name="xdm1000.server",
lifespan_msg_prefix="XDM1000",
)
server.run(
host=SERVER_HOST,
port=SERVER_PORT,
reload=False,
)
if __name__ == "__main__":
main()
Client Measurement
A representative client measurement example is examples/client_meas_volt.py.
#!/usr/bin/env python3
"""Example of measuring voltage with the XDM1000."""
from xdm1000.server_fastapi.clients.sync_xdm1000_client import SyncXdm1000Client
HOST = "127.0.0.1"
PORT = 8000
def main():
dmm = SyncXdm1000Client(HOST, PORT)
print(dmm.meas_one_shot("voltage_dc"))
if __name__ == "__main__":
main()
API Paths
ese774_frame exposes APIs using the following path format:
POST /instance/xdm1000/<api_name>
Examples:
POST /instance/xdm1000/meas_one_shot
POST /instance/xdm1000/get_state
POST /instance/xdm1000/start_continuous_meas
Notes
The FastAPI server instantiates Xdm1000Ctrl.
Xdm1000Ctrl.__init__() must accept logger, log_level, and config.
ese774_frame passes these arguments when creating the device class.
When config is provided, PORT, TIMEOUT, and BAUDRATE must be accessible from it.
Author
- Kengo NAKADA
Metadata
Release files for xdm1000-py 0.2.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xdm1000_py-0.2.10.tar.gz | 39.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xdm1000_py-0.2.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 85.8 kB
Release files / xdm1000_py-0.2.10.tar.gz
| Download URL | xdm1000_py-0.2.10.tar.gz |
|---|---|
| Size | 39.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4db4e6934d40ae6579c9cd8e33118657626c11ee3962cc8a23eed476f49c6532
|
|
BLAKE2b-256 checksum How to use checksums |
6353d33ae9df7f1e9d7a42616626cff821dc0ed068272756f6b0a457028dcebb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / xdm1000_py-0.2.10-py3-none-any.whl
| Download URL | xdm1000_py-0.2.10-py3-none-any.whl |
|---|---|
| Size | 46.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cad0c4f5dd45e644dc64a5f4e53535f7d0cbe4e36725f7508e5659ffe0e6f124
|
|
BLAKE2b-256 checksum How to use checksums |
4fb64f392428b73b751b34bde6ee82e92e3b1c35ab5640fe76082f568a30d9fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for xdm1000-py 0.2.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for xdm1000_py-0.2.10.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.