2 Commits

Author SHA1 Message Date
8ae2aa7ecd fixing_strings (#1)
Reviewed-on: #1
Co-authored-by: Edward Wall <edward.wall@psi.ch>
Co-committed-by: Edward Wall <edward.wall@psi.ch>
2025-04-24 15:46:58 +02:00
7d4f57750b version test fix was incomplete 2022-02-17 14:59:31 +01:00
4 changed files with 36 additions and 6 deletions

View File

@ -1,7 +1,12 @@
include /ioc/tools/driver.makefile include /ioc/tools/driver.makefile
BUILDCLASSES+=Linux MODULE=sinqS7plcFW
BUILDCLASSES=Linux
EPICS_VERSIONS=7.0.7
ARCH_FILTER=RHEL%
DBDS += s7plcFWBase.dbd DBDS += s7plcFWBase.dbd
DBDS_3.14 += s7plcFWCalcout.dbd DBDS_3.14 += s7plcFWCalcout.dbd
DBDS_3.14 += s7plcFWReg.dbd DBDS_3.14 += s7plcFWReg.dbd
USR_CFLAGS += -Wall -Wextra -Wunused-result

13
README.md Normal file
View File

@ -0,0 +1,13 @@
# SinqS7PLCFW
This is a fork of Dirk Zimoch's [epics\_driver\_modules/s7plcFW](https://git.psi.ch/epics_driver_modules/s7plcFW), with the following adjustments:
* 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 default driver behaviour is documented in the file [s7plcFW.html](./s7plcFW.html).

View File

@ -2033,7 +2033,11 @@ STATIC long s7plcFWInitRecordStringin(stringinRecord *record)
STATIC long s7plcFWReadStringin(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; int status;
epicsUInt8 uval8;
S7memPrivate_t *priv = (S7memPrivate_t *)record->dpvt; S7memPrivate_t *priv = (S7memPrivate_t *)record->dpvt;
if (!priv) if (!priv)
@ -2044,11 +2048,18 @@ STATIC long s7plcFWReadStringin(stringinRecord *record)
return -1; return -1;
} }
assert(priv->station); 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); memset(record->val, 0, priv->dlen);
status = s7plcFWReadArray(priv->station, priv->offs, status = s7plcFWReadArray(priv->station, priv->offs+2,
1, priv->dlen, record->val); 1, uval8, record->val);
s7plcFWDebugLog(3, "stringin %s: read array of %d 8bit values\n", 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)) if (record->val[priv->dlen] && !memchr(record->val, 0, priv->dlen))
{ {
/* truncate oversize string */ /* truncate oversize string */

View File

@ -40,7 +40,7 @@
#include "drvS7plcFW.h" #include "drvS7plcFW.h"
#if ((EPICS_VERSION==3 && EPICS_REVISION>=14) || EPICS_VERSION>3) #ifndef BASE_VERSION
/* R3.14 */ /* R3.14 */
#include <dbAccess.h> #include <dbAccess.h>
#include <iocsh.h> #include <iocsh.h>
@ -52,6 +52,7 @@
#include <epicsExport.h> #include <epicsExport.h>
#else #else
/* R3.13 */ /* R3.13 */
#define EPICS_3_13
#include "compat3_13.h" #include "compat3_13.h"
#endif #endif
@ -370,7 +371,7 @@ int s7plcFWConfigure(char *name, char* IPaddr, char *fetchInfo, char *writeInfo,
} }
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#if (EPICS_REVISION>=14) #ifndef EPICS_3_13
static const iocshArg s7plcFWConfigureArg0 = { "name", iocshArgString }; static const iocshArg s7plcFWConfigureArg0 = { "name", iocshArgString };
static const iocshArg s7plcFWConfigureArg1 = { "IPaddr", iocshArgString }; static const iocshArg s7plcFWConfigureArg1 = { "IPaddr", iocshArgString };
static const iocshArg s7plcFWConfigureArg2 = { "fetchInfo", iocshArgString }; static const iocshArg s7plcFWConfigureArg2 = { "fetchInfo", iocshArgString };