removing auth token, adding host_name, modifying .proto to be coherant with the device

This commit is contained in:
2026-05-06 11:58:07 +02:00
parent 33678fb90b
commit 752d2b4ce1
9 changed files with 86 additions and 43 deletions
-3
View File
@@ -1,3 +0,0 @@
export DEVICE_NAME="ePowerSwitch"
export EPOWERSWITCH_SOCKET_NUMBER=8
export AUTH_TOKEN=$(echo $(USERNAME):$(PASSWORD) | base64)
+8 -8
View File
@@ -4,14 +4,14 @@ An EPICS driver based on StreamDevice allowing to control remotely both ePowerSw
# How to use
For a device with 4 outlets
```bash
$ startioc.sh 4
```
Before any execution, look at startioc.sh.
It will show you any environment variables you need to see.
After setting up environment variables, you can start by executing
For a device with 8 outlets
```bash
$ startioc.sh 8
$ startioc.sh
```
# Documentation
@@ -25,10 +25,10 @@ $(DEVICE_NAME)_set_outlet_n
By default, it should be called
```
ePowerSwitch_set_outlet_0
ePowerSwitch_set_outlet_1
ePowerSwitch_set_outlet_2
ePowerSwitch_set_outlet_3
ePowerSwitch_set_outlet_4
```
## Getters
@@ -40,10 +40,10 @@ $(DEVICE_NAME)_get_outlet_n
By default, it should be called
```
ePowerSwitch_get_outlet_0
ePowerSwitch_get_outlet_1
ePowerSwitch_get_outlet_2
ePowerSwitch_get_outlet_3
ePowerSwitch_get_outlet_4
```
Furthermore, a record exposes the number of sockets of this device:
+46 -12
View File
@@ -1,29 +1,58 @@
get4 {
InTerminator="\n";
InTerminator="\r\n";
OutTerminator="\r\n";
out "GET /hidden.htm";
out "Authorization: Basic \$1";
out "GET /hidden.htm HTTP/1.1";
out "Host: \$1";
out "Accept: */*";
out "";
in "Hidden Page";
in "HTTP/1.0 200 OK";
in "Server: lwIP/1.3.2 (http://www.sics.se/~adam/lwip/)";
in "Content-type: text/html;charset=iso-8859-1";
in "%*[^\r]";
in "Pragma: no-cache";
in "";
in "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">";
in "<html>";
in "<head>";
in "<meta http-equiv="Cache-Control" content="no-cache">";
in "<\head>";
in "<body>Hidden Page<br><pre>";
in "%*d%*s%*d %*d:%*d:%*d";
in "Version: %*u.%*u.%*u.%*u";
in "%*s %*s %*s";
in "Version: v %*u.%*u.%*u.%*u";
in "M0:O1=%(AA)s";
in "M0:O2=%(BB)s";
in "M0:O3=%(CC)s";
in "M0:O4=%(DD)s";
in "";
in "</pre>";
in "</body></html>%*s";
disconnect;
}
get8 {
InTerminator="\n";
InTerminator="\r\n";
OutTerminator="\r\n";
out "GET /hidden.htm";
out "Authorization: Basic \$1";
out "GET /hidden.htm HTTP/1.1";
out "Host: \$1";
out "Accept: */*";
out "";
in "Hidden Page";
in "HTTP/1.0 200 OK";
in "Server: lwIP/1.3.2 (http://www.sics.se/~adam/lwip/)";
in "Content-type: text/html;charset=iso-8859-1";
in "%*[^\r]";
in "Pragma: no-cache";
in "";
in "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
in "<html>";
in "<head>";
in "<meta http-equiv=\"Cache-Control\" content=\"no-cache\">";
in "</head>";
in "<body>Hidden Page<br><pre>";
in "%*d%*s%*d %*d:%*d:%*d";
in "Version: %*u.%*u.%*u.%*u";
in "%*s %*s %*s";
in "Version: v %*u.%*u.%*u.%*u";
in "M0:O1=%(AA)s";
in "M0:O2=%(BB)s";
in "M0:O3=%(CC)s";
@@ -32,13 +61,18 @@ get8 {
in "M0:O6=%(FF)s";
in "M0:O7=%(GG)s";
in "M0:O8=%(HH)s";
in "";
in "</pre>";
in "</body></html>%*s";
disconnect;
}
set {
OutTerminator = "\r\n";
out "POST /hidden.htm/M0:O\$2=%s";
out "Authorization: Basic \$1";
out "GET /hidden.htm?M0\%3AO\$2=%s HTTP/1.1";
out "Host: \$1";
out "Accept: */*";
out "Content-Length: 0";
out "";
disconnect;
}
+2 -2
View File
@@ -6,7 +6,7 @@ record(scalcout, "$(DEVICE_NAME)_outlet_getter") {
field(DTYP, "stream")
field(SCAN, "1 second")
field(CALC, "0")
field(OUT, "@$(DB)command.proto get$(OUTLET_NUMBER)($(AUTH_TOKEN)) $(PORT)")
field(FLNK, "$(DEVICE_NAME)_get_outlet_0")
field(OUT, "@$(DB)command.proto get$(OUTLET_NUMBER)($(HOST_NAME)) $(PORT)")
field(FLNK, "$(DEVICE_NAME)_get_outlet_1")
}
+1 -1
View File
@@ -1,7 +1,7 @@
record(stringout, "$(DEVICE_NAME)_set_$(PARAMETER_NAME)_$(PARAMETER_ID)") {
field(DTYP, "stream")
field(PINI, "NO")
field(OUT, "@$(DB)command.proto set($(AUTH_TOKEN), $(PARAMETER_ID)) $(PORT)")
field(OUT, "@$(DB)command.proto set($(HOST_NAME), $(PARAMETER_ID)) $(PORT)")
}
record(stringin, "$(DEVICE_NAME)_get_$(PARAMETER_NAME)_$(PARAMETER_ID)") {
+4 -4
View File
@@ -2,10 +2,10 @@ file socket_record.db
{
pattern
{ PARAMETER_NAME, PARAMETER_ID, SCALCOUT_FIELD_INPUT, FORWARDED_ID}
{ "outlet", 0, "AA", 1}
{ "outlet", 1, "BB", 2}
{ "outlet", 2, "CC", 3}
{ "outlet", 3, "DD", 3}
{ "outlet", 1, "AA", 2}
{ "outlet", 2, "BB", 3}
{ "outlet", 3, "CC", 4}
{ "outlet", 4, "DD", 4}
}
file feedback_records.db
+8 -8
View File
@@ -2,14 +2,14 @@ file socket_record.db
{
pattern
{ PARAMETER_NAME, PARAMETER_ID, SCALCOUT_FIELD_INPUT, FORWARDED_ID}
{ "outlet", 0, "AA", 1}
{ "outlet", 1, "BB", 2}
{ "outlet", 2, "CC", 3}
{ "outlet", 3, "DD", 4}
{ "outlet", 4, "EE", 5}
{ "outlet", 5, "FF", 6}
{ "outlet", 6, "GG", 7}
{ "outlet", 7, "HH", 7}
{ "outlet", 1, "AA", 2}
{ "outlet", 2, "BB", 3}
{ "outlet", 3, "CC", 4}
{ "outlet", 4, "DD", 5}
{ "outlet", 5, "EE", 6}
{ "outlet", 6, "FF", 7}
{ "outlet", 7, "GG", 8}
{ "outlet", 8, "HH", 8}
}
file feedback_records.db
+4 -2
View File
@@ -1,11 +1,13 @@
#!/usr/local/bin/iocsh
require ePowerSwitch,ponsin_h
epicsEnvSet("ASYN_PORT", "myDriverPort")
epicsEnvSet("DB", "$(ePowerSwitch_DB)")
# I use HTTP to use TCP and disconnect after, but no disconnection is done, so I disconnect manually.
drvAsynIPPortConfigure("$(ASYN_PORT)","127.0.0.1:55555 http", 0, 0, 0)
drvAsynIPPortConfigure("$(ASYN_PORT)","$(HOST_NAME):80 http", 0, 0, 0)
dbLoadTemplate("$(DB)template$(EPOWERSWITCH_SOCKET_NUMBER).substitutions", "PORT=$(ASYN_PORT), DEVICE_NAME=$(DEVICE_NAME), DB=$(DB), AUTH_TOKEN=$(AUTH_TOKEN)")
dbLoadTemplate("$(DB)template$(EPOWERSWITCH_SOCKET_NUMBER).substitutions", "PORT=$(ASYN_PORT), DEVICE_NAME=$(DEVICE_NAME), DB=$(DB), HOST_NAME=$(HOST_NAME)")
iocInit()
+13 -3
View File
@@ -1,6 +1,16 @@
#!/bin/bash
source .env #see .env_exemple
echo $DEVICE_NAME
echo "Starting ePowerSwitch drivers"
#an exemple of how to strat this epics drivers
## The device name that will appeard on epics
export DEVICE_NAME="ePowerSwitch"
# The number of outlet that the device had
# This drivers only support 4 or 8 outlet
export EPOWERSWITCH_SOCKET_NUMBER=8
# The host name of the outlet
export HOST_NAME="eps-vms-1-weha.psi.ch"
iocsh st.cmd