Compare commits
81 Commits
stream_2_5
...
stream_2_6
Author | SHA1 | Date | |
---|---|---|---|
97652917c9 | |||
c171a62f93 | |||
c7c28e7fa2 | |||
79a17788f2 | |||
9f0a2d2fb6 | |||
66f6ce9bd2 | |||
e5dfe7b816 | |||
6efb17be64 | |||
0310b30446 | |||
863cdf3d7f | |||
e51bb2555e | |||
9e0157d679 | |||
3e91eb4fc1 | |||
caf811c23a | |||
de116c9e5a | |||
eef38b0557 | |||
0057899476 | |||
0148e6e27e | |||
c6af859f9d | |||
01f0761ca8 | |||
d7770846aa | |||
0e76ba6464 | |||
fcb44ec845 | |||
cec8195e5e | |||
6c0eb32d75 | |||
9ae5f1d583 | |||
3b60bb9420 | |||
db50c35ad6 | |||
4f05d4e254 | |||
c5a17b217d | |||
fdccb0c5a9 | |||
ccbafef55a | |||
c594134317 | |||
11cfaf44ee | |||
a34678cbcc | |||
26fd99823c | |||
42c305c79b | |||
9585506644 | |||
4317ae0f75 | |||
6e6c79f5ea | |||
8da0014091 | |||
60d292b3ea | |||
5ce9b737cf | |||
7bcb494044 | |||
13758eb08e | |||
b9c26cb6f8 | |||
e3dd0a319a | |||
80b7ceea2d | |||
eabcce156a | |||
615beb7d02 | |||
78e6c9355c | |||
20129ea341 | |||
388f950559 | |||
96c93714a4 | |||
252eb44959 | |||
0442e2ae4f | |||
31dae22428 | |||
1d5c7adb61 | |||
c138442a95 | |||
a672ab1234 | |||
c550cc01be | |||
7db71589d8 | |||
910cf77d97 | |||
807fe825d6 | |||
ff46c9a4a7 | |||
a42fbc9c6c | |||
74d950ab2d | |||
9049baf730 | |||
050a165a82 | |||
1428b85a34 | |||
e4f8a6ed40 | |||
5a5b42cb67 | |||
e62553eca6 | |||
0846c1dd5b | |||
774e88241a | |||
03a04a51b6 | |||
103e74be03 | |||
129cc61759 | |||
70073e1b69 | |||
c94c1a1e70 | |||
07026b03ae |
3
Makefile
@ -1,6 +1,7 @@
|
||||
TOP = ..
|
||||
|
||||
DIRS = src
|
||||
streamApp_DEPEND_DIRS = src
|
||||
|
||||
# Look if we have EPICS R3.13 or R3.14
|
||||
ifeq ($(wildcard $(TOP)/configure),)
|
||||
@ -13,6 +14,8 @@ else
|
||||
ifneq ($(words $(CALC) $(SYNAPPS)), 0)
|
||||
# with synApps calc module (contains scalcout)
|
||||
DIRS += srcSynApps
|
||||
srcSynApps_DEPEND_DIRS = src
|
||||
streamApp_DEPEND_DIRS += srcSynApps
|
||||
endif
|
||||
endif
|
||||
|
||||
|
BIN
doc/EPICS.gif
Before Width: | Height: | Size: 453 B |
BIN
doc/SLS.gif
Before Width: | Height: | Size: 2.2 KiB |
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: aai Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: aai Records</h1>
|
||||
<p>
|
||||
<b>Note:</b> aai record support is disabled per default.
|
||||
@ -123,6 +124,5 @@ the written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2006</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: aao Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: aao Records</h1>
|
||||
<p>
|
||||
<b>Note:</b> aao record support is disabled per default.
|
||||
@ -123,6 +124,5 @@ the written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2006</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: ai Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: ai Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -38,6 +39,8 @@ written or read value.
|
||||
definition. <em>StreamDevice</em> does not set it. For example,
|
||||
<code>EOFF=-10</code> and <code>ESLO=0.000305180437934</code>
|
||||
(=20.0/0xFFFF) maps 0x0000 to -10.0, 0x7FFF to 0.0 and 0xFFFF to 10.0.
|
||||
Using unsigned formats with values ≥ 0x800000 gives different results
|
||||
on 64 bit machines.
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
@ -76,6 +79,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: ao Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: ao Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -37,6 +38,8 @@ written or read value.
|
||||
might be set in the record definition. <em>StreamDevice</em> does not set it.
|
||||
For example, <code>EOFF=-10</code> and <code>ESLO=0.000305180437934</code>
|
||||
(=20.0/0xFFFF) maps -10.0 to 0x0000, 0.0 to 0x7FFF and 10.0 to 0xFFFF.
|
||||
Using unsigned formats with values ≥ 0x800000 gives different results
|
||||
on 64 bit machines.
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
@ -77,6 +80,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
BIN
doc/bg.gif
Before Width: | Height: | Size: 868 B |
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: bi Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: bi Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -72,6 +73,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: bo Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: bo Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -71,6 +72,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Bus API</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>Bus API</h1>
|
||||
|
||||
<a name="class"></a>
|
||||
@ -640,6 +641,5 @@ other request method like <code>writeRequest()</code>.
|
||||
</p>
|
||||
<hr>
|
||||
<p><small>Dirk Zimoch, 2007</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: calcout Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: calcout Records</h1>
|
||||
|
||||
<p>
|
||||
@ -78,6 +79,5 @@ Different record fields are used for output and input. The variable
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Using EPICS 3.13</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Using EPICS 3.13</h1>
|
||||
|
||||
<a name="pre"></a>
|
||||
@ -219,6 +220,5 @@ asynSetOption ("PS1", 0, "stop", "1")
|
||||
|
||||
<hr>
|
||||
<p><small>Dirk Zimoch, 2006</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
BIN
doc/favicon.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
@ -3,18 +3,219 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Format Converter API</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Format Converter API</h1>
|
||||
|
||||
<h2>Sorry, this documentation is still missing.</h2>
|
||||
<a name="class"></a>
|
||||
<h2>Converter Class</h2>
|
||||
<p>
|
||||
A user defined converter class inherits public from
|
||||
<i>StreamFormatConverter</i> and handles one or more conversion characters.
|
||||
It is not necessary that a given conversion character supports both,
|
||||
printing and scanning.
|
||||
But if it does, both must be handled by the same converter class.
|
||||
</p>
|
||||
<p>
|
||||
Any conversion corresponds to one data type. The converter class must
|
||||
implement print and/or scan methods for this data type. It must also
|
||||
implement a parse method to analyse the format string.
|
||||
</p>
|
||||
<p>
|
||||
A converter class must be registered with a call to RegisterConverter()
|
||||
in the global file context.
|
||||
</p>
|
||||
<p>
|
||||
The converter must not contain any class variables, because there will be
|
||||
only one global instance for each conversion character - not one for each
|
||||
format string!
|
||||
</p>
|
||||
|
||||
<h3>Example: LONG converter for <code>%Q</code></h3>
|
||||
<pre>
|
||||
#include "StreamFormatConverter.h"
|
||||
|
||||
class MyConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
bool printLong(const StreamFormat&, StreamBuffer&, long);
|
||||
int scanLong(const StreamFormat&, const char*, long&);
|
||||
};
|
||||
|
||||
RegisterConverter(MyConverter,"Q");
|
||||
|
||||
// ... (implementation)
|
||||
</pre>
|
||||
|
||||
<a name="theory"></a>
|
||||
<h2>Theroy of Operation</h2>
|
||||
|
||||
<a name="registration"></a>
|
||||
<h3>Registration </h3>
|
||||
<div class="indent"><code>
|
||||
RegisterConverter(<i>converterClass</i>, "<i>characters</i>");
|
||||
</code></div>
|
||||
<p>
|
||||
This macro registers the converter class for all given conversion
|
||||
characters. In most cases, you will give only one character.
|
||||
The macro must be called once for each class in the global file context.
|
||||
</p>
|
||||
<p>
|
||||
HINT: Do not branch depending on the conversion character.
|
||||
Provide multiple classes, that's more efficient.
|
||||
</p>
|
||||
|
||||
<a name="parsing"></a>
|
||||
<h3>Parsing</h3>
|
||||
<div class="indent"><code>
|
||||
int parse (const StreamFormat& fmt, StreamBuffer& info,
|
||||
const char*& source, bool scanFormat);
|
||||
</code></div>
|
||||
<div class="indent"><code>
|
||||
struct StreamFormat {
|
||||
char conv;
|
||||
StreamFormatType type;
|
||||
unsigned char flags;
|
||||
short prec;
|
||||
unsigned short width;
|
||||
unsigned short infolen;
|
||||
const char* info;
|
||||
};
|
||||
</code></div>
|
||||
|
||||
<p>
|
||||
During initialization, <code>parse()</code> is called whenever one of the
|
||||
conversion characters handled by your converter class is found in a protocol.
|
||||
The fields <code>fmt.conv</code>, <code>fmt.flags</code>,
|
||||
<code>fmt.prec</code>, and <code>fmt.width</code> have
|
||||
already been filled in. If a scan format is parsed, <code>scanFormat</code>
|
||||
is <code>true</code>. If a print format is parsed, <code>scanFormat</code>
|
||||
is <code>false</code>.
|
||||
</p>
|
||||
<p>
|
||||
The <code>fmt.flags</code> field is a bitset and can have any of the following
|
||||
flags set:
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>left_flag</code>: the format contained a <code>-</code>.
|
||||
This is normaly used to indicate that the value should be printed
|
||||
left-aligned.
|
||||
</li>
|
||||
<li><code>sign_flag</code>: the format contained a <code>+</code>.
|
||||
This normaly requests to print a sign even for positive numbers.
|
||||
</li>
|
||||
<li><code>space_flag</code>: the format contained a '<code> </code>' (space).
|
||||
This normaly requests to print a space instead of a sign for positive numbers.
|
||||
</li>
|
||||
<li><code>alt_flag</code>: the format contained a <code>#</code>.
|
||||
This indicated the request to use an alternative format. For example in
|
||||
<code>%#x</code> the hex number is preficed with <code>0x</code>.
|
||||
</li>
|
||||
<li><code>zero_flag</code>: the format contained a <code>0</code>.
|
||||
This normaly requests to pad a numerical value with leading zeros
|
||||
instead of leading spaces.
|
||||
<li><code>skip_flag</code>: the format contained a <code>*</code>.
|
||||
The value is parsed and checked but then discarded.
|
||||
</ul>
|
||||
<p>
|
||||
It is not necessary that these flags have exactly the same meaning in your
|
||||
formats, but a similar and intuitive meaning helpful for the user.
|
||||
</p>
|
||||
<p>
|
||||
There are two additional flags, <code>default_flag</code> indicating a
|
||||
<code>?</code> and <code>compare_flag</code> indicating a <code>=</code>
|
||||
int the format, that are handled internally by <em>StreamDevice</em> and
|
||||
are not of interest to the converter class.
|
||||
</p>
|
||||
<p>
|
||||
The <code>source</code> pointer points to the character of the format string
|
||||
just after the conversion character. You can parse additional characters if
|
||||
they belong to the format string handled by your class.
|
||||
Move the <code>source</code> pointer so that is points to the first character
|
||||
after your format string.
|
||||
This is done for example in the builtin formats
|
||||
<code>%[charset]</code> or <code>%{enum0|enum1}</code>.
|
||||
However, many formats don't need additional characters.
|
||||
|
||||
</p>
|
||||
<h4>Example</h4>
|
||||
<pre>
|
||||
source source
|
||||
before after
|
||||
parse() parse()
|
||||
| |
|
||||
"%39[0-9a-zA-Z]constant text"
|
||||
|
|
||||
conversion
|
||||
character
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
You can write any data you may need later in <code>print*()</code> or
|
||||
<code>scan*()</code> to the
|
||||
<a href="streambuffer.html"><i>Streambuffer</i></a> <code>info</code>.
|
||||
This will probably be necessary if you have parsed additional characters
|
||||
from the format string as in the above example<br>
|
||||
</p>
|
||||
<p>
|
||||
Return <code>long_format</code>, <em>double_format</em>,
|
||||
<em>string_format</em>, or <code>enum_format</code> depending on the
|
||||
datatype associated with the conversion character.
|
||||
It is not necessary to return the same value for print and for scan
|
||||
formats.
|
||||
You can even return different values depending on the format string,
|
||||
but I can't imagine why anyone should do that.
|
||||
</p>
|
||||
<p>
|
||||
If the format is not a real data conversion but does other things with
|
||||
the data (append or check a checksum, encode or decode the data,...),
|
||||
return <code>pseudo_format</code>.
|
||||
</p>
|
||||
<p>
|
||||
Return <code>false</code> if there is any parse error or if print or scan
|
||||
is requested but not supported by this conversion.
|
||||
</p>
|
||||
|
||||
<a name="printing_scanning"></a>
|
||||
<h3>Printing and Scanning</h3>
|
||||
<p>
|
||||
Provide a <code>print[Long|Double|String|Pseudo]()</code> and/or
|
||||
<code>scan[Long|Double|String|Pseudo]()</code> method appropriate
|
||||
for the data type you have returned in the <code>parse()</code> method.
|
||||
That method is called whenever the conversion appears in an output or input,
|
||||
respectively.
|
||||
You only need to implement the flavour of print and/or scan suitable for
|
||||
the datatype returned by <code>parse()</code>.
|
||||
</p>
|
||||
<p>
|
||||
Now, <code>fmt.type</code> contains the value returned by <code>parse()</code>.
|
||||
With <code>fmt.info()</code> get access to the string you have written to
|
||||
<code>info</code> in <code>parse()</code> (null terminated).
|
||||
</p>
|
||||
<p>
|
||||
The length of the info string can be found in <code>fmt.infolen</code>.
|
||||
</p>
|
||||
<p>
|
||||
In <code>print*()</code>, append the converted value to <code>output</code>.
|
||||
Do not modify what is already in output (unless you really know what you're
|
||||
doing).
|
||||
Return <code>true</code> on success, <code>false</code> on failure.
|
||||
</p>
|
||||
<p>
|
||||
In <code>scan*()</code>, read the value from input and return the number of
|
||||
consumed bytes.
|
||||
In the string version, don't write more bytes than <code>maxlen</code>!
|
||||
If the <code>skip_flag</code> is set, you don't need to write to
|
||||
<code>value</code>, since the value will be discarded anyway.
|
||||
Return <code>-1</code> on failure.
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<p><small>Dirk Zimoch, 2006</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
<p><small>Dirk Zimoch, 2007</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
232
doc/formats.html
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Format Converters</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Format Converters</h1>
|
||||
|
||||
<a name="syntax"></a>
|
||||
@ -27,8 +28,8 @@ A format converter consists of
|
||||
</p>
|
||||
<ul>
|
||||
<li>The <code>%</code> character</li>
|
||||
<li>Optionally a field name in <code>()</code></li>
|
||||
<li>Optionally flags out of the characters <code>*# +0-</code></li>
|
||||
<li>Optionally a field <span class="new">or record</span> name in <code>()</code></li>
|
||||
<li>Optionally flags out of the characters <code>*# +0-<span class="new">?=</span></code></li>
|
||||
<li>Optionally an integer <em>width</em> field</li>
|
||||
<li>Optionally a period character (<code>.</code>) followed
|
||||
by an integer <em>precision</em> field (input ony for most formats)</li>
|
||||
@ -36,6 +37,11 @@ A format converter consists of
|
||||
<li>Additional information required by some converters</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
The flags <code>*# +0-</code> work like in the C functions
|
||||
<em>printf()</em> and <em>scanf()</em>.
|
||||
The flags <code>?</code> and <code>=</code> are extensions.
|
||||
</p>
|
||||
<p>
|
||||
The <code>*</code> flag skips data in input formats.
|
||||
Input is consumed and parsed, a mismatch is an error, but the read
|
||||
@ -61,6 +67,16 @@ The <code>0</code> flag says that numbers should be left padded with
|
||||
The <code>-</code> flag specifies that output is left justified if
|
||||
<em>width</em> is larger than required.
|
||||
</p>
|
||||
<p class="new">
|
||||
The <code>?</code> flag makes failing input conversions succeed with
|
||||
a default zero value (0, 0.0, or "", depending on the format type).
|
||||
</p>
|
||||
<p class="new">
|
||||
The <code>=</code> flag allows to compare input with current values.
|
||||
It is only allowed in input formats.
|
||||
Instead of reading a new value from input, the current value is
|
||||
formatted (like for output) and then compared to the input.
|
||||
</p>
|
||||
|
||||
<h3>Examples:</h3>
|
||||
<table>
|
||||
@ -84,6 +100,14 @@ The <code>-</code> flag specifies that output is left justified if
|
||||
<td><code>in "%*i";</code></td>
|
||||
<td>skipped integer number</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>in "%?d";</code></td>
|
||||
<td>decimal number or nothing (read as 0)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>in "%=.3f";</code></td>
|
||||
<td>compare input to the current value formatted as a float with precision 3</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<a name="types"></a>
|
||||
@ -108,18 +132,25 @@ Thus, data type modifiers like <code>l</code> or <code>h</code> do not
|
||||
exist in <em>StreamDevice</em> formats.
|
||||
</p>
|
||||
|
||||
<h3>Accessing record fields directly</h3>
|
||||
<a name="redirection"></a>
|
||||
<h3>Redirection</h3>
|
||||
<p>
|
||||
To use other fields of the record or even fields of other records on the
|
||||
same IOC for the conversion, write the field name in parentheses directly
|
||||
after the <code>%</code>.
|
||||
For example <code>out "%(EGU)s";</code> outputs the <code>EGU</code>
|
||||
field formatted as a string.
|
||||
Use <code>in "%(<i>otherrecord</i>.VAL)f";</code> to write the floating
|
||||
point input value into the <code>VAL</code> field of
|
||||
<code><i>otherrecord</i></code>.
|
||||
(You can't skip <code>.VAL</code> here.)
|
||||
This is very useful when one line of input contains many values that should
|
||||
Use <code>in "%(<i>otherrecord</i>.RVAL)f";</code> to write the floating
|
||||
point input value into the <code>RVAL</code> field of
|
||||
<code><i>otherrecord</i></code>.
|
||||
<span class="new">
|
||||
If no field is given for an other record .VAL is assumed.
|
||||
When a record name conflicts with a field name use .VAL explicitly.
|
||||
</span>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
This feature is very useful when one line of input contains many values that should
|
||||
be distributed to many records.
|
||||
If <code><i>otherrecord</i></code> is passive and the field has the PP
|
||||
attribute (see
|
||||
@ -129,6 +160,8 @@ It is your responsibility that the data type of the record field is
|
||||
compatible to the the data type of the converter.
|
||||
Note that using this syntax is by far not as efficient as using the
|
||||
default field.
|
||||
At the moment it is not possible to set <code>otherrecord</code> to an alarm
|
||||
state when anything fails.
|
||||
</p>
|
||||
|
||||
<h3>Pseudo-converters</h3>
|
||||
@ -144,31 +177,42 @@ No data type corresponds to those <em>pseudo-converters</em> and the
|
||||
<h2>3. Standard DOUBLE Converters (<code>%f</code>, <code>%e</code>,
|
||||
<code>%E</code>, <code>%g</code>, <code>%G</code>)</h2>
|
||||
<p>
|
||||
In output, <code>%f</code> prints fixed point, <code>%e</code> prints
|
||||
<b>Output:</b> <code>%f</code> prints fixed point, <code>%e</code> prints
|
||||
exponential notation and <code>%g</code> prints either fixed point or
|
||||
exponential depending on the magnitude of the value.
|
||||
<code>%E</code> and <code>%G</code> use <code>E</code> instead of
|
||||
<code>e</code> to separate the exponent.
|
||||
</p>
|
||||
<p>
|
||||
With the <code>#</code> flag, output always contains a period character.
|
||||
</p>
|
||||
<p>
|
||||
In input, all these formats are equivalent.
|
||||
Leading whitespaces are skipped.
|
||||
<b>Input:</b> All these formats are equivalent. Leading whitespaces are skipped.
|
||||
</p>
|
||||
<p class="new">
|
||||
With the <code>#</code> flag additional whitespace between sign and number
|
||||
is accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
When a maximum field width is given, leading whitespace only counts to the
|
||||
field witdth when the space flag is given.
|
||||
</p>
|
||||
|
||||
<a name="stdl"></a>
|
||||
<h2>4. Standard LONG Converters (<code>%d</code>, <code>%i</code>,
|
||||
<code>%u</code>, <code>%o</code>, <code>%x</code>, <code>%X</code>)</h2>
|
||||
<p>
|
||||
In output, <code>%d</code> and <code>%i</code> print signed decimal,
|
||||
<b>Output</b>: <code>%d</code> and <code>%i</code> print signed decimal,
|
||||
<code>%u</code> unsigned decimal, <code>%o</code> unsigned octal, and
|
||||
<code>%x</code> or <code>%X</code> unsigned hexadecimal.
|
||||
<code>%X</code> uses upper case letters.
|
||||
</p>
|
||||
<p>
|
||||
With the <code>#</code> flag, octal values are prefixed with <code>0</code>
|
||||
and hexadecimal values with <code>0x</code> or <code>0X</code>.
|
||||
</p>
|
||||
<p>
|
||||
In input, <code>%d</code> matches signed decimal, <code>%u</code> matches
|
||||
<b>Input:</b> <code>%d</code> matches signed decimal, <code>%u</code> matches
|
||||
unsigned decimal, <code>%o</code> unsigned octal.
|
||||
<code>%x</code> and <code>%X</code> both match upper or lower case unsigned
|
||||
hexadecimal.
|
||||
@ -177,23 +221,40 @@ Octal and hexadecimal values can optionally be prefixed.
|
||||
hexadecimal notation.
|
||||
Leading whitespaces are skipped.
|
||||
</p>
|
||||
<p class="new">
|
||||
With the <code>-</code> negative octal and hexadecimal values are accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
With the <code>#</code> flag additional whitespace between sign and number
|
||||
is accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
When a maximum field width is given, leading whitespace only counts to the
|
||||
field witdth when the space flag is given.
|
||||
</p>
|
||||
|
||||
<a name="stds"></a>
|
||||
<h2>5. Standard STRING Converters (<code>%s</code>, <code>%c</code>)</h2>
|
||||
<p>
|
||||
In output, <code>%s</code> prints a string.
|
||||
<b>Output:</b> <code>%s</code> prints a string.
|
||||
If <em>precision</em> is specified, this is the maximum string length.
|
||||
<code>%c</code> is a LONG format in output, printing one character!
|
||||
</p>
|
||||
<p>
|
||||
In input, <code>%s</code> matches a sequence of non-whitespace characters
|
||||
and <code>%c</code> a sequence of not-null characters.
|
||||
<b>Input:</b> <code>%s</code> matches a sequence of non-whitespace characters
|
||||
and <code>%c</code> matches a sequence of not-null characters.
|
||||
The maximum string length is given by <em>width</em>.
|
||||
The default <em>width</em> is infinite for <code>%s</code> and
|
||||
1 for <code>%c</code>.
|
||||
Leading whitespaces are skipped with <code>%s</code> but not with
|
||||
<code>%c</code>.
|
||||
The empty string matches.
|
||||
Leading whitespaces are skipped with <code>%s</code>
|
||||
<span class="new">
|
||||
except when the space flag is given</span>
|
||||
but not with <code>%c</code>.
|
||||
The empty string matches.
|
||||
</p>
|
||||
<p class="new">
|
||||
With the <code>#</code> flag <code>%s</code> matches a sequence of not-null
|
||||
characters instead of non-whitespace characters.
|
||||
</p>
|
||||
|
||||
<a name="cset"></a>
|
||||
@ -217,14 +278,24 @@ to <code>z</code>.
|
||||
This format maps an unsigned integer value on a set of strings.
|
||||
The value 0 corresponds to <em>string0</em> and so on.
|
||||
The strings are separated by <code>|</code>.
|
||||
If one of the strings contains <code>|</code> or <code>}</code>,
|
||||
a <code>\</code> must be used to escape the character.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%{OFF|STANDBY|ON}</code> mapps the string <code>OFF</code>
|
||||
to the value 0, <code>STANDBY</code> to 1 and <code>ON</code> to 2.
|
||||
</p>
|
||||
<p>
|
||||
When using the <code>#</code> flag it is allowed to assign integer values
|
||||
to the strings using <code>=</code>.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%#{neg=-1|stop=0|pos=1|fast=10}</code>.
|
||||
</p>
|
||||
<p>
|
||||
If one of the strings contains <code>|</code> or <code>}</code>
|
||||
(or <code>=</code> if the <code>#</code> flag is used)
|
||||
a <code>\</code> must be used to escape the character.
|
||||
</p>
|
||||
<p>
|
||||
In output, depending on the value, one of the strings is printed.
|
||||
</p>
|
||||
<p>
|
||||
@ -248,12 +319,11 @@ Examples: <code>%B.!</code> or <code>%B\x00\xff</code>.
|
||||
<code>%B01</code> is equivalent to <code>%b</code>.
|
||||
</p>
|
||||
<p>
|
||||
If in output <em>width</em> is larger than the number of significant bits,
|
||||
In output, if <em>width</em> is larger than the number of significant bits,
|
||||
then the flag <code>0</code> means that the value should be padded with
|
||||
with the chosen zero character instead of spaces.
|
||||
If <em>precision</em> is set, it means the number of significant bits.
|
||||
Otherwise, the highest 1 bit defines the number of significant bits.
|
||||
There is no alternate format when <code>#</code> is used.
|
||||
</p>
|
||||
<p>
|
||||
In input, leading spaces are skipped.
|
||||
@ -275,11 +345,9 @@ endian</em>, i.e. least significant byte first.
|
||||
With the <code>0</code> flag, the value is unsigned, otherwise signed.
|
||||
</p>
|
||||
<p>
|
||||
In output, the <em>width</em> least significant bytes of the value
|
||||
are written.
|
||||
If <em>width</em> is larger than the size of a <code>long</code>,
|
||||
the value is sign extended or zero extended, depending on the
|
||||
<code>0</code> flag.
|
||||
In output, the <em>prec</em> (or sizeof(long) whatever is less) least
|
||||
significant bytes of the value are sign extended or zero extended
|
||||
(depending on the <code>0</code> flag) to <em>width</em> bytes.
|
||||
</p>
|
||||
<p>
|
||||
In input, <em>width</em> bytes are read and put into the value.
|
||||
@ -289,9 +357,25 @@ If <em>width</em> is smaller than the size of a <code>long</code>,
|
||||
the value is sign extended or zero extended, depending on the
|
||||
<code>0</code> flag.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>out "%.2r"</code>
|
||||
</p>
|
||||
|
||||
<a name="rawdouble"></a>
|
||||
<h2>10. Raw DOUBLE Converter (<code>%R</code>)</h2>
|
||||
<p>
|
||||
The raw converter does not really "convert".
|
||||
A float or double value is written or read in the internal
|
||||
(maybe IEEE) representation of the computer.
|
||||
The normal byte order is <em>big endian</em>, i.e. most significant byte
|
||||
first.
|
||||
With the <code>#</code> flag, the byte order is changed to <em>little
|
||||
endian</em>, i.e. least significant byte first.
|
||||
The <em>width</em> must be 4 (float) or 8 (double). The default is 4.
|
||||
</p>
|
||||
|
||||
<a name="bcd"></a>
|
||||
<h2>10. Packed BCD (Binary Coded Decimal) LONG Converter (<code>%D</code>)</h2>
|
||||
<h2>11. Packed BCD (Binary Coded Decimal) LONG Converter (<code>%D</code>)</h2>
|
||||
<p>
|
||||
Packed BCD is a format where each byte contains two binary coded
|
||||
decimal digits (<code>0</code> ... <code>9</code>).
|
||||
@ -320,7 +404,7 @@ than 9.
|
||||
</p>
|
||||
|
||||
<a name="chksum"></a>
|
||||
<h2>11. Checksum Pseudo-Converter (<code>%<<em>checksum</em>></code>)</h2>
|
||||
<h2>12. Checksum Pseudo-Converter (<code>%<<em>checksum</em>></code>)</h2>
|
||||
<p>
|
||||
This is not a normal "converter", because no user data is converted.
|
||||
Instead, a checksum is calculated from the input or output.
|
||||
@ -399,6 +483,9 @@ In input, the next byte or bytes must match the checksum.
|
||||
href="http://www.joegeluso.com/software/articles/ccitt.htm">correct?</a>)
|
||||
implementation of the CCITT standard 16 bit crc checksum with augment.
|
||||
(poly=0x1021, init=0x1D0F, xorout=0x0000).</dd>
|
||||
<dt><code>%<ccitt16x></code> or <code>%<crc16c></code> or <code>%<xmodem></code></dt>
|
||||
<dd>Two bytes. The XMODEM checksum.
|
||||
(poly=0x1021, init=0x0000, xorout=0x0000).</dd>
|
||||
<dt><code>%<crc32></code></dt>
|
||||
<dd>Four bytes. The standard 32 bit crc checksum.
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0xFFFFFFFF).</dd>
|
||||
@ -450,7 +537,7 @@ If <em>prec</em> is given, it specifies the sub-expression whose match
|
||||
is retuned.
|
||||
Otherwise the complete match is returned.
|
||||
In any case, the complete match is consumed from the input buffer.
|
||||
If the expression contains a <code>/</code> is must be escaped.
|
||||
If the expression contains a <code>/</code> it must be escaped.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%.1/<title>(.*)<\/title>/</code> returns
|
||||
@ -458,23 +545,82 @@ the title of an HTML page, skipps anything before the
|
||||
<code><title></code> tag and leaves anything after the
|
||||
<code></title></code> tag in the input buffer.
|
||||
</p>
|
||||
<a name="exp"></a>
|
||||
<h2>13. Exponential DOUBLE converter (<code>%m</code>)</h2>
|
||||
<a name="mantexp"></a>
|
||||
<h2>13. MantissaExponent DOUBLE converter (<code>%m</code>)</h2>
|
||||
<p>
|
||||
This experimental input-only format matches numbers in the format
|
||||
<i>[sign] mantissa sign exponent<i>, e.g <code>+123-4</code> meaning
|
||||
123e-4 or 0.0123. Mantissa and exponent are integers. The sign of the
|
||||
mantissa is optional. Compared to the standard <code>%e</code> format,
|
||||
this format does not contain the characters <code>.</code> and <code>e</code>.
|
||||
This exotic and experimental format matches numbers in the format
|
||||
<i>[sign] mantissa sign exponent</i>, e.g <code>+123-4</code> meaning
|
||||
123e-4 or 0.0123. Mantissa and exponent are decimal integers.
|
||||
The sign of the mantissa is optional.
|
||||
Compared to the standard <code>%e</code> format, this format does not
|
||||
contain the characters <code>.</code> and <code>e</code>.
|
||||
</p>
|
||||
<p>
|
||||
Output formatting is ambigous (e.g. <code>123-4</code> versus
|
||||
<code>1230-5</code>). Until it has been specified how to handle this,
|
||||
output is not supported.
|
||||
<code>1230-5</code>). I chose the following convention:
|
||||
Format <em>precision</em> defines number of digits in mantissa.
|
||||
No leading '0' in mantissa (except for 0.0 of course).
|
||||
Number of digits in exponent is at least 2.
|
||||
Format flags <code>+</code>, <code>-</code>, and space are supported in
|
||||
the usual way (always sign, left justified, space instead of + sign).
|
||||
Flags <code>#</code> and <code>0</code> are unsupported.
|
||||
</p>
|
||||
<div class="new">
|
||||
<a name="timestamp"></a>
|
||||
<h2>14. Timestamp DOUBLE converter (<code>%T(<em>timeformat</em>)</code>)</h2>
|
||||
<p>
|
||||
This format reads or writes timestamps and converts them to a double number.
|
||||
The value represents the number of seconds since 1970 (the UNIX epoch).
|
||||
The precision of a double is large enough for microseconds (but not for
|
||||
nanoseconds). This format is probably used best in combination with a
|
||||
redirection to the <code>TIME</code> field. In this case, the value is
|
||||
converted to EPICS timestamps (seconds since 1990 and nanoseconds).
|
||||
The timestamp format understands the usual converters that the C function
|
||||
<em>strftime()</em> understands. In addition, fractions of a second can
|
||||
be specified and the time zone can be set in the format string.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%(TIME)T(%d %b %Y %H:%M:%.3S %z)</code> may print something like
|
||||
<code> 3 Sep 2010 15:45:59 +0200</code>.
|
||||
</p>
|
||||
<p>
|
||||
Fractions of a second can be specified as <code>%.<em>n</em>S</code>
|
||||
(seconds with <em>n</em> fractional digits), as <code>%0<em>n</em>f</code>
|
||||
or <code>%<em>n</em>f</code> (<em>n</em> fractional digits) or as
|
||||
<code>%N</code> (nanoseconds).
|
||||
In input, <em>n</em> is the maximum number of digits parsed, there may be
|
||||
actually less digits in the input.
|
||||
If <em>n</em> is not specified (<code>%.S</code> or <code>%f</code>) it uses
|
||||
a default value of 6.
|
||||
</p>
|
||||
<p>
|
||||
In input, the time zone can be specified in the format like
|
||||
<code>%+<em>hhmm</em></code> or <code>%-<em>hhmm</em></code> for cases
|
||||
where the parsed time stamp does not specify the time zone, where
|
||||
<em>hhmm</em> is a 4 digit number specifying the offset in hours and minutes.
|
||||
</p>
|
||||
<p>
|
||||
In output, the system function <em>strftime()</em> is used to format the time.
|
||||
There may be differences in the implementation between operating systems.
|
||||
</p>
|
||||
<p>
|
||||
In input, <em>StreamDevice</em> used its own implementation because many
|
||||
systems are missing the <em>strptime()</em> function and additional formats
|
||||
are supported.
|
||||
</p>
|
||||
<p>
|
||||
Day of the week can be parsed but is ignored because the information is
|
||||
redundant when used together with day, month and year and more or less
|
||||
useless otherwise. No check is done for consistency.
|
||||
</p>
|
||||
<p>
|
||||
Because of the complexity of the problem, locales are not supported.
|
||||
Thus, only the English month names can be used (week day names are
|
||||
ignored anyway).
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<p align="right"><a href="processing.html">Next: Record Processing</a></p>
|
||||
<p><small>Dirk Zimoch, 2007</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
<p><small>Dirk Zimoch, 2011</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,32 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Headbar</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {margin:0px 0px 0px 0px;}
|
||||
big {font-size: 30px; font-family:serif;}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
<table cellspacing=0 cellpadding=0 border=0 width="100%">
|
||||
<tr><td bgcolor="#267ab8" colspan=6 valign="bottom" height=9 width="100%"></td></tr>
|
||||
<tr><td bgcolor="#000000" colspan=6 valign="bottom" height=1 width="100%"></td></tr>
|
||||
<tr>
|
||||
<td><img src="space.gif" width=180 height=1 alt=""><center><a href="http://www.psi.ch" target="ex"><img src="PSI.gif" width=150 height=55 alt="PSI" border=0></a></center></td>
|
||||
<td><img src="space.gif" width=1 height=65 alt=""></td>
|
||||
<td><a href="http://www.aps.anl.gov/epics" target="ex"><img
|
||||
src="EPICS.gif" border=0 width=50 height=50 alt="EPICS"></a></td>
|
||||
<td width="100%" align="center" nowrap>
|
||||
<big><b><em id="subtitle">StreamDevice</em></b></big></td>
|
||||
<td><img src="space.gif" width=166 height=1 alt=""><center><a href="http://sls.web.psi.ch/view.php/about/index.html" target="ex"><img src="SLS.gif" width=146 height=55 alt="SLS" border=0></a></center></td>
|
||||
</tr>
|
||||
<tr><td bgcolor="#267ab8" colspan=6 valign="bottom" height=4 width="100%"></td></tr>
|
||||
<tr><td bgcolor="#000000" colspan=6 valign="bottom" height=1 width="100%"></td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
124
doc/index.html
@ -1,20 +1,116 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
|
||||
"http://www.w3.org/TR/html4/frameset.dtd">
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice Documentation</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<title>StreamDevice</title>
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<frameset rows="80,*" framespacing=0 frameborder=0 border=0>
|
||||
<frame src="head.html" name="head" scrolling="no" noresize>
|
||||
<frameset cols="180,*" >
|
||||
<frame src="nav.html" name="nav" noresize>
|
||||
<frame src="stream.html" name="text">
|
||||
</frameset>
|
||||
<noframes>
|
||||
<a href="stream.html">Click here for no-frames version.</a>
|
||||
</noframes>
|
||||
</frameset>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>EPICS <em>StreamDevice</em></h1>
|
||||
|
||||
<h2>What is <em>StreamDevice</em>?</h2>
|
||||
<p>
|
||||
<em>StreamDevice</em> is a generic
|
||||
<a href="http://www.aps.anl.gov/epics" 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
|
||||
receiving strings (in the broadest sense, including non-printable
|
||||
characters and even null-bytes).
|
||||
Examples for this type of communication interface are
|
||||
serial line (RS-232, RS-485, ...),
|
||||
IEEE-488 (also known as GPIB or HP-IB), and telnet-like TCP/IP.
|
||||
</p>
|
||||
<p>
|
||||
<em>StreamDevice</em> is not limited to a specific device type or
|
||||
manufacturer nor is it necessary to re-compile anything to support a
|
||||
new device type.
|
||||
Instead, it can be configured for any device type with
|
||||
<a href="protocol.html"><em>protocol files</em></a> in plain ASCII text
|
||||
which describes the commands a device understands and the replies it sends.
|
||||
If the device can be controlled with strings like
|
||||
"<kbd>RF:FREQ 499.655 MHZ</kbd>" <em>StreamDevice</em> can be used.
|
||||
Formatting and parsing of values is done with
|
||||
<a href="formats.html"><em>format converters</em></a> similar to those
|
||||
known from the C functions <em>printf()</em> and <em>scanf()</em>.
|
||||
To support other formats, it is possible to
|
||||
<a href="formatconverter.html">write your own converters</a>.
|
||||
</p>
|
||||
<p>
|
||||
Each record with <em>StreamDevice</em> support runs one protocol
|
||||
from the protocol file to read or write its value.
|
||||
Protocols can be as simple as just one output string or can
|
||||
consist of many strings sent to and read from the device.
|
||||
However, a protocol is linear.
|
||||
That means it runs from start to end each time the record is
|
||||
<a href="processing.html">processed</a>.
|
||||
It does not provide loops or branches.
|
||||
</p>
|
||||
<p>
|
||||
<em>StreamDevice</em> comes with an interface to<a target="ex"
|
||||
href="http://www.aps.anl.gov/epics/modules/soft/asyn/">
|
||||
<em>asynDriver</em></a>
|
||||
but can be extended to
|
||||
<a href="businterface.html">support other bus drivers</a>.
|
||||
Note that <em>StreamDevice</em> is not an alternative or replacement
|
||||
but a supplement for <em>asynDriver</em>.
|
||||
<em>StreamDevice</em> converts record values to and from strings but
|
||||
leaves it to <em>asynDriver</em> (or other bus interfaces) to exchange
|
||||
these strings with the device.
|
||||
Thus any bus type supported by <em>asynDriver</em> (to be exact by
|
||||
<em>asynOctet</em>) can automatically be used with <em>StreamDevice</em>.
|
||||
</p>
|
||||
<p>
|
||||
<em>StreamDevice</em> supports all
|
||||
<a href="recordtypes.html">standard records</a> of EPICS base
|
||||
which can have device support.
|
||||
It is also possible to
|
||||
<a href="recordinterface.html">write support for new record types</a>.
|
||||
</p>
|
||||
|
||||
<h2>What is <em>StreamDevice</em> not?</h2>
|
||||
<p>
|
||||
It is not a programming language for a high-level application.
|
||||
It is, for example, not possible to write a complete scanning program
|
||||
in a protocol.
|
||||
Use other tools for that and use <em>StreamDevice</em> only for the
|
||||
primitive commands.
|
||||
</p>
|
||||
<p>
|
||||
It is not a block oriented device support.
|
||||
It is not possible to send or receive huge blocks of data that contain
|
||||
many process variables distributed over many records.
|
||||
</p>
|
||||
|
||||
<h2>Recommended Readings</h2>
|
||||
<p>
|
||||
<a href="http://www.aps.anl.gov/epics/base/R3-14/12-docs/AppDevGuide"
|
||||
target="ex">IOC Application Developer's Guide</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14"
|
||||
target="ex">EPICS Record Reference Manual</a>
|
||||
</p>
|
||||
|
||||
<h2>Color and Style Conventions</h2>
|
||||
<p>
|
||||
In this document, code is witten in <code>green fixed width font</code>.
|
||||
This marks text you typically type in configuration files etc.
|
||||
</p>
|
||||
<pre>
|
||||
Longer code segments are often set in a box.
|
||||
</pre>
|
||||
<p>
|
||||
Important modifications and new features are
|
||||
<span class="new">highlighted with a yellow background</span>.
|
||||
Obsolete features are <strike class="new">highlighted and crossed out</strike>.
|
||||
</p>
|
||||
<hr>
|
||||
<p align="right"><a href="setup.html">Next: Setup</a></p>
|
||||
<p><small>Dirk Zimoch, 2011</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: longin Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: longin Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -25,6 +26,8 @@ written or read value.
|
||||
<dd>
|
||||
<u>Output:</u> <code><i>x</i>=VAL</code><br>
|
||||
<u>Input:</u> <code>VAL=<i>x</i></code>
|
||||
Using unsigned formats with values ≥ 0x800000 gives different results
|
||||
on 64 bit machines.
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
@ -63,6 +66,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: longout Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: longout Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -25,6 +26,8 @@ written or read value.
|
||||
<dd>
|
||||
<u>Output:</u> <code><i>x</i>=VAL</code><br>
|
||||
<u>Input:</u> <code>VAL=<i>x</i></code>
|
||||
Using unsigned formats with values ≥ 0x800000 gives different results
|
||||
on 64 bit machines.
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
@ -63,6 +66,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: mbbi Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbi Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -89,6 +90,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: mbbiDirect Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbiDirect Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -75,6 +76,5 @@ written or read value.
|
||||
<a href="scalcout.html">calcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: mbbo Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbo Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -90,6 +91,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: mbboDirect Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbboDirect Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -77,6 +78,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
376
doc/nav.html
@ -5,216 +5,210 @@
|
||||
<title>Navbar</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
active="";
|
||||
function show(name) {
|
||||
var m = document.getElementById(name);
|
||||
var b = document.getElementById(name+"Button");
|
||||
if (active != "") { hide(active); }
|
||||
m.style.display = "block";
|
||||
b.innerHTML="[«]";
|
||||
b.href="javascript:hide(\'"+name+"\')"
|
||||
active=name;
|
||||
}
|
||||
function hide(name) {
|
||||
var m = document.getElementById(name);
|
||||
var b = document.getElementById(name+"Button");
|
||||
m.style.display = "none";
|
||||
b.innerHTML="[»]";
|
||||
b.href="javascript:show(\'"+name+"\')"
|
||||
active="";
|
||||
}
|
||||
function printview() {
|
||||
w = window.open(parent.text.location, "_parent", "dependent=yes,width=800,menubar=yes,toolbar=yes,location=yes");
|
||||
}
|
||||
-->
|
||||
</script>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {margin:0px 0px 0px 0px;
|
||||
font-family:sans-serif;
|
||||
body {margin:0 0 13ex 1em;
|
||||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
font-weight:bold;
|
||||
font-size:13px;}
|
||||
font-size:13px;
|
||||
background-color:#e3eaf6;}
|
||||
a {text-decoration:none;}
|
||||
a:link {color:#333333;}
|
||||
a:visited {color:#333333;}
|
||||
a:hover {color:#FF0000;}
|
||||
a:active {color:#FF0000;}
|
||||
.top {margin-bottom: 0px;
|
||||
margin-top: 10px;
|
||||
border-bottom: solid 1px black;}
|
||||
.top ul {margin-left: 5px;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 2px;
|
||||
font-size:95%;
|
||||
line-height:120%;
|
||||
padding-left:1em;}
|
||||
.subsub {margin-left: 15px;
|
||||
line-height:120%;
|
||||
font-size:80%;}
|
||||
|
||||
h1 {font-size:120%;
|
||||
margin-top: 20px;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 10px;
|
||||
color:#267ab8;}
|
||||
|
||||
div {border-bottom:1px solid black;
|
||||
padding-top:1ex;}
|
||||
|
||||
div div, div div div, div:hover div div
|
||||
{
|
||||
padding-top:0;
|
||||
margin-right:.1em;
|
||||
border:none;
|
||||
box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
padding 0;
|
||||
display:block;
|
||||
position:relative;
|
||||
}
|
||||
div div
|
||||
{display:none;
|
||||
margin-left:2em;
|
||||
margin-right:1em;
|
||||
background-color:#e3eaf6;
|
||||
padding:0 .5em .5ex .5em;
|
||||
border-width:0 thick thick 1px;
|
||||
border-color:black;
|
||||
border-style:solid;
|
||||
}
|
||||
:root *> div div
|
||||
{border-width:0 1px 1px 1px;
|
||||
box-shadow: 5px 5px 5px black;
|
||||
-moz-box-shadow: 5px 5px 5px black;
|
||||
-webkit-box-shadow: 5px 5px 5px black;
|
||||
}
|
||||
div:hover div {
|
||||
position:absolute;
|
||||
display:block;}
|
||||
|
||||
div div div {margin-left:0;}
|
||||
|
||||
a {display:block;
|
||||
margin-top:.3ex;}
|
||||
|
||||
div div a {display:list-item;
|
||||
margin-left:1em;
|
||||
list-style-type:disc;
|
||||
}
|
||||
|
||||
div div div a {list-style-type:circle;}
|
||||
|
||||
-->
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body background="bg.gif">
|
||||
<p align="center">
|
||||
</p>
|
||||
<div style="margin-left: 20px;">
|
||||
<h1>User's Guide</h1>
|
||||
<div class="top">
|
||||
<a target="text" href="stream.html">Intro</a>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="setup.html">Setup</a>
|
||||
<a href="javascript:show('setup')" id="setupButton"></a>
|
||||
<ul id="setup">
|
||||
<li><a target="text" href="setup.html#pre">Prerequisites</a>
|
||||
<ul>
|
||||
<li><a target="text" href="epics3_13.html">Using EPICS 3.13</a></li>
|
||||
</ul></li>
|
||||
<li><a target="text" href="setup.html#lib">Build Library</a></li>
|
||||
<li><a target="text" href="setup.html#app">Build Application</a></li>
|
||||
<li><a target="text" href="setup.html#sta">Startup Script</a></li>
|
||||
<li><a target="text" href="setup.html#pro">Protocol File</a>
|
||||
<ul>
|
||||
<li><a target="text" href="setup.html#reload">Reloading</a></li>
|
||||
</ul></li>
|
||||
<li><a target="text" href="setup.html#rec">Records</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="protocol.html">Protocol Files</a>
|
||||
<a href="javascript:show('protocol')" id="protocolButton"></a>
|
||||
<ul id="protocol">
|
||||
<li><a target="text" href="protocol.html#gen">General</a></li>
|
||||
<li><a target="text" href="protocol.html#proto">Protocols</a></li>
|
||||
<li><a target="text" href="protocol.html#cmd">Commands</a></li>
|
||||
<li><a target="text" href="protocol.html#str">Strings</a></li>
|
||||
<li><a target="text" href="protocol.html#var">Variables</a>
|
||||
<ul>
|
||||
<li><a target="text" href="protocol.html#sysvar">System variables</a></li>
|
||||
<li><a target="text" href="protocol.html#argvar">Protocol Arguments</a></li>
|
||||
<li><a target="text" href="protocol.html#usrvar">User variables</a></li>
|
||||
</ul></li>
|
||||
<li><a target="text" href="protocol.html#except">Exception Handlers</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="formats.html">Format Converters</a>
|
||||
<a href="javascript:show('formats')" id="formatsButton"></a>
|
||||
<ul id="formats">
|
||||
<li><a target="text" href="formats.html#syntax">Syntax</a></li>
|
||||
<li><a target="text" href="formats.html#types">Types & Fields</a></li>
|
||||
<li><a target="text" href="formats.html#stdd">%f %e %g</a></li>
|
||||
<li><a target="text" href="formats.html#stdl">%i %d %u %o %x</a></li>
|
||||
<li><a target="text" href="formats.html#stds">%s %c</a></li>
|
||||
<li><a target="text" href="formats.html#cset">%[<em>charset</em>]</a></li>
|
||||
<li><a target="text" href="formats.html#enum">%{<em>s0</em>|<em>s1</em>|...}</a></li>
|
||||
<li><a target="text" href="formats.html#bin">%b %B</a></li>
|
||||
<li><a target="text" href="formats.html#raw">%r</a></li>
|
||||
<li><a target="text" href="formats.html#bcd">%D</a></li>
|
||||
<li><a target="text" href="formats.html#chksum">%<<em>checksum</em>></a></li>
|
||||
<li><a target="text" href="formats.html#regex">%/<em>regex</em>/</a></li>
|
||||
<li><a target="text" href="formats.html#exp">%m</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="processing.html">Record Processing</a>
|
||||
<a href="javascript:show('proc')" id="procButton"></a>
|
||||
<ul id="proc">
|
||||
<li><a target="text" href="processing.html#proc">Normal Processing</a></li>
|
||||
<li><a target="text" href="processing.html#init">Initialization</a></li>
|
||||
<li><a target="text" href="processing.html#iointr">I/O Intr</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="recordtypes.html">Record Types</a>
|
||||
<a href="javascript:show('records')" id="recordsButton"></a>
|
||||
<ul id="records" class="sub">
|
||||
<li><a target="text" href="aai.html">aai</a></li>
|
||||
<li><a target="text" href="aao.html">aao</a></li>
|
||||
<li><a target="text" href="ai.html">ai</a></li>
|
||||
<li><a target="text" href="ao.html">ao</a></li>
|
||||
<li><a target="text" href="bi.html">bi</a></li>
|
||||
<li><a target="text" href="bo.html">bo</a></li>
|
||||
<li><a target="text" href="mbbi.html">mbbi</a></li>
|
||||
<li><a target="text" href="mbbo.html">mbbo</a></li>
|
||||
<li><a target="text" href="mbbiDirect.html">mbbiDirect</a></li>
|
||||
<li><a target="text" href="mbboDirect.html">mbboDirect</a></li>
|
||||
<li><a target="text" href="stringin.html">stringin</a></li>
|
||||
<li><a target="text" href="stringout.html">stringout</a></li>
|
||||
<li><a target="text" href="longin.html">longin</a></li>
|
||||
<li><a target="text" href="longout.html">longout</a></li>
|
||||
<li><a target="text" href="waveform.html">waveform</a></li>
|
||||
<li><a target="text" href="calcout.html">calcout</a></li>
|
||||
<li><a target="text" href="scalcout.html">scalcout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="tipsandtricks.html">Tips & Tricks</a>
|
||||
<a href="javascript:show('tipsandtricks')" id="tipsandtricksButton"></a>
|
||||
<ul id="tipsandtricks">
|
||||
<li><a target="text" href="tipsandtricks.html#argvar">Many almost identical protocols</a></li>
|
||||
<li><a target="text" href="tipsandtricks.html#iointr">Read unsolicited input</a></li>
|
||||
<li><a target="text" href="tipsandtricks.html#multiline">Read multi-line messages</a></li>
|
||||
<li><a target="text" href="tipsandtricks.html#writemany">Write more than one value in one message</a></li>
|
||||
<li><a target="text" href="tipsandtricks.html#readmany">Read more than one value from one message</a></li>
|
||||
<li><a target="text" href="tipsandtricks.html#mixed">Read values of mixed data type</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h1>Programmer's Guide</h1>
|
||||
<div class="top">
|
||||
<a target="text" href="recordinterface.html">Record API</a>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="businterface.html">Bus API</a>
|
||||
<a href="javascript:show('bus')" id="busButton"></a>
|
||||
<ul id="bus">
|
||||
<li><a target="text" href="businterface.html#class">Interface Class</a></li>
|
||||
<li><a target="text" href="businterface.html#theory">Theory of Operation</a>
|
||||
<ul>
|
||||
<li><a target="text" href="businterface.html#registration">Registration</a></li>
|
||||
<li><a target="text" href="businterface.html#create">Creation & deletion</a></li>
|
||||
<li><a target="text" href="businterface.html#connect">Connecting</a></li>
|
||||
<li><a target="text" href="businterface.html#lock">Bus locking</a></li>
|
||||
<li><a target="text" href="businterface.html#write">Writing output</a></li>
|
||||
<li><a target="text" href="businterface.html#read">Reading input</a></li>
|
||||
<li><a target="text" href="businterface.html#event">Handling events</a></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="formatconverter.html">Format Converter API</a>
|
||||
</div>
|
||||
<div class="top">
|
||||
<a target="text" href="osinterface.html">Operating System API</a>
|
||||
<body>
|
||||
<h1>User's Guide</h1>
|
||||
<div>
|
||||
<a target="_parent" href="index.html">Intro</a>
|
||||
</div>
|
||||
<div>
|
||||
<a target="_parent" href="setup.html">Setup</a>
|
||||
<a href="javascript:show('setup')" id="setupButton"></a>
|
||||
<div>
|
||||
<a target="_parent" href="setup.html#pre">Prerequisites</a>
|
||||
<div>
|
||||
<a target="_parent" href="epics3_13.html">Using EPICS 3.13</a>
|
||||
</div>
|
||||
<a target="_parent" href="setup.html#lib">Build Library</a>
|
||||
<a target="_parent" href="setup.html#app">Build Application</a>
|
||||
<a target="_parent" href="setup.html#sta">Startup Script</a>
|
||||
<a target="_parent" href="setup.html#pro">Protocol File</a>
|
||||
<div>
|
||||
<a target="_parent" href="setup.html#reload">Reloading</a>
|
||||
</div>
|
||||
<a target="_parent" href="setup.html#rec">Records</a>
|
||||
</div>
|
||||
</div>
|
||||
<p align="center" style="margin-top:20px;">
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
document.writeln('<a href="javascript:printview()">' +
|
||||
'<img src="printer.gif" alt="Printer friendly" border=0><br>' +
|
||||
'<small>Printer friendly<\/small><\/a>');
|
||||
hide('setup');
|
||||
hide('protocol');
|
||||
hide('formats');
|
||||
hide('proc');
|
||||
hide('records');
|
||||
hide('bus');
|
||||
hide('tipsandtricks');
|
||||
chapter=decodeURIComponent(parent.location.search.substr(1));
|
||||
if (chapter) parent.text.location.href=chapter;
|
||||
//-->
|
||||
</script>
|
||||
</p>
|
||||
<div>
|
||||
<a target="_parent" href="protocol.html">Protocol Files</a>
|
||||
<a href="javascript:show('protocol')" id="protocolButton"></a>
|
||||
<div>
|
||||
<a target="_parent" href="protocol.html#gen">General</a>
|
||||
<a target="_parent" href="protocol.html#proto">Protocols</a>
|
||||
<a target="_parent" href="protocol.html#cmd">Commands</a>
|
||||
<a target="_parent" href="protocol.html#str">Strings</a>
|
||||
<a target="_parent" href="protocol.html#var">Variables</a>
|
||||
<div>
|
||||
<a target="_parent" href="protocol.html#sysvar">System variables</a>
|
||||
<a target="_parent" href="protocol.html#argvar">Protocol Arguments</a>
|
||||
<a target="_parent" href="protocol.html#usrvar">User variables</a>
|
||||
</div>
|
||||
<a target="_parent" href="protocol.html#except">Exception Handlers</a>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<a target="_parent" href="formats.html">Format Converters</a>
|
||||
<a href="javascript:show('formats')" id="formatsButton"></a>
|
||||
<div>
|
||||
<a target="_parent" href="formats.html#syntax">Syntax</a>
|
||||
<a target="_parent" href="formats.html#types">Types & Fields</a>
|
||||
<a target="_parent" href="formats.html#stdd" title="Standard DOUBLE converters">%f %e %g</a>
|
||||
<a target="_parent" href="formats.html#stdl" title="Standard LONG converters">%i %d %u %o %x</a>
|
||||
<a target="_parent" href="formats.html#stds" title="Standard STRING converters">%s %c</a>
|
||||
<a target="_parent" href="formats.html#cset" title="Character set STRING converter">%[<em>charset</em>]</a>
|
||||
<a target="_parent" href="formats.html#enum" title="Enumeration LONG converter">%{<em>s0</em>|<em>s1</em>|...}</a>
|
||||
<a target="_parent" href="formats.html#bin" title="Binary LONG converter">%b %B</a>
|
||||
<a target="_parent" href="formats.html#raw" title="Raw LONG converter">%r</a>
|
||||
<a target="_parent" href="formats.html#rawdouble" title="Raw DOUBLE converter">%R</a>
|
||||
<a target="_parent" href="formats.html#bcd" title="Binary coded decimal LONG converter">%D</a>
|
||||
<a target="_parent" href="formats.html#chksum" title="Checksum pseudo converter">%<<em>checksum</em>></a>
|
||||
<a target="_parent" href="formats.html#regex" title="Perl regular expression STRING converter">%/<em>regex</em>/</a>
|
||||
<a target="_parent" href="formats.html#mantexp" title="MantissaExponent DOUBLE converter">%m</a>
|
||||
<a target="_parent" href="formats.html#timestamp" title="Timestamp DOUBLE converter">%T</a>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<a target="_parent" href="processing.html">Record Processing</a>
|
||||
<a href="javascript:show('proc')" id="procButton"></a>
|
||||
<div>
|
||||
<a target="_parent" href="processing.html#proc">Normal Processing</a>
|
||||
<a target="_parent" href="processing.html#init">Initialization</a>
|
||||
<a target="_parent" href="processing.html#iointr">I/O Intr</a>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<a target="_parent" href="recordtypes.html">Record Types</a>
|
||||
<a href="javascript:show('records')" id="recordsButton"></a>
|
||||
<div>
|
||||
<a target="_parent" href="aai.html">aai</a>
|
||||
<a target="_parent" href="aao.html">aao</a>
|
||||
<a target="_parent" href="ai.html">ai</a>
|
||||
<a target="_parent" href="ao.html">ao</a>
|
||||
<a target="_parent" href="bi.html">bi</a>
|
||||
<a target="_parent" href="bo.html">bo</a>
|
||||
<a target="_parent" href="mbbi.html">mbbi</a>
|
||||
<a target="_parent" href="mbbo.html">mbbo</a>
|
||||
<a target="_parent" href="mbbiDirect.html">mbbiDirect</a>
|
||||
<a target="_parent" href="mbboDirect.html">mbboDirect</a>
|
||||
<a target="_parent" href="stringin.html">stringin</a>
|
||||
<a target="_parent" href="stringout.html">stringout</a>
|
||||
<a target="_parent" href="longin.html">longin</a>
|
||||
<a target="_parent" href="longout.html">longout</a>
|
||||
<a target="_parent" href="waveform.html">waveform</a>
|
||||
<a target="_parent" href="calcout.html">calcout</a>
|
||||
<a target="_parent" href="scalcout.html">scalcout</a>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<a target="_parent" href="tipsandtricks.html">Tips & Tricks</a>
|
||||
<a href="javascript:show('tipsandtricks')" id="tipsandtricksButton"></a>
|
||||
<div>
|
||||
<a target="_parent" href="tipsandtricks.html#argvar">Many almost identical protocols</a>
|
||||
<a target="_parent" href="tipsandtricks.html#iointr">Read unsolicited input</a>
|
||||
<a target="_parent" href="tipsandtricks.html#multiline">Read multi-line messages</a>
|
||||
<a target="_parent" href="tipsandtricks.html#writemany">Write more than one value in one message</a>
|
||||
<a target="_parent" href="tipsandtricks.html#readmany">Read more than one value from one message</a>
|
||||
<a target="_parent" href="tipsandtricks.html#mixed">Read values of mixed data type</a>
|
||||
<a target="_parent" href="tipsandtricks.html#web">Read a web page</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1>Programmer's Guide</h1>
|
||||
<div>
|
||||
<a target="_parent" href="recordinterface.html">Record API</a>
|
||||
</div>
|
||||
<div>
|
||||
<a target="_parent" href="businterface.html">Bus API</a>
|
||||
<a href="javascript:show('bus')" id="busButton"></a>
|
||||
<div>
|
||||
<a target="_parent" href="businterface.html#class">Interface Class</a>
|
||||
<a target="_parent" href="businterface.html#theory">Theory of Operation</a>
|
||||
<div>
|
||||
<a target="_parent" href="businterface.html#registration">Registration</a>
|
||||
<a target="_parent" href="businterface.html#create">Creation & deletion</a>
|
||||
<a target="_parent" href="businterface.html#connect">Connecting</a>
|
||||
<a target="_parent" href="businterface.html#lock">Bus locking</a>
|
||||
<a target="_parent" href="businterface.html#write">Writing output</a>
|
||||
<a target="_parent" href="businterface.html#read">Reading input</a>
|
||||
<a target="_parent" href="businterface.html#event">Handling events</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<a target="_parent" href="formatconverter.html">Format Converter API</a>
|
||||
</div>
|
||||
<div>
|
||||
<a target="_parent" href="osinterface.html">Operating System API</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -3,18 +3,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Operating System API</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Operating System API</h1>
|
||||
|
||||
<h2>Sorry, this documentation is still missing.</h2>
|
||||
|
||||
<hr>
|
||||
<p><small>Dirk Zimoch, 2006</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
BIN
doc/printer.gif
Before Width: | Height: | Size: 1.2 KiB |
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Record Processing</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record Processing</h1>
|
||||
|
||||
<a name="proc"></a>
|
||||
@ -239,6 +240,5 @@ with "<code>ROI</code>", followed by two floating point numbers.
|
||||
<hr>
|
||||
<p align="right"><a href="recordtypes.html">Next: Supported Record Types</a></p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Protocol Files</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Protocol Files</h1>
|
||||
<a name="gen"></a>
|
||||
<h2>1. General Information</h2>
|
||||
@ -241,8 +242,12 @@ that hex value.<br>
|
||||
that octal value.<br>
|
||||
<code>\1</code> to <code>\9</code> followed by up to two more decimal
|
||||
digits means a byte with that decimal value.<br>
|
||||
<code>\?</code> in the argument string of an <code>in</code>
|
||||
<a href="#cmd">command</a> matches any input byte<br>
|
||||
<code>\?</code> in input matches any byte, in output it does not print
|
||||
anything.<br>
|
||||
<span class="new">
|
||||
<code>\_</code> in input matches any amount of white space (including none),
|
||||
in output it prints a single space.<br>
|
||||
</span>
|
||||
<code>\$</code> followed by the name of a
|
||||
<a href="#var">protocol varible</a> is replaced by the contents of that
|
||||
variable.
|
||||
@ -251,29 +256,54 @@ variable.
|
||||
For non-printable characters, it is often easier to write sequences of
|
||||
byte values instead of escaped quoted string literals.
|
||||
A byte is written as an unquoted decimal, hexadecimal, or octal
|
||||
number in the range of -128 to 255 (-0x80 to 0xff, -0200 to 0377).
|
||||
<em>StreamDevice</em> also defines some symbolic names for frequently
|
||||
used byte codes as aliases for the numeric byte value:<br>
|
||||
<code>EOT</code> means <em>end of transmission</em> (ASCII code 4).<br>
|
||||
<code>ACK</code> means <em>acknowledge</em> (ASCII code 6).<br>
|
||||
<code>BEL</code> means <em>bell</em> (ASCII code 7).<br>
|
||||
<code>BS</code> means <em>backspace</em> (ASCII code 8).<br>
|
||||
<code>HT</code> or <code>TAB</code> mean <em>horizontal tabulator</em>
|
||||
(ASCII code 9).<br>
|
||||
<code>LF</code> or <code>NL</code> mean <em>line feed</em> /
|
||||
<em>new line</em> (ASCII code 10).<br>
|
||||
<code>CR</code> means <em>carriage return</em> (ASCII code 13).<br>
|
||||
<code>ESC</code> means <em>escape</em> (ASCII code 27).<br>
|
||||
<code>DEL</code> means <em>delete</em> (ASCII code 127).<br>
|
||||
<code>SKIP</code> in the argument string of an <code>in</code>
|
||||
<a href="#cmd">command</a> matches any input byte.
|
||||
number in the range of <code>-128</code> to <code>255</code>,
|
||||
<code>-0x80</code> to <code>0xff</code> (not case sesitive),
|
||||
or <code>-0200</code> to <code>0377</code>, respectively.
|
||||
</p>
|
||||
<p>
|
||||
<em>StreamDevice</em> also recordgnizes the ASCII symbolic names
|
||||
(not case sensitive) for several byte codes:<br>
|
||||
<code>NUL </code>(= <code>0x00</code>) <em>null</em><br>
|
||||
<code>SOH </code>(= <code>0x01</code>) <em>start of heading</em><br>
|
||||
<code>STX </code>(= <code>0x02</code>) <em>start of text</em><br>
|
||||
<code>ETX </code>(= <code>0x03</code>) <em>end of text</em><br>
|
||||
<code>EOT </code>(= <code>0x04</code>) <em>end of transmission</em><br>
|
||||
<code>ENQ </code>(= <code>0x05</code>) <em>enquiry</em><br>
|
||||
<code>ACK </code>(= <code>0x06</code>) <em>acknowledge</em><br>
|
||||
<code>BEL </code>(= <code>0x07</code>) <em>bell</em><br>
|
||||
<code>BS </code>(= <code>0x08</code>) <em>backspace</em><br>
|
||||
<code>HT</code> or <code>TAB</code> (= <code>0x09</code>) <em>horizontal tabulator</em><br>
|
||||
<code>LF</code> or <code>NL</code> (= <code>0x0A</code> or <code>10</code>) <em>line feed / new line</em><br>
|
||||
<code>VT </code>(= <code>0x0B</code> or <code>11</code>) <em>vertical tabulator</em><br>
|
||||
<code>FF</code> or <code>NP</code> (= <code>0x0C</code> or <code>12</code>) <em>form feed / new page</em><br>
|
||||
<code>CR </code>(= <code>0x0D</code> or <code>13</code>) <em>carriage return</em><br>
|
||||
<code>SO </code>(= <code>0x0E</code> or <code>14</code>) <em>shift out</em><br>
|
||||
<code>SI </code>(= <code>0x0F</code> or <code>15</code>) <em>shift in</em><br>
|
||||
<code>DLE </code>(= <code>0x10</code> or <code>16</code>) <em>data link escape</em><br>
|
||||
<code>DC1 </code>(= <code>0x11</code> or <code>17</code>) <em>device control 1</em><br>
|
||||
<code>DC2 </code>(= <code>0x12</code> or <code>18</code>) <em>device control 2</em><br>
|
||||
<code>DC3 </code>(= <code>0x13</code> or <code>19</code>) <em>device control 3</em><br>
|
||||
<code>DC4 </code>(= <code>0x14</code> or <code>20</code>) <em>device control 4</em><br>
|
||||
<code>NAK </code>(= <code>0x15</code> or <code>21</code>) <em>negative acknowledge</em><br>
|
||||
<code>SYN </code>(= <code>0x16</code> or <code>22</code>) <em>synchronous idle</em><br>
|
||||
<code>ETB </code>(= <code>0x17</code> or <code>23</code>) <em>end of transmission block</em><br>
|
||||
<code>CAN </code>(= <code>0x18</code> or <code>24</code>) <em>cancel</em><br>
|
||||
<code>EM </code>(= <code>0x19</code> or <code>25</code>) <em>end of medium</em><br>
|
||||
<code>SUB </code>(= <code>0x1A</code> or <code>26</code>) <em></em>substitute<br>
|
||||
<code>ESC </code>(= <code>0x1B</code> or <code>27</code>) <em>escape</em><br>
|
||||
<code>FS </code>(= <code>0x1C</code> or <code>28</code>) <em>file separator</em><br>
|
||||
<code>GS </code>(= <code>0x1D</code> or <code>29</code>) <em>group separator</em><br>
|
||||
<code>RS </code>(= <code>0x1E</code> or <code>30</code>) <em>record separator</em><br>
|
||||
<code>US </code>(= <code>0x1F</code> or <code>31</code>) <em>unit separator</em><br>
|
||||
<code>DEL </code>(= <code>0x7F</code> or <code>127</code>) <em>delete</em><br>
|
||||
<code>SKIP</code> or <code>?</code> matches any input byte
|
||||
</p>
|
||||
<p>
|
||||
A single string can be built from several quoted literals and byte values
|
||||
by writing them separated by whitespaces or comma.
|
||||
</p>
|
||||
|
||||
<h3>Example:</h3>
|
||||
<h3>Examples:</h3>
|
||||
<p>
|
||||
The following lines represent the same string:<br>
|
||||
<code>"Hello world\r\n"</code><br>
|
||||
@ -408,9 +438,12 @@ what they influence.
|
||||
(see <a href="formats.html">formats</a> and
|
||||
<a href="waveform.html">waveform record</a>), what string
|
||||
to write or to expect between values?
|
||||
If the first character of the <code>Separator</code> is a
|
||||
<span class="new">
|
||||
<strike>If the first character of the <code>Separator</code> is a
|
||||
space, it matches any number of any whitespace characters in
|
||||
an <code>in</code> command.
|
||||
an <code>in</code> command.</strike> To match arbitrary amount of
|
||||
whitespace in input, use <code>"\_"</code>.
|
||||
</span>
|
||||
</dd>
|
||||
<dt><code>ExtraInput = Error;</code></dt>
|
||||
<dd>
|
||||
@ -546,7 +579,6 @@ settings from the protocol in which the exception occurred.
|
||||
</p>
|
||||
<hr>
|
||||
<p align="right"><a href="formats.html">Next: Format Converters</a></p>
|
||||
<p><small>Dirk Zimoch, 2006</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
<p><small>Dirk Zimoch, 2011</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,18 +3,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Record API</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record API</h1>
|
||||
|
||||
<h2>Sorry, this documentation is still missing.</h2>
|
||||
|
||||
<hr>
|
||||
<p><small>Dirk Zimoch, 2006</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Record Types</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record Types</h1>
|
||||
|
||||
<h2>Supported Record Types</h2>
|
||||
@ -49,6 +50,5 @@ It is also possible to
|
||||
|
||||
<hr>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: scalcout Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: scalcout Records</h1>
|
||||
|
||||
<p>
|
||||
@ -96,6 +97,5 @@ Different record fields are used for output and input. The variable
|
||||
<a href="calcout.html">calcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
192
doc/setup.html
@ -3,79 +3,159 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Setup</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Setup</h1>
|
||||
|
||||
<a name="pre"></a>
|
||||
<h2>1. Prerequisites</h2>
|
||||
<p>
|
||||
<em>StreamDevice</em> requires either
|
||||
<em>StreamDevice</em> requires either
|
||||
<a href="http://www.aps.anl.gov/epics/base/R3-14/index.php"
|
||||
target="ex">EPICS base R3.14.6 or higher</a> or
|
||||
<a href="http://www.aps.anl.gov/epics/base/R3-13.php"
|
||||
target="ex">EPICS base R3.13.7 or higher</a>.
|
||||
How to use <em>StreamDevice</em> on EPICS R3.13 is described on a
|
||||
<a href="epics3_13.html">separate page</a>.
|
||||
Because <em>StreamDevice</em> comes with an interface to
|
||||
<a href="http://www.aps.anl.gov/epics/modules/soft/asyn/"
|
||||
target="ex"><em>asynDriver</em> version R4-3 or higher</a> as the
|
||||
underlying driver layer,
|
||||
you should have <em>asynDriver</em> installed first.
|
||||
</p>
|
||||
<p>
|
||||
<em>StreamDevice</em> has support for the
|
||||
<a href="scalcout.html"><em>scalcout</em></a> record from the
|
||||
<em>calc</em> module of <a target="ex"
|
||||
href="http://www.aps.anl.gov/aod/bcda/synApps/index.php"
|
||||
><em>synApps</em></a>.
|
||||
Up to <em>calc</em> release R2-6 (<em>synApps</em> release R5_1),
|
||||
the <em>scalcout</em> record needs a fix.
|
||||
(See separate <a href="scalcout.html"><em>scalcout</em> page</a>.)
|
||||
Support for the scalcout is optional. <em>StreamDevice</em> works
|
||||
as well without scalcout or SynApps.
|
||||
</p>
|
||||
<h3>Fix required for base R3.14.8.2 and earlier on Windows</h3>
|
||||
<p>
|
||||
Up to release R3.14.8.2, a fix in EPICS base is required to build
|
||||
<em>StreamDevice</em> on Windows (not cygwin).
|
||||
In <kbd>src/iocsh/iocsh.h</kbd>, add the following line
|
||||
Add the following line to <kbd>src/iocsh/iocsh.h</kbd>
|
||||
and rebuild base.
|
||||
</p>
|
||||
<pre>
|
||||
epicsShareFunc int epicsShareAPI iocshCmd(const char *command);
|
||||
</pre>
|
||||
|
||||
<h3>Configuration</h3>
|
||||
<p>
|
||||
Make sure that the <em>asyn</em> library (and the <em>calc</em> module of
|
||||
<em>synApps</em>, if desired) can be found, e.g. by
|
||||
adding <code>ASYN</code>
|
||||
and (if installed) <code>CALC</code> or <code>SYNAPPS</code>
|
||||
to your <kbd><top>/configure/RELEASE</kbd> file:
|
||||
<em>StreamDevice</em> does not come with its own <kbd><top></kbd>
|
||||
location and <kbd><top>/configure</kbd> directory.
|
||||
It expects to be put into an already existing <kbd><top></kbd>
|
||||
directory structure.
|
||||
You can simply create one with <code>makeBaseApp.pl</code>
|
||||
(which is part of EPICS base):
|
||||
</p>
|
||||
<p>
|
||||
<code>mkdir top</code><br>
|
||||
<code>cd top</code><br>
|
||||
<code>makeBaseApp.pl -t support</code>
|
||||
</p>
|
||||
<p>
|
||||
When asked for "Application names" just hit Enter.
|
||||
Then go to the newly created <kbd>configure</kbd> subdirectory and
|
||||
edit the <kbd>RELEASE</kbd> file you find there according to the
|
||||
instructions below.
|
||||
</p>
|
||||
<p>
|
||||
After changing any configuration, you should run <code>make</code>
|
||||
in this directory.
|
||||
</p>
|
||||
<p>
|
||||
For details on <kbd><top></kbd> directories and <kbd>RELEASE</kbd>
|
||||
files please refer to the
|
||||
<a href="http://www.aps.anl.gov/epics/base/R3-14/8-docs/AppDevGuide.pdf"
|
||||
target="ex"><em>IOC Application Developer's Guide</em></a> chapter 4:
|
||||
EPICS Build Facility.
|
||||
</p>
|
||||
|
||||
<h4>Support for <em>asynDriver</em></h4>
|
||||
<p>
|
||||
You most probably want <em>asynDriver</em> support included, because that is the
|
||||
standard way for <em>StreamDevice</em> to talk to hardware.
|
||||
First get and install <a href="http://www.aps.anl.gov/epics/modules/soft/asyn/"
|
||||
target="ex"><em>asynDriver</em></a> version 4-3 or higher before you build <em>StreamDevice</em>.
|
||||
I have tested <em>StreamDevice</em> with <em>asynDriver</em> versions up to 4-17.
|
||||
Make sure that the <em>asyn</em> library can be found by adding the path to the
|
||||
<em><top></em> directory of your <em>asyn</em> installation to the
|
||||
<kbd>RELEASE</kbd> file:
|
||||
<pre>
|
||||
ASYN=/home/epics/asyn/4-5
|
||||
CALC=/home/epics/synApps/calc/2-7
|
||||
ASYN=/home/epics/asyn4-17
|
||||
</pre>
|
||||
|
||||
<h4>Support for sCalcout record</h4>
|
||||
<p>
|
||||
The <a target="ex"
|
||||
href="http://www.aps.anl.gov/bcda/synApps/calc/R2-8/sCalcoutRecord.html"
|
||||
><em>sCalcout</em></a> record is part of <a target="ex"
|
||||
href="http://www.aps.anl.gov/aod/bcda/synApps/index.php"
|
||||
><em>synApps</em></a>.
|
||||
If <em>streamDevice</em> should be built with support for this record,
|
||||
you have to install the <em>calc</em> module from <em>SynApps</em> first.
|
||||
Add references to the <kbd>RELEASE</kbd> file as shown here:
|
||||
<pre>
|
||||
CALC=/home/epics/synApps/calc-2-8
|
||||
</pre>
|
||||
<p>
|
||||
Up to <em>calc</em> release R2-6 (<em>synApps</em> release R5_1),
|
||||
the <em>sCalcout</em> record needs a fix.
|
||||
(See separate <a href="scalcout.html"><em>scalcout</em> page</a>.)
|
||||
And the <em>calc</em> modue had dependencies on other <em>SynApps</em>
|
||||
modules. Release R2-8 or newer is recommended.
|
||||
</p>
|
||||
<p>
|
||||
Support for the scalcout is optional. <em>StreamDevice</em> works
|
||||
as well without scalcout or SynApps.
|
||||
</p>
|
||||
|
||||
<h4>Support for regular expression matching</h4>
|
||||
<p>
|
||||
If you want to enable regular expression matching, you need the <em>PCRE</em> package.
|
||||
For most Linux systems, it is already installed. In that case add the locations
|
||||
of the <em>PCRE</em> header and library to your <kbd>RELEASE</kbd> file:
|
||||
For most Linux systems, it is already installed.
|
||||
In that case add the locations you have to make the locations of the
|
||||
<em>PCRE</em> header file and library known.
|
||||
However, the pre-installed package can only by used for the host architecture.
|
||||
Thus, add them not to <kbd>RELEASE</kbd> but to <kbd>RELEASE.Common.linux-x86</kbd>
|
||||
(if linux-x86 is your EPICS_HOST_ARCH).
|
||||
Note that different Linux distributions may locate the files in different directories.
|
||||
</p>
|
||||
<pre>
|
||||
PCRE_INCLUDE=/usr/include/pcre
|
||||
PCRE_LIB=/usr/lib
|
||||
</pre>
|
||||
<p>
|
||||
If you want to build <em>StreamDevice</em> for platforms without <em>PCRE</em> support,
|
||||
it is the easiest to build <em>PCRE</em> as an EPICS application.
|
||||
Download the <em>PCRE</em> package from <a target=ex href="http://www.pcre.org">www.pcre.org</a>
|
||||
and compile it with my EPICS compatible
|
||||
<a target=ex href="http://epics.web.psi.ch/software/streamdevice/pcre/Makefile">Makefile</a>.
|
||||
Then define the location of the application in your RELEASE file.
|
||||
A pre-compiled Windows version of <em>PCRE</em> is available at
|
||||
<a href="http://sourceforge.net/projects/gnuwin32/files/pcre/7.0/pcre-7.0.exe/download"
|
||||
target="ex">sourceforge</a>
|
||||
</p>
|
||||
<p>
|
||||
If you want to have <em>PCRE</em> support on platforms that don't support it natively,
|
||||
e.g. vxWorks, it is probably the easiest to build <em>PCRE</em> as an EPICS application.
|
||||
</p>
|
||||
<p>
|
||||
<h4>Building the <em>PCRE</em> package as an EPICS module</h4>
|
||||
<p>
|
||||
<ol>
|
||||
<li>
|
||||
Download the <em>PCRE</em> package from <a target=ex href="http://www.pcre.org">www.pcre.org</a>.
|
||||
</li>
|
||||
<li>
|
||||
Extract the <em>PCRE</em> package in the <kbd><top></kbd> directory of
|
||||
<em>StreamDevice</em> or create a separate <kbd><top></kbd> location using
|
||||
<code>makeBaseApp.pl</code>.
|
||||
</li>
|
||||
<li>
|
||||
Download this <a target=ex href="http://epics.web.psi.ch/software/streamdevice/pcre/Makefile"
|
||||
>Makefile</a> and this
|
||||
<a target=ex href="http://epics.web.psi.ch/software/streamdevice/pcre/fixforvxworks.pl"
|
||||
>fixforvxworks.pl</a> script and save them to the extracted pcre directory.
|
||||
</li>
|
||||
<li>
|
||||
Change into the pcre direcrory and run <code>perl fixforvxworks.pl</code>
|
||||
</li>
|
||||
<li>
|
||||
Run <code>make</code> (or <code>gmake</code>)
|
||||
</li>
|
||||
</ol>
|
||||
<p>
|
||||
Define the location of the pcre <kbd><top></kbd> in the RELEASE file for <em>StreamDevice</em>.
|
||||
</p>
|
||||
<pre>
|
||||
PCRE=/home/epics/pcre
|
||||
@ -84,25 +164,17 @@ PCRE=/home/epics/pcre
|
||||
Regular expressions are optional. If you don't want them, you don't need this.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For details on <kbd><top></kbd> directories and RELEASE files,
|
||||
please refer to the
|
||||
<a href="http://www.aps.anl.gov/epics/base/R3-14/8-docs/AppDevGuide.pdf"
|
||||
target="ex"><em>IOC Application Developer's Guide</em></a> chapter 4:
|
||||
EPICS Build Facility.
|
||||
</p>
|
||||
|
||||
<a name="lib"></a>
|
||||
<h2>2. Build the <em>StreamDevice</em> Library</h2>
|
||||
<p>
|
||||
Unpack the
|
||||
<a href="http://epics.web.psi.ch/software/streamdevice/StreamDevice-2.tgz"
|
||||
><em>StreamDevice</em> package</a> in a <kbd><top></kbd> directory
|
||||
><em>StreamDevice</em> package</a> in the <kbd><top></kbd> directory
|
||||
of your application build area.
|
||||
(You might probably have done this already.)
|
||||
Go to the newly created <em>StreamDevice</em> directory
|
||||
and run <kbd>make</kbd> (or <kbd>gmake</kbd>).
|
||||
This will create and install the <em>stream</em> library and the
|
||||
and run <code>make</code> (or <code>gmake</code>).
|
||||
This will create and install the <em>stream</em> library and the
|
||||
<kbd>stream.dbd</kbd> file.
|
||||
</p>
|
||||
<a name="app"></a>
|
||||
@ -121,7 +193,8 @@ PROD_LIBS += asyn
|
||||
</pre>
|
||||
<p>
|
||||
Include the following lines in your xxxAppInclude.dbd file to use
|
||||
<em>stream</em> and <em>asyn</em> with serial lines and IP sockets:
|
||||
<em>stream</em> and <em>asyn</em> with serial lines, IP sockets,
|
||||
and vxi11 ("GPIB over ethernet") support.
|
||||
</p>
|
||||
<pre>
|
||||
include "base.dbd"
|
||||
@ -129,6 +202,7 @@ include "stream.dbd"
|
||||
include "asyn.dbd"
|
||||
registrar(drvAsynIPPortRegisterCommands)
|
||||
registrar(drvAsynSerialPortRegisterCommands)
|
||||
registrar(vxi11RegisterCommands)
|
||||
</pre>
|
||||
<p>
|
||||
You can find an example application in the <kbd>streamApp</kbd>
|
||||
@ -151,7 +225,7 @@ i.e. the current directory.
|
||||
<p>
|
||||
Also configure the buses (in <em>asynDriver</em> terms: ports) you want
|
||||
to use with <em>StreamDevice</em>.
|
||||
You can give the buses any name you want, like <kbd>COM1</kbd> or
|
||||
You can give the buses any name you want, like <kbd>COM1</kbd> or
|
||||
<kbd>socket</kbd>, but I recommend to use names related to the
|
||||
connected device.
|
||||
</p>
|
||||
@ -189,7 +263,7 @@ drvAsynIPPortConfigure ("PS1", "192.168.164.10:23")
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
With a VXI11 (GPIB via TCP/IP) connection, e.g. a
|
||||
With a VXI11 (GPIB via TCP/IP) connection, e.g. a
|
||||
HP E2050A on IP address 192.168.164.10, it would look like this:
|
||||
</p>
|
||||
<pre>
|
||||
@ -211,7 +285,7 @@ During <code>iocInit</code>, <em>streamDevice</em> loads and parses
|
||||
the required protocol files.
|
||||
If the files contain errors, they are printed on the IOC shell.
|
||||
Put the protocol file in one of the directories listed in
|
||||
<code>STREAM_PROTOCOL_PATH</code>.
|
||||
<code>STREAM_PROTOCOL_PATH</code>.
|
||||
</p>
|
||||
<h3>Example:</h3>
|
||||
<p>
|
||||
@ -234,7 +308,7 @@ Terminator = CR LF;
|
||||
|
||||
setCurrent {
|
||||
out "CURRENT %.2f";
|
||||
@init {
|
||||
@init {
|
||||
out "CURRENT?";
|
||||
in "CURRENT %f A";
|
||||
}
|
||||
@ -270,19 +344,24 @@ See the <a href="protocol.html">next chapter</a> for protocol files in depth.
|
||||
<p>
|
||||
To make a record use <em>StreamDevice</em>, set its <code>DTYP</code> field to
|
||||
<code>"stream"</code>.
|
||||
</p>
|
||||
<p>
|
||||
The <code>INP</code> or <code>OUT</code> link has the form
|
||||
<code>"@<var>file protocol bus</var> [<var>address</var> [<var>parameters</var>]]"</code>.
|
||||
</p>
|
||||
<p>
|
||||
Here, <code><var>file</var></code> is the name of the protocol file and
|
||||
<code><var>protocol</var></code> is the name of a protocol defined in this file.
|
||||
(See the <a href="protocol.html">next chapter</a>.)
|
||||
</p>
|
||||
<p>
|
||||
If the protocol requires <a href="protocol.html#argvar">arguments</a>,
|
||||
specify them enclosed in parentheses:
|
||||
<code><var>protocol</var>(<var>arg1,arg2,...</var>)</code>.
|
||||
</p>
|
||||
<p>
|
||||
The communication channel is specified with <code><var>bus</var></code> and
|
||||
<code><var>addr</var></code>.
|
||||
The communication channel is specified with <code><var>bus</var></code>
|
||||
(aka <em>asynDriver</em> "port") and <code><var>addr</var></code>.
|
||||
If the bus does not have addresses, <code><var>addr</var></code> is dispensable.
|
||||
Optional <code><var>parameters</var></code> are passed to the bus driver.
|
||||
</p>
|
||||
@ -298,8 +377,8 @@ The bus is called <em>PS1</em> like the device.
|
||||
record (ao, "PS1:I-set")
|
||||
{
|
||||
field (DESC, "Set current of PS1")
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@ExamplePS.proto setCurrent PS1")
|
||||
<b>field (DTYP, "stream")</b>
|
||||
<b>field (OUT, "@ExamplePS.proto setCurrent PS1")</b>
|
||||
field (EGU, "A")
|
||||
field (PREC, "2")
|
||||
field (DRVL, "0")
|
||||
@ -311,7 +390,6 @@ record (ao, "PS1:I-set")
|
||||
|
||||
<hr>
|
||||
<p align="right"><a href="protocol.html">Next: Protocol Files</a></p>
|
||||
<p><small>Dirk Zimoch, 2007</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
<p><small>Dirk Zimoch, 2011</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
BIN
doc/sls_icon.ico
Before Width: | Height: | Size: 318 B |
BIN
doc/space.gif
Before Width: | Height: | Size: 807 B |
@ -1,13 +1,17 @@
|
||||
a:link {color: #0000D0; text-decoration:none;}
|
||||
a:visited {color: #0000D0; text-decoration:none;}
|
||||
a:hover {color: #FF0000; text-decoration:none;}
|
||||
a:link {color: #0000D0;}
|
||||
a:visited {color: #0000D0;}
|
||||
a:hover {color: #FF0000;}
|
||||
|
||||
body {
|
||||
margin-right:20px;
|
||||
font-family:sans-serif;
|
||||
margin-right:1em;
|
||||
margin-left:15em;
|
||||
margin-top:11ex;
|
||||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
font-size:14px;
|
||||
background-color:#ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
a[name] { position:relative; top:-11ex;}
|
||||
|
||||
pre {
|
||||
background-color:#f4f4f4;
|
||||
@ -17,6 +21,10 @@ pre {
|
||||
margin:2ex;
|
||||
}
|
||||
|
||||
kbd {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
dt {
|
||||
margin-top:0.5ex;
|
||||
}
|
||||
@ -26,6 +34,22 @@ h1 {
|
||||
margin-top:0;
|
||||
font-style:italic;
|
||||
font-family:serif;
|
||||
text-align:center;
|
||||
position:fixed;
|
||||
top:0;
|
||||
left:0;
|
||||
width:100%;
|
||||
min-height:60px;
|
||||
height: 4ex;
|
||||
line-height:190%;
|
||||
background-color:white;
|
||||
border-top:6px solid #1b4486;
|
||||
border-bottom:4px solid #1b4486;
|
||||
white-space:nowrap;
|
||||
background-image:url(PSI.gif);
|
||||
background-repeat:no-repeat;
|
||||
background-position:10px 2px;
|
||||
text-shadow: .1em .1em .1em lightgray;
|
||||
}
|
||||
|
||||
h2 {
|
||||
@ -34,6 +58,11 @@ h2 {
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size:120%;
|
||||
margin-bottom:0.25ex;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size:100%;
|
||||
margin-bottom:0.25ex;
|
||||
}
|
||||
@ -58,22 +87,41 @@ code {
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
/*
|
||||
a[target=ex] {
|
||||
background-image:url(ex.png);
|
||||
background-repeat:no-repeat;
|
||||
background-position:right center;
|
||||
padding-right: 12px;
|
||||
}
|
||||
#navleft {
|
||||
position:fixed;
|
||||
left:0;
|
||||
top:0;
|
||||
padding-top:9ex;
|
||||
width:14em;
|
||||
height:100%;
|
||||
border-style:solid;
|
||||
border-color:black;
|
||||
border-width:0 1px 0 0;
|
||||
background-color:#e3eaf6;
|
||||
overflow:hidden;
|
||||
z-index:0;
|
||||
}
|
||||
|
||||
a[target=ex]:hover {
|
||||
background-image:url(exr.png);
|
||||
}
|
||||
*/
|
||||
.new {
|
||||
background-color: #ffc;
|
||||
}
|
||||
|
||||
a[target=ex]:after {
|
||||
content:" " url(ex.png);
|
||||
}
|
||||
|
||||
a[target=ex]:hover:after {
|
||||
content: " " url(exr.png);
|
||||
}
|
||||
|
||||
@media print {
|
||||
a:link {color: black; text-decoration:none;}
|
||||
a:visited {color: black; text-decoration:none;}
|
||||
a:hover {color: black; text-decoration:none;}
|
||||
a[target=ex] {text-decoration:underline;}
|
||||
a[target=ex]:after {content:" [" attr(href) "]";}
|
||||
code {color: black; }
|
||||
body {margin-left:10px;}
|
||||
h1 {position:absolute;}
|
||||
#navleft {display:none;}
|
||||
}
|
||||
|
@ -1,92 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<h1>EPICS <em>StreamDevice</em> Documentation</h1>
|
||||
|
||||
<h2>What is <em>StreamDevice</em>?</h2>
|
||||
<p>
|
||||
<em>StreamDevice</em> is a generic
|
||||
<a href="http://www.aps.anl.gov/epics" 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
|
||||
receiving strings (in the broadest sense, including non-printable
|
||||
characters and even null-bytes).
|
||||
Examples for this type of communication interface are
|
||||
serial line (RS-232, RS-485, ...),
|
||||
IEEE-488 (also known as GPIB or HP-IB), and TCP/IP.
|
||||
<em>StreamDevice</em> comes with an interface to<a target="ex"
|
||||
href="http://www.aps.anl.gov/epics/modules/soft/asyn/">
|
||||
<em>asynDriver</em></a>
|
||||
but can be extended to
|
||||
<a href="businterface.html">support other bus drivers</a>.
|
||||
</p>
|
||||
<p>
|
||||
If the device can be controlled with strings like
|
||||
"<code>RF:FREQ 499.655 MHZ</code>", <em>StreamDevice</em> can be used.
|
||||
How the strings exactly look like is defined in <em>protocols</em>.
|
||||
Formatting and interpretation of values is done with
|
||||
<a href="formats.html"><em>format converters</em></a> similar to those
|
||||
known from the C functions <em>printf()</em> and <em>scanf()</em>.
|
||||
To support other formats, it is possible to
|
||||
<a href="formatconverter.html">write your own converters</a>.
|
||||
</p>
|
||||
<p>
|
||||
Each record with <em>StreamDevice</em> support runs one <em>protocol</em>
|
||||
to read or write its value.
|
||||
All <em>protocols</em> are defined in
|
||||
<a href="protocol.html"><em>protocol files</em></a> in plain ASCII text.
|
||||
No compiling is necessary to change a protocol or to support new devices.
|
||||
<em>Protocols</em> can be as simple as just one output string or can
|
||||
consist of many strings sent to and read from the device.
|
||||
However, a protocol is linear.
|
||||
That means it runs from start to end each time the record is
|
||||
<a href="processing.html">processed</a>.
|
||||
It does not provide loops or branches.
|
||||
</p>
|
||||
<p>
|
||||
<em>StreamDevice</em> supports all
|
||||
<a href="recordtypes.html">standard records</a> of EPICS base
|
||||
which can have device support.
|
||||
It is also possible to
|
||||
<a href="recordinterface.html">write support for new record types</a>.
|
||||
</p>
|
||||
|
||||
<h2>What is <em>StreamDevice</em> not?</h2>
|
||||
<p>
|
||||
It is not a programming language for a high-level application.
|
||||
It is, for example, not possible to write a complete scanning program
|
||||
in a <em>protocol</em>.
|
||||
Use other tools for that and use <em>StreamDevice</em> only for the
|
||||
primitive commands.
|
||||
</p>
|
||||
<p>
|
||||
It is not a block oriented device support.
|
||||
It is not possible to send or receive huge blocks of data that contain
|
||||
many process variables distributed over many records.
|
||||
</p>
|
||||
|
||||
<h2>Recommended Readings</h2>
|
||||
<p>
|
||||
<a href="http://www.aps.anl.gov/epics/base/R3-14/8-docs/AppDevGuide.pdf"
|
||||
target="ex">IOC Application Developer's Guide (PDF)</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.aps.anl.gov/asd/controls/epics/EpicsDocumentation/AppDevManuals/RecordRef/Recordref-1.html"
|
||||
target="ex">EPICS Record Reference Manual</a>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<p align="right"><a href="setup.html">Next: Setup</a></p>
|
||||
<p><small>Dirk Zimoch, 2006</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,5 +0,0 @@
|
||||
if (parent.head) {
|
||||
parent.head.document.getElementById('subtitle').innerHTML=document.title;
|
||||
parent.document.title=document.title;
|
||||
document.getElementsByTagName('h1')[0].style.display="none";
|
||||
}
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: stringin Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: stringin Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -62,6 +63,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: stringout Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: stringout Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -62,6 +63,5 @@ written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: Tips and Tricks</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Tips and Tricks</h1>
|
||||
|
||||
<a name="argvar"></a>
|
||||
@ -54,7 +55,7 @@ read {in "new value = %f";}
|
||||
<code>
|
||||
record (ai, "$(RECORD)") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@(DEVICETYPE).proto read $(BUS)")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto read $(BUS)")<br>
|
||||
field (SCAN, "I/O Intr")<br>
|
||||
}
|
||||
</code>
|
||||
@ -95,14 +96,14 @@ array_out {separator=", "; out "an array: (%.2f)";}
|
||||
The format <code>%.2f</code> is repeated for each element of the array.
|
||||
All elements are separated by <code>", "</code>.<br>
|
||||
Output will look like this:
|
||||
</p>
|
||||
<pre>
|
||||
an array: (3.14, 17.30, -12.34)
|
||||
</pre>
|
||||
</p>
|
||||
<h3>B) We have up to 12 numeric values</h3>
|
||||
<p>
|
||||
Use a <a href="calcout.html">calcout</a> record and
|
||||
<a href="formats.html#types">field references</a> in the format.
|
||||
<a href="formats.html#redirection">redirection to fields</a>.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
@ -121,24 +122,24 @@ record (calcout, "$(RECORD)") {<br>
|
||||
field (INPC, "$(C_RECORD)")<br>
|
||||
field (CALC, "0")<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (OUT, "@(DEVICETYPE).proto write_ABC $(BUS)")<br>
|
||||
field (OUT, "@$(DEVICETYPE).proto write_ABC $(BUS)")<br>
|
||||
}
|
||||
</code>
|
||||
</p>
|
||||
<h3>C) Values are in other records on the same IOC</h3>
|
||||
<p>
|
||||
Use <a href="formats.html#types">record references</a> in the format.
|
||||
Use <a href="formats.html#redirection">redirection to records</a>.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
acquire {out 'ACQUIRE "%(\$1:directory.VAL)s/%s",%(\$1:time.VAL).3f;';}
|
||||
acquire {out 'ACQUIRE "%(\$1:directory)s/%s",%(\$1:time).3f;';}
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
You must specify the full <code>record.FIELD</code> name,
|
||||
even for <code>VAL</code> fields.
|
||||
To avoid record names in protocol files use
|
||||
<a href="protocol.html#argvar">protocol arguments</a>.
|
||||
You can specify a record name or record.FIELD in parentheses directly
|
||||
after the <code>%</code>.
|
||||
To avoid plain record names in protocol files use
|
||||
<a href="protocol.html#argvar">protocol arguments</a> like <code>\$1</code>.
|
||||
In the link, specify the record name or just the basename of the
|
||||
other records (device name) in parentheses.
|
||||
</p>
|
||||
@ -146,7 +147,7 @@ other records (device name) in parentheses.
|
||||
<code>
|
||||
record (stringout, "$(DEVICE):getimage") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (OUT, "@(DEVICETYPE).proto acquire($(DEVICE)) $(BUS)")<br>
|
||||
field (OUT, "@$(DEVICETYPE).proto acquire($(DEVICE)) $(BUS)")<br>
|
||||
}
|
||||
</code>
|
||||
</p>
|
||||
@ -190,12 +191,12 @@ read_B {in "A=%*f, B=%f";}
|
||||
<code>
|
||||
record (ai, "$(DEVICE):A") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@(DEVICETYPE).proto read_A $(BUS)")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto read_A $(BUS)")<br>
|
||||
field (SCAN, "1 second")<br>
|
||||
}<br>
|
||||
record (ai, "$(DEVICE):B") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@(DEVICETYPE).proto read_B $(BUS)")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto read_B $(BUS)")<br>
|
||||
field (SCAN, "I/O Intr")<br>
|
||||
}
|
||||
</code>
|
||||
@ -215,20 +216,20 @@ Any non-matching input is ignored by record B.
|
||||
</p>
|
||||
<h3>C) Values should be stored in other records on the same IOC</h3>
|
||||
<p>
|
||||
Use <a href="formats.html#types">record references</a> in the format.
|
||||
Use <a href="formats.html#redirection">redirection to records</a>.
|
||||
To avoid record names in protocol files, use
|
||||
<a href="protocol.html#argvar">protocol arguments</a>.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
read_AB {out "GET A,B"; in "A=%f, B=%(\$1.VAL)f";}
|
||||
read_AB {out "GET A,B"; in "A=%f, B=%(\$1)f";}
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
record (ai, "$(DEVICE):A") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@(DEVICETYPE).proto read_AB($(DEVICE):B) $(BUS)")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto read_AB($(DEVICE):B) $(BUS)")<br>
|
||||
field (SCAN, "1 second")<br>
|
||||
}<br>
|
||||
record (ai, "$(DEVICE):B") {<br>
|
||||
@ -243,11 +244,11 @@ processes record B.
|
||||
</p>
|
||||
|
||||
<a name="mixed"></a>
|
||||
<h2>I have a device that sends mixed data types: numbers and strings</h2>
|
||||
<h2>I have a device that sends mixed data types: numbers or strings</h2>
|
||||
<p>
|
||||
Use a <code>@mismatch</code>
|
||||
<a href="protocol.html#except">exception handler</a> and
|
||||
<a href="formats.html#types">record references</a> in the format.
|
||||
<a href="formats.html#redirection">redirection to records</a>.
|
||||
To avoid record names in protocol files, use
|
||||
<a href="protocol.html#argvar">protocol arguments</a>.
|
||||
</p>
|
||||
@ -259,14 +260,14 @@ When asked "<code>CURRENT?</code>", the device send something like
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
read_current {out "CURRENT?"; in "CURRENT %f A"; @mismatch {in "%(\1.VAL)39c";}}
|
||||
read_current {out "CURRENT?"; in "CURRENT %f A"; @mismatch {in "%(\1)39c";}}
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
record (ai, "$(DEVICE):readcurrent") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@(DEVICETYPE).proto read_current($(DEVICE):message) $(BUS)")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto read_current($(DEVICE):message) $(BUS)")<br>
|
||||
}<br>
|
||||
record (stringin, "$(DEVICE):message") {<br>
|
||||
}
|
||||
@ -288,10 +289,124 @@ record (stringout, "$(DEVICE):clean_2") {<br>
|
||||
field (VAL, "OK")<br>
|
||||
field (OUT, "$(DEVICE):message PP")<br>
|
||||
}<br>
|
||||
|
||||
</code>
|
||||
<a name="web"></a>
|
||||
<h2>I need to read a web page</h2>
|
||||
<p>
|
||||
First you have to send a correctly formatted HTML request.
|
||||
Note that this request must contain the full URL like
|
||||
"http://server/page" and must be terminated with <u>two</u> newlines.
|
||||
The server should be the same as in the
|
||||
<a href="setup.html#sta"><code>drvAsynIPPortConfigure</code></a>
|
||||
command (if not using a http proxy).
|
||||
|
||||
The web page you get often contains much more information than you need.
|
||||
<a href="formats.html#regex">Regular expressions</a> are great
|
||||
to find what you are looking for.
|
||||
</p>
|
||||
<h3>Example 1</h3>
|
||||
<p>
|
||||
Read the title of a web page.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
get_title {<br>
|
||||
extrainput = ignore;<br>
|
||||
replyTimeout = 1000;<br>
|
||||
out "GET http://\$1\n\n";<br>
|
||||
in "%+.1/(?im)<title>(.*)<\/title>/";<br>
|
||||
}
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
Terminate the request with two newlines, either explicit like here
|
||||
<u>or</u> using an
|
||||
<a href="protocol.html#sysvar"><code>outTerminator</code></a>.
|
||||
The URI (without http:// but including the web server host name)
|
||||
is passed as <a href="protocol.html#argvar">argument</a> 1 to <code>\$1</code>.
|
||||
Note that web servers may be slow, so allow some
|
||||
<a href="protocol.html#argvar"><code>replyTimeout</code></a>.
|
||||
</p>
|
||||
<p>
|
||||
If you don't use an <code>inTerminator</code> then the whole page is
|
||||
read as one "line" to the <code>in</code> command and can be parsed easily
|
||||
with a regular expression.
|
||||
We want to see the string between <code><title></code> and
|
||||
<code></title></code>, so we put it into a subexpression in
|
||||
<code>()</code> and request the first subexpression with <code>.1</code>.
|
||||
Note that the <code>/</code> in the closing tag has be be escaped
|
||||
to avoid a misinterpretation as the closing <code>/</code> of the regular
|
||||
expression.
|
||||
</p>
|
||||
<p>
|
||||
The tags may be upper or lower case like <code><TITLE></code> or
|
||||
<code><Title></code>, so we ask for case insensitive matching with
|
||||
<code>(?i)</code>.
|
||||
</p>
|
||||
<p>
|
||||
The string should be terminated with the first closing
|
||||
<code></title></code>, not the last one in the file.
|
||||
(There should not be more than one title but you never know.)
|
||||
Thus we ask not to be greedy with <code>(?m)</code>.
|
||||
<code>(?i)</code> and <code>(?m)</code> can be combined to <code>(?im)</code>.
|
||||
See the PCRE documentation for more regexp syntax.
|
||||
</p>
|
||||
<p>
|
||||
The regular expression matcher ignores and discards any content before the
|
||||
matching section.
|
||||
Content after the match is discarded with <code>extrainput = ignore</code>
|
||||
so that it does not trigger errors reporting "surplus input".
|
||||
</p>
|
||||
<p>
|
||||
Finally, the title may be too long for the record.
|
||||
The <code>+</code> tells the format matcher not to fail in this case
|
||||
but to truncate the string instead.
|
||||
You can read the string with a stringin record or for longer strings with
|
||||
a waveform record with data type CHAR.
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
record (stringin, "$(DEVICE):title") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto get_title($(PAGE)) $(BUS)")<br>
|
||||
}<br>
|
||||
record (waveform, "$(DEVICE):longtitle") {<br>
|
||||
field (DTYP, "stream")<br>
|
||||
field (INP, "@$(DEVICETYPE).proto get_title($(PAGE)) $(BUS)")<br>
|
||||
field (FTVL, "CHAR")<br>
|
||||
field (NELM, "100")<br>
|
||||
}<br>
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<h3>Example 2</h3>
|
||||
<p>
|
||||
Read a number from a web page. First we have to locate the number.
|
||||
For that we match against any known string right before the number
|
||||
(and <a href="formats.html#syntax">discard the match</a> with <code>*</code>).
|
||||
Then we read the number.
|
||||
</p>
|
||||
<code>
|
||||
get_title {<br>
|
||||
extrainput = ignore;<br>
|
||||
replyTimeout = 1000;<br>
|
||||
out "GET http://\$1\n\n";<br>
|
||||
in "%*/Interesting value:/%f more text";<br>
|
||||
}
|
||||
</code>
|
||||
<p>
|
||||
When using <code>extrainput = ignore;</code>, it is always a good idea to
|
||||
match a few bytes after the value, too.
|
||||
This catches errors where loading of the page is interrupted in the middle
|
||||
of the number. (You don't want to miss the exponent from something like 1.23E-14).
|
||||
</p>
|
||||
<p>
|
||||
You can read more than one value from a file with successive regular expressions
|
||||
and <a href="formats.html#redirection">redirections</a>.
|
||||
But this only works if the order of the values is predictible.
|
||||
<i>StreamDevice</i> is not an XML parser! It always reads sequentially.
|
||||
</p>
|
||||
<hr>
|
||||
<p><small>Dirk Zimoch, 2007</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
<p><small>Dirk Zimoch, 2012</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,12 +3,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>StreamDevice: waveform Records</title>
|
||||
<link rel="shortcut icon" href="sls_icon.ico">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="stream.css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<meta name="author" content="Dirk Zimoch">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: waveform Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
@ -121,6 +122,5 @@ the written or read value.
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<script src="stream.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
32
makefile
@ -8,6 +8,8 @@ BUILDCLASSES += Linux
|
||||
DBDS = stream.dbd
|
||||
|
||||
BUSSES += AsynDriver
|
||||
BUSSES += Dummy
|
||||
|
||||
FORMATS += Enum
|
||||
FORMATS += BCD
|
||||
FORMATS += Raw
|
||||
@ -32,8 +34,8 @@ SOURCES += $(FORMATS:%=src/%Converter.cc)
|
||||
SOURCES += $(BUSSES:%=src/%Interface.cc)
|
||||
SOURCES += $(wildcard src/Stream*.cc)
|
||||
SOURCES += src/StreamVersion.c
|
||||
SOURCES_3.14 += src/devcalcoutStream.c
|
||||
|
||||
HEADERS += devStream.h
|
||||
HEADERS += StreamFormat.h
|
||||
HEADERS += StreamFormatConverter.h
|
||||
HEADERS += StreamBuffer.h
|
||||
@ -42,31 +44,15 @@ HEADERS += StreamError.h
|
||||
ifeq (${EPICS_BASETYPE},3.13)
|
||||
USR_INCLUDES += -include $(INSTALL_INCLUDE)/compat3_13.h
|
||||
endif
|
||||
ifeq (${EPICS_BASETYPE},3.14)
|
||||
RECORDTYPES += calcout
|
||||
endif
|
||||
|
||||
StreamCore.o: streamReferences
|
||||
|
||||
streamReferences:
|
||||
@for i in $(BUSSES); \
|
||||
do echo "extern void* ref_$${i}Interface;"; \
|
||||
echo "void* p$$i = ref_$${i}Interface;"; \
|
||||
done > $@
|
||||
@for i in $(FORMATS); \
|
||||
do echo "extern void* ref_$${i}Converter;"; \
|
||||
echo "void* p$$i = ref_$${i}Converter;"; \
|
||||
done >> $@
|
||||
perl ../src/makeref.pl Interface $(BUSSES) > $@
|
||||
perl ../src/makeref.pl Converter $(FORMATS) >> $@
|
||||
|
||||
ifeq (${EPICS_BASETYPE},3.13)
|
||||
stream.dbd:
|
||||
@for r in $(RECORDTYPES); \
|
||||
do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \
|
||||
done > $@
|
||||
@echo "driver(stream)" >> $@
|
||||
else
|
||||
stream.dbd:
|
||||
@for r in $(RECORDTYPES) calcout; \
|
||||
do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \
|
||||
done > $@
|
||||
@echo "driver(stream)" >> $@
|
||||
@echo "variable(streamDebug, int)" >> $@
|
||||
@echo "registrar(streamRegistrar)" >> $@
|
||||
endif
|
||||
perl ../src/makedbd.pl $(RECORDTYPES) > $@
|
||||
|
@ -22,14 +22,19 @@
|
||||
#include "StreamError.h"
|
||||
#include "StreamBuffer.h"
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#include <epicsAssert.h>
|
||||
#include <epicsTime.h>
|
||||
#include <epicsTimer.h>
|
||||
#else
|
||||
#include <epicsVersion.h>
|
||||
#ifdef BASE_VERSION
|
||||
#define EPICS_3_13
|
||||
#endif
|
||||
|
||||
#ifdef EPICS_3_13
|
||||
#include <assert.h>
|
||||
#include <wdLib.h>
|
||||
#include <sysLib.h>
|
||||
#else
|
||||
#include <epicsAssert.h>
|
||||
#include <epicsTime.h>
|
||||
#include <epicsTimer.h>
|
||||
extern "C" {
|
||||
#include <callback.h>
|
||||
}
|
||||
@ -126,7 +131,7 @@ static const char* ioActionStr[] = {
|
||||
};
|
||||
|
||||
static const char* asynStatusStr[] = {
|
||||
"asynSuccess", "asynTimeout", "asynOverflow", "asynError"
|
||||
"asynSuccess", "asynTimeout", "asynOverflow", "asynError", "asynDisconnected", "asynDisabled"
|
||||
};
|
||||
|
||||
static const char* eomReasonStr[] = {
|
||||
@ -134,7 +139,7 @@ static const char* eomReasonStr[] = {
|
||||
};
|
||||
|
||||
class AsynDriverInterface : StreamBusInterface
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
, epicsTimerNotify
|
||||
#endif
|
||||
{
|
||||
@ -164,12 +169,12 @@ class AsynDriverInterface : StreamBusInterface
|
||||
const char* outputBuffer;
|
||||
size_t outputSize;
|
||||
int peeksize;
|
||||
#ifdef EPICS_3_14
|
||||
epicsTimerQueueActive* timerQueue;
|
||||
epicsTimer* timer;
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
WDOG_ID timer;
|
||||
CALLBACK timeoutCallback;
|
||||
#else
|
||||
epicsTimerQueueActive* timerQueue;
|
||||
epicsTimer* timer;
|
||||
#endif
|
||||
|
||||
AsynDriverInterface(Client* client);
|
||||
@ -189,11 +194,11 @@ class AsynDriverInterface : StreamBusInterface
|
||||
bool disconnectRequest();
|
||||
void finish();
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
static void expire(CALLBACK *pcallback);
|
||||
#else
|
||||
// epicsTimerNotify methods
|
||||
epicsTimerNotify::expireStatus expire(const epicsTime &);
|
||||
#else
|
||||
static void expire(CALLBACK *pcallback);
|
||||
#endif
|
||||
|
||||
// local methods
|
||||
@ -205,26 +210,28 @@ class AsynDriverInterface : StreamBusInterface
|
||||
void connectHandler();
|
||||
void disconnectHandler();
|
||||
bool connectToAsynPort();
|
||||
void asynReadHandler(const char *data, int numchars, int eomReason);
|
||||
void asynReadHandler(const char *data, size_t numchars, int eomReason);
|
||||
asynQueuePriority priority() {
|
||||
return static_cast<asynQueuePriority>
|
||||
(StreamBusInterface::priority());
|
||||
}
|
||||
void startTimer(double timeout) {
|
||||
#ifdef EPICS_3_14
|
||||
timer->start(*this, timeout);
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
callbackSetPriority(priority(), &timeoutCallback);
|
||||
wdStart(timer, (int)((timeout+1)*sysClkRateGet())-1,
|
||||
reinterpret_cast<FUNCPTR>(callbackRequest),
|
||||
reinterpret_cast<int>(&timeoutCallback));
|
||||
#else
|
||||
timer->start(*this, timeout
|
||||
+epicsThreadSleepQuantum()*0.5
|
||||
);
|
||||
#endif
|
||||
}
|
||||
void cancelTimer() {
|
||||
#ifdef EPICS_3_14
|
||||
timer->cancel();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
wdCancel(timer);
|
||||
#else
|
||||
timer->cancel();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -263,15 +270,15 @@ AsynDriverInterface(Client* client) : StreamBusInterface(client)
|
||||
handleTimeout);
|
||||
assert(pasynUser);
|
||||
pasynUser->userPvt = this;
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
timer = wdCreate();
|
||||
callbackSetCallback(expire, &timeoutCallback);
|
||||
callbackSetUser(this, &timeoutCallback);
|
||||
#else
|
||||
timerQueue = &epicsTimerQueueActive::allocate(true);
|
||||
assert(timerQueue);
|
||||
timer = &timerQueue->createTimer();
|
||||
assert(timer);
|
||||
#else
|
||||
timer = wdCreate();
|
||||
callbackSetCallback(expire, &timeoutCallback);
|
||||
callbackSetUser(this, &timeoutCallback);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -306,11 +313,11 @@ AsynDriverInterface::
|
||||
}
|
||||
// Now, no handler is running any more and none will start.
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
wdDelete(timer);
|
||||
#else
|
||||
timer->destroy();
|
||||
timerQueue->release();
|
||||
#else
|
||||
wdDelete(timer);
|
||||
#endif
|
||||
pasynManager->disconnect(pasynUser);
|
||||
pasynManager->freeAsynUser(pasynUser);
|
||||
@ -502,6 +509,30 @@ connectToAsynPort()
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
// Is it really connected?
|
||||
|
||||
/* does not work because read(...,0,...) deletes 1 byte from input.
|
||||
|
||||
if (connected && !pasynGpib)
|
||||
{
|
||||
size_t received;
|
||||
int eomReason;
|
||||
char buffer[8];
|
||||
|
||||
pasynUser->timeout = 0.0;
|
||||
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||
buffer, 0, &received, &eomReason);
|
||||
debug("AsynDriverInterface::connectToAsynPort(%s): "
|
||||
"read(..., 0, ...) [timeout=%g sec] = %s\n",
|
||||
clientName(), pasynUser->timeout,
|
||||
asynStatusStr[status]);
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
debug("AsynDriverInterface::connectToAsynPort(%s): "
|
||||
"device was %sconnected!\n",
|
||||
clientName(),connected?"":"dis");
|
||||
}
|
||||
*/
|
||||
|
||||
debug("AsynDriverInterface::connectToAsynPort(%s) is %s connected\n",
|
||||
clientName(), connected ? "already" : "not yet");
|
||||
if (!connected)
|
||||
@ -534,15 +565,6 @@ lockHandler()
|
||||
debug("AsynDriverInterface::lockHandler(%s)\n",
|
||||
clientName());
|
||||
pasynManager->blockProcessCallback(pasynUser, false);
|
||||
|
||||
#ifndef ASYN_VERSION // asyn < 4.14
|
||||
asynStatus status;
|
||||
status = pasynManager->lockPort(pasynUser);
|
||||
if(status!=asynSuccess) {
|
||||
debug("Failed locking port");
|
||||
}
|
||||
#endif
|
||||
|
||||
connected = connectToAsynPort();
|
||||
lockCallback(connected ? StreamIoSuccess : StreamIoFault);
|
||||
}
|
||||
@ -553,15 +575,6 @@ unlock()
|
||||
{
|
||||
debug("AsynDriverInterface::unlock(%s)\n",
|
||||
clientName());
|
||||
|
||||
#ifndef ASYN_VERSION // asyn < 4.14
|
||||
asynStatus status;
|
||||
status = pasynManager->unlockPort(pasynUser);
|
||||
if (status != asynSuccess) {
|
||||
debug("Failed unlocking port");
|
||||
}
|
||||
#endif
|
||||
|
||||
pasynManager->unblockProcessCallback(pasynUser, false);
|
||||
return true;
|
||||
}
|
||||
@ -604,19 +617,29 @@ writeHandler()
|
||||
clientName());
|
||||
asynStatus status;
|
||||
size_t written = 0;
|
||||
pasynUser->timeout = writeTimeout;
|
||||
|
||||
// discard any early input or early events
|
||||
status = pasynOctet->flush(pvtOctet, pasynUser);
|
||||
pasynUser->timeout = 0;
|
||||
if (pasynGpib)
|
||||
pasynOctet->flush(pvtOctet, pasynUser);
|
||||
else
|
||||
// discard any early input, but forward it to potential async records
|
||||
// thus do not use pasynOctet->flush()
|
||||
do {
|
||||
char buffer [256];
|
||||
size_t received = sizeof(buffer);
|
||||
int eomReason = 0;
|
||||
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||
buffer, received, &received, &eomReason);
|
||||
#ifndef NO_TEMPORARY
|
||||
if (received) debug("AsynDriverInterface::writeHandler(%s): flushing %ld bytes: \"%s\"\n",
|
||||
clientName(), (long)received, StreamBuffer(buffer, received).expand()());
|
||||
#endif
|
||||
} while (status != asynTimeout);
|
||||
|
||||
// discard any early events
|
||||
receivedEvent = 0;
|
||||
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynOctet->flush() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
}
|
||||
|
||||
pasynUser->timeout = writeTimeout;
|
||||
|
||||
// has stream already added a terminator or should
|
||||
// asyn do so?
|
||||
@ -640,6 +663,25 @@ writeHandler()
|
||||
}
|
||||
status = pasynOctet->write(pvtOctet, pasynUser,
|
||||
outputBuffer, outputSize, &written);
|
||||
debug("AsynDriverInterface::writeHandler(%s): "
|
||||
"write(..., outputSize=%ld, written=%ld) "
|
||||
"[timeout=%g sec] = %s\n",
|
||||
clientName(), (long)outputSize, (long)written,
|
||||
pasynUser->timeout, asynStatusStr[status]);
|
||||
|
||||
// Up to asyn 4.17 I can't see when the server has disconnected. Why?
|
||||
int connected;
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
debug("AsynDriverInterface::writeHandler(%s): "
|
||||
"device is %sconnected\n",
|
||||
clientName(),connected?"":"dis");
|
||||
if (!connected) {
|
||||
error("%s: connection closed in write\n",
|
||||
clientName());
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldeoslen >= 0) // restore asyn terminator
|
||||
{
|
||||
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
||||
@ -707,7 +749,7 @@ readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms,
|
||||
long _expectedLength, bool async)
|
||||
{
|
||||
debug("AsynDriverInterface::readRequest(%s, %ld msec reply, "
|
||||
"%ld msec read, expect %ld bytes, asyn=%s)\n",
|
||||
"%ld msec read, expect %ld bytes, async=%s)\n",
|
||||
clientName(), replyTimeout_ms, readTimeout_ms,
|
||||
_expectedLength, async?"yes":"no");
|
||||
|
||||
@ -731,8 +773,20 @@ readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms,
|
||||
}
|
||||
status = pasynManager->queueRequest(pasynUser,
|
||||
priority(), queueTimeout);
|
||||
if (status != asynSuccess && !async)
|
||||
debug("AsynDriverInterface::readRequest %s: "
|
||||
"queueRequest(..., priority=%d, queueTimeout=%g sec) = %s [async=%s] %s\n",
|
||||
clientName(), priority(), queueTimeout,
|
||||
asynStatusStr[status], async? "true" : "false",
|
||||
status!=asynSuccess ? pasynUser->errorMessage : "");
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
// Not queued for some reason (e.g. disconnected / already queued)
|
||||
if (async)
|
||||
{
|
||||
// silently try again later
|
||||
startTimer(replyTimeout);
|
||||
return true;
|
||||
}
|
||||
error("%s readRequest: pasynManager->queueRequest() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
@ -757,40 +811,46 @@ readHandler()
|
||||
streameos = getInTerminator(streameoslen);
|
||||
deveos = streameos;
|
||||
deveoslen = streameoslen;
|
||||
if (streameos) do // streameos == NULL means: don't change eos
|
||||
if (streameos) // streameos == NULL means: don't change eos
|
||||
{
|
||||
asynStatus status;
|
||||
status = pasynOctet->getInputEos(pvtOctet,
|
||||
pasynUser, oldeos, sizeof(oldeos)-1, &oldeoslen);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
oldeoslen = -1;
|
||||
// No EOS support?
|
||||
}
|
||||
// device (e.g. GPIB) might not accept full eos length
|
||||
if (pasynOctet->setInputEos(pvtOctet, pasynUser,
|
||||
deveos, deveoslen) == asynSuccess)
|
||||
{
|
||||
#ifndef NO_TEMPORARY
|
||||
if (ioAction != AsyncRead)
|
||||
if (streameos[0])
|
||||
{
|
||||
debug("AsynDriverInterface::readHandler(%s) "
|
||||
"input EOS set to %s\n",
|
||||
clientName(),
|
||||
StreamBuffer(deveos, deveoslen).expand()());
|
||||
error("%s: warning: No input EOS support.\n",
|
||||
clientName());
|
||||
}
|
||||
oldeoslen = -1;
|
||||
} else do {
|
||||
// device (e.g. GPIB) might not accept full eos length
|
||||
if (pasynOctet->setInputEos(pvtOctet, pasynUser,
|
||||
deveos, deveoslen) == asynSuccess)
|
||||
{
|
||||
#ifndef NO_TEMPORARY
|
||||
if (ioAction != AsyncRead)
|
||||
{
|
||||
debug("AsynDriverInterface::readHandler(%s) "
|
||||
"input EOS set to %s\n",
|
||||
clientName(),
|
||||
StreamBuffer(deveos, deveoslen).expand()());
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
deveos++; deveoslen--;
|
||||
if (!deveoslen)
|
||||
{
|
||||
error("%s: warning: pasynOctet->setInputEos() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
}
|
||||
} while (deveoslen);
|
||||
break;
|
||||
}
|
||||
deveos++; deveoslen--;
|
||||
if (!deveoslen)
|
||||
{
|
||||
error("%s: warning: pasynOctet->setInputEos() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
}
|
||||
} while (deveoslen);
|
||||
}
|
||||
|
||||
int bytesToRead = peeksize;
|
||||
long bytesToRead = peeksize;
|
||||
long buffersize;
|
||||
|
||||
if (expectedLength > 0)
|
||||
@ -824,6 +884,7 @@ readHandler()
|
||||
int eomReason;
|
||||
asynStatus status;
|
||||
long readMore;
|
||||
int connected;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -831,16 +892,26 @@ readHandler()
|
||||
received = 0;
|
||||
eomReason = 0;
|
||||
|
||||
debug("AsynDriverInterface::readHandler(%s): ioAction=%s "
|
||||
"read(..., bytesToRead=%ld, ...) "
|
||||
"[timeout=%g sec]\n",
|
||||
clientName(), ioActionStr[ioAction],
|
||||
bytesToRead, pasynUser->timeout);
|
||||
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||
buffer, bytesToRead, &received, &eomReason);
|
||||
if (ioAction == Read || status != asynTimeout)
|
||||
{
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"read(..., bytesToRead=%d, ...) [timeout=%f seconds] = %s\n",
|
||||
clientName(), bytesToRead, pasynUser->timeout,
|
||||
asynStatusStr[status]);
|
||||
}
|
||||
// pasynOctet->read() has already cut off terminator.
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"read returned %s: ioAction=%s received=%ld, eomReason=%s, buffer=\"%s\"\n",
|
||||
clientName(), asynStatusStr[status], ioActionStr[ioAction],
|
||||
(long)received,eomReasonStr[eomReason&0x7],
|
||||
StreamBuffer(buffer, received).expand()());
|
||||
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"device is now %sconnected\n",
|
||||
clientName(),connected?"":"dis");
|
||||
// asyn 4.16 sets reason to ASYN_EOM_END when device disconnects.
|
||||
// What about earlier versions?
|
||||
if (!connected) eomReason |= ASYN_EOM_END;
|
||||
|
||||
if (status == asynTimeout &&
|
||||
pasynUser->timeout == 0.0 &&
|
||||
@ -859,24 +930,25 @@ readHandler()
|
||||
{
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"AsyncRead poll: received %d of %d bytes \"%s\" "
|
||||
"AsyncRead poll: received %ld of %ld bytes \"%s\" "
|
||||
"eomReason=%s [data ignored]\n",
|
||||
clientName(), (int)received, bytesToRead,
|
||||
StreamBuffer(buffer, (int)received).expand()(),
|
||||
clientName(), (long)received, bytesToRead,
|
||||
StreamBuffer(buffer, received).expand()(),
|
||||
eomReasonStr[eomReason&0x7]);
|
||||
#endif
|
||||
// ignore what we got from here.
|
||||
// input was already handeled by asynReadHandler()
|
||||
|
||||
// read until no more input is available
|
||||
readMore = -1;
|
||||
break;
|
||||
}
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"received %d of %d bytes \"%s\" "
|
||||
"received %ld of %ld bytes \"%s\" "
|
||||
"eomReason=%s\n",
|
||||
clientName(), (int)received, bytesToRead,
|
||||
StreamBuffer(buffer, (int)received).expand()(),
|
||||
clientName(), (long)received, bytesToRead,
|
||||
StreamBuffer(buffer, received).expand()(),
|
||||
eomReasonStr[eomReason&0x7]);
|
||||
#endif
|
||||
// asynOctet->read() cuts off terminator, but:
|
||||
@ -916,6 +988,9 @@ readHandler()
|
||||
// reply timeout
|
||||
if (ioAction == AsyncRead)
|
||||
{
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"no async input, retry in in %g seconds\n",
|
||||
clientName(), replyTimeout);
|
||||
// start next poll after timer expires
|
||||
if (replyTimeout != 0.0) startTimer(replyTimeout);
|
||||
// continues with:
|
||||
@ -932,9 +1007,10 @@ readHandler()
|
||||
// read timeout
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"ioAction=%s, timeout [%f seconds] after %d of %d bytes \"%s\"\n",
|
||||
"ioAction=%s, timeout [%g sec] "
|
||||
"after %ld of %ld bytes \"%s\"\n",
|
||||
clientName(), ioActionStr[ioAction], pasynUser->timeout,
|
||||
(int)received, bytesToRead,
|
||||
(long)received, bytesToRead,
|
||||
StreamBuffer(buffer, received).expand()());
|
||||
#endif
|
||||
if (ioAction == AsyncRead || ioAction == AsyncReadMore)
|
||||
@ -971,18 +1047,18 @@ readHandler()
|
||||
case asynDisconnected:
|
||||
error("%s: asynDisconnected in read: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
case asynDisabled:
|
||||
error("%s: asynDisconnected in read: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
error("%s: unknown asyn error in read: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
}
|
||||
if (!readMore) break;
|
||||
@ -995,7 +1071,7 @@ readHandler()
|
||||
bytesToRead = inputBuffer.capacity();
|
||||
}
|
||||
debug("AsynDriverInterface::readHandler(%s) "
|
||||
"readMore=%ld bytesToRead=%d\n",
|
||||
"readMore=%ld bytesToRead=%ld\n",
|
||||
clientName(), readMore, bytesToRead);
|
||||
pasynUser->timeout = readTimeout;
|
||||
waitForReply = false;
|
||||
@ -1027,7 +1103,7 @@ void intrCallbackOctet(void* /*pvt*/, asynUser *pasynUser,
|
||||
|
||||
// get asynchronous input
|
||||
void AsynDriverInterface::
|
||||
asynReadHandler(const char *buffer, int received, int eomReason)
|
||||
asynReadHandler(const char *buffer, size_t received, int eomReason)
|
||||
{
|
||||
// Due to multithreading, timerExpired() might come at any time.
|
||||
// It queues the next poll request which is now useless because
|
||||
@ -1043,9 +1119,9 @@ asynReadHandler(const char *buffer, int received, int eomReason)
|
||||
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::asynReadHandler(%s, buffer=\"%s\", "
|
||||
"received=%d eomReason=%s) ioAction=%s\n",
|
||||
"received=%ld eomReason=%s) ioAction=%s\n",
|
||||
clientName(), StreamBuffer(buffer, received).expand()(),
|
||||
received, eomReasonStr[eomReason&0x7], ioActionStr[ioAction]);
|
||||
(long)received, eomReasonStr[eomReason&0x7], ioActionStr[ioAction]);
|
||||
#endif
|
||||
|
||||
ioAction = None;
|
||||
@ -1101,7 +1177,7 @@ asynReadHandler(const char *buffer, int received, int eomReason)
|
||||
// set by stream, cut it off now.
|
||||
status = pasynOctet->getInputEos(pvtOctet,
|
||||
pasynUser, deveos, sizeof(deveos)-1, &deveoslen);
|
||||
if (status == asynSuccess && received >= deveoslen)
|
||||
if (status == asynSuccess && (long)received >= (long)deveoslen)
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i <= deveoslen; i++)
|
||||
@ -1192,6 +1268,9 @@ timerExpired()
|
||||
int autoconnect, connected;
|
||||
switch (ioAction)
|
||||
{
|
||||
case None:
|
||||
// Timeout of async poll crossed with parasitic input
|
||||
return;
|
||||
case ReceiveEvent:
|
||||
// timeout while waiting for event
|
||||
ioAction = None;
|
||||
@ -1210,6 +1289,8 @@ timerExpired()
|
||||
// queueRequest might fail if another request was just queued
|
||||
pasynManager->isAutoConnect(pasynUser, &autoconnect);
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
debug("%s: polling for I/O Intr: autoconnected: %d, connect: %d\n",
|
||||
clientName(), autoconnect, connected);
|
||||
if (autoconnect && !connected)
|
||||
{
|
||||
// has explicitely been disconnected
|
||||
@ -1220,8 +1301,14 @@ timerExpired()
|
||||
else
|
||||
{
|
||||
// queue for read poll (no timeout)
|
||||
pasynManager->queueRequest(pasynUser,
|
||||
asynStatus status = pasynManager->queueRequest(pasynUser,
|
||||
asynQueuePriorityLow, -1.0);
|
||||
// if this fails, we are already queued by another thread
|
||||
debug("AsynDriverInterface::timerExpired %s: "
|
||||
"queueRequest(..., priority=Low, queueTimeout=-1) = %s %s\n",
|
||||
clientName(), asynStatusStr[status],
|
||||
status!=asynSuccess ? pasynUser->errorMessage : "");
|
||||
if (status != asynSuccess) startTimer(replyTimeout);
|
||||
// continues with:
|
||||
// handleRequest() -> readHandler() -> readCallback()
|
||||
}
|
||||
@ -1233,14 +1320,7 @@ timerExpired()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
epicsTimerNotify::expireStatus AsynDriverInterface::
|
||||
expire(const epicsTime &)
|
||||
{
|
||||
timerExpired();
|
||||
return noRestart;
|
||||
}
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
void AsynDriverInterface::
|
||||
expire(CALLBACK *pcallback)
|
||||
{
|
||||
@ -1248,6 +1328,13 @@ expire(CALLBACK *pcallback)
|
||||
static_cast<AsynDriverInterface*>(pcallback->user);
|
||||
interface->timerExpired();
|
||||
}
|
||||
#else
|
||||
epicsTimerNotify::expireStatus AsynDriverInterface::
|
||||
expire(const epicsTime &)
|
||||
{
|
||||
timerExpired();
|
||||
return noRestart;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool AsynDriverInterface::
|
||||
@ -1346,6 +1433,7 @@ void handleRequest(asynUser* pasynUser)
|
||||
{
|
||||
AsynDriverInterface* interface =
|
||||
static_cast<AsynDriverInterface*>(pasynUser->userPvt);
|
||||
interface->cancelTimer();
|
||||
debug("AsynDriverInterface::handleRequest(%s) %s\n",
|
||||
interface->clientName(), ioActionStr[interface->ioAction]);
|
||||
switch (interface->ioAction)
|
||||
|
@ -130,9 +130,10 @@ scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
int width = format.width;
|
||||
if (width == 0) width = -1;
|
||||
int length = 0;
|
||||
while (isspace(input[length])) length++; // skip whitespaces
|
||||
char zero = format.info[0];
|
||||
char one = format.info[1];
|
||||
if (!isspace(zero) && !isspace(one))
|
||||
while (isspace(input[length])) length++; // skip whitespaces
|
||||
if (input[length] != zero && input[length] != one) return -1;
|
||||
if (format.flags & alt_flag)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ RECORDS += longout longin
|
||||
RECORDS += stringout stringin
|
||||
RECORDS += waveform
|
||||
RECORDS += calcout
|
||||
#RECORDS += aai aao
|
||||
RECORDS += aai aao
|
||||
|
||||
# Do you have synApps and want support for scalcout?
|
||||
# Then define CALC or SYNAPPS in your RELEASE file
|
||||
@ -22,6 +22,7 @@ RECORDS += calcout
|
||||
# you have to build the 'sscan' and 'genSub'
|
||||
# modules before building 'calc'.
|
||||
# See doc/scalcout.html for a required fix in scalcout.
|
||||
|
||||
SYNAPPS_RECORDS += scalcout
|
||||
|
||||
# You may add more bus interfaces
|
||||
@ -29,7 +30,7 @@ SYNAPPS_RECORDS += scalcout
|
||||
# $(BUS)Interface.cc
|
||||
# asynDriver interface is added automatically
|
||||
# if ASYN is defined in your RELEASE file.
|
||||
# BUSSES += Debug
|
||||
|
||||
BUSSES += Debug
|
||||
BUSSES += Dummy
|
||||
|
||||
|
@ -265,7 +265,7 @@ static ulong crc_0x04C11DB7(const uchar* data, ulong len, ulong crc)
|
||||
{
|
||||
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
||||
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
||||
const static ulong table[] = {
|
||||
const static unsigned int table[] = {
|
||||
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
|
||||
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
||||
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
||||
@ -340,7 +340,7 @@ static ulong crc_0x04C11DB7_r(const uchar* data, ulong len, ulong crc)
|
||||
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
||||
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
||||
// reflected
|
||||
const static ulong table[] = {
|
||||
const static unsigned int table[] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
||||
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
@ -545,9 +545,9 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
debug("ChecksumConverter %s: output to check: \"%s\"\n",
|
||||
checksumMap[fnum].name, output.expand(start,length)());
|
||||
|
||||
sum = checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
||||
sum = (checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
||||
reinterpret_cast<uchar*>(output(start)), length,
|
||||
checksumMap[fnum].init) & mask[checksumMap[fnum].bytes];
|
||||
checksumMap[fnum].init)) & mask[checksumMap[fnum].bytes];
|
||||
|
||||
debug("ChecksumConverter %s: output checksum is 0x%lX\n",
|
||||
checksumMap[fnum].name, sum);
|
||||
@ -555,6 +555,17 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
int i;
|
||||
unsigned outchar;
|
||||
|
||||
if (format.flags & sign_flag) // decimal
|
||||
{
|
||||
// get number of decimal digits from number of bytes: ceil(xbytes*2.5)
|
||||
i = (checksumMap[fnum].bytes+1)*25/10-2;
|
||||
output.print("%0*ld", i, sum);
|
||||
debug("ChecksumConverter %s: decimal appending %0*ld\n",
|
||||
checksumMap[fnum].name, i, sum);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (format.flags & alt_flag) // lsb first (little endian)
|
||||
{
|
||||
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
||||
@ -563,7 +574,7 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
debug("ChecksumConverter %s: little endian appending 0x%X\n",
|
||||
checksumMap[fnum].name, outchar);
|
||||
if (format.flags & zero_flag) // ASCII
|
||||
output.printf("%02X", outchar);
|
||||
output.print("%02X", outchar);
|
||||
else // binary
|
||||
output.append(outchar);
|
||||
sum >>= 8;
|
||||
@ -578,7 +589,7 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
debug("ChecksumConverter %s: big endian appending 0x%X\n",
|
||||
checksumMap[fnum].name, outchar);
|
||||
if (format.flags & zero_flag) // ASCII
|
||||
output.printf("%02X", outchar);
|
||||
output.print("%02X", outchar);
|
||||
else // binary
|
||||
output.append(outchar);
|
||||
sum <<= 8;
|
||||
@ -606,9 +617,9 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
return -1;
|
||||
}
|
||||
|
||||
sum = checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
||||
sum = (checksumMap[fnum].xorout ^ checksumMap[fnum].func(
|
||||
reinterpret_cast<uchar*>(input(start)), length,
|
||||
checksumMap[fnum].init) & mask[checksumMap[fnum].bytes];
|
||||
checksumMap[fnum].init)) & mask[checksumMap[fnum].bytes];
|
||||
|
||||
debug("ChecksumConverter %s: input checksum is 0x%0*lX\n",
|
||||
checksumMap[fnum].name, 2*checksumMap[fnum].bytes, sum);
|
||||
@ -616,6 +627,24 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
int i,j;
|
||||
unsigned inchar;
|
||||
|
||||
if (format.flags & sign_flag) // decimal
|
||||
{
|
||||
ulong sumin = 0;
|
||||
// get number of decimal digits from number of bytes: ceil(xbytes*2.5)
|
||||
j = (checksumMap[fnum].bytes+1)*25/10-2;
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
inchar = input[cursor+i];
|
||||
if (isdigit(inchar)) sumin = sumin*10+inchar-'0';
|
||||
else break;
|
||||
}
|
||||
if (sumin==sum) return i;
|
||||
error("Input %0*lu does not match checksum %0*lu\n",
|
||||
i, sumin, j, sum);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (format.flags & alt_flag) // lsb first (little endian)
|
||||
{
|
||||
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
||||
|
28
src/Makefile
@ -65,7 +65,8 @@ ifdef PCRE
|
||||
LIB_LIBS += pcre
|
||||
else
|
||||
ifneq ($(words $(PCRE_LIB) $(PCRE_INCLUDE)),0)
|
||||
LIB_SYS_LIBS += pcre
|
||||
LIB_SYS_LIBS_DEFAULT += pcre
|
||||
LIB_SYS_LIBS_WIN32 += $(PCRE_LIB)\\pcre
|
||||
SHRLIB_DEPLIB_DIRS += $(PCRE_LIB)
|
||||
endif
|
||||
endif
|
||||
@ -78,30 +79,21 @@ include $(TOP)/configure/RULES
|
||||
|
||||
# Update version string (contains __DATE__ and __TIME__)
|
||||
# each time make runs.
|
||||
StreamVersion$(OBJ): FORCE
|
||||
FORCE:
|
||||
StreamVersion$(OBJ): ../*.c ../*.h ../*.cc ../CONFIG_STREAM ../Makefile
|
||||
|
||||
# Add references to all registrars to main file to avoid
|
||||
# missing initialization.
|
||||
StreamCore$(OBJ): streamReferences
|
||||
StreamCore$(OBJ) StreamCore$(DEP): streamReferences
|
||||
|
||||
streamReferences: ../CONFIG_STREAM
|
||||
@for i in $(BUSSES); \
|
||||
do echo "extern void* ref_$${i}Interface;"; \
|
||||
echo "void* p$$i = ref_$${i}Interface;"; \
|
||||
done > $@
|
||||
@for i in $(FORMATS); \
|
||||
do echo "extern void* ref_$${i}Converter;"; \
|
||||
echo "void* p$$i = ref_$${i}Converter;"; \
|
||||
done >> $@
|
||||
$(PERL) ../makeref.pl Interface $(BUSSES) > $@
|
||||
$(PERL) ../makeref.pl Converter $(FORMATS) >> $@
|
||||
|
||||
# create stream.dbd from all RECORDS
|
||||
$(COMMON_DIR)/$(LIBRARY_DEFAULT).dbd: ../CONFIG_STREAM
|
||||
@for r in $(RECORDS); \
|
||||
do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \
|
||||
done > $@
|
||||
@echo "driver(stream)" >> $@
|
||||
@echo "variable(streamDebug, int)" >> $@
|
||||
@echo "registrar(streamRegistrar)" >> $@
|
||||
$(PERL) ../makedbd.pl $(RECORDS) > $@
|
||||
|
||||
$(LIBRARY_DEFAULT).dbd$(DEP): ../CONFIG_STREAM
|
||||
echo $(LIBRARY_DEFAULT).dbd: $< > $@
|
||||
|
||||
endif
|
||||
|
@ -39,7 +39,4 @@ include $(TOP)/config/RULES.Host
|
||||
|
||||
# create stream.dbd from all RECORDS
|
||||
stream.dbd: ../CONFIG_STREAM
|
||||
@for r in $(RECORDS_3_13); \
|
||||
do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \
|
||||
done > $@
|
||||
@echo "driver(stream)" >> $@
|
||||
$(PERL) ../makedbd.pl -3.13 $(RECORDS_3_13) > $@
|
||||
|
@ -75,7 +75,7 @@ printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
||||
int prec = fmt.prec;
|
||||
|
||||
if (prec < 1) prec = 6;
|
||||
buf.printf("%.*e", prec-1, fabs(value)/pow(10.0, prec-1));
|
||||
buf.print("%.*e", prec-1, fabs(value)/pow(10.0, prec-1));
|
||||
buf.remove(1,1);
|
||||
buf.remove(buf.find('e'),1);
|
||||
|
||||
|
@ -70,7 +70,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
}
|
||||
if (*source == esc) {
|
||||
source++;
|
||||
pattern.printf("\\x%02x", *source++ & 0xFF);
|
||||
pattern.print("\\x%02x", *source++ & 0xFF);
|
||||
continue;
|
||||
}
|
||||
pattern.append(*source++);
|
||||
@ -110,7 +110,7 @@ scanString(const StreamFormat& fmt, const char* input,
|
||||
len = ovector[subexpr*2+1] - ovector[subexpr*2];
|
||||
if (len >= maxlen) {
|
||||
if (!(fmt.flags & sign_flag)) {
|
||||
debug("Matching string \"%s\" too long (%d>%d bytes)\n",
|
||||
error("Regexp: Matching string \"%s\" too long (%d>%d bytes). You may want to try the + flag: \"%%+/.../\"\n",
|
||||
StreamBuffer(input+ovector[subexpr*2], len).expand()(),
|
||||
(int)len, (int)maxlen-1);
|
||||
return -1;
|
||||
|
@ -109,7 +109,7 @@ grow(long minsize)
|
||||
memset(newbuffer+len, 0, newcap-len);
|
||||
if (buffer != local)
|
||||
{
|
||||
delete buffer;
|
||||
delete [] buffer;
|
||||
}
|
||||
buffer = newbuffer;
|
||||
cap = newcap;
|
||||
@ -219,7 +219,7 @@ replace(long remstart, long remlen, const void* ins, long inslen)
|
||||
memset(newbuffer+newlen, 0, newcap-newlen);
|
||||
if (buffer != local)
|
||||
{
|
||||
delete buffer;
|
||||
delete [] buffer;
|
||||
}
|
||||
buffer = newbuffer;
|
||||
cap = newcap;
|
||||
@ -248,7 +248,7 @@ replace(long remstart, long remlen, const void* ins, long inslen)
|
||||
}
|
||||
|
||||
StreamBuffer& StreamBuffer::
|
||||
printf(const char* fmt, ...)
|
||||
print(const char* fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
int printed;
|
||||
@ -296,7 +296,7 @@ StreamBuffer StreamBuffer::expand(long start, long length) const
|
||||
c = buffer[i];
|
||||
if ((c & 0x7f) < 0x20 || (c & 0x7f) == 0x7f)
|
||||
{
|
||||
result.printf("<%02x>", c & 0xff);
|
||||
result.print("<%02x>", c & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -312,17 +312,17 @@ dump() const
|
||||
StreamBuffer result(256+cap*5);
|
||||
result.append("\033[0m");
|
||||
long i;
|
||||
result.printf("%ld,%ld,%ld:\033[37m", offs, len, cap);
|
||||
result.print("%ld,%ld,%ld:\033[37m", offs, len, cap);
|
||||
for (i = 0; i < cap; i++)
|
||||
{
|
||||
if (i == offs) result.append("\033[34m[\033[0m");
|
||||
if ((buffer[i] & 0x7f) < 0x20 || (buffer[i] & 0x7f) == 0x7f)
|
||||
{
|
||||
if (i < offs || i >= offs+len)
|
||||
result.printf(
|
||||
result.print(
|
||||
"<%02x>", buffer[i] & 0xff);
|
||||
else
|
||||
result.printf(
|
||||
result.print(
|
||||
"\033[34m<%02x>\033[37m", buffer[i] & 0xff);
|
||||
}
|
||||
else
|
||||
|
@ -21,7 +21,6 @@
|
||||
#define StreamBuffer_h
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x)
|
||||
@ -189,7 +188,7 @@ public:
|
||||
StreamBuffer& insert(long pos, char c)
|
||||
{return replace(pos, 0, &c, 1);}
|
||||
|
||||
StreamBuffer& printf(const char* fmt, ...)
|
||||
StreamBuffer& print(const char* fmt, ...)
|
||||
__attribute__ ((format(printf,2,3)));
|
||||
|
||||
// find: get index of data in buffer or -1
|
||||
|
@ -66,7 +66,7 @@ find(Client* client, const char* busname, int addr, const char* param)
|
||||
{
|
||||
StreamBusInterfaceRegistrarBase* r;
|
||||
StreamBusInterface* bus;
|
||||
for (r = r->first; r; r = r->next)
|
||||
for (r = StreamBusInterfaceRegistrarBase::first; r; r = r->next)
|
||||
{
|
||||
bus = r->find(client, busname, addr, param);
|
||||
if (bus) return bus;
|
||||
|
@ -52,42 +52,62 @@ public:
|
||||
protected:
|
||||
StreamBusInterface* businterface;
|
||||
bool busSupportsEvent() {
|
||||
return businterface->supportsEvent();
|
||||
if (businterface)
|
||||
return businterface->supportsEvent();
|
||||
else return false;
|
||||
}
|
||||
bool busSupportsAsyncRead() {
|
||||
return businterface->supportsAsyncRead();
|
||||
if (businterface)
|
||||
return businterface->supportsAsyncRead();
|
||||
else return false;
|
||||
}
|
||||
bool busAcceptEvent(unsigned long mask,
|
||||
unsigned long replytimeout_ms) {
|
||||
return businterface->acceptEvent(mask, replytimeout_ms);
|
||||
if (businterface)
|
||||
return businterface->acceptEvent(mask, replytimeout_ms);
|
||||
else return false;
|
||||
}
|
||||
void busRelease() {
|
||||
businterface->release();
|
||||
if (businterface)
|
||||
businterface->release();
|
||||
}
|
||||
bool busLockRequest(unsigned long timeout_ms) {
|
||||
return businterface->lockRequest(timeout_ms);
|
||||
if (businterface)
|
||||
return businterface->lockRequest(timeout_ms);
|
||||
else return false;
|
||||
}
|
||||
bool busUnlock() {
|
||||
return businterface->unlock();
|
||||
if (businterface)
|
||||
return businterface->unlock();
|
||||
else return false;
|
||||
}
|
||||
bool busWriteRequest(const void* output, size_t size,
|
||||
unsigned long timeout_ms) {
|
||||
return businterface->writeRequest(output, size, timeout_ms);
|
||||
if (businterface)
|
||||
return businterface->writeRequest(output, size, timeout_ms);
|
||||
else return false;
|
||||
}
|
||||
bool busReadRequest(unsigned long replytimeout_ms,
|
||||
unsigned long readtimeout_ms, long expectedLength,
|
||||
bool async) {
|
||||
return businterface->readRequest(replytimeout_ms,
|
||||
readtimeout_ms, expectedLength, async);
|
||||
if (businterface)
|
||||
return businterface->readRequest(replytimeout_ms,
|
||||
readtimeout_ms, expectedLength, async);
|
||||
else return false;
|
||||
}
|
||||
void busFinish() {
|
||||
businterface->finish();
|
||||
if (businterface)
|
||||
businterface->finish();
|
||||
}
|
||||
bool busConnectRequest(unsigned long timeout_ms) {
|
||||
return businterface->connectRequest(timeout_ms);
|
||||
if (businterface)
|
||||
return businterface->connectRequest(timeout_ms);
|
||||
else return false;
|
||||
}
|
||||
bool busDisconnect() {
|
||||
return businterface->disconnectRequest();
|
||||
if (businterface)
|
||||
return businterface->disconnectRequest();
|
||||
else return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -57,12 +57,12 @@ static char* printCommands(StreamBuffer& buffer, const char* c)
|
||||
break;
|
||||
case wait_cmd:
|
||||
timeout = extract<unsigned long>(c);
|
||||
buffer.printf(" wait %ld;\n # ms", timeout);
|
||||
buffer.print(" wait %ld;\n # ms", timeout);
|
||||
break;
|
||||
case event_cmd:
|
||||
eventnumber = extract<unsigned long>(c);
|
||||
timeout = extract<unsigned long>(c);
|
||||
buffer.printf(" event(%ld) %ld; # ms\n", eventnumber, timeout);
|
||||
buffer.print(" event(%ld) %ld; # ms\n", eventnumber, timeout);
|
||||
break;
|
||||
case exec_cmd:
|
||||
buffer.append(" exec \"");
|
||||
@ -71,7 +71,7 @@ static char* printCommands(StreamBuffer& buffer, const char* c)
|
||||
break;
|
||||
case connect_cmd:
|
||||
timeout = extract<unsigned long>(c);
|
||||
buffer.printf(" connect %ld; # ms\n", timeout);
|
||||
buffer.print(" connect %ld; # ms\n", timeout);
|
||||
break;
|
||||
case disconnect_cmd:
|
||||
buffer.append(" disconnect;\n");
|
||||
@ -118,7 +118,6 @@ printProtocol()
|
||||
if (onMismatch)
|
||||
printf(" @Mismatch {\n%s }\n",
|
||||
printCommands(buffer.clear(), onMismatch()));
|
||||
debug("StreamCore::printProtocol: commands=%s\n", commands.expand()());
|
||||
printf("\n%s}\n",
|
||||
printCommands(buffer.clear(), commands()));
|
||||
}
|
||||
@ -650,9 +649,12 @@ formatOutput()
|
||||
unsigned short addrlen = extract<unsigned short>(commandIndex);
|
||||
fieldAddress.set(commandIndex, addrlen);
|
||||
commandIndex += addrlen;
|
||||
goto normal_format;
|
||||
}
|
||||
case StreamProtocolParser::format:
|
||||
{
|
||||
fieldAddress.clear();
|
||||
normal_format:
|
||||
// code layout:
|
||||
// formatstring <eos> StreamFormat [info]
|
||||
formatstring = commandIndex;
|
||||
@ -696,7 +698,6 @@ formatOutput()
|
||||
name(), formatstr.expand()());
|
||||
return false;
|
||||
}
|
||||
fieldAddress.clear();
|
||||
continue;
|
||||
}
|
||||
case StreamProtocolParser::whitespace:
|
||||
@ -823,10 +824,16 @@ lockCallback(StreamIoStatus status)
|
||||
}
|
||||
flags &= ~LockPending;
|
||||
flags |= BusOwner;
|
||||
if (status != StreamIoSuccess)
|
||||
switch (status)
|
||||
{
|
||||
finishProtocol(LockTimeout);
|
||||
return;
|
||||
case StreamIoSuccess:
|
||||
break;
|
||||
case StreamIoTimeout:
|
||||
finishProtocol(LockTimeout);
|
||||
return;
|
||||
default:
|
||||
finishProtocol(Fault);
|
||||
return;
|
||||
}
|
||||
flags |= WritePending;
|
||||
if (!busWriteRequest(outputLine(), outputLine.length(), writeTimeout))
|
||||
@ -1151,8 +1158,7 @@ matchInput()
|
||||
*/
|
||||
char command;
|
||||
const char* fieldName = NULL;
|
||||
const char* formatstring;
|
||||
int formatstringlen;
|
||||
StreamBuffer formatstring;
|
||||
|
||||
consumedInput = 0;
|
||||
|
||||
@ -1169,28 +1175,23 @@ matchInput()
|
||||
unsigned short addrlen = extract<unsigned short>(commandIndex);
|
||||
fieldAddress.set(commandIndex, addrlen);
|
||||
commandIndex += addrlen;
|
||||
goto normal_format;
|
||||
}
|
||||
case StreamProtocolParser::format:
|
||||
{
|
||||
fieldAddress.clear();
|
||||
normal_format:
|
||||
int consumed;
|
||||
// code layout:
|
||||
// formatstring <eos> StreamFormat [info]
|
||||
formatstring = commandIndex;
|
||||
// jump after <eos>
|
||||
while (*commandIndex)
|
||||
{
|
||||
if (*commandIndex == esc) commandIndex++;
|
||||
commandIndex++;
|
||||
}
|
||||
formatstringlen = commandIndex-formatstring;
|
||||
commandIndex++;
|
||||
commandIndex = StreamProtocolParser::printString(formatstring, commandIndex);
|
||||
|
||||
StreamFormat fmt = extract<StreamFormat>(commandIndex);
|
||||
fmt.info = commandIndex; // point to info string
|
||||
commandIndex += fmt.infolen;
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("StreamCore::matchInput(%s): format = %%%s\n",
|
||||
name(), StreamBuffer(formatstring, formatstringlen).expand()());
|
||||
debug("StreamCore::matchInput(%s): format = \"%%%s\"\n",
|
||||
name(), formatstring());
|
||||
#endif
|
||||
|
||||
if (fmt.flags & skip_flag || fmt.type == pseudo_format)
|
||||
@ -1232,10 +1233,10 @@ matchInput()
|
||||
{
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
error("%s: Input \"%s%s\" does not match format %%%s\n",
|
||||
error("%s: Input \"%s%s\" does not match format \"%%%s\"\n",
|
||||
name(), inputLine.expand(consumedInput, 20)(),
|
||||
inputLine.length()-consumedInput > 20 ? "..." : "",
|
||||
formatstring);
|
||||
formatstring());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1249,13 +1250,12 @@ matchInput()
|
||||
flags &= ~Separator;
|
||||
if (!formatValue(fmt, fieldAddress ? fieldAddress() : NULL))
|
||||
{
|
||||
StreamBuffer formatstr(formatstring, formatstringlen);
|
||||
if (fieldAddress)
|
||||
error("%s: Cannot format field '%s' with '%%%s'\n",
|
||||
name(), fieldName, formatstr.expand()());
|
||||
error("%s: Cannot format variable \"%s\" with \"%%%s\"\n",
|
||||
name(), fieldName, formatstring());
|
||||
else
|
||||
error("%s: Cannot format value with '%%%s'\n",
|
||||
name(), formatstr.expand()());
|
||||
error("%s: Cannot format value with \"%%%s\"\n",
|
||||
name(), formatstring());
|
||||
return false;
|
||||
}
|
||||
#ifndef NO_TEMPORARY
|
||||
@ -1268,11 +1268,11 @@ matchInput()
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
error("%s: Input \"%s%s\" too short."
|
||||
" No match for format %%%s (\"%s\")\n",
|
||||
" No match for format \"%%%s\" (\"%s\")\n",
|
||||
name(),
|
||||
inputLine.length() > 20 ? "..." : "",
|
||||
inputLine.expand(-20)(),
|
||||
formatstring,
|
||||
formatstring(),
|
||||
outputLine.expand()());
|
||||
}
|
||||
return false;
|
||||
@ -1281,11 +1281,10 @@ matchInput()
|
||||
{
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
error("%s: Input \"%s%s\" does not match"
|
||||
" format %%%s (\"%s\")\n",
|
||||
error("%s: Input \"%s%s\" does not match format \"%%%s\" (\"%s\")\n",
|
||||
name(), inputLine.expand(consumedInput, 20)(),
|
||||
inputLine.length()-consumedInput > 20 ? "..." : "",
|
||||
formatstring,
|
||||
formatstring(),
|
||||
outputLine.expand()());
|
||||
}
|
||||
return false;
|
||||
@ -1299,18 +1298,17 @@ matchInput()
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
if (flags & ScanTried)
|
||||
error("%s: Input \"%s%s\" does not match format %%%s\n",
|
||||
error("%s: Input \"%s%s\" does not match format \"%%%s\"\n",
|
||||
name(), inputLine.expand(consumedInput, 20)(),
|
||||
inputLine.length()-consumedInput > 20 ? "..." : "",
|
||||
formatstring);
|
||||
formatstring());
|
||||
else
|
||||
error("%s: Format %%%s has data type %s which does not match this variable.\n",
|
||||
name(), formatstring, StreamFormatTypeStr[fmt.type] );
|
||||
error("%s: Format \"%%%s\" has data type %s which does not match variable \"%s\".\n",
|
||||
name(), formatstring(), StreamFormatTypeStr[fmt.type], fieldName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// matchValue() has already removed consumed bytes from inputBuffer
|
||||
fieldAddress.clear();
|
||||
break;
|
||||
}
|
||||
case StreamProtocolParser::skip:
|
||||
@ -1332,12 +1330,12 @@ matchInput()
|
||||
while (commandIndex[i] >= ' ') i++;
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
{
|
||||
error("%s: Input \"%s%s\" too short.",
|
||||
error("%s: Input \"%s%s\" too short.\n",
|
||||
name(),
|
||||
inputLine.length() > 20 ? "..." : "",
|
||||
inputLine.expand(-20)());
|
||||
#ifndef NO_TEMPORARY
|
||||
error(" No match for \"%s\"\n",
|
||||
error("No match for \"%s\"\n",
|
||||
StreamBuffer(commandIndex-1,i+1).expand()());
|
||||
#endif
|
||||
}
|
||||
|
@ -18,11 +18,16 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include "StreamCore.h"
|
||||
#include "StreamError.h"
|
||||
#include "devStream.h"
|
||||
|
||||
#ifndef EPICS_3_14
|
||||
#include <epicsVersion.h>
|
||||
#ifdef BASE_VERSION
|
||||
#define EPICS_3_13
|
||||
#endif
|
||||
|
||||
#ifdef EPICS_3_13
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@ -34,10 +39,11 @@ extern "C" {
|
||||
#include <recSup.h>
|
||||
#include <recGbl.h>
|
||||
#include <devLib.h>
|
||||
#define epicsAlarmGLOBAL
|
||||
#include <alarm.h>
|
||||
#include <callback.h>
|
||||
|
||||
#ifndef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
|
||||
#include <semLib.h>
|
||||
#include <wdLib.h>
|
||||
@ -87,24 +93,24 @@ extern "C" void streamRecordProcessCallback(CALLBACK *pcallback);
|
||||
extern "C" long streamReload(char* recordname);
|
||||
|
||||
class Stream : protected StreamCore
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
, epicsTimerNotify
|
||||
#endif
|
||||
{
|
||||
dbCommon* record;
|
||||
struct link *ioLink;
|
||||
const struct link *ioLink;
|
||||
streamIoFunction readData;
|
||||
streamIoFunction writeData;
|
||||
#ifdef EPICS_3_14
|
||||
epicsTimerQueueActive* timerQueue;
|
||||
epicsTimer* timer;
|
||||
epicsMutex mutex;
|
||||
epicsEvent initDone;
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
WDOG_ID timer;
|
||||
CALLBACK timeoutCallback;
|
||||
SEM_ID mutex;
|
||||
SEM_ID initDone;
|
||||
#else
|
||||
epicsTimerQueueActive* timerQueue;
|
||||
epicsTimer* timer;
|
||||
epicsMutex mutex;
|
||||
epicsEvent initDone;
|
||||
#endif
|
||||
StreamBuffer fieldBuffer;
|
||||
int status;
|
||||
@ -115,11 +121,11 @@ class Stream : protected StreamCore
|
||||
CALLBACK processCallback;
|
||||
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
static void expire(CALLBACK *pcallback);
|
||||
#else
|
||||
// epicsTimerNotify method
|
||||
expireStatus expire(const epicsTime&);
|
||||
#else
|
||||
static void expire(CALLBACK *pcallback);
|
||||
#endif
|
||||
|
||||
// StreamCore methods
|
||||
@ -139,16 +145,19 @@ class Stream : protected StreamCore
|
||||
friend void streamRecordProcessCallback(CALLBACK *pcallback);
|
||||
|
||||
// Stream Epics methods
|
||||
long initRecord();
|
||||
Stream(dbCommon* record, struct link *ioLink,
|
||||
Stream(dbCommon* record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData);
|
||||
~Stream();
|
||||
long parseLink(const struct link *ioLink, char* filename, char* protocol,
|
||||
char* busname, int* addr, char* busparam);
|
||||
long initRecord(const char* filename, const char* protocol,
|
||||
const char* busname, int addr, const char* busparam);
|
||||
bool print(format_t *format, va_list ap);
|
||||
bool scan(format_t *format, void* pvalue, size_t maxStringSize);
|
||||
bool process();
|
||||
|
||||
// device support functions
|
||||
friend long streamInitRecord(dbCommon *record, struct link *ioLink,
|
||||
friend long streamInitRecord(dbCommon *record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData);
|
||||
friend long streamReadWrite(dbCommon *record);
|
||||
friend long streamGetIointInfo(int cmd, dbCommon *record,
|
||||
@ -166,7 +175,7 @@ public:
|
||||
|
||||
|
||||
// shell functions ///////////////////////////////////////////////////////
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
extern "C" {
|
||||
epicsExportAddress(int, streamDebug);
|
||||
}
|
||||
@ -225,7 +234,7 @@ extern "C" long streamReload(char* recordname)
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
static const iocshArg streamReloadArg0 =
|
||||
{ "recordname", iocshArgString };
|
||||
static const iocshArg * const streamReloadArgs[] =
|
||||
@ -251,7 +260,7 @@ static void streamRegistrar ()
|
||||
extern "C" {
|
||||
epicsExportRegistrar(streamRegistrar);
|
||||
}
|
||||
#endif // EPICS_3_14
|
||||
#endif
|
||||
|
||||
// driver support ////////////////////////////////////////////////////////
|
||||
|
||||
@ -265,19 +274,13 @@ struct stream_drvsup {
|
||||
Stream::drvInit
|
||||
};
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
#ifndef EPICS_3_13
|
||||
extern "C" {
|
||||
epicsExportAddress(drvet, stream);
|
||||
}
|
||||
#endif
|
||||
|
||||
void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
{
|
||||
int tlen;
|
||||
epicsTime tm = epicsTime::getCurrent();
|
||||
tlen = tm.strftime(buffer, size, "%Y/%m/%d %H:%M:%S.%03f");
|
||||
sprintf(buffer+tlen, " %.*s", size-tlen-2, epicsThreadGetNameSelf());
|
||||
}
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
{
|
||||
int tlen;
|
||||
@ -292,6 +295,14 @@ void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
tlen = strlen(buffer);
|
||||
sprintf(buffer+tlen, " %.*s", size-tlen-2, taskName(0));
|
||||
}
|
||||
#else
|
||||
void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
{
|
||||
int tlen;
|
||||
epicsTime tm = epicsTime::getCurrent();
|
||||
tlen = tm.strftime(buffer, size, "%Y/%m/%d %H:%M:%S.%06f");
|
||||
sprintf(buffer+tlen, " %.*s", size-tlen-2, epicsThreadGetNameSelf());
|
||||
}
|
||||
#endif
|
||||
|
||||
long Stream::
|
||||
@ -393,9 +404,16 @@ long streamInit(int after)
|
||||
return OK;
|
||||
}
|
||||
|
||||
long streamInitRecord(dbCommon* record, struct link *ioLink,
|
||||
long streamInitRecord(dbCommon* record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData)
|
||||
{
|
||||
char filename[80];
|
||||
char protocol[80];
|
||||
char busname[80];
|
||||
int addr = -1;
|
||||
char busparam[80];
|
||||
memset(busparam, 0 ,sizeof(busparam));
|
||||
|
||||
debug("streamInitRecord(%s): SEVR=%d\n", record->name, record->sevr);
|
||||
Stream* pstream = (Stream*)record->dpvt;
|
||||
if (!pstream)
|
||||
@ -407,8 +425,12 @@ long streamInitRecord(dbCommon* record, struct link *ioLink,
|
||||
// stop any running protocol
|
||||
pstream->finishProtocol(Stream::Abort);
|
||||
}
|
||||
// scan the i/o link
|
||||
pstream->parseLink(ioLink, filename, protocol,
|
||||
busname, &addr, busparam);
|
||||
// (re)initialize bus and protocol
|
||||
long status = pstream->initRecord();
|
||||
long status = pstream->initRecord(filename, protocol,
|
||||
busname, addr, busparam);
|
||||
if (status != OK && status != DO_NOT_CONVERT)
|
||||
{
|
||||
error("%s: Record initialization failed\n", record->name);
|
||||
@ -436,7 +458,8 @@ long streamGetIointInfo(int cmd, dbCommon *record, IOSCANPVT *ppvt)
|
||||
{
|
||||
Stream* pstream = (Stream*)record->dpvt;
|
||||
debug("streamGetIointInfo(%s,cmd=%d): pstream=%p, ioscanpvt=%p\n",
|
||||
record->name, cmd, (void*)pstream, pstream ? pstream->ioscanpvt : NULL);
|
||||
record->name, cmd,
|
||||
(void*)pstream, pstream ? pstream->ioscanpvt : NULL);
|
||||
if (!pstream)
|
||||
{
|
||||
error("streamGetIointInfo called without stream instance\n");
|
||||
@ -495,20 +518,20 @@ long streamScanfN(dbCommon* record, format_t *format,
|
||||
// Stream methods ////////////////////////////////////////////////////////
|
||||
|
||||
Stream::
|
||||
Stream(dbCommon* _record, struct link *ioLink,
|
||||
Stream(dbCommon* _record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData)
|
||||
:record(_record), ioLink(ioLink), readData(readData), writeData(writeData)
|
||||
{
|
||||
streamname = record->name;
|
||||
#ifdef EPICS_3_14
|
||||
timerQueue = &epicsTimerQueueActive::allocate(true);
|
||||
timer = &timerQueue->createTimer();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
timer = wdCreate();
|
||||
mutex = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY);
|
||||
initDone = semBCreate(SEM_Q_FIFO, SEM_EMPTY);
|
||||
callbackSetCallback(expire, &timeoutCallback);
|
||||
callbackSetUser(this, &timeoutCallback);
|
||||
#else
|
||||
timerQueue = &epicsTimerQueueActive::allocate(true);
|
||||
timer = &timerQueue->createTimer();
|
||||
#endif
|
||||
callbackSetCallback(streamExecuteCommand, &commandCallback);
|
||||
callbackSetUser(this, &commandCallback);
|
||||
@ -532,57 +555,57 @@ Stream::
|
||||
record->dpvt = NULL;
|
||||
debug("~Stream(%s): dpvt cleared\n", name());
|
||||
}
|
||||
#ifdef EPICS_3_14
|
||||
#ifdef EPICS_3_13
|
||||
wdDelete(timer);
|
||||
debug("~Stream(%s): watchdog destroyed\n", name());
|
||||
#else
|
||||
timer->destroy();
|
||||
debug("~Stream(%s): timer destroyed\n", name());
|
||||
timerQueue->release();
|
||||
debug("~Stream(%s): timer queue released\n", name());
|
||||
#else
|
||||
wdDelete(timer);
|
||||
debug("~Stream(%s): watchdog destroyed\n", name());
|
||||
#endif
|
||||
releaseMutex();
|
||||
}
|
||||
|
||||
long Stream::
|
||||
initRecord()
|
||||
parseLink(const struct link *ioLink, char* filename,
|
||||
char* protocol, char* busname, int* addr, char* busparam)
|
||||
{
|
||||
// scan link parameters: filename protocol busname addr busparam
|
||||
// It is safe to call this function again with different
|
||||
// link text or different protocol file.
|
||||
|
||||
char filename[80];
|
||||
char protocol[80];
|
||||
char busname[80];
|
||||
int addr = -1;
|
||||
char busparam[80];
|
||||
// parse link parameters: filename protocol busname addr busparam
|
||||
int n;
|
||||
|
||||
if (ioLink->type != INST_IO)
|
||||
{
|
||||
error("%s: Wrong link type %s\n", name(),
|
||||
error("%s: Wrong I/O link type %s\n", name(),
|
||||
pamaplinkType[ioLink->type].strvalue);
|
||||
return S_dev_badInitRet;
|
||||
}
|
||||
int items = sscanf(ioLink->value.instio.string, "%79s%79s%79s%n%i%n",
|
||||
filename, protocol, busname, &n, &addr, &n);
|
||||
int items = sscanf(ioLink->value.instio.string, "%s%s%s%n%i%n",
|
||||
filename, protocol, busname, &n, addr, &n);
|
||||
if (items <= 0)
|
||||
{
|
||||
error("%s: Empty link. Forgot the leading '@' or confused INP with OUT ?\n",
|
||||
error("%s: Empty I/O link. "
|
||||
"Forgot the leading '@' or confused INP with OUT ?\n",
|
||||
name());
|
||||
return S_dev_badInitRet;
|
||||
}
|
||||
if (items < 3)
|
||||
{
|
||||
error("%s: Wrong link format\n"
|
||||
error("%s: Wrong I/O link format\n"
|
||||
" expect \"@file protocol bus addr params\"\n"
|
||||
" in \"@%s\"\n", name(),
|
||||
ioLink->value.instio.string);
|
||||
return S_dev_badInitRet;
|
||||
}
|
||||
memset(busparam, 0 ,80);
|
||||
for (n = 0; isspace((unsigned char)ioLink->value.instio.string[n]); n++);
|
||||
strncpy (busparam, ioLink->value.constantStr+n, 79);
|
||||
while (isspace((unsigned char)ioLink->value.instio.string[n])) n++;
|
||||
strcpy (busparam, ioLink->value.constantStr+n);
|
||||
return OK;
|
||||
}
|
||||
|
||||
long Stream::
|
||||
initRecord(const char* filename, const char* protocol,
|
||||
const char* busname, int addr, const char* busparam)
|
||||
{
|
||||
// It is safe to call this function again with different arguments
|
||||
|
||||
// attach to bus interface
|
||||
if (!attachBus(busname, addr, busparam))
|
||||
@ -610,7 +633,8 @@ initRecord()
|
||||
name());
|
||||
if (record->scan == SCAN_IO_EVENT)
|
||||
{
|
||||
debug("Stream::initRecord %s: restarting \"I/O Intr\" after reload\n",
|
||||
debug("Stream::initRecord %s: "
|
||||
"restarting \"I/O Intr\" after reload\n",
|
||||
name());
|
||||
if (!startProtocol(StartAsync))
|
||||
{
|
||||
@ -635,10 +659,10 @@ initRecord()
|
||||
}
|
||||
debug("Stream::initRecord %s: waiting for initDone\n",
|
||||
name());
|
||||
#ifdef EPICS_3_14
|
||||
initDone.wait();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
semTake(initDone, WAIT_FOREVER);
|
||||
#else
|
||||
initDone.wait();
|
||||
#endif
|
||||
debug("Stream::initRecord %s: initDone\n",
|
||||
name());
|
||||
@ -664,8 +688,11 @@ process()
|
||||
{
|
||||
if (status != NO_ALARM)
|
||||
{
|
||||
debug("Stream::process(%s) error status=%d\n",
|
||||
name(), status);
|
||||
debug("Stream::process(%s) error status=%s (%d)\n",
|
||||
name(),
|
||||
status >= 0 && status < ALARM_NSTATUS ?
|
||||
epicsAlarmConditionStrings[status] : "ERROR",
|
||||
status);
|
||||
(void) recGblSetSevr(record, status, INVALID_ALARM);
|
||||
return false;
|
||||
}
|
||||
@ -690,6 +717,7 @@ process()
|
||||
debug("Stream::process(%s): could not start, status=%d\n",
|
||||
name(), status);
|
||||
(void) recGblSetSevr(record, status, INVALID_ALARM);
|
||||
record->pact = false;
|
||||
return false;
|
||||
}
|
||||
debug("Stream::process(%s): protocol started\n", name());
|
||||
@ -743,7 +771,8 @@ scan(format_t *format, void* value, size_t maxStringSize)
|
||||
break;
|
||||
case DBF_STRING:
|
||||
sptr = (char*)value;
|
||||
currentValueLength = scanValue(*format->priv, sptr, maxStringSize);
|
||||
currentValueLength = scanValue(*format->priv, sptr,
|
||||
maxStringSize);
|
||||
break;
|
||||
default:
|
||||
error("INTERNAL ERROR (%s): Illegal format type\n", name());
|
||||
@ -761,20 +790,20 @@ scan(format_t *format, void* value, size_t maxStringSize)
|
||||
|
||||
// epicsTimerNotify virtual method ///////////////////////////////////////
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
epicsTimerNotify::expireStatus Stream::
|
||||
expire(const epicsTime&)
|
||||
{
|
||||
timerCallback();
|
||||
return noRestart;
|
||||
}
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
void Stream::
|
||||
expire(CALLBACK *pcallback)
|
||||
{
|
||||
Stream* pstream = static_cast<Stream*>(pcallback->user);
|
||||
pstream->timerCallback();
|
||||
}
|
||||
#else
|
||||
epicsTimerNotify::expireStatus Stream::
|
||||
expire(const epicsTime&)
|
||||
{
|
||||
timerCallback();
|
||||
return noRestart;
|
||||
}
|
||||
#endif
|
||||
|
||||
// StreamCore virtual methods ////////////////////////////////////////////
|
||||
@ -834,10 +863,10 @@ protocolFinishHook(ProtocolResult result)
|
||||
}
|
||||
if (flags & InitRun)
|
||||
{
|
||||
#ifdef EPICS_3_14
|
||||
initDone.signal();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
semGive(initDone);
|
||||
#else
|
||||
initDone.signal();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -890,13 +919,13 @@ startTimer(unsigned long timeout)
|
||||
{
|
||||
debug("Stream::startTimer(stream=%s, timeout=%lu) = %f seconds\n",
|
||||
name(), timeout, timeout * 0.001);
|
||||
#ifdef EPICS_3_14
|
||||
timer->start(*this, timeout * 0.001);
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
callbackSetPriority(priority(), &timeoutCallback);
|
||||
wdStart(timer, (timeout+1)*sysClkRateGet()/1000-1,
|
||||
reinterpret_cast<FUNCPTR>(callbackRequest),
|
||||
reinterpret_cast<int>(&timeoutCallback));
|
||||
#else
|
||||
timer->start(*this, timeout * 0.001);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -956,7 +985,8 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
|
||||
if (format.type != double_format)
|
||||
{
|
||||
error ("%s: can only read double values from TIME field\n", name());
|
||||
error ("%s: can only read double values from TIME field\n",
|
||||
name());
|
||||
return false;
|
||||
}
|
||||
if (pdbaddr->precord == record)
|
||||
@ -964,8 +994,10 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
/* if getting time from own record, update timestamp first */
|
||||
recGblGetTimeStamp(record);
|
||||
}
|
||||
time = pdbaddr->precord->time.secPastEpoch + 631152000u + pdbaddr->precord->time.nsec * 1e-9;
|
||||
debug("Stream::formatValue(%s): read %f from TIME field\n", name(), time);
|
||||
time = pdbaddr->precord->time.secPastEpoch +
|
||||
631152000u + pdbaddr->precord->time.nsec * 1e-9;
|
||||
debug("Stream::formatValue(%s): read %f from TIME field\n",
|
||||
name(), time);
|
||||
return printValue(format, time);
|
||||
}
|
||||
|
||||
@ -1003,7 +1035,8 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
return false;
|
||||
break;
|
||||
case pseudo_format:
|
||||
error("%s: %%(FIELD) syntax not allowed with pseudo formats\n",
|
||||
error("%s: %%(FIELD) syntax not allowed "
|
||||
"with pseudo formats\n",
|
||||
name());
|
||||
default:
|
||||
error("INTERNAL ERROR %s: Illegal format.type=%d\n",
|
||||
@ -1053,30 +1086,49 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
buffer = fieldBuffer.clear().reserve(size);
|
||||
for (nord = 0; nord < nelem; nord++)
|
||||
{
|
||||
debug("Stream::matchValue(%s): buffer before: %s\n",
|
||||
name(), fieldBuffer.expand()());
|
||||
switch (format.type)
|
||||
{
|
||||
case long_format:
|
||||
{
|
||||
consumed = scanValue(format, lval);
|
||||
if (consumed >= 0) ((epicsInt32*)buffer)[nord] = lval;
|
||||
debug("Stream::matchValue(%s): %s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name, nord, lval);
|
||||
break;
|
||||
}
|
||||
case enum_format:
|
||||
{
|
||||
consumed = scanValue(format, lval);
|
||||
if (consumed >= 0) ((epicsUInt16*)buffer)[nord] = (epicsUInt16)lval;
|
||||
if (consumed >= 0)
|
||||
((epicsUInt16*)buffer)[nord] = (epicsUInt16)lval;
|
||||
debug("Stream::matchValue(%s): %s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name, nord, lval);
|
||||
break;
|
||||
}
|
||||
case double_format:
|
||||
{
|
||||
consumed = scanValue(format, dval);
|
||||
if (consumed >= 0) ((epicsFloat64*)buffer)[nord] = dval;
|
||||
// Direct assignment to buffer fails with
|
||||
// gcc 3.4.3 for xscale_be
|
||||
// Optimization bug?
|
||||
epicsFloat64 f64=dval;
|
||||
if (consumed >= 0)
|
||||
memcpy(((epicsFloat64*)buffer)+nord,
|
||||
&f64, sizeof(f64));
|
||||
debug("Stream::matchValue(%s): %s[%li] = %#g %#g\n",
|
||||
name(), pdbaddr->precord->name, nord, dval,
|
||||
((epicsFloat64*)buffer)[nord]);
|
||||
break;
|
||||
}
|
||||
case string_format:
|
||||
{
|
||||
consumed = scanValue(format,
|
||||
buffer+MAX_STRING_SIZE*nord, MAX_STRING_SIZE);
|
||||
debug("Stream::matchValue(%s): %s[%li] = \"%.*s\"\n",
|
||||
name(), pdbaddr->precord->name, nord,
|
||||
MAX_STRING_SIZE, buffer+MAX_STRING_SIZE*nord);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1084,6 +1136,8 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
"Illegal format type\n", name());
|
||||
return false;
|
||||
}
|
||||
debug("Stream::matchValue(%s): buffer after: %s\n",
|
||||
name(), fieldBuffer.expand()());
|
||||
if (consumed < 0) break;
|
||||
consumedInput += consumed;
|
||||
}
|
||||
@ -1092,7 +1146,8 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
// scan error: set other record to alarm status
|
||||
if (pdbaddr->precord != record)
|
||||
{
|
||||
(void) recGblSetSevr(pdbaddr->precord, CALC_ALARM, INVALID_ALARM);
|
||||
(void) recGblSetSevr(pdbaddr->precord,
|
||||
CALC_ALARM, INVALID_ALARM);
|
||||
if (!INIT_RUN)
|
||||
{
|
||||
// process other record to send alarm monitor
|
||||
@ -1106,19 +1161,24 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
#ifdef epicsTimeEventDeviceTime
|
||||
if (format.type != double_format)
|
||||
{
|
||||
error ("%s: can only write double values to TIME field\n", name());
|
||||
error ("%s: can only write double values to TIME field\n",
|
||||
name());
|
||||
return false;
|
||||
}
|
||||
dval = dval-631152000u;
|
||||
pdbaddr->precord->time.secPastEpoch = (long)dval;
|
||||
/* rouding: we don't have 9 digits precision in a double of today's number of seconds */
|
||||
// rouding: we don't have 9 digits precision
|
||||
// in a double of today's number of seconds
|
||||
pdbaddr->precord->time.nsec = (long)((dval-(long)dval)*1e6)*1000;
|
||||
debug("Stream::matchValue(%s): writing %i.%i to TIME field\n", name(),
|
||||
pdbaddr->precord->time.secPastEpoch, pdbaddr->precord->time.nsec);
|
||||
debug("Stream::matchValue(%s): writing %i.%i to TIME field\n",
|
||||
name(),
|
||||
pdbaddr->precord->time.secPastEpoch,
|
||||
pdbaddr->precord->time.nsec);
|
||||
pdbaddr->precord->tse = epicsTimeEventDeviceTime;
|
||||
return true;
|
||||
#else
|
||||
error ("%s: writing TIME field is not supported in this EPICS version\n", name());
|
||||
error ("%s: writing TIME field is not supported "
|
||||
"in this EPICS version\n", name());
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@ -1127,12 +1187,13 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
{
|
||||
// write into own record, thus don't process it
|
||||
// in @init we must not process other record
|
||||
debug("Stream::matchValue(%s): dbPut(%s.%s,...)\n",
|
||||
debug("Stream::matchValue(%s): dbPut(%s.%s,%s)\n",
|
||||
name(),
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name);
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
fieldBuffer.expand()());
|
||||
putfunc = "dbPut";
|
||||
status = dbPut(pdbaddr, dbfMapping[format.type], fieldBuffer(), nord);
|
||||
status = dbPut(pdbaddr, dbfMapping[format.type], buffer, nord);
|
||||
if (INIT_RUN && pdbaddr->precord != record)
|
||||
{
|
||||
// clean error status of other record in @init
|
||||
@ -1144,12 +1205,14 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
else
|
||||
{
|
||||
// write into other record, thus process it
|
||||
debug("Stream::matchValue(%s): dbPutField(%s.%s,...)\n",
|
||||
debug("Stream::matchValue(%s): dbPutField(%s.%s,%s)\n",
|
||||
name(),
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name);
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
fieldBuffer.expand()());
|
||||
putfunc = "dbPutField";
|
||||
status = dbPutField(pdbaddr, dbfMapping[format.type], fieldBuffer(), nord);
|
||||
status = dbPutField(pdbaddr, dbfMapping[format.type],
|
||||
buffer, nord);
|
||||
}
|
||||
if (status != 0)
|
||||
{
|
||||
@ -1212,13 +1275,15 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef EPICS_3_14
|
||||
// Pass command to iocsh
|
||||
#ifdef EPICS_3_13
|
||||
// Pass command to vxWorks shell
|
||||
extern "C" int execute(const char *cmd);
|
||||
|
||||
void streamExecuteCommand(CALLBACK *pcallback)
|
||||
{
|
||||
Stream* pstream = static_cast<Stream*>(pcallback->user);
|
||||
|
||||
if (iocshCmd(pstream->outputLine()) != OK)
|
||||
if (execute(pstream->outputLine()) != OK)
|
||||
{
|
||||
pstream->execCallback(StreamIoFault);
|
||||
}
|
||||
@ -1228,14 +1293,12 @@ void streamExecuteCommand(CALLBACK *pcallback)
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Pass command to vxWorks shell
|
||||
extern "C" int execute(const char *cmd);
|
||||
|
||||
// Pass command to iocsh
|
||||
void streamExecuteCommand(CALLBACK *pcallback)
|
||||
{
|
||||
Stream* pstream = static_cast<Stream*>(pcallback->user);
|
||||
|
||||
if (execute(pstream->outputLine()) != OK)
|
||||
if (iocshCmd(pstream->outputLine()) != OK)
|
||||
{
|
||||
pstream->execCallback(StreamIoFault);
|
||||
}
|
||||
@ -1257,19 +1320,19 @@ execute()
|
||||
void Stream::
|
||||
lockMutex()
|
||||
{
|
||||
#ifdef EPICS_3_14
|
||||
mutex.lock();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
semTake(mutex, WAIT_FOREVER);
|
||||
#else
|
||||
mutex.lock();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Stream::
|
||||
releaseMutex()
|
||||
{
|
||||
#ifdef EPICS_3_14
|
||||
mutex.unlock();
|
||||
#else
|
||||
#ifdef EPICS_3_13
|
||||
semGive(mutex);
|
||||
#else
|
||||
mutex.unlock();
|
||||
#endif
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "StreamError.h"
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int streamDebug = 0;
|
||||
extern "C" {
|
||||
|
@ -20,8 +20,8 @@
|
||||
#ifndef StreamError_h
|
||||
#define StreamError_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x)
|
||||
|
@ -316,7 +316,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
bool StdLongConverter::
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
output.printf(fmt.info, value);
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
bool StdDoubleConverter::
|
||||
printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
||||
{
|
||||
output.printf(fmt.info, value);
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
bool StdStringConverter::
|
||||
printString(const StreamFormat& fmt, StreamBuffer& output, const char* value)
|
||||
{
|
||||
output.printf(fmt.info, value);
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -549,7 +549,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
bool StdCharsConverter::
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
output.printf(fmt.info, value);
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ getProtocol(const StreamBuffer& protocolAndParams)
|
||||
return new Protocol(*protocol, name, 0);
|
||||
}
|
||||
error("Protocol '%s' not found in protocol file '%s'\n",
|
||||
name(), filename());
|
||||
protocolAndParams(), filename());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -634,7 +634,7 @@ printString(StreamBuffer& buffer, const char* s)
|
||||
switch (*s)
|
||||
{
|
||||
case esc:
|
||||
buffer.printf("\\x%02x", (*++s) & 0xff);
|
||||
buffer.print("\\x%02x", (*++s) & 0xff);
|
||||
break;
|
||||
case '\r':
|
||||
buffer.append("\\r");
|
||||
@ -655,7 +655,7 @@ printString(StreamBuffer& buffer, const char* s)
|
||||
buffer.append("\\\\");
|
||||
break;
|
||||
case format_field:
|
||||
buffer.printf("%%(%s)", ++s);
|
||||
buffer.print("%%(%s)", ++s);
|
||||
while (*s++);
|
||||
s += extract<unsigned short>(s); // skip fieldaddress
|
||||
goto format;
|
||||
@ -670,7 +670,7 @@ format: {
|
||||
continue;
|
||||
default:
|
||||
if ((*s & 0x7f) < 0x20 || (*s & 0x7f) == 0x7f)
|
||||
buffer.printf("\\x%02x", *s & 0xff);
|
||||
buffer.print("\\x%02x", *s & 0xff);
|
||||
else
|
||||
buffer.append(*s);
|
||||
}
|
||||
@ -742,7 +742,7 @@ Protocol(const Protocol& p, StreamBuffer& name, int _line)
|
||||
int i;
|
||||
const char* nextparameter;
|
||||
parameter[0] = protocolname();
|
||||
for (i = 0; i < 10; i++)
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
debug("StreamProtocolParser::Protocol::Protocol $%d=\"%s\"\n",
|
||||
i, parameter[i]);
|
||||
@ -1037,7 +1037,7 @@ compileNumber(unsigned long& number, const char*& source, unsigned long max)
|
||||
"Garbage after numeric value: %s\n", buffer());
|
||||
return false;
|
||||
}
|
||||
if (n < 0 || n > max)
|
||||
if (n > max)
|
||||
{
|
||||
debug("StreamProtocolParser::Protocol::compileNumber: %s\n",
|
||||
buffer.expand()());
|
||||
@ -1059,7 +1059,6 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
FormatType formatType, Client* client, int quoted)
|
||||
{
|
||||
bool escaped = false;
|
||||
int n;
|
||||
int newline = 0;
|
||||
StreamBuffer formatbuffer;
|
||||
int formatpos = buffer.length();
|
||||
@ -1136,7 +1135,8 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
if (escaped) // char after \ in quoted text
|
||||
{
|
||||
escaped = false;
|
||||
unsigned int temp;
|
||||
unsigned int c;
|
||||
int n=1;
|
||||
switch (*source)
|
||||
{
|
||||
case '$': // can't be: readToken would have made a token from this
|
||||
@ -1145,61 +1145,50 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
return false;
|
||||
case '?':
|
||||
buffer.append(skip);
|
||||
break;
|
||||
source++;
|
||||
continue;
|
||||
case '_':
|
||||
buffer.append(whitespace);
|
||||
break;
|
||||
source++;
|
||||
continue;
|
||||
case 'a':
|
||||
buffer.append(7);
|
||||
c=7;
|
||||
break;
|
||||
case 'b':
|
||||
buffer.append(8);
|
||||
c=8;
|
||||
break;
|
||||
case 't':
|
||||
buffer.append(9);
|
||||
c=9;
|
||||
break;
|
||||
case 'n':
|
||||
buffer.append('\n');
|
||||
c='\n';
|
||||
break;
|
||||
case 'r':
|
||||
buffer.append('\r');
|
||||
c='\r';
|
||||
break;
|
||||
case 'e':
|
||||
buffer.append(esc).append(esc);
|
||||
c=esc;
|
||||
break;
|
||||
case '0': // octal numbers (max 3 digits after 0)
|
||||
sscanf (source, "%3o%n", &temp, &n);
|
||||
if (temp > 0xFF)
|
||||
case '0': // octal numbers (max 4 digits)
|
||||
sscanf (source, "%4o%n", &c, &n); //cannot fail
|
||||
if (c > 0xFF)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Octal source %#o does not fit in byte: %s\n",
|
||||
temp, source-1);
|
||||
"Octal number %#o does not fit in byte: \"%s\"\n",
|
||||
c, source-1);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(temp);
|
||||
source += n;
|
||||
continue;
|
||||
case 'x': // hex numbers (max 2 digits after 0)
|
||||
if (sscanf (source+1, "%2x%n", &temp, &n) < 1)
|
||||
break;
|
||||
case 'x': // hex numbers (max 2 digits after x)
|
||||
if (sscanf (source+1, "%2x%n", &c, &n) < 1)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Hex digit expected after \\x: %s\n",
|
||||
"Hex digit expected after \\x: \"%s\"\n",
|
||||
source-1);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(temp);
|
||||
source += n+1;
|
||||
continue;
|
||||
n++;
|
||||
break;
|
||||
case '1': // decimal numbers (max 3 digits)
|
||||
case '2':
|
||||
case '3':
|
||||
@ -1209,26 +1198,24 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
sscanf (source, "%3u%n", &temp, &n);
|
||||
if (temp > 0xFF)
|
||||
sscanf (source, "%3u%n", &c, &n); //cannot fail
|
||||
if (c > 0xFF)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Decimal source %d does not fit in byte: %s\n",
|
||||
temp, source-1);
|
||||
"Decimal number %d does not fit in byte: \"%s\"\n",
|
||||
c, source-1);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(temp);
|
||||
source += n;
|
||||
continue;
|
||||
break;
|
||||
default: // escaped literals
|
||||
buffer.append(esc).append(*source);
|
||||
c=*source;
|
||||
}
|
||||
source++;
|
||||
source+=n;
|
||||
if (formatType != NoFormat)
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(c);
|
||||
continue;
|
||||
}
|
||||
if (quoted) // look for ending quotes and escapes
|
||||
@ -1281,7 +1268,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
}
|
||||
// try numeric byte value
|
||||
char* p;
|
||||
int temp = strtol(source, &p, 0);
|
||||
int c = strtol(source, &p, 0);
|
||||
if (p != source)
|
||||
{
|
||||
if (*p != 0)
|
||||
@ -1290,18 +1277,17 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
"Garbage after numeric source: %s", source);
|
||||
return false;
|
||||
}
|
||||
if (temp > 0xFF || temp < -0x80)
|
||||
if (c > 0xFF || c < -0x80)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Value %s does not fit in byte\n", source);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
if (formatType != NoFormat)
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
buffer.append(temp);
|
||||
buffer.append(c);
|
||||
source = p+1+sizeof(int);
|
||||
continue;
|
||||
}
|
||||
@ -1348,7 +1334,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
{"del", 0x7f}
|
||||
};
|
||||
size_t i;
|
||||
char c = 0;
|
||||
c=-1;
|
||||
for (i = 0; i < sizeof(codes)/sizeof(*codes); i++)
|
||||
{
|
||||
if (strcmp(source, codes[i].name) == 0)
|
||||
@ -1361,8 +1347,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
source);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat &&
|
||||
(temp < last_function_code || temp == esc))
|
||||
if (formatType != NoFormat)
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
@ -1371,10 +1356,10 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (c) continue;
|
||||
if (c >= 0) continue;
|
||||
// source may contain a function name
|
||||
error(line, filename(),
|
||||
"Unexpected word: %s\n", source);
|
||||
"Unexpected word: \"%s\"\n", source);
|
||||
return false;
|
||||
}
|
||||
debug("StreamProtocolParser::Protocol::compileString buffer=%s\n", buffer.expand()());
|
||||
@ -1493,8 +1478,10 @@ compileFormat(StreamBuffer& buffer, const char*& formatstr,
|
||||
buffer.append(&streamFormat, sizeof(streamFormat));
|
||||
buffer.append(infoString);
|
||||
|
||||
debug("StreamProtocolParser::Protocol::compileFormat: format.type=%s, infolen=%d\n",
|
||||
StreamFormatTypeStr[streamFormat.type], streamFormat.infolen);
|
||||
debug("StreamProtocolParser::Protocol::compileFormat: format.type=%s, "
|
||||
"infolen=%d infostring=\"%s\"\n",
|
||||
StreamFormatTypeStr[streamFormat.type],
|
||||
streamFormat.infolen, infoString.expand()());
|
||||
formatstr = source; // move pointer after parsed format
|
||||
return true;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define STR2(x) #x
|
||||
#define STR(x) STR2(x)
|
||||
const char StreamVersion [] =
|
||||
"StreamDevice " STR(STREAM_MAJOR) "." STR(STREAM_MINOR)
|
||||
"StreamDevice " STR(STREAM_MAJOR)
|
||||
"." STR(STREAM_MINOR)
|
||||
"." STR(STREAM_PATCHLEVEL)
|
||||
" built " __DATE__ " " __TIME__;
|
||||
|
||||
|
@ -82,14 +82,14 @@ parse(const StreamFormat&, StreamBuffer& info,
|
||||
if (*c == 'f')
|
||||
{
|
||||
source = c;
|
||||
info.printf("%%0%uf", n);
|
||||
info.print("%%0%uf", n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* look for nanoseconds %N of %f */
|
||||
if (*source == 'N' || *source == 'f')
|
||||
{
|
||||
info.printf("%%09f");
|
||||
info.print("%%09f");
|
||||
break;
|
||||
}
|
||||
/* look for seconds with fractions like %.3S */
|
||||
@ -100,7 +100,7 @@ parse(const StreamFormat&, StreamBuffer& info,
|
||||
if (toupper(*c) == 'S')
|
||||
{
|
||||
source = c;
|
||||
info.printf("%%%c.%%0%uf", *c, n);
|
||||
info.print("%%%c.%%0%uf", *c, n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,8 @@
|
||||
#define devStream_h
|
||||
|
||||
#define STREAM_MAJOR 2
|
||||
#define STREAM_MINOR 4
|
||||
#define STREAM_MINOR 6
|
||||
#define STREAM_PATCHLEVEL 0
|
||||
|
||||
#if defined(__vxworks) || defined(vxWorks)
|
||||
#include <vxWorks.h>
|
||||
@ -40,11 +41,11 @@
|
||||
#define INIT_RUN (!interruptAccept)
|
||||
|
||||
#include <epicsVersion.h>
|
||||
#if (EPICS_VERSION == 3 && EPICS_REVISION == 14)
|
||||
#define EPICS_3_14
|
||||
#ifdef BASE_RELEASE
|
||||
#define EPICS_3_13
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(EPICS_3_14)
|
||||
#if defined(__cplusplus) && defined(EPICS_3_13)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@ -55,7 +56,7 @@ extern "C" {
|
||||
/* #include <dbFldTypes.h> */
|
||||
#include <dbAccess.h>
|
||||
|
||||
#if defined(__cplusplus) && !defined(EPICS_3_14)
|
||||
#if defined(__cplusplus) && defined(EPICS_3_13)
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -69,23 +70,22 @@ typedef const struct format_s {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern FILE* StreamDebugFile;
|
||||
epicsShareExtern FILE* StreamDebugFile;
|
||||
|
||||
extern const char StreamVersion [];
|
||||
|
||||
typedef long (*streamIoFunction) (dbCommon*, format_t*);
|
||||
|
||||
long streamInit(int after);
|
||||
long streamInitRecord(dbCommon *record, struct link *ioLink,
|
||||
epicsShareExtern long streamInit(int after);
|
||||
epicsShareExtern long streamInitRecord(dbCommon *record,
|
||||
const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData);
|
||||
long streamReport(int interest);
|
||||
long streamReadWrite(dbCommon *record);
|
||||
long streamGetIointInfo(int cmd, dbCommon *record, IOSCANPVT *ppvt);
|
||||
long streamPrintf(dbCommon *record, format_t *format, ...);
|
||||
long streamScanfN(dbCommon *record, format_t *format,
|
||||
epicsShareExtern long streamReport(int interest);
|
||||
epicsShareExtern long streamReadWrite(dbCommon *record);
|
||||
epicsShareExtern long streamGetIointInfo(int cmd,
|
||||
dbCommon *record, IOSCANPVT *ppvt);
|
||||
epicsShareExtern long streamPrintf(dbCommon *record, format_t *format, ...);
|
||||
epicsShareExtern long streamScanfN(dbCommon *record, format_t *format,
|
||||
void*, size_t maxStringSize);
|
||||
|
||||
/* backward compatibility stuff */
|
||||
|
@ -44,10 +44,10 @@ static long readData (dbCommon *record, format_t *format)
|
||||
switch (aai->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
((double *)aai->bptr)[aai->nord] = dval;
|
||||
((epicsFloat64 *)aai->bptr)[aai->nord] = (epicsFloat64)dval;
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
((float *)aai->bptr)[aai->nord] = (float)dval;
|
||||
((epicsFloat32 *)aai->bptr)[aai->nord] = (epicsFloat32)dval;
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -67,23 +67,23 @@ static long readData (dbCommon *record, format_t *format)
|
||||
switch (aai->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
((double *)aai->bptr)[aai->nord] = lval;
|
||||
((epicsFloat64 *)aai->bptr)[aai->nord] = (epicsFloat64)lval;
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
((float *)aai->bptr)[aai->nord] = (float)lval;
|
||||
((epicsFloat32 *)aai->bptr)[aai->nord] = (epicsFloat32)lval;
|
||||
break;
|
||||
case DBF_LONG:
|
||||
case DBF_ULONG:
|
||||
((long *)aai->bptr)[aai->nord] = lval;
|
||||
((epicsInt32 *)aai->bptr)[aai->nord] = (epicsInt32)lval;
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
((short *)aai->bptr)[aai->nord] = (short)lval;
|
||||
((epicsInt16 *)aai->bptr)[aai->nord] = (epicsInt16)lval;
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
case DBF_UCHAR:
|
||||
((char *)aai->bptr)[aai->nord] = (char)lval;
|
||||
((epicsInt8 *)aai->bptr)[aai->nord] = (epicsInt8)lval;
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -157,29 +157,29 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
switch (aai->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
dval = ((double *)aai->bptr)[nowd];
|
||||
dval = ((epicsFloat64 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
dval = ((float *)aai->bptr)[nowd];
|
||||
dval = ((epicsFloat32 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_LONG:
|
||||
dval = ((long *)aai->bptr)[nowd];
|
||||
dval = ((epicsInt32 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_ULONG:
|
||||
dval = ((unsigned long *)aai->bptr)[nowd];
|
||||
dval = ((epicsUInt32 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
dval = ((short *)aai->bptr)[nowd];
|
||||
dval = ((epicsInt16 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
dval = ((unsigned short *)aai->bptr)[nowd];
|
||||
dval = ((epicsUInt16 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
dval = ((char *)aai->bptr)[nowd];
|
||||
dval = ((epicsInt8 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_UCHAR:
|
||||
dval = ((unsigned char *)aai->bptr)[nowd];
|
||||
dval = ((epicsUInt8 *)aai->bptr)[nowd];
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -197,21 +197,23 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
switch (aai->ftvl)
|
||||
{
|
||||
case DBF_LONG:
|
||||
lval = ((epicsInt32 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_ULONG:
|
||||
lval = ((long *)aai->bptr)[nowd];
|
||||
lval = ((epicsUInt32 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
lval = ((short *)aai->bptr)[nowd];
|
||||
lval = ((epicsInt16 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
lval = ((unsigned short *)aai->bptr)[nowd];
|
||||
lval = ((epicsUInt16 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
lval = ((char *)aai->bptr)[nowd];
|
||||
lval = ((epicsInt8 *)aai->bptr)[nowd];
|
||||
break;
|
||||
case DBF_UCHAR:
|
||||
lval = ((unsigned char *)aai->bptr)[nowd];
|
||||
lval = ((epicsUInt8 *)aai->bptr)[nowd];
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
|
@ -44,10 +44,10 @@ static long readData (dbCommon *record, format_t *format)
|
||||
switch (aao->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
((double *)aao->bptr)[aao->nord] = dval;
|
||||
((epicsFloat64 *)aao->bptr)[aao->nord] = (epicsFloat64)dval;
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
((float *)aao->bptr)[aao->nord] = (float)dval;
|
||||
((epicsFloat32 *)aao->bptr)[aao->nord] = (epicsFloat32)dval;
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -67,23 +67,23 @@ static long readData (dbCommon *record, format_t *format)
|
||||
switch (aao->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
((double *)aao->bptr)[aao->nord] = lval;
|
||||
((epicsFloat64 *)aao->bptr)[aao->nord] = (epicsFloat64)lval;
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
((float *)aao->bptr)[aao->nord] = (float)lval;
|
||||
((epicsFloat32 *)aao->bptr)[aao->nord] = (epicsFloat32)lval;
|
||||
break;
|
||||
case DBF_LONG:
|
||||
case DBF_ULONG:
|
||||
((long *)aao->bptr)[aao->nord] = lval;
|
||||
((epicsInt32 *)aao->bptr)[aao->nord] = (epicsInt32)lval;
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
((short *)aao->bptr)[aao->nord] = (short)lval;
|
||||
((epicsInt16 *)aao->bptr)[aao->nord] = (epicsInt16)lval;
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
case DBF_UCHAR:
|
||||
((char *)aao->bptr)[aao->nord] = (char)lval;
|
||||
((epicsInt8 *)aao->bptr)[aao->nord] = (epicsInt8)lval;
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -157,29 +157,29 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
switch (aao->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
dval = ((double *)aao->bptr)[nowd];
|
||||
dval = ((epicsFloat64 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
dval = ((float *)aao->bptr)[nowd];
|
||||
dval = ((epicsFloat32 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_LONG:
|
||||
dval = ((long *)aao->bptr)[nowd];
|
||||
dval = ((epicsInt32 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_ULONG:
|
||||
dval = ((unsigned long *)aao->bptr)[nowd];
|
||||
dval = ((epicsUInt32 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
dval = ((short *)aao->bptr)[nowd];
|
||||
dval = ((epicsInt16 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
dval = ((unsigned short *)aao->bptr)[nowd];
|
||||
dval = ((epicsUInt16 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
dval = ((char *)aao->bptr)[nowd];
|
||||
dval = ((epicsInt8 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_UCHAR:
|
||||
dval = ((unsigned char *)aao->bptr)[nowd];
|
||||
dval = ((epicsUInt8 *)aao->bptr)[nowd];
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -197,21 +197,23 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
switch (aao->ftvl)
|
||||
{
|
||||
case DBF_LONG:
|
||||
lval = ((epicsInt32 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_ULONG:
|
||||
lval = ((long *)aao->bptr)[nowd];
|
||||
lval = ((epicsUInt32 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
lval = ((short *)aao->bptr)[nowd];
|
||||
lval = ((epicsInt16 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
lval = ((unsigned short *)aao->bptr)[nowd];
|
||||
lval = ((epicsUInt16 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
lval = ((char *)aao->bptr)[nowd];
|
||||
lval = ((epicsInt8 *)aao->bptr)[nowd];
|
||||
break;
|
||||
case DBF_UCHAR:
|
||||
lval = ((unsigned char *)aao->bptr)[nowd];
|
||||
lval = ((epicsUInt8 *)aao->bptr)[nowd];
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
|
@ -44,10 +44,10 @@ static long readData (dbCommon *record, format_t *format)
|
||||
switch (wf->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
((double *)wf->bptr)[wf->nord] = dval;
|
||||
((epicsFloat64 *)wf->bptr)[wf->nord] = (epicsFloat64)dval;
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
((float *)wf->bptr)[wf->nord] = (float)dval;
|
||||
((epicsFloat32 *)wf->bptr)[wf->nord] = (epicsFloat32)dval;
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -67,23 +67,23 @@ static long readData (dbCommon *record, format_t *format)
|
||||
switch (wf->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
((double *)wf->bptr)[wf->nord] = (double)lval;
|
||||
((epicsFloat64 *)wf->bptr)[wf->nord] = (epicsFloat64)lval;
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
((float *)wf->bptr)[wf->nord] = (float)lval;
|
||||
((epicsFloat32 *)wf->bptr)[wf->nord] = (epicsFloat32)lval;
|
||||
break;
|
||||
case DBF_LONG:
|
||||
case DBF_ULONG:
|
||||
((long *)wf->bptr)[wf->nord] = lval;
|
||||
((epicsInt32 *)wf->bptr)[wf->nord] = (epicsInt32)lval;
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
((short *)wf->bptr)[wf->nord] = (short)lval;
|
||||
((epicsInt16 *)wf->bptr)[wf->nord] = (epicsInt16)lval;
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
case DBF_UCHAR:
|
||||
((char *)wf->bptr)[wf->nord] = (char)lval;
|
||||
((epicsInt8 *)wf->bptr)[wf->nord] = (epicsInt8)lval;
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -157,29 +157,29 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
switch (wf->ftvl)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
dval = ((double *)wf->bptr)[nowd];
|
||||
dval = ((epicsFloat64 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_FLOAT:
|
||||
dval = ((float *)wf->bptr)[nowd];
|
||||
dval = ((epicsFloat32 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_LONG:
|
||||
dval = ((long *)wf->bptr)[nowd];
|
||||
dval = ((epicsInt32 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_ULONG:
|
||||
dval = ((unsigned long *)wf->bptr)[nowd];
|
||||
dval = ((epicsUInt32 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
dval = ((short *)wf->bptr)[nowd];
|
||||
dval = ((epicsInt16 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
dval = ((unsigned short *)wf->bptr)[nowd];
|
||||
dval = ((epicsUInt16 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
dval = ((char *)wf->bptr)[nowd];
|
||||
dval = ((epicsInt8 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_UCHAR:
|
||||
dval = ((unsigned char *)wf->bptr)[nowd];
|
||||
dval = ((epicsUInt8 *)wf->bptr)[nowd];
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
@ -197,21 +197,23 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
switch (wf->ftvl)
|
||||
{
|
||||
case DBF_LONG:
|
||||
lval = ((epicsInt32 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_ULONG:
|
||||
lval = ((long *)wf->bptr)[nowd];
|
||||
lval = ((epicsUInt32 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_SHORT:
|
||||
lval = ((short *)wf->bptr)[nowd];
|
||||
lval = ((epicsInt16 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_USHORT:
|
||||
case DBF_ENUM:
|
||||
lval = ((unsigned short *)wf->bptr)[nowd];
|
||||
lval = ((epicsUInt16 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_CHAR:
|
||||
lval = ((char *)wf->bptr)[nowd];
|
||||
lval = ((epicsInt8 *)wf->bptr)[nowd];
|
||||
break;
|
||||
case DBF_UCHAR:
|
||||
lval = ((unsigned char *)wf->bptr)[nowd];
|
||||
lval = ((epicsUInt8 *)wf->bptr)[nowd];
|
||||
break;
|
||||
default:
|
||||
errlogSevPrintf (errlogFatal,
|
||||
|
10
src/makedbd.pl
Normal file
@ -0,0 +1,10 @@
|
||||
if (@ARGV[0] == "-3.13") {
|
||||
shift;
|
||||
} else {
|
||||
print "variable(streamDebug, int)\n";
|
||||
print "registrar(streamRegistrar)\n";
|
||||
}
|
||||
print "driver(stream)\n";
|
||||
for (@ARGV) {
|
||||
print "device($_,INST_IO,dev${_}Stream,\"stream\")\n";
|
||||
}
|
6
src/makeref.pl
Normal file
@ -0,0 +1,6 @@
|
||||
$t=@ARGV[0];
|
||||
shift;
|
||||
for (@ARGV) {
|
||||
print "extern void* ref_${_}$t;\n";
|
||||
print "void* p$_ = ref_${_}$t;\n";
|
||||
}
|
@ -20,6 +20,4 @@ include $(TOP)/configure/RULES
|
||||
|
||||
# create streamSynApps.dbd from all SYNAPPS_RECORDS
|
||||
$(COMMON_DIR)/$(LIBRARY_DEFAULT).dbd: ../../src/CONFIG_STREAM
|
||||
@for r in $(SYNAPPS_RECORDS); \
|
||||
do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \
|
||||
done > $@
|
||||
$(PERL) ../../src/makedbd.pl $(SYNAPPS_RECORDS) > $@
|
||||
|
@ -17,6 +17,9 @@ PROD = streamApp
|
||||
DBD = streamApp.dbd
|
||||
|
||||
streamApp_DBD += base.dbd
|
||||
|
||||
# In 3.14.12 aaiRecord.dbd and aaoRecord.dbd are part of base.dbd
|
||||
# In earlier versions, these records are buggy and not included by default
|
||||
#streamApp_DBD += aaiRecord.dbd aaoRecord.dbd
|
||||
|
||||
PROD_SRCS += streamApp_registerRecordDeviceDriver.cpp
|
||||
@ -25,52 +28,51 @@ PROD_SRCS_vxWorks = -nil-
|
||||
|
||||
PROD_LIBS = stream
|
||||
|
||||
ifdef PCRE
|
||||
# With local PCRE package
|
||||
PROD_LIBS += pcre
|
||||
else
|
||||
ifneq ($(words $(PCRE_LIB) $(PCRE_INCLUDE)),0)
|
||||
# With system wide PCRE installation
|
||||
PROD_SYS_LIBS += pcre
|
||||
PROD_DEPLIB_DIRS += $(PCRE_LIB)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef ASYN
|
||||
# Which types of asyn busses do you have?
|
||||
ifneq ($(OS_CLASS), WIN32)
|
||||
# asynDriver up to version 4-8 does not support serial port for Windows!
|
||||
streamApp_DBD += drvAsynSerialPort.dbd
|
||||
endif
|
||||
streamApp_DBD += drvAsynIPPort.dbd
|
||||
#streamApp_DBD += drvGsIP488.dbd
|
||||
#streamApp_DBD += drvNi1014.dbd
|
||||
streamApp_DBD += drvVxi11.dbd
|
||||
# edit asynRegistrars.dbd if necessary
|
||||
streamApp_DBD += asynRegistrars.dbd
|
||||
# add asynRecord.dbd if you like
|
||||
streamApp_DBD += asynRecord.dbd
|
||||
PROD_LIBS += asyn
|
||||
endif
|
||||
|
||||
ifneq ($(words $(CALC) $(SYNAPPS)), 0)
|
||||
# With synApps scalcout record
|
||||
streamApp_DBD += calc.dbd
|
||||
streamApp_DBD += calcSupport.dbd
|
||||
streamApp_DBD += streamSynApps.dbd
|
||||
PROD_LIBS += calc sscan
|
||||
PROD_LIBS += calc
|
||||
# older calc versions require sscan
|
||||
#PROD_LIBS += sscan
|
||||
PROD_LIBS_DEFAULT += streamSynApps
|
||||
endif
|
||||
|
||||
streamApp_DBD += stream.dbd
|
||||
|
||||
ifdef PCRE
|
||||
LIB_LIBS += pcre
|
||||
else
|
||||
ifneq ($(words $(PCRE_LIB) $(PCRE_INCLUDE)),0)
|
||||
PROD_SYS_LIBS_DEFAULT += pcre
|
||||
PROD_SYS_LIBS_WIN32 += $(PCRE_LIB)\\pcre
|
||||
SHRLIB_DEPLIB_DIRS += $(PCRE_LIB)
|
||||
endif
|
||||
endif
|
||||
|
||||
PROD_LIBS += $(EPICS_BASE_IOC_LIBS)
|
||||
|
||||
# Write StreamDevice debug output to this file
|
||||
# If unset output goes to stdout
|
||||
CPPFLAGS += -DDEBUGFILE=StreamDebug.log
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
ifeq ($(BASE_3_14), YES)
|
||||
clean:: myclean
|
||||
|
||||
myclean:
|
||||
rm -f core* StreamDebug.log
|
||||
|
||||
else
|
||||
clean: myclean
|
||||
endif
|
||||
|
||||
myclean:
|
||||
$(RM) core* StreamDebug.log
|
||||
|
||||
endif
|
||||
|
9
streamApp/asynRegistrars.dbd
Normal file
@ -0,0 +1,9 @@
|
||||
registrar(asynRegister)
|
||||
registrar(asynInterposeFlushRegister)
|
||||
registrar(asynInterposeEosRegister)
|
||||
|
||||
# asynDriver up to version 4-16 does not support serial port for Windows!
|
||||
registrar(drvAsynSerialPortRegisterCommands)
|
||||
registrar(drvAsynIPPortRegisterCommands)
|
||||
registrar(drvAsynIPServerPortRegisterCommands)
|
||||
registrar(vxi11RegisterCommands)
|
@ -1,7 +1,5 @@
|
||||
#!/usr/bin/env wish
|
||||
|
||||
wm iconify .
|
||||
|
||||
proc createTerm {sock} {
|
||||
global socket port
|
||||
toplevel .$sock
|
||||
@ -19,16 +17,8 @@ proc createTerm {sock} {
|
||||
wm title .$sock "port $port <-> [fconfigure $sock -peername]"
|
||||
}
|
||||
|
||||
set port [lindex $argv 0]
|
||||
if {$port == ""} { set port 40000 }
|
||||
if [catch {
|
||||
socket -server connect $port
|
||||
} msg ] {
|
||||
return -code error "$msg (port $port)"
|
||||
}
|
||||
|
||||
proc connect {sock addr port} {
|
||||
fconfigure $sock -blocking 0 -buffering none
|
||||
fconfigure $sock -blocking 0 -buffering none -translation binary
|
||||
createTerm $sock
|
||||
fileevent $sock readable "receiveHandler $sock"
|
||||
}
|
||||
@ -74,6 +64,9 @@ proc receiveHandler {sock} {
|
||||
set l [split $a]
|
||||
if [catch {
|
||||
switch -- [lindex $l 0] {
|
||||
"exit" {
|
||||
exit
|
||||
}
|
||||
"disconnect" {
|
||||
sendReply $sock [string range $a 11 end]
|
||||
destroy .$sock
|
||||
@ -81,6 +74,10 @@ proc receiveHandler {sock} {
|
||||
"echo" {
|
||||
sendReply $sock [string range $a 5 end]
|
||||
}
|
||||
"binary" {
|
||||
set x [checkNum [lindex $l 1]]
|
||||
sendReply $sock [format %c $x]
|
||||
}
|
||||
"longmsg" {
|
||||
set length [checkNum [lindex $l 1]]
|
||||
sendReply $sock "[string range x[string repeat 0123456789abcdefghijklmnopqrstuvwxyz [expr $length / 36 + 1]] 1 $length]\n"
|
||||
@ -92,7 +89,7 @@ proc receiveHandler {sock} {
|
||||
"start" {
|
||||
set wait [checkNum [lindex $l 1]]
|
||||
set ::counter 0
|
||||
after $wait sendAsync $wait [list [lindex $l 2]]
|
||||
after $wait sendAsync $wait [list [lrange $l 2 end-1]]
|
||||
sendReply $sock "Started\n"
|
||||
}
|
||||
"stop" {
|
||||
@ -113,12 +110,16 @@ proc receiveHandler {sock} {
|
||||
"help" {
|
||||
sendReply $sock "help this text\n"
|
||||
sendReply $sock "echo string reply string\n"
|
||||
sendReply $sock "wait msec reply Done after some time\n"
|
||||
sendReply $sock "binary number reply byte with value number\n"
|
||||
sendReply $sock "longmsg length reply string with length characters\n"
|
||||
sendReply $sock "wait msec reply \"Done\" after some time\n"
|
||||
sendReply $sock "start msec start sending messages priodically\n"
|
||||
sendReply $sock "stop stop sending messages\n"
|
||||
sendReply $sock "set key value set a value\n"
|
||||
sendReply $sock "get key reply value\n"
|
||||
sendReply $sock "set key value store a value into variable key\n"
|
||||
sendReply $sock "get key reply previously stored value from key\n"
|
||||
sendReply $sock "disconnect close connection\n"
|
||||
sendReply $sock "exit kill terminal server\n"
|
||||
|
||||
}
|
||||
}
|
||||
} msg] {
|
||||
@ -150,7 +151,6 @@ rename $paste tkTextPaste_org
|
||||
rename $pastesel tkTextPasteSel_org
|
||||
|
||||
proc $insert {w s} {
|
||||
puts [list insert $w $s]
|
||||
global socket
|
||||
if {[string equal $s ""] || [string equal [$w cget -state] "disabled"]} {
|
||||
return
|
||||
@ -188,8 +188,20 @@ for {set ascii 0x61} {$ascii <= 0x7a} {incr ascii} {
|
||||
bind Text <Control-[format %c $ascii]> ""
|
||||
}
|
||||
#remove bindings on symbolic tags
|
||||
foreach tag {Clear Paste Copy Cut } {
|
||||
foreach tag {Clear Paste Copy Cut} {
|
||||
bind Text <<$tag>> ""
|
||||
}
|
||||
|
||||
bind Text <Control-Key> [list $insert %W %A]
|
||||
|
||||
set port [lindex $argv 0]
|
||||
if {$port == ""} { set port 40000 }
|
||||
if [catch {
|
||||
socket -server connect $port
|
||||
} msg ] {
|
||||
return -code error "$msg (port $port)"
|
||||
}
|
||||
|
||||
label .info -text "Accepting connections on port $port"
|
||||
button .exit -text "Exit" -command exit
|
||||
pack .info .exit -expand yes -fill x
|
||||
|
@ -2,17 +2,20 @@ record (stringout, "$(P):cmd")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@test.proto command terminal")
|
||||
field (PRIO, "HIGH")
|
||||
field (VAL, "")
|
||||
}
|
||||
record (stringout, "$(P):info")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@test.proto info terminal")
|
||||
field (PRIO, "HIGH")
|
||||
}
|
||||
record (stringout, "$(P):request")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@test.proto request($(P):reply.VAL) terminal")
|
||||
field (PRIO, "HIGH")
|
||||
}
|
||||
record (stringin, "$(P):reply")
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
terminator = CR LF;
|
||||
readtimeout = 1000;
|
||||
terminator = LF;
|
||||
readtimeout = 10;
|
||||
pollperiod = 10;
|
||||
replytimeout = 1000;
|
||||
command {
|
||||
|
@ -52,7 +52,7 @@ proc startioc {} {
|
||||
|
||||
if [info exists streamversion] {
|
||||
puts $fd "#!/usr/local/bin/iocsh"
|
||||
puts $fd "require stream,$streamversion"
|
||||
puts $fd "require stream2,$streamversion"
|
||||
} else {
|
||||
puts $fd "#!../O.$env(EPICS_HOST_ARCH)/streamApp"
|
||||
puts $fd "dbLoadDatabase ../O.Common/streamApp.dbd"
|
||||
@ -158,19 +158,22 @@ proc assure {args} {
|
||||
}
|
||||
|
||||
proc escape {string} {
|
||||
while {![string is print -failindex index $string]} {
|
||||
set char [string index $string $index]
|
||||
scan $char "%c" code
|
||||
switch $char {
|
||||
"\r" { set escaped "\\r" }
|
||||
"\n" { set escaped "\\n" }
|
||||
"\a" { set escaped "\\a" }
|
||||
"\t" { set escaped "\\t" }
|
||||
default { set escaped [format "<%02x>" $code] }
|
||||
set result ""
|
||||
set length [string length $string]
|
||||
for {set i 0} {$i < $length} {incr i} {
|
||||
set c [string index $string $i]
|
||||
scan $c %c n
|
||||
if {$n == 13} {
|
||||
append result "\\r"
|
||||
} elseif {$n == 10} {
|
||||
append result "\\n"
|
||||
} elseif {($n & 127) < 32} {
|
||||
append result [format "<%02x>" $n]
|
||||
} else {
|
||||
append result $c
|
||||
}
|
||||
set string [string replace $string $index $index $escaped]
|
||||
}
|
||||
return $string
|
||||
return $result
|
||||
}
|
||||
|
||||
proc finish {} {
|
||||
|
@ -45,6 +45,9 @@ set debug 0
|
||||
|
||||
startioc
|
||||
|
||||
set inf [format %f inf]
|
||||
set nan [format %f nan]
|
||||
|
||||
ioccmd {dbpf DZ:test1.PROC 1}
|
||||
send "3.14159265359\n"
|
||||
assure "|3.141593| 3.141593|3.14| 3.14159 | 3.141593|+3.141593|3.1 |3.141593|\n"
|
||||
@ -56,10 +59,10 @@ send "0\n"
|
||||
assure "|0.000000| 0.000000|0.00| 0.00000 | 0.000000|+0.000000|0.0 |0.000000|\n"
|
||||
ioccmd {dbpf DZ:test1.PROC 1}
|
||||
send "NAN\n"
|
||||
assure "|nan| nan|nan| nan | nan|+nan|nan |nan|\n"
|
||||
assure "|$nan| $nan|$nan| $nan | $nan|+$nan|$nan |$nan|\n"
|
||||
ioccmd {dbpf DZ:test1.PROC 1}
|
||||
send "-Inf\n"
|
||||
assure "|-inf| -inf|-inf|-inf |-inf|-inf|-inf |-inf|\n"
|
||||
assure "|-$inf| -$inf|-$inf|-$inf |-$inf|-$inf|-$inf |-$inf|\n"
|
||||
ioccmd {dbpf DZ:test1.PROC 1}
|
||||
send "1e6\n"
|
||||
assure "|1000000.000000|1000000.000000|1000000.00| 1000000.00000| 1000000.000000|+1000000.000000|1000000.0|1000000.000000|\n"
|
||||
|
@ -1,75 +0,0 @@
|
||||
#!/usr/bin/env tclsh
|
||||
source streamtestlib.tcl
|
||||
|
||||
# Define records, protocol and startup (text goes to files)
|
||||
# The asynPort "dummy" is not connected to any I/O
|
||||
# Send commands to the ioc shell with ioccmd
|
||||
|
||||
set records {
|
||||
record (ao, "DZ:test1")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@test.proto test1 dummy")
|
||||
}
|
||||
}
|
||||
|
||||
set protocol {
|
||||
Terminator = LF;
|
||||
test1 {exec "dbpr %(NAME)s %i >testDummyInterface.out";}
|
||||
}
|
||||
|
||||
set startup {
|
||||
}
|
||||
|
||||
set debug 0
|
||||
|
||||
startioc
|
||||
|
||||
ioccmd {dbpf DZ:test1 3}
|
||||
|
||||
after 1000
|
||||
|
||||
if [catch {
|
||||
set fd [open testDummyInterface.out]
|
||||
set output [read $fd]
|
||||
close $fd
|
||||
} msg] {
|
||||
puts stderr $msg
|
||||
incr faults
|
||||
}
|
||||
|
||||
set expected {ACKS: NO_ALARM ACKT: YES ADEL: 0 ALST: 0
|
||||
AOFF: 0 ASG: ASLO: 0 BKPT: 00
|
||||
DESC: DISA: 0 DISP: 0 DISS: NO_ALARM
|
||||
DISV: 1 DOL:CONSTANT DRVH: 0 DRVL: 0
|
||||
DTYP: stream EGU: EGUF: 0 EGUL: 0
|
||||
EOFF: 0 ESLO: 1 EVNT: 0 FLNK:CONSTANT 0
|
||||
HHSV: NO_ALARM HIGH: 0 HIHI: 0 HOPR: 0
|
||||
HSV: NO_ALARM HYST: 0 INIT: 1
|
||||
IVOA: Continue normally IVOV: 0 LALM: 3
|
||||
LBRK: 0 LCNT: 0 LINR: NO CONVERSION LLSV: NO_ALARM
|
||||
LOLO: 0 LOPR: 0 LOW: 0 LSV: NO_ALARM
|
||||
MDEL: 0 MLST: 0 NAME: DZ:test1 NSEV: NO_ALARM
|
||||
NSTA: NO_ALARM OIF: Full OMOD: 1 OMSL: supervisory
|
||||
ORAW: 0 ORBV: 0 OROC: 0
|
||||
OUT:INST_IO @test.proto test1 dummy OVAL: 3 PACT: 1
|
||||
PHAS: 0 PINI: NO PREC: 0 PRIO: LOW
|
||||
PROC: 0 PUTF: 1 PVAL: 3 RBV: 0
|
||||
ROFF: 0 RPRO: 0 RVAL: 3 SCAN: Passive
|
||||
SDIS:CONSTANT SEVR: INVALID SIML:CONSTANT SIMM: NO
|
||||
SIMS: NO_ALARM SIOL:CONSTANT STAT: UDF TIME: <undefined>
|
||||
TPRO: 0 TSE: 0 TSEL:CONSTANT UDF: 0
|
||||
VAL: 3
|
||||
}
|
||||
|
||||
if {"$output" != "$expected"} {
|
||||
puts stderr "Wrong output:"
|
||||
puts stderr "$output"
|
||||
puts stderr "instead of:"
|
||||
puts stderr "$expected"
|
||||
incr faults
|
||||
} else {
|
||||
file delete testDummyInterface.out
|
||||
}
|
||||
|
||||
finish
|
@ -7,6 +7,11 @@ source streamtestlib.tcl
|
||||
# Send commands to the ioc shell with ioccmd
|
||||
|
||||
set records {
|
||||
record (bo, "DZ:percent")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@test.proto percent device")
|
||||
}
|
||||
record (ao, "DZ:ao")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
@ -34,6 +39,7 @@ set records {
|
||||
|
||||
set protocol {
|
||||
Terminator = LF;
|
||||
percent {out "\%\x25\37\045" 0x25 37 045;}
|
||||
ao {out "%.2f %.2e %.2E %.2g %.2G %i %d %u %o %04x %#.2f %#.2e %#.2E %#.2g %#.2G %#i %#d %#u %#o %#06x";}
|
||||
lo {out "%d %(VAL)d %06d %x %06X %b %06b %.6b %B.! %06B.!";}
|
||||
bcd {out "%D %6D %.2D %.4D %.6D %.8D %#D %#6D %#.2D %#.4D %#.6D";}
|
||||
@ -58,6 +64,8 @@ startioc
|
||||
# This is normal. E.g. -1 HAS a different number of 1 bits.
|
||||
# Specify the width field in the format if this is a problem.
|
||||
|
||||
ioccmd {dbpf DZ:percent 1}
|
||||
assure "%%%%%%%\n"
|
||||
ioccmd {dbpf DZ:ao 0}
|
||||
assure "0.00 0.00e+00 0.00E+00 0 0 32767 32767 32767 77777 7fff 0.00 0.00e+00 0.00E+00 0.0 0.0 32767 32767 32767 077777 0x7fff\n"
|
||||
ioccmd {dbpf DZ:ao 10}
|
||||
|
41
streamApp/tests/testParallelAccess
Executable file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env tclsh
|
||||
source streamtestlib.tcl
|
||||
|
||||
# Define records, protocol and startup (text goes to files)
|
||||
# The asynPort "device" is connected to a network TCP socket
|
||||
# Talk to the socket with send/receive/assure
|
||||
# Send commands to the ioc shell with ioccmd
|
||||
|
||||
set records {
|
||||
record (ao, "DZ:slow")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@test.proto slow device")
|
||||
}
|
||||
record (ao, "DZ:fast")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@test.proto fast device")
|
||||
}
|
||||
}
|
||||
|
||||
set protocol {
|
||||
Terminator = LF;
|
||||
slow { out "slow start"; wait 1000; out "slow finished";}
|
||||
fast { out "fast"; }
|
||||
}
|
||||
|
||||
set startup {
|
||||
}
|
||||
|
||||
set debug 0
|
||||
|
||||
startioc
|
||||
|
||||
ioccmd {dbpf DZ:slow 1}
|
||||
ioccmd {dbpf DZ:fast 1}
|
||||
assure "slow start\n"
|
||||
assure "slow finished\n"
|
||||
assure "fast\n"
|
||||
|
||||
finish
|
@ -12,10 +12,26 @@ set records {
|
||||
field (DTYP, "stream")
|
||||
field (OUT, "@test.proto test1 device")
|
||||
}
|
||||
record (longin, "DZ:test2")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (INP, "@test.proto test2 device")
|
||||
}
|
||||
record (longin, "DZ:test3")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (INP, "@test.proto test3 device")
|
||||
}
|
||||
record (longin, "DZ:test4")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (INP, "@test.proto test4 device")
|
||||
}
|
||||
}
|
||||
|
||||
set protocol {
|
||||
Terminator = LF;
|
||||
OutTerminator = LF;
|
||||
MaxInput = 4;
|
||||
test1 {
|
||||
out "%r"; out "%.1r"; out "%.2r"; out "%.3r"; out "%.4r"; out "%.5r";
|
||||
out "%#r"; out "%#.1r"; out "%#.2r"; out "%#.3r"; out "%#.4r"; out "%#.5r";
|
||||
@ -23,6 +39,18 @@ set protocol {
|
||||
out "%0r"; out "%01r"; out "%02r"; out "%03r"; out "%04r"; out "%05r";
|
||||
out "%#0r"; out "%#01r"; out "%#02r"; out "%#03r"; out "%#04r"; out "%#05r";
|
||||
};
|
||||
test2 {
|
||||
in "%04.4r";
|
||||
out "%08x";
|
||||
}
|
||||
test3{
|
||||
in "%#3r\?";
|
||||
out "%08x";
|
||||
}
|
||||
test4{
|
||||
in "%#03r\?";
|
||||
out "%08x";
|
||||
}
|
||||
}
|
||||
|
||||
set startup {
|
||||
@ -192,6 +220,35 @@ assure "\xef\x00\x00\n"
|
||||
assure "\xef\x00\x00\x00\n"
|
||||
assure "\xef\x00\x00\x00\x00\n"
|
||||
|
||||
ioccmd {dbpf DZ:test2.PROC 1}
|
||||
send "\x01\x02\x03\x04"
|
||||
assure "01020304\n"
|
||||
ioccmd {dbpf DZ:test2.PROC 1}
|
||||
send "\xde\xad\xbe\xef"
|
||||
assure "deadbeef\n"
|
||||
ioccmd {dbpf DZ:test2.PROC 1}
|
||||
send "\x00\x00\x00\x00"
|
||||
assure "00000000\n"
|
||||
|
||||
ioccmd {dbpf DZ:test3.PROC 1}
|
||||
send "\x04\x03\x02\x01"
|
||||
assure "00020304\n"
|
||||
ioccmd {dbpf DZ:test3.PROC 1}
|
||||
send "\xde\xad\xbe\xef"
|
||||
assure "ffbeadde\n"
|
||||
ioccmd {dbpf DZ:test3.PROC 1}
|
||||
send "\x00\x00\x00\x00"
|
||||
assure "00000000\n"
|
||||
|
||||
ioccmd {dbpf DZ:test4.PROC 1}
|
||||
send "\x04\x03\x02\x01"
|
||||
assure "00020304\n"
|
||||
ioccmd {dbpf DZ:test4.PROC 1}
|
||||
send "\xde\xad\xbe\xef"
|
||||
assure "00beadde\n"
|
||||
ioccmd {dbpf DZ:test4.PROC 1}
|
||||
send "\x00\x00\x00\x00"
|
||||
assure "00000000\n"
|
||||
|
||||
|
||||
finish
|
||||
|
@ -48,6 +48,7 @@ int main () {
|
||||
assert (haystack.find(needle) == 0);
|
||||
haystack.clear();
|
||||
assert (haystack.find(needle) == 0);
|
||||
haystack.reserve(10000);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
@ -1,3 +1,4 @@
|
||||
rm -f test.* *.out *.ioclog StreamDebug.log
|
||||
for i in test*
|
||||
do
|
||||
if [ $i != testall -a -x $i ]
|
||||
@ -6,7 +7,7 @@ do
|
||||
if ! $i "$@"
|
||||
then
|
||||
echo -e "\033[31;7mFailed.\033[0m"
|
||||
(( fail++ ))
|
||||
(( fail+=1 ))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|