Skip to main content

Python library for medjc09 hub

Project description

MEDJC09 Hub Python

PyPI Python

MED-JC09デバイスと通信するためのPythonライブラリです。

概要

このライブラリは、MED-JC09ハブデバイスとシリアル通信を行うための非同期Pythonインターフェースを提供します。以下の機能をサポートしています:

  • デバイスとの接続管理
  • コマンド送信とレスポンス処理
  • ポーリングモードによる定期的なデータ取得
  • 各種センサーデータの取得

インストール方法

Ryeを使用してインストールします:

rye add medjc09-hub-python

または、pipを使用する場合:

pip install medjc09-hub-python

使用方法

基本的な使い方

import asyncio
from medjc09 import Medjc09

async def main():
    device = Medjc09('/dev/tty.usbserial-1234')
    await device.connect()
    
    # バージョン情報の取得
    version = await device.get_version()
    print(f"Firmware version: {version}")
    
    # ベース電圧の取得
    voltage = await device.get_base_voltage()
    print(f"Base voltage: {voltage}V")
    
    await device.close()

asyncio.run(main())

ポーリングモードの使用

デバイスの初期化時にポーリングハンドラーを指定することで、ポーリングモードを使用できます。

def polling_handler(report):
    print(f"Voltage: {report['voltage']}V")
    print(f"ME voltages: {report['me_voltage']}")

async def main():
    device = Medjc09('/dev/tty.usbserial-1234', polling_handler=polling_handler)
    await device.connect()
    
    # ポーリングモード開始
    await device.start_polling()
    
    # 10秒間ポーリング
    await asyncio.sleep(10)
    
    # ポーリングモード停止
    await device.stop_polling()
    
    await device.close()

asyncio.run(main())

主要な機能

  • connect(): デバイスに接続
  • close(): 接続を閉じる
  • get_version(): ファームウェアバージョンを取得
  • get_base_voltage(): ベース電圧を取得
  • get_connections(): 各チャンネルの接続状態を取得
  • get_me(): ME(Main Electrode)の測定値を取得
  • get_sme(): SME(Sub Electrode)の測定値を取得
  • start_polling(): ポーリングモードを開始
  • stop_polling(): ポーリングモードを停止

テストの実行

プロジェクトのテストを実行するには、以下のコマンドを使用します:

rye run pytest

ビルド方法

rye build --wheel

ライセンス

このプロジェクトはMITライセンスの下で公開されています。詳細はLICENSEファイルを参照してください。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

medjc09_hub_python-0.4.0.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

medjc09_hub_python-0.4.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file medjc09_hub_python-0.4.0.tar.gz.

File metadata

  • Download URL: medjc09_hub_python-0.4.0.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for medjc09_hub_python-0.4.0.tar.gz
Algorithm Hash digest
SHA256 529b9d4a2ceba4f5808560f2570af4324b86d46b65bc39cf6b99f102907ede02
MD5 1f7390286c069f031f073a9841ceb1ad
BLAKE2b-256 27474ddfd30e23ba446ef3307621427f088092f1e590550cbc5140fd3a8ab6ee

See more details on using hashes here.

File details

Details for the file medjc09_hub_python-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for medjc09_hub_python-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 363ce4b469f738bd3ede28c4280104282ea49c8df4799900a8af5f8094bc8364
MD5 24a77d9d50f6974422b2dd508176ec67
BLAKE2b-256 6537f91af86d79158ff341dcce37f2ba91ded308f8692c06f56ae8e4a55c85c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page