Compare commits

..

9 Commits
2.8.1 ... 2.8.4

8 changed files with 46 additions and 63 deletions

View File

@ -73,7 +73,7 @@ public:
{init(NULL, size);} {init(NULL, size);}
~StreamBuffer() ~StreamBuffer()
{if (buffer != local) delete buffer;} {if (buffer != local) delete [] buffer;}
// operator (): get char* pointing to index // operator (): get char* pointing to index
const char* operator()(ssize_t index=0) const const char* operator()(ssize_t index=0) const

View File

@ -534,11 +534,11 @@ long streamInitRecord(dbCommon* record, const struct link *ioLink,
streamIoFunction readData, streamIoFunction writeData) streamIoFunction readData, streamIoFunction writeData)
{ {
long status; long status;
char filename[80]; char filename[256];
char protocol[80]; char protocol[256];
char busname[80]; char busname[256];
int addr = -1; int addr = -1;
char busparam[80]; char busparam[256];
memset(busparam, 0 ,sizeof(busparam)); memset(busparam, 0 ,sizeof(busparam));
debug("streamInitRecord(%s): SEVR=%d\n", record->name, record->sevr); debug("streamInitRecord(%s): SEVR=%d\n", record->name, record->sevr);
@ -831,7 +831,7 @@ initRecord(const char* filename, const char* protocol,
return ERROR; return ERROR;
} }
debug("Stream::initRecord %s: initialized. %s\n", debug("Stream::initRecord %s: initialized. %s\n",
name(), convert==2 ? name(), convert == DO_NOT_CONVERT ?
"convert" : "don't convert"); "convert" : "don't convert");
return convert; return convert;
} }
@ -843,6 +843,7 @@ process()
debug("Stream::process(%s)\n", name()); debug("Stream::process(%s)\n", name());
if (record->pact || record->scan == SCAN_IO_EVENT) if (record->pact || record->scan == SCAN_IO_EVENT)
{ {
record->proc = 0;
if (status != NO_ALARM) if (status != NO_ALARM)
{ {
debug("Stream::process(%s) error status=%s (%d)\n", debug("Stream::process(%s) error status=%s (%d)\n",
@ -854,7 +855,7 @@ process()
return false; return false;
} }
debug("Stream::process(%s) ready. %s\n", debug("Stream::process(%s) ready. %s\n",
name(), convert==2 ? name(), convert == DO_NOT_CONVERT ?
"convert" : "don't convert"); "convert" : "don't convert");
return true; return true;
} }
@ -868,11 +869,15 @@ process()
debug("Stream::process(%s) start\n", name()); debug("Stream::process(%s) start\n", name());
status = NO_ALARM; status = NO_ALARM;
convert = OK; convert = OK;
if (!startProtocol(record->proc==2 ? StreamCore::StartInit : StreamCore::StartNormal)) if (!startProtocol(record->proc == 2 ? StreamCore::StartInit : StreamCore::StartNormal))
{ {
debug("Stream::process(%s): could not start %sprotocol, status=%d\n", debug("Stream::process(%s): could not start %sprotocol, status=%s (%d)\n",
name(), record->proc==2 ? "@init " : "", status); name(), record->proc == 2 ? "@init " : "",
status >= 0 && status < ALARM_NSTATUS ?
epicsAlarmConditionStrings[status] : "ERROR",
status);
(void) recGblSetSevr(record, status ? status : UDF_ALARM, INVALID_ALARM); (void) recGblSetSevr(record, status ? status : UDF_ALARM, INVALID_ALARM);
record->proc = 0;
return false; return false;
} }
debug("Stream::process(%s): protocol started\n", name()); debug("Stream::process(%s): protocol started\n", name());

View File

@ -116,17 +116,11 @@ static long readData(dbCommon *record, format_t *format)
if ((length = streamScanfN(record, format, if ((length = streamScanfN(record, format,
(char *)aai->bptr, aai->nelm)) == ERROR) (char *)aai->bptr, aai->nelm)) == ERROR)
{ {
memset(aai->bptr, 0, aai->nelm);
return ERROR; return ERROR;
} }
if (lval < (ssize_t)aai->nelm) if (length < (ssize_t)aai->nelm)
{ {
memset(((char*)aai->bptr)+lval , 0, aai->nelm-lval); ((char*)aai->bptr)[length] = 0;
lval++;
}
else
{
((char*)aai->bptr)[aai->nelm-1] = 0;
} }
aai->nord = (long)length; aai->nord = (long)length;
return OK; return OK;

View File

@ -113,17 +113,11 @@ static long readData(dbCommon *record, format_t *format)
if ((length = streamScanfN(record, format, if ((length = streamScanfN(record, format,
(char *)aao->bptr, aao->nelm)) == ERROR) (char *)aao->bptr, aao->nelm)) == ERROR)
{ {
memset(aao->bptr, 0, aao->nelm);
return ERROR; return ERROR;
} }
if (length < (ssize_t)aao->nelm) if (length < (ssize_t)aao->nelm)
{ {
memset(((char*)aao->bptr)+lval , 0, aao->nelm-lval); ((char*)aao->bptr)[length] = 0;
lval++;
}
else
{
((char*)aao->bptr)[aao->nelm-1] = 0;
} }
aao->nord = (long)length; aao->nord = (long)length;
goto end_no_check; goto end_no_check;

View File

@ -23,30 +23,27 @@
static long readData(dbCommon *record, format_t *format) static long readData(dbCommon *record, format_t *format)
{ {
lsiRecord *lsi = (lsiRecord *)record; lsiRecord *lsi = (lsiRecord *)record;
ssize_t length;
if (format->type == DBF_STRING) if (format->type != DBF_STRING) return ERROR;
if ((length = streamScanfN(record, format, lsi->val, (long)lsi->sizv)) == ERROR)
{ {
long len;
if ((len = streamScanfN(record, format, lsi->val, lsi->sizv) == ERROR))
{
lsi->len = 0;
return ERROR; return ERROR;
} }
lsi->len = len; if (length < (ssize_t)lsi->sizv)
{
lsi->val[length] = 0;
}
lsi->len = length;
return OK; return OK;
}
return ERROR;
} }
static long writeData(dbCommon *record, format_t *format) static long writeData(dbCommon *record, format_t *format)
{ {
lsiRecord *lsi = (lsiRecord *)record; lsiRecord *lsi = (lsiRecord *)record;
if (format->type == DBF_STRING) if (format->type != DBF_STRING) return ERROR;
{
return streamPrintf(record, format, lsi->val); return streamPrintf(record, format, lsi->val);
}
return ERROR;
} }
static long initRecord(dbCommon *record) static long initRecord(dbCommon *record)

View File

@ -24,17 +24,19 @@
static long readData(dbCommon *record, format_t *format) static long readData(dbCommon *record, format_t *format)
{ {
lsoRecord *lso = (lsoRecord *)record; lsoRecord *lso = (lsoRecord *)record;
long len; ssize_t length;
unsigned short monitor_mask; unsigned short monitor_mask;
if (format->type != DBF_STRING) if (format->type != DBF_STRING) return ERROR;
return ERROR; if ((length = streamScanfN(record, format, lso->val, lso->sizv)) == ERROR)
if ((len = streamScanfN(record, format, lso->val, lso->sizv) == ERROR))
{ {
lso->len = 0;
return ERROR; return ERROR;
} }
lso->len = len; if (length < (ssize_t)lso->sizv)
{
lso->val[length] = 0;
}
lso->len = length;
if (record->pact) return OK; if (record->pact) return OK;
/* In @init handler, no processing, enforce monitor updates. */ /* In @init handler, no processing, enforce monitor updates. */
monitor_mask = recGblResetAlarms(record); monitor_mask = recGblResetAlarms(record);
@ -60,11 +62,8 @@ static long writeData(dbCommon *record, format_t *format)
{ {
lsoRecord *lso = (lsoRecord *)record; lsoRecord *lso = (lsoRecord *)record;
if (format->type == DBF_STRING) if (format->type != DBF_STRING) return ERROR;
{
return streamPrintf(record, format, lso->val); return streamPrintf(record, format, lso->val);
}
return ERROR;
} }
static long initRecord(dbCommon *record) static long initRecord(dbCommon *record)

View File

@ -42,7 +42,7 @@ static long readData(dbCommon *record, format_t *format)
return OK; return OK;
} }
case DBF_LONG: case DBF_LONG:
case DBF_UONG: case DBF_ULONG:
case DBF_ENUM: case DBF_ENUM:
{ {
long lval; long lval;
@ -72,7 +72,7 @@ static long writeData(dbCommon *record, format_t *format)
return streamPrintf(record, format, sco->oval); return streamPrintf(record, format, sco->oval);
} }
case DBF_LONG: case DBF_LONG:
case DBF_UONG: case DBF_ULONG:
case DBF_ENUM: case DBF_ENUM:
{ {
return streamPrintf(record, format, (long)sco->oval); return streamPrintf(record, format, (long)sco->oval);

View File

@ -117,17 +117,11 @@ static long readData(dbCommon *record, format_t *format)
if ((length = streamScanfN(record, format, if ((length = streamScanfN(record, format,
(char *)wf->bptr, wf->nelm)) == ERROR) (char *)wf->bptr, wf->nelm)) == ERROR)
{ {
memset(wf->bptr, 0, wf->nelm);
return ERROR; return ERROR;
} }
if (length < (ssize_t)wf->nelm) if (length < (ssize_t)wf->nelm)
{ {
memset(((char*)wf->bptr)+lval , 0, wf->nelm-lval); ((char*)wf->bptr)[length] = 0;
lval++;
}
else
{
((char*)wf->bptr)[wf->nelm-1] = 0;
} }
wf->nord = (long)length; wf->nord = (long)length;
return OK; return OK;