reads current string length from SPS register
This commit is contained in:
17
devS7plcFW.c
17
devS7plcFW.c
@ -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 */
|
||||||
|
Reference in New Issue
Block a user