diff --git a/.env_exemple b/.env_exemple deleted file mode 100644 index eec5707..0000000 --- a/.env_exemple +++ /dev/null @@ -1,3 +0,0 @@ -export DEVICE_NAME="ePowerSwitch" -export EPOWERSWITCH_SOCKET_NUMBER=8 -export AUTH_TOKEN=$(echo $(USERNAME):$(PASSWORD) | base64) diff --git a/README.md b/README.md index fca9ae3..8694321 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/db/command.proto b/db/command.proto index c9a352a..72de11f 100644 --- a/db/command.proto +++ b/db/command.proto @@ -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 ""; + in ""; + in "
"; + in ""; + in "<\head>"; + in "Hidden Page";
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 "";
+ in "%*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 "";
+ in "";
+ in "";
+ in "";
+ in "";
+ in "Hidden Page";
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 "";
+ in "%*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;
}
\ No newline at end of file
diff --git a/db/feedback_records.db b/db/feedback_records.db
index 293a5d9..a06b002 100644
--- a/db/feedback_records.db
+++ b/db/feedback_records.db
@@ -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")
}
diff --git a/db/socket_record.db b/db/socket_record.db
index 3551239..c490294 100644
--- a/db/socket_record.db
+++ b/db/socket_record.db
@@ -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)") {
diff --git a/db/template4.substitutions b/db/template4.substitutions
index 25839a8..98bc042 100644
--- a/db/template4.substitutions
+++ b/db/template4.substitutions
@@ -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
diff --git a/db/template8.substitutions b/db/template8.substitutions
index 0fca9a4..e801178 100644
--- a/db/template8.substitutions
+++ b/db/template8.substitutions
@@ -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
diff --git a/st.cmd b/st.cmd
index e7622be..83dadd7 100644
--- a/st.cmd
+++ b/st.cmd
@@ -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()
diff --git a/startioc.sh b/startioc.sh
index 0d7a0ed..e96caaf 100755
--- a/startioc.sh
+++ b/startioc.sh
@@ -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