Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for RND power supplies #613

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions contrib/rnd.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: AISEC Pentesting Team
#
# SPDX-License-Identifier: CC0-1.0

KERNEL=="ttyACM[0-9]*", SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0416", ATTRS{idProduct}=="5011", SYMLINK+="rnd-netzteil"
3 changes: 2 additions & 1 deletion src/opennetzteil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# SPDX-License-Identifier: Apache-2.0

from opennetzteil.devices.http.client import HTTPNetzteil
from opennetzteil.devices.rnd import RND320
from opennetzteil.devices.rs.hmc804 import HMC804
from opennetzteil.netzteil import BaseNetzteil

netzteile: list[type[BaseNetzteil]] = [HTTPNetzteil, HMC804]
netzteile: list[type[BaseNetzteil]] = [HTTPNetzteil, HMC804, RND320]
67 changes: 67 additions & 0 deletions src/opennetzteil/devices/rnd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# SPDX-FileCopyrightText: AISEC Pentesting Team
#
# SPDX-License-Identifier: Apache-2.0

import asyncio
from pathlib import Path
from typing import Any

from opennetzteil.exceptions import OperationNotSupportedError
from opennetzteil.netzteil import BaseNetzteil


class RND320(BaseNetzteil):
PRODUCT_ID = "RND320"

async def _send(self, data: str) -> None:
with Path(self.target.path).open("w") as f:
await asyncio.to_thread(f.write, data)

async def get_ident(self) -> str:
raise OperationNotSupportedError()

async def get_master(self) -> bool:
raise OperationNotSupportedError()

async def set_master(self, enabled: bool) -> None:
cmd = "OUT1" if enabled else "OUT0"
await self._send(cmd)

async def get_channels(self) -> int:
return 1

async def get_current(self, channel: int) -> float:
raise OperationNotSupportedError()

async def set_current(self, channel: int, value: float) -> None:
raise OperationNotSupportedError()

async def get_voltage(self, channel: int) -> float:
raise OperationNotSupportedError()

async def set_voltage(self, channel: int, value: float) -> None:
raise OperationNotSupportedError()

async def get_output(self, channel: int) -> bool:
raise OperationNotSupportedError()

async def set_output(self, channel: int, enabled: bool) -> None:
await self.set_master(enabled)

async def status(self) -> dict[str, Any]:
raise OperationNotSupportedError()

async def get_ocp(self, channel: int) -> bool:
raise OperationNotSupportedError()

async def set_ocp(self, channel: int, enabled: bool) -> None:
raise OperationNotSupportedError()

async def get_ovp(self, channel: int) -> bool:
raise OperationNotSupportedError()

async def set_ovp(self, channel: int, enabled: bool) -> None:
raise OperationNotSupportedError()

async def set_beep(self, enabled: bool) -> None:
raise OperationNotSupportedError()
Empty file.