From b3480aa85869160aa5fe2eccc8a326b632831fe6 Mon Sep 17 00:00:00 2001 From: Edward Wall Date: Thu, 17 Apr 2025 11:02:47 +0200 Subject: [PATCH 1/3] reads current string length from SPS register --- devS7plcFW.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/devS7plcFW.c b/devS7plcFW.c index 6096460..d3060f0 100644 --- a/devS7plcFW.c +++ b/devS7plcFW.c @@ -2033,7 +2033,11 @@ STATIC long s7plcFWInitRecordStringin(stringinRecord *record) STATIC long s7plcFWReadStringin(stringinRecord *record) { + // The SPS includes the max length of the string and the length of the + // current string, as the first two bytes in the register. + int status; + epicsUInt8 uval8; S7memPrivate_t *priv = (S7memPrivate_t *)record->dpvt; if (!priv) @@ -2044,11 +2048,18 @@ STATIC long s7plcFWReadStringin(stringinRecord *record) return -1; } assert(priv->station); + + status = s7plcFWRead(priv->station, priv->offs+1, + 1, &uval8); + s7plcFWDebugLog(3, "stringin %s: read 8bit %02x\n", + record->name, uval8); + uval8 = uval8 <= priv->dlen ? uval8 : priv->dlen; + memset(record->val, 0, priv->dlen); - status = s7plcFWReadArray(priv->station, priv->offs, - 1, priv->dlen, record->val); + status = s7plcFWReadArray(priv->station, priv->offs+2, + 1, uval8, record->val); s7plcFWDebugLog(3, "stringin %s: read array of %d 8bit values\n", - record->name, priv->dlen); + record->name, uval8); if (record->val[priv->dlen] && !memchr(record->val, 0, priv->dlen)) { /* truncate oversize string */ -- 2.49.0 From a6d6eee472cf5b4fc91ecec178a820be75917e30 Mon Sep 17 00:00:00 2001 From: Edward Wall Date: Thu, 17 Apr 2025 11:11:09 +0200 Subject: [PATCH 2/3] Adds README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b76b664 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# S7PLCFW + +This is a fork of [epics\_driver\_modules/s7plcFW](https://git.psi.ch/epics_driver_modules/s7plcFW), with the following adjustments: + +* String length is no longer static, but instead read from the SPS directly +* The String offset, now takes the two prefix bytes (max string length, current string length) into account, so you don't have to add 2 to each offset in order for the driver to read the correct string + +The driver is documented in the file [s7plcFW.html](./s7plcFW.html). -- 2.49.0 From 62f2488f59fc0a16f103239e81f569dd34e9e4a6 Mon Sep 17 00:00:00 2001 From: Edward Wall Date: Thu, 24 Apr 2025 15:44:32 +0200 Subject: [PATCH 3/3] build with SINQ specific name due to changes --- Makefile | 7 ++++++- README.md | 15 ++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 8eea25f..db3ea14 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,12 @@ include /ioc/tools/driver.makefile -BUILDCLASSES+=Linux +MODULE=sinqS7plcFW +BUILDCLASSES=Linux +EPICS_VERSIONS=7.0.7 +ARCH_FILTER=RHEL% DBDS += s7plcFWBase.dbd DBDS_3.14 += s7plcFWCalcout.dbd DBDS_3.14 += s7plcFWReg.dbd + +USR_CFLAGS += -Wall -Wextra -Wunused-result diff --git a/README.md b/README.md index b76b664..c722123 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,13 @@ -# S7PLCFW +# SinqS7PLCFW -This is a fork of [epics\_driver\_modules/s7plcFW](https://git.psi.ch/epics_driver_modules/s7plcFW), with the following adjustments: +This is a fork of Dirk Zimoch's [epics\_driver\_modules/s7plcFW](https://git.psi.ch/epics_driver_modules/s7plcFW), with the following adjustments: -* String length is no longer static, but instead read from the SPS directly -* The String offset, now takes the two prefix bytes (max string length, current string length) into account, so you don't have to add 2 to each offset in order for the driver to read the correct string +* The String offset, now takes the two prefix bytes (max string length, current + string length) into account, so you don't have to add 2 to each offset in + order for the driver to read the correct string +* The length of a String read from the SPS and written to the Val field of a + stringin record is no longer static, but instead read from the SPS directly, + to avoid having bytes leftover in the buffer from a previous string. +* The Makefile has been slightly adjusted, limiting the build targets. -The driver is documented in the file [s7plcFW.html](./s7plcFW.html). +The default driver behaviour is documented in the file [s7plcFW.html](./s7plcFW.html). -- 2.49.0