Compare commits

..

16 Commits
2.8.1 ... 2.8.5

Author SHA1 Message Date
da281ebf97 Merge branch 'master' of github.com:paulscherrerinstitute/StreamDevice 2018-09-19 16:42:12 +02:00
c832efbcb6 Merge pull request #17 from shadowguy/master
Updated more EPICS web links.  SynApps link was actually broken
2018-09-19 16:41:37 +02:00
b7b3bc0af0 Fix problem with \? at end of input format when no more input is available. Used to work. Works again (but was not really intended) 2018-09-19 16:36:01 +02:00
4a42c3d43a Web link fixes, updated 3.14.8 dev guide link to 3.14.12 2018-09-17 14:13:39 +02:00
624cc0134a Merge branch 'master' of github.com:paulscherrerinstitute/StreamDevice 2018-09-14 16:19:09 +02:00
d9d5d5f55d Merge pull request #16 from shadowguy/master
Typo
2018-09-14 16:18:07 +02:00
53ea75dc80 use macro instead of magic value 2018-09-12 09:48:55 +02:00
b1f4c2a7d9 improve debug message 2018-09-11 18:27:52 +02:00
d87e9cedd2 reset proc to 0 in case it had been 2 to trigger @init 2018-09-11 18:19:58 +02:00
32d93d9028 Merge pull request #15 from darcato/master
Fix typos
2018-09-11 15:10:06 +02:00
3d30827798 Typos on DFB_ULONG 2018-09-11 15:01:33 +02:00
b688f14c22 Merge pull request #14 from icshwi/master
minor modifications related delete and char size
2018-09-10 15:16:10 +02:00
9e972d3f33 Typo 2018-09-05 22:21:12 +02:00
f5da2ea6b3 Do not limit to 80 chars when the link can be 256 by @krisztianloki 2018-08-29 22:27:07 +02:00
4edd2f2eff Fixed new[] / delete mismatch by @krisztianloki 2018-08-29 22:08:23 +02:00
846b884eb5 fix (and simplify) reading strings into waveform, aai, aao, lsi, lso 2018-08-21 16:03:03 +02:00
14 changed files with 54 additions and 71 deletions

View File

@ -1,6 +1,6 @@
# StreamDevice
_StreamDevice_ is a generic [EPICS](https://www.aps.anl.gov/epics)
_StreamDevice_ is a generic [EPICS](https://epics.anl.gov/)
device support for devices with a "byte stream" based
communication interface.
That means devices that can be controlled by sending and receiving

View File

@ -53,7 +53,7 @@ RegisterConverter(MyConverter,"Q");
</pre>
<a name="theory"></a>
<h2>Theroy of Operation</h2>
<h2>Theory of Operation</h2>
<a name="registration"></a>
<h3>Registration </h3>

View File

@ -15,7 +15,7 @@
<h2>What is <em>StreamDevice</em>?</h2>
<p>
<em>StreamDevice</em> is a generic
<a href="https://www.aps.anl.gov/epics" target="ex">EPICS</a>
<a href="https://epics.anl.gov/" target="ex">EPICS</a>
device support for devices with a "byte stream" based
communication interface.
That means devices that can be controlled by sending and

View File

@ -16,7 +16,7 @@
<h2>1. Normal Processing</h2>
<p>
<em>StreamDevice</em> is an asynchronous device support
(see <a href="http://www.aps.anl.gov/epics/base/R3-14/8-docs/AppDevGuide.pdf"
(see <a href="http://www.aps.anl.gov/epics/base/R3-14/12-docs/AppDevGuide.pdf"
target="ex">IOC Application Developer's Guide</a> chapter 12:
Device Support).
Whenever the record is processed, the <a href="protocol.html">protocol</a>

View File

@ -15,7 +15,7 @@
<p>
<b>Note:</b> The scalcout record is part of the <i>calc</i> module of
the <a target="ex"
href="http://www.aps.anl.gov/aod/bcda/synApps/index.php"
href="https://www.aps.anl.gov/BCDA/synApps"
><em>synApps</em></a> package.
Device support for scalcout records is only available for <i>calc</i>
module release 2-4 or higher.

View File

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

View File

@ -1315,12 +1315,12 @@ normal_format:
break;
}
case StreamProtocolParser::skip:
// ignore next input byte
consumedInput++;
// ignore next input byte (if exists)
if (consumedInput < inputLine.length()) consumedInput++;
break;
case StreamProtocolParser::whitespace:
// any number of whitespace (including 0)
while (isspace(inputLine[consumedInput])) consumedInput++;
while (consumedInput < inputLine.length() && isspace(inputLine[consumedInput])) consumedInput++;
break;
case esc:
// escaped literal byte

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,7 @@ static long readData(dbCommon *record, format_t *format)
return OK;
}
case DBF_LONG:
case DBF_UONG:
case DBF_ULONG:
case DBF_ENUM:
{
long lval;
@ -72,7 +72,7 @@ static long writeData(dbCommon *record, format_t *format)
return streamPrintf(record, format, sco->oval);
}
case DBF_LONG:
case DBF_UONG:
case DBF_ULONG:
case DBF_ENUM:
{
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,
(char *)wf->bptr, wf->nelm)) == ERROR)
{
memset(wf->bptr, 0, wf->nelm);
return ERROR;
}
if (length < (ssize_t)wf->nelm)
{
memset(((char*)wf->bptr)+lval , 0, wf->nelm-lval);
lval++;
}
else
{
((char*)wf->bptr)[wf->nelm-1] = 0;
((char*)wf->bptr)[length] = 0;
}
wf->nord = (long)length;
return OK;