Skip to content

Commit

Permalink
Merge pull request #1275 from BasicServicePeople/eth008_driver
Browse files Browse the repository at this point in the history
power: add eth008 power backend
  • Loading branch information
jluebbe committed Dec 15, 2023
2 parents 54f4229 + 5a8acba commit e8fdd87
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ Currently available are:
interface, this module deliberately uses the standard password '1' and is
not compatible with a different password.

``eth008``
Controls a Robot-Electronics eth008 via a simple HTTP API.

``gude``
Controls a Gude PDU via a simple HTTP API.

Expand Down
41 changes: 41 additions & 0 deletions labgrid/driver/power/eth008.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
This driver implements a power port for the robot electronics 8 relay
outputs board.
Driver has been tested with:
* ETH008 - 8 relay outputs
"""

import requests
from ..exception import ExecutionError

PORT = 80

def power_set(host, port, index, value):
index = int(index)
assert 1 <= index <= 8
# access the web interface...
value_str = "A" if value else "I"
response = requests.get(
f"http://{host}:{port}/io.cgi?DO{value_str}{index}"
)
response.raise_for_status()

# Check, that the port is in the desired state
state = get_state(response, index)
if state != value:
raise ExecutionError(f"failed to set port {index} to status {value}")

def power_get(host, port, index):
index = int(index)
assert 1 <= index <= 8
# get the contents of the main page
response = requests.get(f"http://{host}:{port}/io.cgi?relay")

response.raise_for_status()
state = get_state(response, index)
return state

def get_state(request, index):
value = request.text.split()[1][index-1]
return bool(int(value))
1 change: 1 addition & 0 deletions tests/test_powerdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def test_import_backends(self):
import labgrid.driver.power.apc
import labgrid.driver.power.digipower
import labgrid.driver.power.digitalloggers_http
import labgrid.driver.power.eth008
import labgrid.driver.power.gude
import labgrid.driver.power.gude24
import labgrid.driver.power.netio
Expand Down

0 comments on commit e8fdd87

Please sign in to comment.