Compare commits
78 Commits
stream_2_6
...
2-7
Author | SHA1 | Date | |
---|---|---|---|
d5dc15e321 | |||
cfa777d718 | |||
54bc78f7c7 | |||
77d110de70 | |||
19467bd5d5 | |||
d69c74bc8f | |||
e09506c2bb | |||
343eef324b | |||
a798cf2f21 | |||
23f3e806e2 | |||
56b6c9a627 | |||
2830f07324 | |||
abd8daafc3 | |||
489e783872 | |||
10d1fa8b02 | |||
c8bffebfc6 | |||
0a90eb3d9c | |||
0936ac7840 | |||
704ece6231 | |||
5c6e98127e | |||
8805437c68 | |||
3acf791409 | |||
0ba674a341 | |||
40c33abac7 | |||
bc67317b0b | |||
06e212c66e | |||
7b314ccffd | |||
1d84986ee8 | |||
2ca8a129f7 | |||
126da8c499 | |||
ea110d5047 | |||
b37fad41c6 | |||
74775996db | |||
74426aab66 | |||
690bbb13d4 | |||
871fbed2b0 | |||
85c68d2ae6 | |||
8870611d4d | |||
67af7fc1bf | |||
93bea174e4 | |||
84fc6aabc8 | |||
38c4f5bcb6 | |||
e2af7e3149 | |||
950d75ba43 | |||
e651c99697 | |||
9694628d3f | |||
046582d1a0 | |||
f6f0ea9ae5 | |||
018547cdf3 | |||
d763a64f03 | |||
cefa460a0d | |||
cc5948ad0b | |||
be1943a66d | |||
d9acb47afe | |||
b721d26fb8 | |||
7530c7c67d | |||
824cd4d283 | |||
2e30e7aee6 | |||
3a5a3e22b9 | |||
51bd766ba6 | |||
0ab0d6db07 | |||
a12de614d6 | |||
240abd2788 | |||
e131fcb32f | |||
f88f594e87 | |||
56ef0651f2 | |||
9b9726b800 | |||
b139221f0b | |||
b0ab8a7a8b | |||
ddac589676 | |||
5b380cdaad | |||
cc9adc77fa | |||
2b38f7bcfa | |||
0ceada70b5 | |||
7bf91b403d | |||
bf5c359649 | |||
c41ac44bd1 | |||
e36013d64e |
@ -1,12 +1,11 @@
|
||||
# Remove this file if not using the PSI build system
|
||||
include /ioc/tools/driver.makefile
|
||||
EXCLUDE_VERSIONS = 3.13.2
|
||||
PROJECT=stream2
|
||||
PROJECT=stream
|
||||
BUILDCLASSES += Linux
|
||||
|
||||
#DOCUDIR = doc
|
||||
|
||||
DBDS = stream.dbd
|
||||
|
||||
BUSSES += AsynDriver
|
||||
BUSSES += Dummy
|
||||
|
||||
@ -41,18 +40,17 @@ HEADERS += StreamFormatConverter.h
|
||||
HEADERS += StreamBuffer.h
|
||||
HEADERS += StreamError.h
|
||||
|
||||
ifeq (${EPICS_BASETYPE},3.13)
|
||||
USR_INCLUDES += -include $(INSTALL_INCLUDE)/compat3_13.h
|
||||
endif
|
||||
ifeq (${EPICS_BASETYPE},3.14)
|
||||
ifneq (${EPICS_BASETYPE},3.13)
|
||||
RECORDTYPES += calcout
|
||||
endif
|
||||
|
||||
StreamCore.o: streamReferences
|
||||
StreamCore.o StreamCore.d: streamReferences
|
||||
|
||||
streamReferences:
|
||||
perl ../src/makeref.pl Interface $(BUSSES) > $@
|
||||
perl ../src/makeref.pl Converter $(FORMATS) >> $@
|
||||
|
||||
stream.dbd:
|
||||
export DBDFILES = streamSup.dbd
|
||||
streamSup.dbd:
|
||||
@echo Creating $@
|
||||
perl ../src/makedbd.pl $(RECORDTYPES) > $@
|
5
MODULE
5
MODULE
@ -1,5 +0,0 @@
|
||||
# Please change the following email with yours.
|
||||
Email: dirk.zimoch@psi.ch
|
||||
Module-Name: StreamDevice2
|
||||
Description: StreamDevice2
|
||||
Project-Name:
|
BIN
doc/PSI.gif
BIN
doc/PSI.gif
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
BIN
doc/PSI.png
Normal file
BIN
doc/PSI.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: aai Records</h1>
|
||||
<h1>aai Records</h1>
|
||||
<p>
|
||||
<b>Note:</b> aai record support is disabled per default.
|
||||
Enable it in <code>src/CONFIG_STREAM</code>.
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: aao Records</h1>
|
||||
<h1>aao Records</h1>
|
||||
<p>
|
||||
<b>Note:</b> aao record support is disabled per default.
|
||||
Enable it in <code>src/CONFIG_STREAM</code>.
|
||||
|
10
doc/ai.html
10
doc/ai.html
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: ai Records</h1>
|
||||
<h1>ai Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
@ -41,6 +41,12 @@ written or read value.
|
||||
(=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.
|
||||
<p>
|
||||
If <code>LINR=="NO CONVERSION"</code> (the default), <code>VAL</code>
|
||||
is directly converted from and to <code>long</code> without going through
|
||||
<code>RVAL</code>. This allows for more bits on 64 bit machines.
|
||||
To get the old behavior, use <code>LINR=="LINEAR"</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
@ -78,6 +84,6 @@ written or read value.
|
||||
<a href="calcout.html">calcout</a>
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<p><small>Dirk Zimoch, 2015</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
10
doc/ao.html
10
doc/ao.html
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: ao Records</h1>
|
||||
<h1>ao Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
@ -40,6 +40,12 @@ written or read value.
|
||||
(=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.
|
||||
<p>
|
||||
If <code>LINR=="NO CONVERSION"</code> (the default), <code>OVAL</code>
|
||||
is directly converted to <code>long</code> without going through
|
||||
<code>RVAL</code>. This allows for more bits on 64 bit machines.
|
||||
To get the old behavior, use <code>LINR=="LINEAR"</code>.
|
||||
</p>
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
@ -79,6 +85,6 @@ written or read value.
|
||||
<a href="calcout.html">calcout</a>
|
||||
<a href="scalcout.html">scalcout</a>
|
||||
</p>
|
||||
<p><small>Dirk Zimoch, 2005</small></p>
|
||||
<p><small>Dirk Zimoch, 2015</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: bi Records</h1>
|
||||
<h1>bi Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: bo Records</h1>
|
||||
<h1>bo Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: calcout Records</h1>
|
||||
<h1>calcout Records</h1>
|
||||
|
||||
<p>
|
||||
<b>Note:</b> Device support for calcout records is only available for
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Using EPICS 3.13</h1>
|
||||
<h1>Using EPICS 3.13</h1>
|
||||
|
||||
<a name="pre"></a>
|
||||
<h2>1. Prerequisites</h2>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Format Converter API</h1>
|
||||
<h1>Format Converter API</h1>
|
||||
|
||||
<a name="class"></a>
|
||||
<h2>Converter Class</h2>
|
||||
|
206
doc/formats.html
206
doc/formats.html
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Format Converters</h1>
|
||||
<h1>Format Converters</h1>
|
||||
|
||||
<a name="syntax"></a>
|
||||
<h2>1. Format Syntax</h2>
|
||||
@ -28,8 +28,8 @@ A format converter consists of
|
||||
</p>
|
||||
<ul>
|
||||
<li>The <code>%</code> character</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 a field or record name in <code>()</code></li>
|
||||
<li>Optionally flags out of the characters <code>*# +0-?=!</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>
|
||||
@ -40,7 +40,7 @@ A format converter consists of
|
||||
<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.
|
||||
The flags <code>?</code>, <code>=</code> and <code>!</code> are extensions.
|
||||
</p>
|
||||
<p>
|
||||
The <code>*</code> flag skips data in input formats.
|
||||
@ -67,16 +67,24 @@ 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">
|
||||
<p>
|
||||
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">
|
||||
<p>
|
||||
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>
|
||||
<p>
|
||||
The <code>!</code> flag demands that input is exactly <em>width</em>
|
||||
bytes long (normally <em>width</em> defines the maximum number of
|
||||
bytes read in many formats).
|
||||
For example <code>in "%!5d";</code> expects exactly 5 digits.
|
||||
Fewer digits are considered loss of data and make the format fail.
|
||||
This feature has been added by Klemen Vodopivec, SNS.
|
||||
</p>
|
||||
|
||||
<h3>Examples:</h3>
|
||||
<table>
|
||||
@ -143,11 +151,8 @@ field formatted as a string.
|
||||
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
|
||||
@ -158,6 +163,9 @@ attribute (see
|
||||
target="ex">Record Reference Manual</a>), the record will be processed.
|
||||
It is your responsibility that the data type of the record field is
|
||||
compatible to the the data type of the converter.
|
||||
STRING formats are compatible with arrays of CHAR or UCHAR.
|
||||
</p>
|
||||
<p>
|
||||
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
|
||||
@ -189,13 +197,13 @@ With the <code>#</code> flag, output always contains a period character.
|
||||
<p>
|
||||
<b>Input:</b> All these formats are equivalent. Leading whitespaces are skipped.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
With the <code>#</code> flag additional whitespace between sign and number
|
||||
is accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
When a maximum field width is given, leading whitespace only counts to the
|
||||
field witdth when the space flag is given.
|
||||
field witdth when the space flag is used.
|
||||
</p>
|
||||
|
||||
<a name="stdl"></a>
|
||||
@ -210,6 +218,10 @@ field witdth when the space flag is given.
|
||||
<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>
|
||||
Unlike printf, <code>%x</code> and <code>%X</code> truncate the
|
||||
output to the the given width (number of least significant half bytes).
|
||||
</p>
|
||||
</p>
|
||||
<p>
|
||||
<b>Input:</b> <code>%d</code> matches signed decimal, <code>%u</code> matches
|
||||
@ -221,16 +233,16 @@ Octal and hexadecimal values can optionally be prefixed.
|
||||
hexadecimal notation.
|
||||
Leading whitespaces are skipped.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
With the <code>-</code> negative octal and hexadecimal values are accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
With the <code>#</code> flag additional whitespace between sign and number
|
||||
is accepted.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
When a maximum field width is given, leading whitespace only counts to the
|
||||
field witdth when the space flag is given.
|
||||
field witdth when the space flag is used.
|
||||
</p>
|
||||
|
||||
<a name="stds"></a>
|
||||
@ -246,13 +258,11 @@ 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>
|
||||
<span class="new">
|
||||
except when the space flag is given</span>
|
||||
but not with <code>%c</code>.
|
||||
Leading whitespaces are skipped with <code>%s</code> except when
|
||||
the space flag is used but not with <code>%c</code>.
|
||||
The empty string matches.
|
||||
</p>
|
||||
<p class="new">
|
||||
<p>
|
||||
With the <code>#</code> flag <code>%s</code> matches a sequence of not-null
|
||||
characters instead of non-whitespace characters.
|
||||
</p>
|
||||
@ -286,9 +296,20 @@ to the value 0, <code>STANDBY</code> to 1 and <code>ON</code> to 2.
|
||||
<p>
|
||||
When using the <code>#</code> flag it is allowed to assign integer values
|
||||
to the strings using <code>=</code>.
|
||||
Unassigned strings increment their values by 1 as usual.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%#{neg=-1|stop=0|pos=1|fast=10}</code>.
|
||||
If one string is the initial substing of another, the substing must come
|
||||
later to ensure correct matching.
|
||||
In particular if one string is the emptry string, it must be the last one.
|
||||
Use <code>#</code> and <code>=</code> to renumber if necessary.
|
||||
</p>
|
||||
<p>
|
||||
Use the assignment <code>=?</code> for the last string to make it the
|
||||
default value for output formats.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%#{neg=-1|stop|pos|fast=10|rewind=-10}</code>.
|
||||
</p>
|
||||
<p>
|
||||
If one of the strings contains <code>|</code> or <code>}</code>
|
||||
@ -296,10 +317,11 @@ If one of the strings contains <code>|</code> or <code>}</code>
|
||||
a <code>\</code> must be used to escape the character.
|
||||
</p>
|
||||
<p>
|
||||
In output, depending on the value, one of the strings is printed.
|
||||
<b>Output:</b> Depending on the value, one of the strings is printed,
|
||||
or the default if no value matches.
|
||||
</p>
|
||||
<p>
|
||||
In input, if any of the strings matches the value is set accordingly.
|
||||
<b>Input:</b> If any of the strings matches, the value is set accordingly.
|
||||
</p>
|
||||
|
||||
<a name="bin"></a>
|
||||
@ -345,9 +367,12 @@ 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>prec</em> (or sizeof(long) whatever is less) least
|
||||
In output, the <em>precision</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.
|
||||
The default for <em>precision</em> is 1. Thus if you do not specify
|
||||
the <em>precision</em>, only the least significant byte is written!
|
||||
It is common error to write <code>out "%2r";</code> instead of <code>out "%.2r";</code>.
|
||||
</p>
|
||||
<p>
|
||||
In input, <em>width</em> bytes are read and put into the value.
|
||||
@ -358,7 +383,7 @@ the value is sign extended or zero extended, depending on the
|
||||
<code>0</code> flag.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>out "%.2r"</code>
|
||||
Examples: <code>out "%.2r"; in "%02r";</code>
|
||||
</p>
|
||||
|
||||
<a name="rawdouble"></a>
|
||||
@ -412,7 +437,7 @@ The <em>width</em> field is the byte number from which to start
|
||||
calculating the checksum.
|
||||
Default is 0, i.e. the first byte of the input or output of the current
|
||||
command.
|
||||
The last byte is <em>prec</em> bytes before the checksum (default 0).
|
||||
The last byte is <em>precision</em> bytes before the checksum (default 0).
|
||||
For example in <code>"abcdefg%<xor>"</code> the checksum is calculated
|
||||
from <code>abcdefg</code>,
|
||||
but in <code>"abcdefg%2.1<xor>"</code> only from <code>cdef</code>.
|
||||
@ -466,21 +491,24 @@ In input, the next byte or bytes must match the checksum.
|
||||
(poly=0x07, init=0x00, xorout=0x00).</dd>
|
||||
<dt><code>%<ccitt8></code></dt>
|
||||
<dd>One byte. The CCITT standard 8 bit crc checksum
|
||||
(poly=0x31, init=0x00, xorout=0x00).</dd>
|
||||
(poly=0x31, init=0x00, xorout=0x00, reflected).</dd>
|
||||
<dt><code>%<crc16></code></dt>
|
||||
<dd>Two bytes. An often used 16 bit crc checksum
|
||||
(poly=0x8005, init=0x0000, xorout=0x0000).</dd>
|
||||
<dt><code>%<crc16r></code></dt>
|
||||
<dd>Two bytes. An often used reflected 16 bit crc checksum
|
||||
(poly=0x8005, init=0x0000, xorout=0x0000).</dd>
|
||||
(poly=0x8005, init=0x0000, xorout=0x0000, reflected).</dd>
|
||||
<dt><code>%<modbus></code></dt>
|
||||
<dd>Two bytes. The modbus 16 bit crc checksum
|
||||
(poly=0x8005, init=0xffff, xorout=0x0000, reflected)</dd>
|
||||
<dt><code>%<ccitt16></code></dt>
|
||||
<dd>Two bytes. The usual (but <a target="ex"
|
||||
href="http://www.joegeluso.com/software/articles/ccitt.htm">wrong?</a>)
|
||||
href="http://srecord.sourceforge.net/crc16-ccitt.html">wrong?</a>)
|
||||
implementation of the CCITT standard 16 bit crc checksum
|
||||
(poly=0x1021, init=0xFFFF, xorout=0x0000).</dd>
|
||||
<dt><code>%<ccitt16a></code></dt>
|
||||
<dd>Two bytes. The unusual (but <a target="ex"
|
||||
href="http://www.joegeluso.com/software/articles/ccitt.htm">correct?</a>)
|
||||
href="http://srecord.sourceforge.net/crc16-ccitt.html">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>
|
||||
@ -491,10 +519,10 @@ In input, the next byte or bytes must match the checksum.
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0xFFFFFFFF).</dd>
|
||||
<dt><code>%<crc32r></code></dt>
|
||||
<dd>Four bytes. The standard reflected 32 bit crc checksum.
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0xFFFFFFFF).</dd>
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0xFFFFFFFF, reflected).</dd>
|
||||
<dt><code>%<jamcrc></code></dt>
|
||||
<dd>Four bytes. Another reflected 32 bit crc checksum.
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0x00000000).</dd>
|
||||
(poly=0x04C11DB7, init=0xFFFFFFFF, xorout=0x00000000, reflected).</dd>
|
||||
<dt><code>%<adler32></code></dt>
|
||||
<dd>Four bytes. The Adler32 checksum according to <a target="ex"
|
||||
href="http://www.ietf.org/rfc/rfc1950.txt">RFC 1950</a>.</dd>
|
||||
@ -503,41 +531,44 @@ In input, the next byte or bytes must match the checksum.
|
||||
</dl>
|
||||
|
||||
<a name="regex"></a>
|
||||
<h2>12. Regular Expresion STRING Converter (<code>%/<em>regex</em>/</code>)</h2>
|
||||
<h2>13. Regular Expresion STRING Converter (<code>%/<em>regex</em>/</code>)</h2>
|
||||
<p>
|
||||
This input-only format matches <a target="ex"
|
||||
href="http://www.pcre.org/" >Perl compatible regular expressions (PCRE)</a>.
|
||||
It is only available if a PCRE library is installed.
|
||||
</p>
|
||||
<div class="box">
|
||||
<p>
|
||||
If PCRE is not available for your host or cross architecture, download
|
||||
the sourcecode from <a target="ex" href="http://www.pcre.org/">www.pcre.org</a>
|
||||
and try my EPICS compatible <a target="ex"
|
||||
href="http://epics.web.psi.ch/software/streamdevice/pcre/Makefile">Makefile</a>
|
||||
to compile it like a normal EPICS application.
|
||||
to compile it like a normal EPICS support module.
|
||||
The Makefile is known to work with EPICS 3.14.8 and PCRE 7.2.
|
||||
In your RELEASE file define the variable <code>PCRE</code> so that
|
||||
it points to the install location of PCRE.
|
||||
</p>
|
||||
<p>
|
||||
If PCRE is already installed on your system, use the variables
|
||||
<code>PCRE_INCLUDE</code> and <code>PCRE_LIB</code> instead to provide
|
||||
the install directories of <code>pcre.h</code> and the library.
|
||||
</p>
|
||||
<p>
|
||||
If you have PCRE installed in different locations for different (cross)
|
||||
architectures, define the variables in RELEASE.Common.<architecture>
|
||||
instead of the global RELEASE file.
|
||||
If PCRE is already installed on (some of) your systems, you may add
|
||||
architectures where PCRE can be found in standard include and library
|
||||
locations to the variable <code>WITH_SYSTEM_PCRE</code>.
|
||||
If either the header file or the library are in a non-standard place,
|
||||
set in your RELEASE file the variables <code>PCRE_INCLUDE_<em>arch</em></code>
|
||||
and/or <code>PCRE_LIB_<em>arch</em></code> for the respective architectures
|
||||
to the correct directories or set
|
||||
<code>PCRE_INCLUDE</code> and/or <code>PCRE_LIB</code>
|
||||
in architecture specific RELEASE.Common.<em>arch</em> files.
|
||||
</p>
|
||||
</div>
|
||||
<p>
|
||||
If the regular expression is not anchored, i.e. does not start with
|
||||
<code>^</code>, leading non-matching input is skipped.
|
||||
A maximum of <em>width</em> bytes is matched, if specified.
|
||||
If <em>prec</em> is given, it specifies the sub-expression whose match
|
||||
is retuned.
|
||||
If <em>precision</em> is given, it specifies the sub-expression in <code>()</code>
|
||||
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> it must be escaped.
|
||||
If the expression contains a <code>/</code> it must be escaped like <code>\/</code>.
|
||||
</p>
|
||||
<p>
|
||||
Example: <code>%.1/<title>(.*)<\/title>/</code> returns
|
||||
@ -545,8 +576,81 @@ 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="regsub"></a>
|
||||
<h2>14. Regular Expresion Substitution Pseudo-Converter (<code>%#/<em>regex</em>/<em>subst</em>/</code>)</h2>
|
||||
<p>
|
||||
This is a variant of the previous converter (note the <code>#</code>)
|
||||
but instead of returning the matching string,
|
||||
it can be used as a pre-processor for input or
|
||||
as a post-processor for output.
|
||||
</p>
|
||||
<p>
|
||||
Matches of the <em>regex</em> are replaced by the string <em>subst</em> with all
|
||||
<code>&</code> in <em>subst</em> replaced with the match itself and all
|
||||
<code>\1</code> through <code>\9</code> replaced with the match of the corresponding
|
||||
sub-expression <span class="new"> if such a sub-expression exists.
|
||||
|
||||
Due to limitations of the parser, <code>\1</code> and <code>\x01</code> are the same
|
||||
which makes it difficult to use literal bytes with values lower than 10 in <em>subst</em>.
|
||||
Therefore <code>\0</code> aways means a literal byte (incompatible change from earlier version!)
|
||||
and <code>\1</code> through <code>\9</code> mean literal bytes if they are larger than
|
||||
the number of sub-expressions.
|
||||
</span>
|
||||
|
||||
To get a literal <code>&</code> or <code>\</code> or <code>/</code> in the substitution write
|
||||
<code>\&</code> or <code>\\</code> or <code>\/</code>.
|
||||
</p>
|
||||
<p>
|
||||
If <em>width</em> is specified, it limits the number of characters processed.
|
||||
If the <code>-</code> flag is used (i.e. <em>width</em> looks like a negative number)
|
||||
only the last <em>width</em> characters are processed, else the first.
|
||||
Without <em>width</em> (or 0) all available characters are processed.
|
||||
</p>
|
||||
<p>
|
||||
If <em>precision</em> is specified, it indicates which matches to replace.
|
||||
With the <code>+</code> flag given, <em>precision</em> is the maximum
|
||||
number of matches to replace.
|
||||
Otherwise <em>precision</em> is the index (counting from 1) of the match to replace.
|
||||
Without <em>precision</em> (or 0), all matches are replaced.
|
||||
</p>
|
||||
<p>
|
||||
In input this converter pre-processes data received from the device before
|
||||
following converters read it.
|
||||
Converters preceding this one will read unmodified input.
|
||||
Thus place this converter before those whose input should be pre-processed.
|
||||
</p>
|
||||
<p>
|
||||
In output it post-processes data already formatted by preceding converters
|
||||
before sending it to the device.
|
||||
Converters following this one will send their output unmodified.
|
||||
Thus place this converter after those whose output should be post-processed.
|
||||
</p>
|
||||
<p>
|
||||
Examples:
|
||||
<div class="indent">
|
||||
<code>%#+-10.2/ab/X/</code> replaces the string <code>ab</code> with <code>X</code>
|
||||
maximal 2 times in the last 10 characters.
|
||||
(<code>abcabcabcabc</code> becomes <code>abcXcXcabc</code>)
|
||||
</div>
|
||||
<div class="indent">
|
||||
<code>%#/\\/\//</code> replaces all <code>\</code> with <code>/</code>
|
||||
(<code>\dir\file</code> becomes <code>/dir/file</code>)
|
||||
</div>
|
||||
<div class="indent">
|
||||
<code>%#/..\B/&:/</code> inserts <code>:</code> after every second character
|
||||
which is not at the end of a word.
|
||||
(<code>0b19353134</code> becomes <code>0b:19:35:31:34</code>)
|
||||
</div>
|
||||
<div class="indent">
|
||||
<code>%#/://</code> removes all <code>:</code> characters.
|
||||
(<code>0b:19:35:31:34</code> becomes <code>0b19353134</code>)
|
||||
</div>
|
||||
<div class="indent">
|
||||
<code>%#/([^+-])*([+-])/\2\1/</code> moves a postfix sign to the front.
|
||||
(<code>1.23-</code> becomes <code>-1.23</code>)<br>
|
||||
</div>
|
||||
<a name="mantexp"></a>
|
||||
<h2>13. MantissaExponent DOUBLE converter (<code>%m</code>)</h2>
|
||||
<h2>15. MantissaExponent DOUBLE converter (<code>%m</code>)</h2>
|
||||
<p>
|
||||
This exotic and experimental format matches numbers in the format
|
||||
<i>[sign] mantissa sign exponent</i>, e.g <code>+123-4</code> meaning
|
||||
@ -565,9 +669,8 @@ 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>
|
||||
<h2>16. 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).
|
||||
@ -604,7 +707,7 @@ 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
|
||||
In input, <em>StreamDevice</em> uses its own implementation because many
|
||||
systems are missing the <em>strptime()</em> function and additional formats
|
||||
are supported.
|
||||
</p>
|
||||
@ -618,9 +721,8 @@ 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, 2011</small></p>
|
||||
<p><small>Dirk Zimoch, 2015</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -104,13 +104,8 @@ This marks text you typically type in configuration files etc.
|
||||
<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>
|
||||
<p><small>Dirk Zimoch, 2015</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: longin Records</h1>
|
||||
<h1>longin Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: longout Records</h1>
|
||||
<h1>longout Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
35
doc/makepdf
Executable file
35
doc/makepdf
Executable file
@ -0,0 +1,35 @@
|
||||
PAGES="
|
||||
index.html
|
||||
setup.html
|
||||
epics3_13.html
|
||||
protocol.html
|
||||
formats.html
|
||||
processing.html
|
||||
recordtypes.html
|
||||
aai.html
|
||||
aao.html
|
||||
ai.html
|
||||
ao.html
|
||||
bi.html
|
||||
bo.html
|
||||
mbbi.html
|
||||
mbbo.html
|
||||
mbbiDirect.html
|
||||
mbboDirect.html
|
||||
stringin.html
|
||||
stringout.html
|
||||
longin.html
|
||||
longout.html
|
||||
waveform.html
|
||||
calcout.html
|
||||
scalcout.html
|
||||
tipsandtricks.html
|
||||
recordinterface.html
|
||||
businterface.html
|
||||
formatconverter.html
|
||||
osinterface.html
|
||||
"
|
||||
|
||||
rm -f stream.pdf
|
||||
wkhtmltopdf --print-media-type --dpi 1200 --zoom 0.85 --page-size Letter \
|
||||
$PAGES stream.pdf
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbi Records</h1>
|
||||
<h1>mbbi Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbiDirect Records</h1>
|
||||
<h1>mbbiDirect Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbbo Records</h1>
|
||||
<h1>mbbo Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: mbboDirect Records</h1>
|
||||
<h1>mbboDirect Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -132,6 +132,7 @@ div div div a {list-style-type:circle;}
|
||||
<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#regsub" title="Perl regular expression substitution pseudo converter">%#/<em>regex</em>/<em>subst</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>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Operating System API</h1>
|
||||
<h1>Operating System API</h1>
|
||||
|
||||
<h2>Sorry, this documentation is still missing.</h2>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record Processing</h1>
|
||||
<h1>Record Processing</h1>
|
||||
|
||||
<a name="proc"></a>
|
||||
<h2>1. Normal Processing</h2>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Protocol Files</h1>
|
||||
<h1>Protocol Files</h1>
|
||||
<a name="gen"></a>
|
||||
<h2>1. General Information</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record API</h1>
|
||||
<h1>Record API</h1>
|
||||
|
||||
<h2>Sorry, this documentation is still missing.</h2>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Record Types</h1>
|
||||
<h1>Record Types</h1>
|
||||
|
||||
<h2>Supported Record Types</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: scalcout Records</h1>
|
||||
<h1>scalcout Records</h1>
|
||||
|
||||
<p>
|
||||
<b>Note:</b> The scalcout record is part of the <i>calc</i> module of
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Setup</h1>
|
||||
<h1>Setup</h1>
|
||||
|
||||
<a name="pre"></a>
|
||||
<h2>1. Prerequisites</h2>
|
||||
|
@ -5,8 +5,9 @@ a:hover {color: #FF0000;}
|
||||
body {
|
||||
margin-right:1em;
|
||||
margin-left:15em;
|
||||
margin-top:11ex;
|
||||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
margin-top:70px;
|
||||
padding-top:1px;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size:14px;
|
||||
background-color:#ffffff;
|
||||
}
|
||||
@ -30,26 +31,26 @@ dt {
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size:225%;
|
||||
font-size:250%;
|
||||
margin-top:0;
|
||||
font-style:italic;
|
||||
font-family:serif;
|
||||
font-weight:bold;
|
||||
font-family:"Times New Roman", 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;
|
||||
border-width:0;
|
||||
border-bottom:3px solid #1b4486;
|
||||
white-space:nowrap;
|
||||
background-image:url(PSI.gif);
|
||||
background-image:url(PSI.png);
|
||||
background-repeat:no-repeat;
|
||||
background-position:10px 2px;
|
||||
text-shadow: .1em .1em .1em lightgray;
|
||||
background-position:10px 5px;
|
||||
text-shadow:.1em .1em .1em darkgray;
|
||||
box-shadow:0 .3em .1em -.2em darkgray;
|
||||
}
|
||||
|
||||
h2 {
|
||||
@ -87,11 +88,21 @@ code {
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.box {
|
||||
margin-left:1ex;
|
||||
margin-right:1ex;
|
||||
margin-top:0.5ex;
|
||||
padding: 0 1ex;
|
||||
border: 1px solid black;
|
||||
text-align:left;
|
||||
background-color:#f0f0f0;
|
||||
}
|
||||
|
||||
#navleft {
|
||||
position:fixed;
|
||||
left:0;
|
||||
top:0;
|
||||
padding-top:9ex;
|
||||
padding-top:70px;
|
||||
width:14em;
|
||||
height:100%;
|
||||
border-style:solid;
|
||||
@ -115,13 +126,9 @@ a[target=ex]:hover:after {
|
||||
}
|
||||
|
||||
@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:link {text-decoration:none;}
|
||||
a[target=ex]:after {content:" [" attr(href) "]";}
|
||||
code {color: black; }
|
||||
body {margin-left:10px;}
|
||||
h1 {position:absolute;}
|
||||
body {margin:0 4em;}
|
||||
h1 {position:relative; background-position:0 0;}
|
||||
#navleft {display:none;}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: stringin Records</h1>
|
||||
<h1>stringin Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: stringout Records</h1>
|
||||
<h1>stringout Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: Tips and Tricks</h1>
|
||||
<h1>Tips and Tricks</h1>
|
||||
|
||||
<a name="argvar"></a>
|
||||
<h2>I have many almost identical protocols</h2>
|
||||
@ -281,7 +281,7 @@ With some more records, you can clean the message record if SEVR is not INVALID.
|
||||
<code>
|
||||
record (calcout, "$(DEVICE):clean_1") {<br>
|
||||
field (INPA, "$(DEVICE):readcurrent.SEVR CP")<br>
|
||||
field (CALC, "A!=2")<br>
|
||||
field (CALC, "A#3")<br>
|
||||
field (OOPT, "When Non-zero")<br>
|
||||
field (OUT, "$(DEVICE):clean_2.PROC")<br>
|
||||
}<br>
|
||||
|
@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="nav.html" id="navleft"></iframe>
|
||||
<h1>StreamDevice: waveform Records</h1>
|
||||
<h1>waveform Records</h1>
|
||||
|
||||
<h2>Normal Operation</h2>
|
||||
<p>
|
||||
|
@ -22,11 +22,6 @@
|
||||
#include "StreamError.h"
|
||||
#include "StreamBuffer.h"
|
||||
|
||||
#include <epicsVersion.h>
|
||||
#ifdef BASE_VERSION
|
||||
#define EPICS_3_13
|
||||
#endif
|
||||
|
||||
#ifdef EPICS_3_13
|
||||
#include <assert.h>
|
||||
#include <wdLib.h>
|
||||
@ -376,9 +371,11 @@ supportsEvent()
|
||||
intrCallbackInt32, this, &intrPvtInt32);
|
||||
return true;
|
||||
}
|
||||
error("%s: port does not allow to register for "
|
||||
const char *portname;
|
||||
pasynManager->getPortName(pasynUser, &portname);
|
||||
error("%s: port %s does not allow to register for "
|
||||
"Int32 interrupts: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
clientName(), portname, pasynUser->errorMessage);
|
||||
pasynInt32 = NULL;
|
||||
intrPvtInt32 = NULL;
|
||||
}
|
||||
@ -402,9 +399,11 @@ supportsEvent()
|
||||
intrCallbackUInt32, this, 0xFFFFFFFF, &intrPvtInt32);
|
||||
return true;
|
||||
}
|
||||
error("%s: port does not allow to register for "
|
||||
const char *portname;
|
||||
pasynManager->getPortName(pasynUser, &portname);
|
||||
error("%s: port %s does not allow to register for "
|
||||
"UInt32 interrupts: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
clientName(), portname, pasynUser->errorMessage);
|
||||
pasynUInt32 = NULL;
|
||||
intrPvtUInt32 = NULL;
|
||||
}
|
||||
@ -423,7 +422,13 @@ supportsAsyncRead()
|
||||
intrCallbackOctet, this, &intrPvtOctet) != asynSuccess)
|
||||
{
|
||||
const char *portname;
|
||||
int addr;
|
||||
pasynManager->getPortName(pasynUser, &portname);
|
||||
pasynManager->getAddr(pasynUser, &addr);
|
||||
if (addr >= 0)
|
||||
error("%s: asyn port %s addr %d does not support asynchronous input: %s\n",
|
||||
clientName(), portname, addr, pasynUser->errorMessage);
|
||||
else
|
||||
error("%s: asyn port %s does not support asynchronous input: %s\n",
|
||||
clientName(), portname, pasynUser->errorMessage);
|
||||
return false;
|
||||
@ -490,23 +495,14 @@ connectToBus(const char* portname, int addr)
|
||||
bool AsynDriverInterface::
|
||||
lockRequest(unsigned long lockTimeout_ms)
|
||||
{
|
||||
int connected;
|
||||
asynStatus status;
|
||||
|
||||
debug("AsynDriverInterface::lockRequest(%s, %ld msec)\n",
|
||||
clientName(), lockTimeout_ms);
|
||||
lockTimeout = lockTimeout_ms ? lockTimeout_ms*0.001 : -1.0;
|
||||
ioAction = Lock;
|
||||
status = pasynManager->isConnected(pasynUser, &connected);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynManager->isConnected() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
status = pasynManager->queueRequest(pasynUser,
|
||||
connected ? priority() : asynQueuePriorityConnect,
|
||||
lockTimeout);
|
||||
priority(), lockTimeout);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s lockRequest: pasynManager->queueRequest() failed: %s\n",
|
||||
@ -534,7 +530,7 @@ connectToAsynPort()
|
||||
connected ? "yes" : "no");
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynManager->isConnected() failed: %s\n",
|
||||
error("%s connectToAsynPort: pasynManager->isConnected() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
@ -566,19 +562,13 @@ connectToAsynPort()
|
||||
clientName(), connected ? "already" : "not yet");
|
||||
if (!connected)
|
||||
{
|
||||
printf ("%s: AsynDriverInterface::connectToAsynPort: "
|
||||
"pasynCommon->connect(%p, %p)\n",
|
||||
clientName(), pvtCommon, pasynUser);
|
||||
status = pasynCommon->connect(pvtCommon, pasynUser);
|
||||
printf ("%s: AsynDriverInterface::connectToAsynPort: "
|
||||
"pasynCommon->connect(%p, %p) = %s\n",
|
||||
clientName(), pvtCommon, pasynUser, asynStatusStr[status]);
|
||||
debug("AsynDriverInterface::connectToAsynPort(%s): "
|
||||
"status=%s\n",
|
||||
clientName(), asynStatusStr[status]);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynCommon->connect() failed: %s\n",
|
||||
error("%s connectToAsynPort: pasynCommon->connect() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
return false;
|
||||
}
|
||||
@ -597,25 +587,14 @@ void AsynDriverInterface::
|
||||
lockHandler()
|
||||
{
|
||||
asynStatus status;
|
||||
int connected;
|
||||
|
||||
debug("AsynDriverInterface::lockHandler(%s)\n",
|
||||
clientName());
|
||||
|
||||
status = pasynManager->isConnected(pasynUser, &connected);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynManager->isConnected() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
lockCallback(StreamIoFault);
|
||||
return;
|
||||
}
|
||||
if (!connected) lockCallback(StreamIoFault);
|
||||
|
||||
status = pasynManager->blockProcessCallback(pasynUser, false);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynManager->blockProcessCallback() failed: %s\n",
|
||||
error("%s lockHandler: pasynManager->blockProcessCallback() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
lockCallback(StreamIoFault);
|
||||
return;
|
||||
@ -634,9 +613,8 @@ unlock()
|
||||
status = pasynManager->unblockProcessCallback(pasynUser, false);
|
||||
if (status != asynSuccess)
|
||||
{
|
||||
error("%s: pasynManager->unblockProcessCallback() failed: %s\n",
|
||||
error("%s unlock: pasynManager->unblockProcessCallback() failed: %s\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
lockCallback(StreamIoFault);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -682,23 +660,32 @@ writeHandler()
|
||||
size_t written = 0;
|
||||
|
||||
pasynUser->timeout = 0;
|
||||
if (pasynGpib)
|
||||
pasynOctet->flush(pvtOctet, pasynUser);
|
||||
else
|
||||
if (!pasynGpib)
|
||||
// discard any early input, but forward it to potential async records
|
||||
// thus do not use pasynOctet->flush()
|
||||
// unfortunately we cannot do this with GPIB because addressing a device as talker
|
||||
// when it has nothing to say is an error. Also timeout=0 does not help here (would need
|
||||
// a change in asynGPIB), thus use flush() for GPIB.
|
||||
do {
|
||||
char buffer [256];
|
||||
size_t received = 0;
|
||||
int eomReason = 0;
|
||||
debug("AsynDriverInterface::writeHandler(%s): reading old input\n",
|
||||
clientName());
|
||||
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||
buffer, sizeof(buffer), &received, &eomReason);
|
||||
if (received == 0) break;
|
||||
if (status == asynError || received == 0) break;
|
||||
#ifndef NO_TEMPORARY
|
||||
if (received) debug("AsynDriverInterface::writeHandler(%s): flushing %ld bytes: \"%s\"\n",
|
||||
clientName(), (long)received, StreamBuffer(buffer, received).expand()());
|
||||
#endif
|
||||
} while (status == asynSuccess);
|
||||
else
|
||||
{
|
||||
debug("AsynDriverInterface::writeHandler(%s): flushing old input\n",
|
||||
clientName());
|
||||
pasynOctet->flush(pvtOctet, pasynUser);
|
||||
}
|
||||
|
||||
// discard any early events
|
||||
receivedEvent = 0;
|
||||
@ -725,13 +712,25 @@ writeHandler()
|
||||
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
||||
NULL, 0);
|
||||
}
|
||||
pasynUser->errorMessage[0] = 0;
|
||||
status = pasynOctet->write(pvtOctet, pasynUser,
|
||||
outputBuffer, outputSize, &written);
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::writeHandler(%s): "
|
||||
"write(..., outputSize=%ld, written=%ld) "
|
||||
"[timeout=%g sec] = %s\n",
|
||||
clientName(), (long)outputSize, (long)written,
|
||||
pasynUser->timeout, asynStatusStr[status]);
|
||||
"write(..., \"%s\", outputSize=%ld, written=%ld) "
|
||||
"[timeout=%g sec] = %s (%s)\n",
|
||||
clientName(),
|
||||
StreamBuffer(outputBuffer, outputSize).expand()(),
|
||||
(long)outputSize, (long)written,
|
||||
pasynUser->timeout, asynStatusStr[status],
|
||||
pasynUser->errorMessage);
|
||||
#endif
|
||||
|
||||
if (oldeoslen >= 0) // restore asyn terminator
|
||||
{
|
||||
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
||||
oldeos, oldeoslen);
|
||||
}
|
||||
|
||||
// Up to asyn 4.17 I can't see when the server has disconnected. Why?
|
||||
int connected;
|
||||
@ -740,17 +739,12 @@ writeHandler()
|
||||
"device is %sconnected\n",
|
||||
clientName(),connected?"":"dis");
|
||||
if (!connected) {
|
||||
error("%s: connection closed in write\n",
|
||||
error("%s: write failed because connection was closed by device\n",
|
||||
clientName());
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldeoslen >= 0) // restore asyn terminator
|
||||
{
|
||||
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
||||
oldeos, oldeoslen);
|
||||
}
|
||||
switch (status)
|
||||
{
|
||||
case asynSuccess:
|
||||
@ -775,32 +769,34 @@ writeHandler()
|
||||
writeCallback(StreamIoSuccess);
|
||||
return;
|
||||
case asynTimeout:
|
||||
error("%s: asynTimeout (%g sec) in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->timeout, pasynUser->errorMessage);
|
||||
writeCallback(StreamIoTimeout);
|
||||
return;
|
||||
case asynOverflow:
|
||||
error("%s: asynOverflow in write: %s\n",
|
||||
error("%s: asynOverflow in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
case asynError:
|
||||
error("%s: asynError in write: %s\n",
|
||||
error("%s: asynError in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
#ifdef ASYN_VERSION // asyn >= 4.14
|
||||
case asynDisconnected:
|
||||
error("%s: asynDisconnected in write: %s\n",
|
||||
error("%s: asynDisconnected in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
case asynDisabled:
|
||||
error("%s: asynDisconnected in write: %s\n",
|
||||
error("%s: asynDisconnected in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
error("%s: unknown asyn error in write: %s\n",
|
||||
error("%s: unknown asyn error in write. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
writeCallback(StreamIoFault);
|
||||
return;
|
||||
@ -891,6 +887,11 @@ readHandler()
|
||||
oldeoslen = -1;
|
||||
} else do {
|
||||
// device (e.g. GPIB) might not accept full eos length
|
||||
if ((int)deveoslen == oldeoslen && strcmp(deveos, oldeos) == 0)
|
||||
{
|
||||
// nothing to do: old and new eos are the same
|
||||
break;
|
||||
}
|
||||
if (pasynOctet->setInputEos(pvtOctet, pasynUser,
|
||||
deveos, deveoslen) == asynSuccess)
|
||||
{
|
||||
@ -898,8 +899,9 @@ readHandler()
|
||||
if (ioAction != AsyncRead)
|
||||
{
|
||||
debug("AsynDriverInterface::readHandler(%s) "
|
||||
"input EOS set to %s\n",
|
||||
"input EOS changed from \"%s\" to \"%s\"\n",
|
||||
clientName(),
|
||||
StreamBuffer(oldeos, oldeoslen).expand()(),
|
||||
StreamBuffer(deveos, deveoslen).expand()());
|
||||
}
|
||||
#endif
|
||||
@ -955,6 +957,7 @@ readHandler()
|
||||
readMore = 0;
|
||||
received = 0;
|
||||
eomReason = 0;
|
||||
pasynUser->errorMessage[0] = 0;
|
||||
|
||||
debug("AsynDriverInterface::readHandler(%s): ioAction=%s "
|
||||
"read(..., bytesToRead=%ld, ...) "
|
||||
@ -963,12 +966,13 @@ readHandler()
|
||||
bytesToRead, pasynUser->timeout);
|
||||
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||
buffer, bytesToRead, &received, &eomReason);
|
||||
#ifndef NO_TEMPORARY
|
||||
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()());
|
||||
|
||||
#endif
|
||||
pasynManager->isConnected(pasynUser, &connected);
|
||||
debug("AsynDriverInterface::readHandler(%s): "
|
||||
"device is now %sconnected\n",
|
||||
@ -1098,29 +1102,29 @@ readHandler()
|
||||
}
|
||||
peeksize = inputBuffer.capacity();
|
||||
// deliver whatever we could save
|
||||
error("%s: asynOverflow in read: %s\n",
|
||||
error("%s: asynOverflow in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault, buffer, received);
|
||||
break;
|
||||
case asynError:
|
||||
error("%s: asynError in read: %s\n",
|
||||
error("%s: asynError in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault, buffer, received);
|
||||
break;
|
||||
#ifdef ASYN_VERSION // asyn >= 4.14
|
||||
case asynDisconnected:
|
||||
error("%s: asynDisconnected in read: %s\n",
|
||||
error("%s: asynDisconnected in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
case asynDisabled:
|
||||
error("%s: asynDisconnected in read: %s\n",
|
||||
error("%s: asynDisconnected in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
error("%s: unknown asyn error in read: %s\n",
|
||||
error("%s: unknown asyn error in read. Asyn driver says: \"%s\"\n",
|
||||
clientName(), pasynUser->errorMessage);
|
||||
readCallback(StreamIoFault);
|
||||
return;
|
||||
@ -1142,10 +1146,16 @@ readHandler()
|
||||
}
|
||||
|
||||
// restore original EOS
|
||||
if (oldeoslen >= 0)
|
||||
if (oldeoslen >= 0 && oldeoslen != (int)deveoslen && strcmp(deveos, oldeos) != 0)
|
||||
{
|
||||
pasynOctet->setInputEos(pvtOctet, pasynUser,
|
||||
oldeos, oldeoslen);
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("AsynDriverInterface::readHandler(%s) "
|
||||
"input EOS restored to \"%s\"\n",
|
||||
clientName(),
|
||||
StreamBuffer(oldeos, oldeoslen).expand()());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,9 @@ class BCDConverter : public StreamFormatConverter
|
||||
};
|
||||
|
||||
int BCDConverter::
|
||||
parse(const StreamFormat&, StreamBuffer&, const char*&, bool)
|
||||
parse(const StreamFormat& fmt, StreamBuffer&, const char*&, bool)
|
||||
{
|
||||
return long_format;
|
||||
return (fmt.flags & sign_flag) ? signed_format : unsigned_format;
|
||||
}
|
||||
|
||||
bool BCDConverter::
|
||||
|
@ -19,6 +19,7 @@
|
||||
***************************************************************/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include "StreamFormatConverter.h"
|
||||
#include "StreamError.h"
|
||||
|
||||
@ -32,11 +33,16 @@ class BinaryConverter : public StreamFormatConverter
|
||||
};
|
||||
|
||||
int BinaryConverter::
|
||||
parse(const StreamFormat& format, StreamBuffer& info,
|
||||
parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
const char*& source, bool)
|
||||
{
|
||||
if (format.conv == 'B')
|
||||
if (fmt.conv == 'b')
|
||||
{
|
||||
// default characters 0 and 1 for %b
|
||||
info.append("01");
|
||||
return unsigned_format;
|
||||
}
|
||||
|
||||
// user defined characters for %B (next 2 in source)
|
||||
if (*source)
|
||||
{
|
||||
@ -46,37 +52,40 @@ parse(const StreamFormat& format, StreamBuffer& info,
|
||||
{
|
||||
if (*source == esc) source++;
|
||||
info.append(*source++);
|
||||
return long_format;
|
||||
return unsigned_format;
|
||||
}
|
||||
}
|
||||
error("Missing characters after %%B format conversion\n");
|
||||
return false;
|
||||
}
|
||||
// default characters for %b
|
||||
info.append("01");
|
||||
return long_format;
|
||||
}
|
||||
|
||||
bool BinaryConverter::
|
||||
printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
int prec = format.prec;
|
||||
int prec = fmt.prec;
|
||||
if (prec == -1)
|
||||
{
|
||||
// find number of significant bits
|
||||
prec = sizeof (value) * 8;
|
||||
while (prec && (value & (1L << (prec - 1))) == 0) prec--;
|
||||
// Find number of significant bits is nothing is specified.
|
||||
unsigned long x = (unsigned long) value;
|
||||
prec = 32;
|
||||
#if (LONG_BIT > 32)
|
||||
if (x > 0xFFFFFFFF) { prec = 64; x >>=32; }
|
||||
#endif
|
||||
if (x <= 0x0000FFFF) { prec -= 16; x <<=16; }
|
||||
if (x <= 0x00FFFFFF) { prec -= 8; x <<=8; }
|
||||
if (x <= 0x0FFFFFFF) { prec -= 4; x <<=4; }
|
||||
if (x <= 0x3FFFFFFF) { prec -= 2; x <<=2; }
|
||||
if (x <= 0x7FFFFFFF) { prec -= 1; }
|
||||
}
|
||||
if (prec == 0) prec++; // print at least one bit
|
||||
int width = prec;
|
||||
if (format.width > width) width = format.width;
|
||||
char zero = format.info[0];
|
||||
char one = format.info[1];
|
||||
char fill = (format.flags & zero_flag) ? zero : ' ';
|
||||
if (format.flags & alt_flag)
|
||||
if (fmt.width > width) width = fmt.width;
|
||||
char zero = fmt.info[0];
|
||||
char one = fmt.info[1];
|
||||
char fill = (fmt.flags & zero_flag) ? zero : ' ';
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
// little endian (least significant bit first)
|
||||
if (!(format.flags & left_flag))
|
||||
if (!(fmt.flags & left_flag))
|
||||
{
|
||||
// pad left
|
||||
while (width > prec)
|
||||
@ -100,7 +109,7 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
else
|
||||
{
|
||||
// big endian (most significant bit first)
|
||||
if (!(format.flags & left_flag))
|
||||
if (!(fmt.flags & left_flag))
|
||||
{
|
||||
// pad left
|
||||
while (width > prec)
|
||||
@ -124,18 +133,18 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
}
|
||||
|
||||
int BinaryConverter::
|
||||
scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
long val = 0;
|
||||
int width = format.width;
|
||||
int width = fmt.width;
|
||||
if (width == 0) width = -1;
|
||||
int length = 0;
|
||||
char zero = format.info[0];
|
||||
char one = format.info[1];
|
||||
char zero = fmt.info[0];
|
||||
char one = fmt.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)
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
// little endian (least significan bit first)
|
||||
long mask = 1;
|
||||
|
@ -22,9 +22,21 @@
|
||||
#include "StreamError.h"
|
||||
#if defined(__vxworks) || defined(vxWorks) || defined(_WIN32) || defined(__rtems__)
|
||||
// These systems have no strncasecmp
|
||||
#include <epicsVersion.h>
|
||||
#ifdef BASE_VERSION
|
||||
// 3.13
|
||||
#include <ctype.h>
|
||||
static int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
int r=0;
|
||||
while (n && (r = toupper(*s1)-toupper(*s2)) == 0) { n--; s1++; s2++; };
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
#include <epicsString.h>
|
||||
#define strncasecmp epicsStrnCaseCmp
|
||||
#endif
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
typedef unsigned int (*checksumFunc)(const unsigned char* data, unsigned int len, unsigned int init);
|
||||
@ -469,6 +481,7 @@ static checksum checksumMap[] =
|
||||
{"ccitt8", crc_0x31, 0x00, 0x00, 1}, // 0xA1
|
||||
{"crc16", crc_0x8005, 0x0000, 0x0000, 2}, // 0xFEE8
|
||||
{"crc16r", crc_0x8005_r, 0x0000, 0x0000, 2}, // 0xBB3D
|
||||
{"modbus", crc_0x8005_r, 0xFFFF, 0x0000, 2}, // 0x4B37
|
||||
{"ccitt16", crc_0x1021, 0xFFFF, 0x0000, 2}, // 0x29B1
|
||||
{"ccitt16a",crc_0x1021, 0x1D0F, 0x0000, 2}, // 0xE5CC
|
||||
{"ccitt16x",crc_0x1021, 0x0000, 0x0000, 2}, // 0x31C3
|
||||
|
@ -36,7 +36,7 @@ class EnumConverter : public StreamFormatConverter
|
||||
|
||||
int EnumConverter::
|
||||
parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
const char*& source, bool)
|
||||
const char*& source, bool scanFormat)
|
||||
{
|
||||
if (fmt.flags & (left_flag|sign_flag|space_flag|zero_flag))
|
||||
{
|
||||
@ -56,7 +56,30 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
if (*source == '=' && (fmt.flags & alt_flag))
|
||||
{
|
||||
char* p;
|
||||
index = strtol(++source, &p, 0);
|
||||
|
||||
if (*++source == '?')
|
||||
{
|
||||
// default choice
|
||||
if (scanFormat)
|
||||
{
|
||||
error("Default value only allowed in output formats\n");
|
||||
return false;
|
||||
}
|
||||
if (*++source != '}')
|
||||
{
|
||||
error("Default value must be last\n");
|
||||
return false;
|
||||
}
|
||||
source++;
|
||||
numEnums = -(numEnums+1);
|
||||
info.append('\0');
|
||||
memcpy(info(n), &numEnums, sizeof(numEnums));
|
||||
debug("EnumConverter::parse %ld choices with default: %s\n",
|
||||
-numEnums, info.expand()());
|
||||
return enum_format;
|
||||
}
|
||||
|
||||
index = strtol(source, &p, 0);
|
||||
if (p == source || (*p != '|' && *p != '}'))
|
||||
{
|
||||
error("Integer expected after '=' "
|
||||
@ -99,6 +122,9 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
const char* s = fmt.info;
|
||||
long numEnums = extract<long>(s);
|
||||
long index = extract<long>(s);
|
||||
bool noDefault = numEnums >= 0;
|
||||
|
||||
if (numEnums < 0) numEnums=-numEnums-1;
|
||||
while (numEnums-- && (value != index))
|
||||
{
|
||||
while(*s)
|
||||
@ -109,7 +135,7 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
s++;
|
||||
index = extract<long>(s);
|
||||
}
|
||||
if (numEnums == -1)
|
||||
if (numEnums == -1 && noDefault)
|
||||
{
|
||||
error("Value %li not found in enum set\n", value);
|
||||
return false;
|
||||
|
@ -31,23 +31,23 @@ class RawConverter : public StreamFormatConverter
|
||||
};
|
||||
|
||||
int RawConverter::
|
||||
parse(const StreamFormat&, StreamBuffer&,
|
||||
parse(const StreamFormat& fmt, StreamBuffer&,
|
||||
const char*&, bool)
|
||||
{
|
||||
return long_format;
|
||||
return (fmt.flags & (sign_flag|zero_flag)) ? signed_format : unsigned_format;
|
||||
}
|
||||
|
||||
bool RawConverter::
|
||||
printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
int prec = format.prec; // number of bytes from value
|
||||
int prec = fmt.prec; // number of bytes from value
|
||||
if (prec == -1) prec = 1; // default: 1 byte
|
||||
int width = prec; // number of bytes in output
|
||||
if (prec > (int)sizeof(long)) prec=sizeof(long);
|
||||
if (format.width > width) width = format.width;
|
||||
if (fmt.width > width) width = fmt.width;
|
||||
|
||||
char byte = 0;
|
||||
if (format.flags & alt_flag) // little endian (lsb first)
|
||||
if (fmt.flags & alt_flag) // little endian (lsb first)
|
||||
{
|
||||
while (prec--)
|
||||
{
|
||||
@ -56,7 +56,7 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
value >>= 8;
|
||||
width--;
|
||||
}
|
||||
if (format.flags & zero_flag)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
byte = 0;
|
||||
@ -73,7 +73,7 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
}
|
||||
else // big endian (msb first)
|
||||
{
|
||||
if (format.flags & zero_flag)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
byte = 0;
|
||||
@ -97,17 +97,17 @@ printLong(const StreamFormat& format, StreamBuffer& output, long value)
|
||||
}
|
||||
|
||||
int RawConverter::
|
||||
scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
long length = 0;
|
||||
long val = 0;
|
||||
int width = format.width;
|
||||
int width = fmt.width;
|
||||
if (width == 0) width = 1; // default: 1 byte
|
||||
if (format.flags & skip_flag)
|
||||
if (fmt.flags & skip_flag)
|
||||
{
|
||||
return width; // just skip input
|
||||
}
|
||||
if (format.flags & alt_flag)
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
// little endian (lsb first)
|
||||
unsigned int shift = 0;
|
||||
@ -118,7 +118,7 @@ scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
}
|
||||
if (width == 0)
|
||||
{
|
||||
if (format.flags & zero_flag)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
val |= ((unsigned char) input[length++]) << shift;
|
||||
@ -134,7 +134,7 @@ scanLong(const StreamFormat& format, const char* input, long& value)
|
||||
else
|
||||
{
|
||||
// big endian (msb first)
|
||||
if (format.flags & zero_flag)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
val = (unsigned char) input[length++];
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "string.h"
|
||||
#include "pcre.h"
|
||||
|
||||
// Perl regular expressions (PCRE) %/regexp/
|
||||
// Perl regular expressions (PCRE) %/regexp/ and %#/regexp/subst/
|
||||
|
||||
/* Notes:
|
||||
- Memory for compiled regexp is allocated in parse but never freed.
|
||||
@ -32,61 +32,93 @@
|
||||
run-time leak.
|
||||
- A maximum of 9 subexpressions is supported. Only one of them can
|
||||
be the result of the match.
|
||||
- vxWorks and maybe other OS don't have a PCRE library. Provide one?
|
||||
*/
|
||||
|
||||
class RegexpConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse (const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
int scanString(const StreamFormat&, const char*, char*, size_t);
|
||||
int parse (const StreamFormat& fmt, StreamBuffer&, const char*&, bool);
|
||||
int scanString(const StreamFormat& fmt, const char*, char*, size_t);
|
||||
int scanPseudo(const StreamFormat& fmt, StreamBuffer& input, long& cursor);
|
||||
bool printPseudo(const StreamFormat& fmt, StreamBuffer& output);
|
||||
};
|
||||
|
||||
int RegexpConverter::
|
||||
parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
const char*& source, bool scanFormat)
|
||||
{
|
||||
if (!scanFormat)
|
||||
if (!scanFormat && !(fmt.flags & alt_flag))
|
||||
{
|
||||
error("Format conversion %%/regexp/ is only allowed in input formats\n");
|
||||
return false;
|
||||
}
|
||||
if (fmt.prec > 9)
|
||||
{
|
||||
error("Subexpression index %d too big (>9)\n", fmt.prec);
|
||||
return false;
|
||||
}
|
||||
if (fmt.flags & (left_flag|space_flag|zero_flag|alt_flag))
|
||||
{
|
||||
error("Use of modifiers '-', ' ', '0', '#'"
|
||||
"not allowed with %%/regexp/ conversion\n");
|
||||
error("Sub-expression index %d too big (>9)\n", fmt.prec);
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamBuffer pattern;
|
||||
while (*source != '/')
|
||||
{
|
||||
if (!*source) {
|
||||
error("Missing closing '/' after %%/ format conversion\n");
|
||||
error("Missing closing '/' after %%/%s format conversion\n", pattern());
|
||||
return false;
|
||||
}
|
||||
if (*source == esc) {
|
||||
source++;
|
||||
pattern.print("\\x%02x", *source++ & 0xFF);
|
||||
if (*source == esc) { // handle escaped chars
|
||||
if (*++source != '/') // just un-escape /
|
||||
{
|
||||
pattern.append('\\');
|
||||
if ((*source & 0x7f) < 0x30) // handle control chars
|
||||
{
|
||||
pattern.print("x%02x", *source++);
|
||||
continue;
|
||||
}
|
||||
// fall through for PCRE codes like \B
|
||||
}
|
||||
}
|
||||
pattern.append(*source++);
|
||||
}
|
||||
source++;
|
||||
debug("regexp = \"%s\"\n", pattern());
|
||||
debug("regexp = \"%s\"\n", pattern.expand()());
|
||||
|
||||
const char* errormsg;
|
||||
int eoffset;
|
||||
pcre* code = pcre_compile(pattern(), 0,
|
||||
&errormsg, &eoffset, NULL);
|
||||
int nsubexpr;
|
||||
|
||||
pcre* code = pcre_compile(pattern(), 0, &errormsg, &eoffset, NULL);
|
||||
if (!code)
|
||||
{
|
||||
error("%s after \"%s\"\n", errormsg, pattern.expand(0, eoffset)());
|
||||
return false;
|
||||
}
|
||||
pcre_fullinfo(code, NULL, PCRE_INFO_CAPTURECOUNT, &nsubexpr);
|
||||
if (fmt.prec > nsubexpr)
|
||||
{
|
||||
error("Sub-expression index is %d but pattern has only %d sub-expression\n", fmt.prec, nsubexpr);
|
||||
return false;
|
||||
}
|
||||
info.append(&code, sizeof(code));
|
||||
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
StreamBuffer subst;
|
||||
|
||||
debug("check for subst in \"%s\"\n", StreamBuffer(source).expand()());
|
||||
while (*source != '/')
|
||||
{
|
||||
if (!*source) {
|
||||
error("Missing closing '/' after %%#/%s/%s format conversion\n", pattern(), subst());
|
||||
return false;
|
||||
}
|
||||
if (*source == esc)
|
||||
subst.append(*source++);
|
||||
subst.append(*source++);
|
||||
}
|
||||
source++;
|
||||
debug("subst = \"%s\"\n", subst.expand()());
|
||||
info.append(subst).append('\0');
|
||||
return pseudo_format;
|
||||
}
|
||||
return string_format;
|
||||
}
|
||||
|
||||
@ -94,32 +126,130 @@ int RegexpConverter::
|
||||
scanString(const StreamFormat& fmt, const char* input,
|
||||
char* value, size_t maxlen)
|
||||
{
|
||||
pcre* code;
|
||||
size_t len;
|
||||
int ovector[30];
|
||||
int rc;
|
||||
int subexpr = 0;
|
||||
unsigned int l;
|
||||
|
||||
memcpy (&code, fmt.info, sizeof(code));
|
||||
const char* info = fmt.info;
|
||||
pcre* code = extract<pcre*>(info);
|
||||
int length = fmt.width > 0 ? fmt.width : strlen(input);
|
||||
int subexpr = fmt.prec > 0 ? fmt.prec : 0;
|
||||
|
||||
len = fmt.width > 0 ? fmt.width : strlen(input);
|
||||
subexpr = fmt.prec > 0 ? fmt.prec : 0;
|
||||
rc = pcre_exec(code, NULL, input, len, 0, 0, ovector, 30);
|
||||
if (rc < 1) return -1;
|
||||
if (fmt.flags & skip_flag) return ovector[1];
|
||||
len = ovector[subexpr*2+1] - ovector[subexpr*2];
|
||||
if (len >= maxlen) {
|
||||
if (!(fmt.flags & sign_flag)) {
|
||||
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);
|
||||
debug("input = \"%s\"\n", input);
|
||||
debug("length=%d\n", length);
|
||||
|
||||
rc = pcre_exec(code, NULL, input, length, 0, 0, ovector, 30);
|
||||
debug("pcre_exec match \"%.*s\" result = %d\n", length, input, rc);
|
||||
if ((subexpr && rc <= subexpr) || rc < 0)
|
||||
{
|
||||
// error or no match or not enough sub-expressions
|
||||
return -1;
|
||||
}
|
||||
len = maxlen-1;
|
||||
if (fmt.flags & skip_flag) return ovector[subexpr*2+1];
|
||||
|
||||
l = ovector[subexpr*2+1] - ovector[subexpr*2];
|
||||
if (l >= maxlen) {
|
||||
if (!(fmt.flags & sign_flag)) {
|
||||
error("Regexp: Matching string \"%s\" too long (%d>%ld bytes). You may want to try the + flag: \"%%+/.../\"\n",
|
||||
StreamBuffer(input + ovector[subexpr*2],l).expand()(),
|
||||
l, (long)maxlen-1);
|
||||
return -1;
|
||||
}
|
||||
memcpy(value, input+ovector[subexpr*2], len);
|
||||
value[len]=0;
|
||||
return ovector[1];
|
||||
l = maxlen-1;
|
||||
}
|
||||
memcpy(value, input + ovector[subexpr*2], l);
|
||||
value[l] = '\0';
|
||||
return ovector[1]; // consume input until end of match
|
||||
}
|
||||
|
||||
static void regsubst(const StreamFormat& fmt, StreamBuffer& buffer, long start)
|
||||
{
|
||||
const char* subst = fmt.info;
|
||||
pcre* code = extract<pcre*>(subst);
|
||||
long length;
|
||||
int rc, l, c, r, rl, n;
|
||||
int ovector[30];
|
||||
StreamBuffer s;
|
||||
|
||||
length = buffer.length() - start;
|
||||
if (fmt.width && fmt.width < length)
|
||||
length = fmt.width;
|
||||
if (fmt.flags & left_flag)
|
||||
start = buffer.length() - length;
|
||||
|
||||
debug("regsubst buffer=\"%s\", start=%ld, length=%ld, subst = \"%s\"\n",
|
||||
buffer.expand()(), start, length, StreamBuffer(subst).expand()());
|
||||
|
||||
for (c = 0, n = 1; c < length; n++)
|
||||
{
|
||||
rc = pcre_exec(code, NULL, buffer(start+c), length-c, 0, 0, ovector, 30);
|
||||
debug("pcre_exec match \"%s\" result = %d\n", buffer.expand(start+c, length-c)(), rc);
|
||||
if (rc < 0) // no match
|
||||
return;
|
||||
|
||||
if (!(fmt.flags & sign_flag) && n < fmt.prec) // without + flag
|
||||
{
|
||||
// do not yet replace this match
|
||||
c += ovector[1];
|
||||
continue;
|
||||
}
|
||||
// replace & by match in subst
|
||||
l = ovector[1] - ovector[0];
|
||||
debug("before [%d]= \"%s\"\n", ovector[0], buffer.expand(start+c,ovector[0])());
|
||||
debug("match [%d]= \"%s\"\n", l, buffer.expand(start+c+ovector[0],l)());
|
||||
for (r = 1; r < rc; r++)
|
||||
debug("sub%d = \"%s\"\n", r, buffer.expand(start+c+ovector[r*2], ovector[r*2+1]-ovector[r*2])());
|
||||
debug("after = \"%s\"\n", buffer.expand(start+c+ovector[1])());
|
||||
s = subst;
|
||||
debug("subs = \"%s\"\n", s.expand()());
|
||||
for (r = 0; r < s.length(); r++)
|
||||
{
|
||||
debug("check \"%s\"\n", s.expand(r)());
|
||||
if (s[r] == esc)
|
||||
{
|
||||
unsigned char ch = s[r+1];
|
||||
if (c != 0 && ch < rc) // escaped 1 - 9 : replace with subexpr
|
||||
{
|
||||
ch *= 2;
|
||||
rl = ovector[ch+1] - ovector[ch];
|
||||
debug("replace \\%d: \"%s\"\n", ch/2, buffer.expand(start+c+ovector[ch], rl)());
|
||||
s.replace(r, 2, buffer(start+c+ovector[ch]), rl);
|
||||
r += rl - 1;
|
||||
}
|
||||
else
|
||||
s.remove(r, 1); // just remove escape
|
||||
}
|
||||
else if (s[r] == '&') // unescaped & : replace with match
|
||||
{
|
||||
debug("replace &: \"%s\"\n", buffer.expand(start+c+ovector[0], l)());
|
||||
s.replace(r, 1, buffer(start+c+ovector[0]), l);
|
||||
r += l - 1;
|
||||
}
|
||||
else continue;
|
||||
debug("subs = \"%s\"\n", s.expand()());
|
||||
}
|
||||
buffer.replace(start+c+ovector[0], l, s);
|
||||
length += s.length() - l;
|
||||
c += ovector[0] + s.length();
|
||||
if (n == fmt.prec) // max match reached
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int RegexpConverter::
|
||||
scanPseudo(const StreamFormat& fmt, StreamBuffer& input, long& cursor)
|
||||
{
|
||||
/* re-write input buffer */
|
||||
regsubst(fmt, input, cursor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RegexpConverter::
|
||||
printPseudo(const StreamFormat& fmt, StreamBuffer& output)
|
||||
{
|
||||
/* re-write output buffer */
|
||||
regsubst(fmt, output, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterConverter (RegexpConverter, "/");
|
||||
|
@ -296,7 +296,7 @@ StreamBuffer StreamBuffer::expand(ssize_t start, ssize_t length) const
|
||||
for (i = start; i < end; i++)
|
||||
{
|
||||
c = buffer[i];
|
||||
if ((c & 0x7f) < 0x20 || (c & 0x7f) == 0x7f)
|
||||
if (c < 0x20 || c >= 0x7f)
|
||||
{
|
||||
result.print("<%02x>", c & 0xff);
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
StreamBuffer& append(const StreamBuffer& s)
|
||||
{return append(s.buffer+s.offs, s.len);}
|
||||
|
||||
// operator += alias for set
|
||||
// operator += alias for append
|
||||
StreamBuffer& operator+=(char c)
|
||||
{return append(c);}
|
||||
|
||||
|
@ -20,13 +20,7 @@
|
||||
#include "StreamBusInterface.h"
|
||||
#include "StreamError.h"
|
||||
|
||||
const char* StreamIoStatusStr[] = {
|
||||
"StreamIoSuccess",
|
||||
"StreamIoTimeout",
|
||||
"StreamIoNoReply",
|
||||
"StreamIoEnd",
|
||||
"StreamIoFault"
|
||||
};
|
||||
StreamIoStatusStrClass StreamIoStatusStr;
|
||||
|
||||
StreamBusInterfaceRegistrarBase* StreamBusInterfaceRegistrarBase::first;
|
||||
|
||||
|
@ -21,13 +21,26 @@
|
||||
#define StreamBusInterface_h
|
||||
|
||||
#include <stddef.h>
|
||||
#include <StreamBuffer.h>
|
||||
|
||||
enum StreamIoStatus {
|
||||
StreamIoSuccess, StreamIoTimeout, StreamIoNoReply,
|
||||
StreamIoEnd, StreamIoFault
|
||||
};
|
||||
|
||||
extern const char* StreamIoStatusStr[];
|
||||
class StreamIoStatusStrClass {
|
||||
public:
|
||||
const char* operator [] (int index) {
|
||||
switch (index) {
|
||||
case StreamIoSuccess: return "StreamIoSuccess";
|
||||
case StreamIoTimeout: return "StreamIoTimeout";
|
||||
case StreamIoNoReply: return "StreamIoNoReply";
|
||||
case StreamIoEnd: return "StreamIoEnd";
|
||||
case StreamIoFault: return "StreamIoFault";
|
||||
default: return "illegal status";
|
||||
}
|
||||
}
|
||||
} extern StreamIoStatusStr;
|
||||
|
||||
class StreamBusInterface
|
||||
{
|
||||
@ -89,6 +102,9 @@ public:
|
||||
bool busDisconnect() {
|
||||
return businterface && businterface->disconnectRequest();
|
||||
}
|
||||
void busPrintStatus(StreamBuffer& buffer) {
|
||||
if (businterface) businterface->printStatus(buffer);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
@ -137,6 +153,7 @@ protected:
|
||||
virtual bool connectRequest(unsigned long connecttimeout_ms);
|
||||
virtual bool disconnectRequest();
|
||||
virtual void finish();
|
||||
virtual void printStatus(StreamBuffer& buffer) {};
|
||||
|
||||
// pure virtual
|
||||
virtual bool lockRequest(unsigned long timeout_ms) = 0;
|
||||
|
@ -59,7 +59,7 @@ static char* printCommands(StreamBuffer& buffer, const char* c)
|
||||
break;
|
||||
case wait_cmd:
|
||||
timeout = extract<unsigned long>(c);
|
||||
buffer.print(" wait %ld;\n # ms", timeout);
|
||||
buffer.print(" wait %ld; # ms\n", timeout);
|
||||
break;
|
||||
case event_cmd:
|
||||
eventnumber = extract<unsigned long>(c);
|
||||
@ -460,7 +460,7 @@ finishProtocol(ProtocolResult status)
|
||||
status = Fault;
|
||||
}
|
||||
//// flags &= ~(AcceptInput|AcceptEvent);
|
||||
if (runningHandler)
|
||||
if (runningHandler || flags & InitRun)
|
||||
{
|
||||
// get original error status
|
||||
if (status == Success) status = runningHandler;
|
||||
@ -749,7 +749,7 @@ printSeparator()
|
||||
bool StreamCore::
|
||||
printValue(const StreamFormat& fmt, long value)
|
||||
{
|
||||
if (fmt.type != long_format && fmt.type != enum_format)
|
||||
if (fmt.type != unsigned_format && fmt.type != signed_format && fmt.type != enum_format)
|
||||
{
|
||||
error("%s: printValue(long) called with %%%c format\n",
|
||||
name(), fmt.conv);
|
||||
@ -763,8 +763,8 @@ printValue(const StreamFormat& fmt, long value)
|
||||
name(), value);
|
||||
return false;
|
||||
}
|
||||
debug("StreamCore::printValue(%s, long): \"%s\"\n",
|
||||
name(), outputLine.expand()());
|
||||
debug("StreamCore::printValue %s %%%c long %ld (%lx): \"%s\"\n",
|
||||
name(), fmt.conv, value, value, outputLine.expand()());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -785,8 +785,8 @@ printValue(const StreamFormat& fmt, double value)
|
||||
name(), value);
|
||||
return false;
|
||||
}
|
||||
debug("StreamCore::printValue(%s, double): \"%s\"\n",
|
||||
name(), outputLine.expand()());
|
||||
debug("StreamCore::printValue %s %%%c double %#g: \"%s\"\n",
|
||||
name(), fmt.conv, value, outputLine.expand()());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -808,8 +808,8 @@ printValue(const StreamFormat& fmt, char* value)
|
||||
name(), buffer.expand()());
|
||||
return false;
|
||||
}
|
||||
debug("StreamCore::printValue(%s, char*): \"%s\"\n",
|
||||
name(), outputLine.expand()());
|
||||
debug("StreamCore::printValue %s %%%c char* \"%s\"): \"%s\"\n",
|
||||
name(), fmt.conv, value, outputLine.expand()());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -818,7 +818,7 @@ lockCallback(StreamIoStatus status)
|
||||
{
|
||||
MutexLock lock(this);
|
||||
debug("StreamCore::lockCallback(%s, status=%s)\n",
|
||||
name(), status ? "Timeout" : "Success");
|
||||
name(), StreamIoStatusStr[status]);
|
||||
if (!(flags & LockPending))
|
||||
{
|
||||
error("StreamCore::lockCallback(%s) called unexpectedly\n",
|
||||
@ -832,11 +832,21 @@ lockCallback(StreamIoStatus status)
|
||||
case StreamIoSuccess:
|
||||
break;
|
||||
case StreamIoTimeout:
|
||||
error("%s: Cannot lock device within %ld ms\n",
|
||||
debug("%s: Cannot lock device within %ld ms, device seems to be busy\n",
|
||||
name(), lockTimeout);
|
||||
flags &= ~BusOwner;
|
||||
finishProtocol(LockTimeout);
|
||||
return;
|
||||
case StreamIoFault:
|
||||
error("%s: Locking failed because of a device fault\n",
|
||||
name());
|
||||
flags &= ~BusOwner;
|
||||
finishProtocol(LockTimeout);
|
||||
return;
|
||||
default:
|
||||
error("StreamCore::lockCallback(%s) unexpected status %s\n",
|
||||
name(), StreamIoStatusStr[status]);
|
||||
flags &= ~BusOwner;
|
||||
finishProtocol(Fault);
|
||||
return;
|
||||
}
|
||||
@ -981,7 +991,7 @@ readCallback(StreamIoStatus status,
|
||||
evalIn();
|
||||
return 0;
|
||||
}
|
||||
error("%s: No reply from device within %ld ms\n",
|
||||
debug("StreamCore::readCallback(%s): No reply from device within %ld ms\n",
|
||||
name(), replyTimeout);
|
||||
inputBuffer.clear();
|
||||
finishProtocol(ReplyTimeout);
|
||||
@ -1206,7 +1216,8 @@ normal_format:
|
||||
double ddummy;
|
||||
switch (fmt.type)
|
||||
{
|
||||
case long_format:
|
||||
case unsigned_format:
|
||||
case signed_format:
|
||||
case enum_format:
|
||||
consumed = StreamFormatConverter::find(fmt.conv)->
|
||||
scanLong(fmt, inputLine(consumedInput), ldummy);
|
||||
@ -1309,8 +1320,8 @@ normal_format:
|
||||
inputLine.length()-consumedInput > 20 ? "..." : "",
|
||||
formatstring());
|
||||
else
|
||||
error("%s: Format \"%%%s\" has data type %s which does not match variable \"%s\".\n",
|
||||
name(), formatstring(), StreamFormatTypeStr[fmt.type], fieldName);
|
||||
error("%s: Format \"%%%s\" has data type %s which does not match the type of \"%s\".\n",
|
||||
name(), formatstring(), StreamFormatTypeStr[fmt.type], fieldAddress ? fieldName : name());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1447,7 +1458,7 @@ matchSeparator()
|
||||
long StreamCore::
|
||||
scanValue(const StreamFormat& fmt, long& value)
|
||||
{
|
||||
if (fmt.type != long_format && fmt.type != enum_format)
|
||||
if (fmt.type != unsigned_format && fmt.type != signed_format && fmt.type != enum_format)
|
||||
{
|
||||
error("%s: scanValue(long&) called with %%%c format\n",
|
||||
name(), fmt.conv);
|
||||
@ -1468,6 +1479,7 @@ scanValue(const StreamFormat& fmt, long& value)
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
if (fmt.flags & fix_width_flag && consumed != fmt.width) return -1;
|
||||
if (consumed > inputLine.length()-consumedInput) return -1;
|
||||
debug("StreamCore::scanValue(%s) scanned %li\n",
|
||||
name(), value);
|
||||
@ -1499,6 +1511,7 @@ scanValue(const StreamFormat& fmt, double& value)
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
if (fmt.flags & fix_width_flag && (consumed != (fmt.width + fmt.prec + 1))) return -1;
|
||||
if (consumed > inputLine.length()-consumedInput) return -1;
|
||||
debug("StreamCore::scanValue(%s) scanned %#g\n",
|
||||
name(), value);
|
||||
@ -1531,6 +1544,7 @@ scanValue(const StreamFormat& fmt, char* value, long maxlen)
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
if (fmt.flags & fix_width_flag && consumed != fmt.width) return -1;
|
||||
if (consumed > inputLine.length()-consumedInput) return -1;
|
||||
#ifndef NO_TEMPORARY
|
||||
debug("StreamCore::scanValue(%s) scanned \"%s\"\n",
|
||||
@ -1740,4 +1754,25 @@ disconnectCallback(StreamIoStatus status)
|
||||
}
|
||||
}
|
||||
|
||||
void StreamCore::
|
||||
printStatus(StreamBuffer& buffer)
|
||||
{
|
||||
buffer.print("active command=%s ",
|
||||
activeCommand ? commandName(*activeCommand) : "NULL");
|
||||
buffer.print("flags=0x%04lx ", flags);
|
||||
if (flags & IgnoreExtraInput) buffer.append("IgnoreExtraInput ");
|
||||
if (flags & InitRun) buffer.append("InitRun ");
|
||||
if (flags & AsyncMode) buffer.append("AsyncMode ");
|
||||
if (flags & GotValue) buffer.append("GotValue ");
|
||||
if (flags & BusOwner) buffer.append("BusOwner ");
|
||||
if (flags & Separator) buffer.append("Separator ");
|
||||
if (flags & ScanTried) buffer.append("ScanTried ");
|
||||
if (flags & AcceptInput) buffer.append("AcceptInput ");
|
||||
if (flags & AcceptEvent) buffer.append("AcceptEvent ");
|
||||
if (flags & LockPending) buffer.append("LockPending ");
|
||||
if (flags & WritePending) buffer.append("WritePending ");
|
||||
if (flags & WaitPending) buffer.append("WaitPending ");
|
||||
busPrintStatus(buffer);
|
||||
}
|
||||
|
||||
#include "streamReferences"
|
||||
|
@ -219,6 +219,7 @@ public:
|
||||
bool parse(const char* filename, const char* protocolname);
|
||||
void printProtocol();
|
||||
const char* name() { return streamname; }
|
||||
void printStatus(StreamBuffer& buffer);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -115,7 +115,6 @@ class Stream : protected StreamCore
|
||||
epicsMutex mutex;
|
||||
epicsEvent initDone;
|
||||
#endif
|
||||
StreamBuffer fieldBuffer;
|
||||
int status;
|
||||
int convert;
|
||||
long currentValueLength;
|
||||
@ -181,6 +180,7 @@ public:
|
||||
#ifndef EPICS_3_13
|
||||
extern "C" {
|
||||
epicsExportAddress(int, streamDebug);
|
||||
epicsExportAddress(int, streamError);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -196,8 +196,12 @@ extern "C" long streamReload(char* recordname)
|
||||
dbCommon* record;
|
||||
long status;
|
||||
|
||||
int oldStreamError = streamError;
|
||||
streamError = 1;
|
||||
|
||||
if(!pdbbase) {
|
||||
error("No database has been loaded\n");
|
||||
streamError = oldStreamError;
|
||||
return ERROR;
|
||||
}
|
||||
debug("streamReload(%s)\n", recordname);
|
||||
@ -234,6 +238,7 @@ extern "C" long streamReload(char* recordname)
|
||||
}
|
||||
dbFinishEntry(&dbentry);
|
||||
StreamProtocolParser::free();
|
||||
streamError = oldStreamError;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -270,7 +275,7 @@ epicsExportRegistrar(streamRegistrar);
|
||||
struct stream_drvsup {
|
||||
long number;
|
||||
long (*report)(int);
|
||||
DRVSUPFUN init;
|
||||
long (*init)();
|
||||
} stream = {
|
||||
2,
|
||||
Stream::report,
|
||||
@ -350,6 +355,12 @@ report(int interest)
|
||||
{
|
||||
printf(" %s: %s\n", pstream->name(),
|
||||
pstream->ioLink->value.instio.string);
|
||||
if (interest == 3)
|
||||
{
|
||||
StreamBuffer buffer;
|
||||
pstream->printStatus(buffer);
|
||||
printf(" %s\n", buffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
@ -402,6 +413,7 @@ long streamInit(int after)
|
||||
{
|
||||
if (after)
|
||||
{
|
||||
streamError = 0; // Switch off errors after init in order not to spam messages when a device is down.
|
||||
StreamProtocolParser::free();
|
||||
}
|
||||
return OK;
|
||||
@ -410,6 +422,7 @@ long streamInit(int after)
|
||||
long streamInitRecord(dbCommon* record, const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData)
|
||||
{
|
||||
long status;
|
||||
char filename[80];
|
||||
char protocol[80];
|
||||
char busname[80];
|
||||
@ -435,12 +448,13 @@ long streamInitRecord(dbCommon* record, const struct link *ioLink,
|
||||
// scan the i/o link
|
||||
debug("streamInitRecord(%s): parse link \"%s\"\n",
|
||||
record->name, ioLink->value.instio.string);
|
||||
pstream->parseLink(ioLink, filename, protocol,
|
||||
status = pstream->parseLink(ioLink, filename, protocol,
|
||||
busname, &addr, busparam);
|
||||
// (re)initialize bus and protocol
|
||||
debug("streamInitRecord(%s): calling initRecord\n",
|
||||
record->name);
|
||||
long status = pstream->initRecord(filename, protocol,
|
||||
if (status == 0)
|
||||
status = pstream->initRecord(filename, protocol,
|
||||
busname, addr, busparam);
|
||||
if (status != OK && status != DO_NOT_CONVERT)
|
||||
{
|
||||
@ -596,7 +610,7 @@ parseLink(const struct link *ioLink, char* filename,
|
||||
if (items <= 0)
|
||||
{
|
||||
error("%s: Empty I/O link. "
|
||||
"Forgot the leading '@' or confused INP with OUT ?\n",
|
||||
"Forgot the leading '@' or confused INP with OUT or link is too long ?\n",
|
||||
name());
|
||||
return S_dev_badInitRet;
|
||||
}
|
||||
@ -727,37 +741,31 @@ process()
|
||||
debug("Stream::process(%s) start\n", name());
|
||||
status = NO_ALARM;
|
||||
convert = OK;
|
||||
record->pact = true;
|
||||
if (!startProtocol(StreamCore::StartNormal))
|
||||
{
|
||||
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());
|
||||
record->pact = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Stream::
|
||||
print(format_t *format, va_list ap)
|
||||
{
|
||||
long lval;
|
||||
double dval;
|
||||
char* sval;
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ENUM:
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
lval = va_arg(ap, long);
|
||||
return printValue(*format->priv, lval);
|
||||
case DBF_ENUM:
|
||||
return printValue(*format->priv, va_arg(ap, long));
|
||||
case DBF_DOUBLE:
|
||||
dval = va_arg(ap, double);
|
||||
return printValue(*format->priv, dval);
|
||||
return printValue(*format->priv, va_arg(ap, double));
|
||||
case DBF_STRING:
|
||||
sval = va_arg(ap, char*);
|
||||
return printValue(*format->priv, sval);
|
||||
return printValue(*format->priv, va_arg(ap, char*));
|
||||
}
|
||||
error("INTERNAL ERROR (%s): Illegal format type\n", name());
|
||||
return false;
|
||||
@ -767,27 +775,22 @@ bool Stream::
|
||||
scan(format_t *format, void* value, size_t maxStringSize)
|
||||
{
|
||||
// called by streamScanfN
|
||||
long* lptr;
|
||||
double* dptr;
|
||||
char* sptr;
|
||||
|
||||
// first remove old value from inputLine (if we are scanning arrays)
|
||||
consumedInput += currentValueLength;
|
||||
currentValueLength = 0;
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
lptr = (long*)value;
|
||||
currentValueLength = scanValue(*format->priv, *lptr);
|
||||
currentValueLength = scanValue(*format->priv, *(long*)value);
|
||||
break;
|
||||
case DBF_DOUBLE:
|
||||
dptr = (double*)value;
|
||||
currentValueLength = scanValue(*format->priv, *dptr);
|
||||
currentValueLength = scanValue(*format->priv, *(double*)value);
|
||||
break;
|
||||
case DBF_STRING:
|
||||
sptr = (char*)value;
|
||||
currentValueLength = scanValue(*format->priv, sptr,
|
||||
currentValueLength = scanValue(*format->priv, (char*)value,
|
||||
maxStringSize);
|
||||
break;
|
||||
default:
|
||||
@ -957,13 +960,13 @@ getFieldAddress(const char* fieldname, StreamBuffer& address)
|
||||
else
|
||||
{
|
||||
// FIELD in this record or VAL in other record
|
||||
char fullname[PVNAME_SZ + 1];
|
||||
sprintf(fullname, "%s.%s", name(), fieldname);
|
||||
if (dbNameToAddr(fullname, &dbaddr) != OK)
|
||||
StreamBuffer fullname;
|
||||
fullname.print("%s.%s", name(), fieldname);
|
||||
if (dbNameToAddr(fullname(), &dbaddr) != OK)
|
||||
{
|
||||
// VAL in other record
|
||||
sprintf(fullname, "%s.VAL", fieldname);
|
||||
if (dbNameToAddr(fullname, &dbaddr) != OK) return false;
|
||||
fullname.clear().print("%s.VAL", fieldname);
|
||||
if (dbNameToAddr(fullname(), &dbaddr) != OK) return false;
|
||||
}
|
||||
}
|
||||
address.append(&dbaddr, sizeof(dbaddr));
|
||||
@ -971,9 +974,9 @@ getFieldAddress(const char* fieldname, StreamBuffer& address)
|
||||
}
|
||||
|
||||
static const unsigned char dbfMapping[] =
|
||||
{0, DBF_LONG, DBF_ENUM, DBF_DOUBLE, DBF_STRING};
|
||||
{0, DBF_ULONG, DBF_LONG, DBF_ENUM, DBF_DOUBLE, DBF_STRING};
|
||||
static const short typeSize[] =
|
||||
{0, sizeof(epicsInt32), sizeof(epicsUInt16),
|
||||
{0, sizeof(epicsUInt32), sizeof(epicsInt32), sizeof(epicsUInt16),
|
||||
sizeof(epicsFloat64), MAX_STRING_SIZE};
|
||||
|
||||
bool Stream::
|
||||
@ -985,16 +988,17 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
// -- TO DO: If SCAN is "I/O Intr" and record has not been processed, --
|
||||
// -- do it now to get the latest value (only for output records?) --
|
||||
|
||||
format_s fmt;
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
if (fieldaddress)
|
||||
{
|
||||
// Format like "%([record.]field)..." has requested to get value
|
||||
// from field of this or other record.
|
||||
StreamBuffer fieldBuffer;
|
||||
DBADDR* pdbaddr = (DBADDR*)fieldaddress;
|
||||
long i;
|
||||
long nelem = pdbaddr->no_elements;
|
||||
size_t size = nelem * typeSize[format.type];
|
||||
char* buffer = fieldBuffer.clear().reserve(size);
|
||||
|
||||
/* Handle time stamps special. %T converter takes double. */
|
||||
if (strcmp(((dbFldDes*)pdbaddr->pfldDes)->name, "TIME") == 0)
|
||||
{
|
||||
double time;
|
||||
@ -1010,6 +1014,8 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
/* if getting time from own record, update timestamp first */
|
||||
recGblGetTimeStamp(record);
|
||||
}
|
||||
/* convert EPICS epoch (1990) to unix epoch (1970) */
|
||||
/* we are losing about 3 digits precision here */
|
||||
time = pdbaddr->precord->time.secPastEpoch +
|
||||
631152000u + pdbaddr->precord->time.nsec * 1e-9;
|
||||
debug("Stream::formatValue(%s): read %f from TIME field\n",
|
||||
@ -1017,7 +1023,28 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
return printValue(format, time);
|
||||
}
|
||||
|
||||
if (dbGet(pdbaddr, dbfMapping[format.type], buffer,
|
||||
/* convert type to LONG, ENUM, DOUBLE, or STRING */
|
||||
long nelem = pdbaddr->no_elements;
|
||||
size_t size = nelem * typeSize[format.type];
|
||||
|
||||
/* print (U)CHAR arrays as string */
|
||||
if (format.type == string_format &&
|
||||
(pdbaddr->field_type == DBF_CHAR || pdbaddr->field_type == DBF_UCHAR))
|
||||
{
|
||||
debug("Stream::formatValue(%s): format %s.%s array[%ld] size %d of %s as string\n",
|
||||
name(),
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nelem,
|
||||
pdbaddr->field_size,
|
||||
pamapdbfType[pdbaddr->field_type].strvalue);
|
||||
fmt.type = DBF_CHAR;
|
||||
size = nelem;
|
||||
}
|
||||
|
||||
char* buffer = fieldBuffer.clear().reserve(size);
|
||||
|
||||
if (dbGet(pdbaddr, fmt.type, buffer,
|
||||
NULL, &nelem, NULL) != 0)
|
||||
{
|
||||
error("%s: dbGet(%s.%s, %s) failed\n",
|
||||
@ -1027,6 +1054,18 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
pamapdbfType[dbfMapping[format.type]].strvalue);
|
||||
return false;
|
||||
}
|
||||
debug("Stream::formatValue(%s): got %ld elements\n",
|
||||
name(),nelem);
|
||||
|
||||
/* terminate CHAR array as string */
|
||||
if (fmt.type == DBF_CHAR)
|
||||
{
|
||||
if (nelem >= pdbaddr->no_elements) nelem = pdbaddr->no_elements-1;
|
||||
buffer[nelem] = 0;
|
||||
nelem = 1; /* array is only 1 string */
|
||||
}
|
||||
|
||||
long i;
|
||||
for (i = 0; i < nelem; i++)
|
||||
{
|
||||
switch (format.type)
|
||||
@ -1036,7 +1075,12 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
(long)((epicsUInt16*)buffer)[i]))
|
||||
return false;
|
||||
break;
|
||||
case long_format:
|
||||
case unsigned_format:
|
||||
if (!printValue(format,
|
||||
(long)((epicsUInt32*)buffer)[i]))
|
||||
return false;
|
||||
break;
|
||||
case signed_format:
|
||||
if (!printValue(format,
|
||||
(long)((epicsInt32*)buffer)[i]))
|
||||
return false;
|
||||
@ -1054,6 +1098,7 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
error("%s: %%(FIELD) syntax not allowed "
|
||||
"with pseudo formats\n",
|
||||
name());
|
||||
return false;
|
||||
default:
|
||||
error("INTERNAL ERROR %s: Illegal format.type=%d\n",
|
||||
name(), format.type);
|
||||
@ -1062,9 +1107,6 @@ formatValue(const StreamFormat& format, const void* fieldaddress)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
format_s fmt;
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
debug("Stream::formatValue(%s) format=%%%c type=%s\n",
|
||||
name(), format.conv, pamapdbfType[fmt.type].strvalue);
|
||||
if (!writeData)
|
||||
@ -1090,11 +1132,15 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
char* buffer;
|
||||
int status;
|
||||
const char* putfunc;
|
||||
format_s fmt;
|
||||
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
if (fieldaddress)
|
||||
{
|
||||
// Format like "%([record.]field)..." has requested to put value
|
||||
// to field of this or other record.
|
||||
StreamBuffer fieldBuffer;
|
||||
DBADDR* pdbaddr = (DBADDR*)fieldaddress;
|
||||
long nord;
|
||||
long nelem = pdbaddr->no_elements;
|
||||
@ -1106,12 +1152,24 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
name(), fieldBuffer.expand()());
|
||||
switch (format.type)
|
||||
{
|
||||
case long_format:
|
||||
case unsigned_format:
|
||||
{
|
||||
consumed = scanValue(format, lval);
|
||||
if (consumed >= 0) ((epicsUInt32*)buffer)[nord] = lval;
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = %lu\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, lval);
|
||||
break;
|
||||
}
|
||||
case signed_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);
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, lval);
|
||||
break;
|
||||
}
|
||||
case enum_format:
|
||||
@ -1119,8 +1177,10 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
consumed = scanValue(format, lval);
|
||||
if (consumed >= 0)
|
||||
((epicsUInt16*)buffer)[nord] = (epicsUInt16)lval;
|
||||
debug("Stream::matchValue(%s): %s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name, nord, lval);
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = %li\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, lval);
|
||||
break;
|
||||
}
|
||||
case double_format:
|
||||
@ -1133,18 +1193,34 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
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,
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = %#g %#g\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, dval,
|
||||
((epicsFloat64*)buffer)[nord]);
|
||||
break;
|
||||
}
|
||||
case string_format:
|
||||
{
|
||||
if (pdbaddr->field_type == DBF_CHAR)
|
||||
{
|
||||
// string to char array
|
||||
consumed = scanValue(format, buffer, nelem);
|
||||
debug("Stream::matchValue(%s): %s.%s = \"%.*s\"\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
(int)consumed, buffer);
|
||||
nord = nelem;
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
debug("Stream::matchValue(%s): %s.%s[%li] = \"%.*s\"\n",
|
||||
name(), pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
nord, MAX_STRING_SIZE, buffer+MAX_STRING_SIZE*nord);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1181,15 +1257,17 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
name());
|
||||
return false;
|
||||
}
|
||||
/* convert from Unix epoch (1 Jan 1970) to EPICS epoch (1 Jan 1990) */
|
||||
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
|
||||
pdbaddr->precord->time.nsec = (long)((dval-(long)dval)*1e6)*1000;
|
||||
debug("Stream::matchValue(%s): writing %i.%i to TIME field\n",
|
||||
debug("Stream::matchValue(%s): writing %i.%i to %s.TIME field\n",
|
||||
name(),
|
||||
pdbaddr->precord->time.secPastEpoch,
|
||||
pdbaddr->precord->time.nsec);
|
||||
pdbaddr->precord->time.nsec,
|
||||
pdbaddr->precord->name);
|
||||
pdbaddr->precord->tse = epicsTimeEventDeviceTime;
|
||||
return true;
|
||||
#else
|
||||
@ -1198,18 +1276,19 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (format.type == string_format &&
|
||||
(pdbaddr->field_type == DBF_CHAR || pdbaddr->field_type == DBF_UCHAR))
|
||||
{
|
||||
/* write strings to [U]CHAR arrays */
|
||||
nord = consumed;
|
||||
fmt.type = DBF_CHAR;
|
||||
}
|
||||
if (pdbaddr->precord == record || INIT_RUN)
|
||||
{
|
||||
// write into own record, thus don't process it
|
||||
// in @init we must not process other record
|
||||
debug("Stream::matchValue(%s): dbPut(%s.%s,%s)\n",
|
||||
name(),
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
fieldBuffer.expand()());
|
||||
putfunc = "dbPut";
|
||||
status = dbPut(pdbaddr, dbfMapping[format.type], buffer, nord);
|
||||
status = dbPut(pdbaddr, fmt.type, buffer, nord);
|
||||
if (INIT_RUN && pdbaddr->precord != record)
|
||||
{
|
||||
// clean error status of other record in @init
|
||||
@ -1221,41 +1300,44 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
else
|
||||
{
|
||||
// write into other record, thus process it
|
||||
debug("Stream::matchValue(%s): dbPutField(%s.%s,%s)\n",
|
||||
name(),
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
fieldBuffer.expand()());
|
||||
putfunc = "dbPutField";
|
||||
status = dbPutField(pdbaddr, dbfMapping[format.type],
|
||||
status = dbPutField(pdbaddr, fmt.type,
|
||||
buffer, nord);
|
||||
}
|
||||
debug("Stream::matchValue(%s): %s(%s.%s, %s, %s) status=0x%x\n",
|
||||
name(), putfunc,
|
||||
pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
pamapdbfType[fmt.type].strvalue,
|
||||
fieldBuffer.expand()(),
|
||||
status);
|
||||
if (status != 0)
|
||||
{
|
||||
flags &= ~ScanTried;
|
||||
switch (format.type)
|
||||
switch (fmt.type)
|
||||
{
|
||||
case long_format:
|
||||
case enum_format:
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
error("%s: %s(%s.%s, %s, %li) failed\n",
|
||||
putfunc, name(), pdbaddr->precord->name,
|
||||
name(), putfunc, pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
pamapdbfType[dbfMapping[format.type]].strvalue,
|
||||
pamapdbfType[fmt.type].strvalue,
|
||||
lval);
|
||||
return false;
|
||||
case double_format:
|
||||
case DBF_DOUBLE:
|
||||
error("%s: %s(%s.%s, %s, %#g) failed\n",
|
||||
putfunc, name(), pdbaddr->precord->name,
|
||||
name(), putfunc, pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
pamapdbfType[dbfMapping[format.type]].strvalue,
|
||||
pamapdbfType[fmt.type].strvalue,
|
||||
dval);
|
||||
return false;
|
||||
case string_format:
|
||||
error("%s: %s(%s.%s, %s, \"%s\") failed\n",
|
||||
putfunc, name(), pdbaddr->precord->name,
|
||||
case DBF_STRING:
|
||||
error("%s: %s(%s.%s, %s, \"%.*s\") failed\n",
|
||||
name(), putfunc, pdbaddr->precord->name,
|
||||
((dbFldDes*)pdbaddr->pfldDes)->name,
|
||||
pamapdbfType[dbfMapping[format.type]].strvalue,
|
||||
buffer);
|
||||
pamapdbfType[fmt.type].strvalue,
|
||||
(int)consumed, buffer);
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
@ -1264,9 +1346,6 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
return true;
|
||||
}
|
||||
// no fieldaddress (the "normal" case)
|
||||
format_s fmt;
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
if (!readData)
|
||||
{
|
||||
error("%s: No readData() function provided\n", name());
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int streamDebug = 0;
|
||||
int streamError = 1;
|
||||
extern "C" {
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
@ -74,6 +75,7 @@ void StreamError(int line, const char* file, const char* fmt, ...)
|
||||
void StreamVError(int line, const char* file, const char* fmt, va_list args)
|
||||
{
|
||||
char timestamp[40];
|
||||
if (!streamError) return; // Error logging disabled
|
||||
StreamPrintTimestampFunction(timestamp, 40);
|
||||
#ifdef va_copy
|
||||
if (StreamDebugFile)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#endif
|
||||
|
||||
extern int streamDebug;
|
||||
extern int streamError;
|
||||
extern void (*StreamPrintTimestampFunction)(char* buffer, int size);
|
||||
|
||||
void StreamError(int line, const char* file, const char* fmt, ...)
|
||||
|
@ -30,15 +30,17 @@ typedef enum {
|
||||
zero_flag = 0x10,
|
||||
skip_flag = 0x20,
|
||||
default_flag = 0x40,
|
||||
compare_flag = 0x80
|
||||
compare_flag = 0x80,
|
||||
fix_width_flag = 0x100,
|
||||
} StreamFormatFlag;
|
||||
|
||||
typedef enum {
|
||||
long_format = 1,
|
||||
enum_format = 2,
|
||||
double_format = 3,
|
||||
string_format = 4,
|
||||
pseudo_format = 5
|
||||
unsigned_format = 1,
|
||||
signed_format,
|
||||
enum_format,
|
||||
double_format,
|
||||
string_format,
|
||||
pseudo_format
|
||||
} StreamFormatType;
|
||||
|
||||
extern const char* StreamFormatTypeStr[];
|
||||
@ -47,7 +49,7 @@ typedef struct StreamFormat
|
||||
{
|
||||
char conv;
|
||||
StreamFormatType type;
|
||||
unsigned char flags;
|
||||
unsigned short flags;
|
||||
short prec;
|
||||
unsigned short width;
|
||||
unsigned short infolen;
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include "StreamFormatConverter.h"
|
||||
#include "StreamError.h"
|
||||
|
||||
@ -37,7 +38,7 @@ parseFormat(const char*& source, FormatType formatType, StreamFormat& streamForm
|
||||
{
|
||||
/*
|
||||
source := [flags] [width] ['.' prec] conv [extra]
|
||||
flags := '-' | '+' | ' ' | '#' | '0' | '*' | '?' | '='
|
||||
flags := '-' | '+' | ' ' | '#' | '0' | '*' | '?' | '=' | '!'
|
||||
width := integer
|
||||
prec := integer
|
||||
conv := character
|
||||
@ -84,6 +85,15 @@ parseFormat(const char*& source, FormatType formatType, StreamFormat& streamForm
|
||||
}
|
||||
streamFormat.flags |= default_flag;
|
||||
break;
|
||||
case '!':
|
||||
if (formatType != ScanFormat)
|
||||
{
|
||||
error("Use of fixed width modifier '!' "
|
||||
"only allowed in input formats\n");
|
||||
return false;
|
||||
}
|
||||
streamFormat.flags |= fix_width_flag;
|
||||
break;
|
||||
case '=':
|
||||
if (formatType != ScanFormat)
|
||||
{
|
||||
@ -310,12 +320,16 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
info.append('l');
|
||||
info.append(fmt.conv);
|
||||
}
|
||||
return long_format;
|
||||
if (fmt.conv == 'd' || fmt.conv == 'i') return signed_format;
|
||||
return unsigned_format;
|
||||
}
|
||||
|
||||
bool StdLongConverter::
|
||||
printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
// limits %x/%X formats to number of half bytes in width.
|
||||
if (fmt.width && (fmt.conv == 'x' || fmt.conv == 'X') && fmt.width < 2*sizeof(long))
|
||||
value &= ~(-1L << (fmt.width*4));
|
||||
output.print(fmt.info, value);
|
||||
return true;
|
||||
}
|
||||
@ -327,6 +341,7 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
int length;
|
||||
bool neg;
|
||||
int base;
|
||||
long v;
|
||||
|
||||
length = prepareval(fmt, input, neg);
|
||||
if (length < 0) return -1;
|
||||
@ -336,14 +351,11 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
base = 10;
|
||||
break;
|
||||
case 'o':
|
||||
base = 8;
|
||||
goto signcheck;
|
||||
case 'x':
|
||||
case 'X':
|
||||
base = 16;
|
||||
signcheck:
|
||||
// allow negative hex and oct numbers with - flag
|
||||
if (neg && !(fmt.flags & left_flag)) return -1;
|
||||
base = (fmt.conv == 'o') ? 8 : 16;
|
||||
break;
|
||||
case 'u':
|
||||
if (neg) return -1;
|
||||
@ -352,10 +364,10 @@ signcheck:
|
||||
default:
|
||||
base = 0;
|
||||
}
|
||||
value = strtoul(input, &end, base);
|
||||
if (neg) value = -value;
|
||||
v = strtoul(input, &end, base);
|
||||
if (end == input) return -1;
|
||||
length += end-input;
|
||||
value = neg ? -v : v;
|
||||
return length;
|
||||
}
|
||||
|
||||
@ -543,7 +555,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
info.append("%n");
|
||||
return string_format;
|
||||
}
|
||||
return long_format;
|
||||
return unsigned_format;
|
||||
}
|
||||
|
||||
bool StdCharsConverter::
|
||||
|
@ -26,7 +26,8 @@
|
||||
#include "StreamError.h"
|
||||
|
||||
const char* StreamFormatTypeStr[] = {
|
||||
"none", "long", "enum", "double", "string", "pseudo"
|
||||
// must match the order in StreamFormat.h
|
||||
"none", "unsigned", "signed", "enum", "double", "string", "pseudo"
|
||||
};
|
||||
|
||||
class StreamProtocolParser::Protocol::Variable
|
||||
@ -511,7 +512,16 @@ Each time newline is read, line is incremented.
|
||||
buffer(token));
|
||||
return false;
|
||||
}
|
||||
if (c == '$' && buffer[-1] == '\\')
|
||||
buffer.append(c);
|
||||
if (c == quote)
|
||||
{
|
||||
quote = false;
|
||||
break;
|
||||
}
|
||||
if (c == '\\')
|
||||
{
|
||||
c = getc(file);
|
||||
if (c == '$')
|
||||
{
|
||||
// quoted variable reference
|
||||
// terminate string here and do variable in next pass
|
||||
@ -519,11 +529,13 @@ Each time newline is read, line is incremented.
|
||||
ungetc(c, file);
|
||||
break;
|
||||
}
|
||||
buffer.append(c);
|
||||
if (c == quote && buffer[-2] != '\\')
|
||||
if (c == EOF || c == '\n')
|
||||
{
|
||||
quote = false;
|
||||
break;
|
||||
error(line, filename(), "Backslash at end of line: %s\n",
|
||||
buffer(token));
|
||||
return false;
|
||||
}
|
||||
buffer.append(c);
|
||||
}
|
||||
c = getc(file);
|
||||
}
|
||||
@ -1347,7 +1359,8 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
source);
|
||||
return false;
|
||||
}
|
||||
if (formatType != NoFormat)
|
||||
if (formatType != NoFormat &&
|
||||
i > 2 /* do not escape skip */)
|
||||
{
|
||||
buffer.append(esc);
|
||||
}
|
||||
@ -1438,7 +1451,7 @@ compileFormat(StreamBuffer& buffer, const char*& formatstr,
|
||||
// parsing failed
|
||||
return false;
|
||||
}
|
||||
if (type < long_format && type > pseudo_format)
|
||||
if (type < 1 && type > pseudo_format)
|
||||
{
|
||||
error(line, filename(),
|
||||
"Illegal format type %d returned from '%%%c' converter\n",
|
||||
|
@ -26,6 +26,24 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* timezone in UNIX contains the seconds between UTC and local time,
|
||||
but not in Free-BSD! Here timezone() is a function delivering
|
||||
the time zone abbreviation (e.g. CET). Alternatively, the timezone
|
||||
value can also be gained from tm_gmtoff of the tm-structure.
|
||||
HJK, 4.4.14 */
|
||||
/* The same seems to be true for other BSDs. DZ. */
|
||||
|
||||
#if defined(__FreeBSD__) || \
|
||||
defined(__NetBSD__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(__bsdi__ ) || \
|
||||
defined(__DragonFly__)
|
||||
static int timezone_bsd=0;
|
||||
#define timezone timezone_bsd
|
||||
#define tzset() { struct tm tm; time_t timet; tzset(); time(&timet); \
|
||||
localtime_r(&timet, &tm); timezone=tm.tm_gmtoff; }
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define tzset() _tzset()
|
||||
#define timezone _timezone
|
||||
@ -46,6 +64,13 @@ int timezone = 0;
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
/* MinGW has no re-entrant localtime. How about other environments? */
|
||||
/* Just let's hope for the best */
|
||||
#undef localtime_r
|
||||
#define localtime_r(timet,tm) (*(tm)=*localtime(timet))
|
||||
#endif
|
||||
|
||||
class TimestampConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
@ -366,7 +391,7 @@ startover:
|
||||
debug ("TimestampConverter::scantime: %s hour = %d\n", pm?"PM":"AM", tm->tm_hour);
|
||||
break;
|
||||
case 'M': /* minute */
|
||||
i = nummatch(input, 1, 59);
|
||||
i = nummatch(input, 0, 59);
|
||||
if (i < 0)
|
||||
{
|
||||
error ("error parsing minute: '%.20s'\n", input);
|
||||
@ -376,7 +401,7 @@ startover:
|
||||
debug ("TimestampConverter::scantime: min = %d\n", tm->tm_min);
|
||||
break;
|
||||
case 'S': /* second */
|
||||
i = nummatch(input, 1, 60);
|
||||
i = nummatch(input, 0, 60);
|
||||
if (i < 0)
|
||||
{
|
||||
error ("error parsing week second: '%.20s'\n", input);
|
||||
|
@ -22,8 +22,8 @@
|
||||
#define devStream_h
|
||||
|
||||
#define STREAM_MAJOR 2
|
||||
#define STREAM_MINOR 6
|
||||
#define STREAM_PATCHLEVEL 3
|
||||
#define STREAM_MINOR 7
|
||||
#define STREAM_PATCHLEVEL 14
|
||||
|
||||
#if defined(__vxworks) || defined(vxWorks)
|
||||
#include <vxWorks.h>
|
||||
@ -58,7 +58,6 @@ extern "C" {
|
||||
#include <dbCommon.h>
|
||||
#include <dbScan.h>
|
||||
#include <devSup.h>
|
||||
/* #include <dbFldTypes.h> */
|
||||
#include <dbAccess.h>
|
||||
|
||||
#ifdef devStream_epicsExportSharedSymbols
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "devStream.h"
|
||||
#include <aaiRecord.h>
|
||||
#include <errlog.h>
|
||||
#include <aaiRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -57,6 +57,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
@ -191,6 +192,7 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
return ERROR;
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "devStream.h"
|
||||
#include <aaoRecord.h>
|
||||
#include <errlog.h>
|
||||
#include <aaoRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -57,6 +57,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
@ -191,6 +192,7 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
return ERROR;
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
|
@ -18,10 +18,18 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <math.h>
|
||||
#include <menuConvert.h>
|
||||
#include <aiRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <private/mathP.h>
|
||||
#define isinf(x) isInf(x)
|
||||
#define isnan(x) isNan(x)
|
||||
#endif
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
aiRecord *ai = (aiRecord *) record;
|
||||
@ -32,20 +40,31 @@ static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
double val;
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
if (ai->aslo != 0.0) val *= ai->aslo;
|
||||
if (ai->aslo != 0.0 && ai->aslo != 1.0) val *= ai->aslo;
|
||||
val += ai->aoff;
|
||||
if (!INIT_RUN && ai->smoo != 0.0)
|
||||
{
|
||||
if (!(ai->smoo == 0.0 || ai->init || ai->udf || isinf(ai->val) || isnan(ai->val)))
|
||||
val = ai->val * ai->smoo + val * (1.0 - ai->smoo);
|
||||
}
|
||||
ai->val = val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
long rval;
|
||||
if (streamScanf (record, format, &rval)) return ERROR;
|
||||
ai->rval = rval;
|
||||
if (ai->linr == menuConvertNO_CONVERSION)
|
||||
{
|
||||
/* allow integers with more than 32 bits */
|
||||
double val;
|
||||
if (format->type == DBF_ULONG)
|
||||
val = (unsigned long)rval;
|
||||
else
|
||||
val = rval;
|
||||
if (ai->aslo != 0.0 && ai->aslo != 1.0) val *= ai->aslo;
|
||||
ai->val = val + ai->aoff;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
@ -55,18 +74,31 @@ static long readData (dbCommon *record, format_t *format)
|
||||
static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
aiRecord *ai = (aiRecord *) record;
|
||||
double val;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
{
|
||||
val = ai->val - ai->aoff;
|
||||
if (ai->aslo != 0) val /= ai->aslo;
|
||||
double val = ai->val - ai->aoff;
|
||||
if (ai->aslo != 0.0 && ai->aslo != 1.0) val /= ai->aslo;
|
||||
return streamPrintf (record, format, val);
|
||||
}
|
||||
case DBF_ULONG:
|
||||
{
|
||||
if (ai->linr == menuConvertNO_CONVERSION)
|
||||
{
|
||||
/* allow more bits than 32 */
|
||||
return streamPrintf (record, format, (unsigned long)ai->val);
|
||||
}
|
||||
return streamPrintf (record, format, (unsigned long)ai->rval);
|
||||
}
|
||||
case DBF_LONG:
|
||||
{
|
||||
if (ai->linr == menuConvertNO_CONVERSION)
|
||||
{
|
||||
/* allow more bits than 32 */
|
||||
return streamPrintf (record, format, (long)ai->val);
|
||||
}
|
||||
return streamPrintf (record, format, (long)ai->rval);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,9 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <menuConvert.h>
|
||||
#include <aoRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -32,16 +33,29 @@ static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
double val;
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
if (ao->aslo != 0) val *= ao->aslo;
|
||||
if (ao->aslo != 0.0 && ao->aslo != 1.0) val *= ao->aslo;
|
||||
ao->val = val + ao->aoff;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
long rval;
|
||||
if (streamScanf (record, format, &rval)) return ERROR;
|
||||
ao->rbv = rval;
|
||||
if (INIT_RUN) ao->rval = rval;
|
||||
ao->rval = rval;
|
||||
if (ao->linr == menuConvertNO_CONVERSION)
|
||||
{
|
||||
/* allow integers with more than 32 bits */
|
||||
double val;
|
||||
if (format->type == DBF_ULONG)
|
||||
val = (unsigned long)rval;
|
||||
else
|
||||
val = rval;
|
||||
if (ao->aslo != 0.0 && ao->aslo != 1.0) val *= ao->aslo;
|
||||
ao->val = val + ao->aoff;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
@ -52,19 +66,31 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
aoRecord *ao = (aoRecord *) record;
|
||||
|
||||
double val = (INIT_RUN ? ao->val : ao->oval) - ao->aoff;
|
||||
if (ao->aslo != 0.0 && ao->aslo != 1.0) val /= ao->aslo;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_DOUBLE:
|
||||
{
|
||||
double val;
|
||||
if (INIT_RUN) val = ao->val;
|
||||
else val = ao->oval;
|
||||
val -= ao->aoff;
|
||||
if (ao->aslo != 0) val /= ao->aslo;
|
||||
return streamPrintf (record, format, val);
|
||||
}
|
||||
case DBF_ULONG:
|
||||
{
|
||||
if (ao->linr == menuConvertNO_CONVERSION)
|
||||
{
|
||||
/* allow integers with more than 32 bits */
|
||||
return streamPrintf (record, format, (unsigned long)val);
|
||||
}
|
||||
return streamPrintf (record, format, (unsigned long)ao->rval);
|
||||
}
|
||||
case DBF_LONG:
|
||||
{
|
||||
if (ao->linr == menuConvertNO_CONVERSION)
|
||||
{
|
||||
/* allow integers with more than 32 bits */
|
||||
return streamPrintf (record, format, (long)val);
|
||||
}
|
||||
return streamPrintf (record, format, (long)ao->rval);
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,9 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <biRecord.h>
|
||||
#include <string.h>
|
||||
#include <biRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -30,6 +30,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
@ -69,6 +70,7 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
return streamPrintf (record, format, bi->rval);
|
||||
|
@ -18,9 +18,9 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <boRecord.h>
|
||||
#include <string.h>
|
||||
#include <boRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -30,6 +30,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
@ -70,6 +71,7 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
return streamPrintf (record, format, bo->rval);
|
||||
|
@ -17,9 +17,9 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <postfix.h>
|
||||
#include <calcoutRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -32,13 +32,17 @@ static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
return streamScanf (record, format, &co->val);
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
long lval;
|
||||
|
||||
if (streamScanf (record, format, &lval)) return ERROR;
|
||||
if (format->type == DBF_LONG)
|
||||
co->val = lval;
|
||||
else
|
||||
co->val = (unsigned long)lval;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
@ -55,8 +59,12 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
return streamPrintf (record, format, co->oval);
|
||||
}
|
||||
case DBF_LONG:
|
||||
case DBF_ULONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
return streamPrintf (record, format, (unsigned long)co->oval);
|
||||
}
|
||||
case DBF_LONG:
|
||||
{
|
||||
return streamPrintf (record, format, (long)co->oval);
|
||||
}
|
||||
|
@ -18,21 +18,26 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <longinRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
longinRecord *li = (longinRecord *) record;
|
||||
|
||||
if (format->type == DBF_LONG || format->type == DBF_ENUM)
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
long val;
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
li->val = val;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
@ -40,8 +45,12 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
longinRecord *li = (longinRecord *) record;
|
||||
|
||||
if (format->type == DBF_LONG || format->type == DBF_ENUM)
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_ENUM:
|
||||
return streamPrintf (record, format, (unsigned long)li->val);
|
||||
case DBF_LONG:
|
||||
return streamPrintf (record, format, (long)li->val);
|
||||
}
|
||||
return ERROR;
|
||||
|
@ -19,21 +19,26 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <longoutRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
longoutRecord *lo = (longoutRecord *) record;
|
||||
|
||||
if (format->type == DBF_LONG || format->type == DBF_ENUM)
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
long val;
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
lo->val = val;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
@ -41,8 +46,12 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
longoutRecord *lo = (longoutRecord *) record;
|
||||
|
||||
if (format->type == DBF_LONG || format->type == DBF_ENUM)
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_ENUM:
|
||||
return streamPrintf (record, format, (unsigned long)lo->val);
|
||||
case DBF_LONG:
|
||||
return streamPrintf (record, format, (long)lo->val);
|
||||
}
|
||||
return ERROR;
|
||||
|
@ -19,16 +19,16 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <mbbiDirectRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
mbbiDirectRecord *mbbiD = (mbbiDirectRecord *) record;
|
||||
long val;
|
||||
unsigned long val;
|
||||
|
||||
if (format->type == DBF_LONG)
|
||||
if (format->type == DBF_ULONG || format->type == DBF_LONG)
|
||||
{
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
if (mbbiD->mask)
|
||||
@ -40,7 +40,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
else
|
||||
{
|
||||
/* No MASK, (NOBT = 0): use VAL field */
|
||||
mbbiD->val = (short)val;
|
||||
mbbiD->val = (unsigned short)val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
}
|
||||
@ -50,9 +50,9 @@ static long readData (dbCommon *record, format_t *format)
|
||||
static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
mbbiDirectRecord *mbbiD = (mbbiDirectRecord *) record;
|
||||
long val;
|
||||
unsigned long val;
|
||||
|
||||
if (format->type == DBF_LONG)
|
||||
if (format->type == DBF_ULONG || format->type == DBF_LONG)
|
||||
{
|
||||
if (mbbiD->mask) val = mbbiD->rval & mbbiD->mask;
|
||||
else val = mbbiD->val;
|
||||
|
@ -19,19 +19,20 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <mbbiRecord.h>
|
||||
#include <string.h>
|
||||
#include <mbbiRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
mbbiRecord *mbbi = (mbbiRecord *) record;
|
||||
long val;
|
||||
unsigned long val;
|
||||
int i;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
|
@ -19,16 +19,17 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <mbboDirectRecord.h>
|
||||
#include "alarm.h"
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
mbboDirectRecord *mbboD = (mbboDirectRecord *) record;
|
||||
long val;
|
||||
unsigned long val;
|
||||
|
||||
if (format->type == DBF_LONG)
|
||||
if (format->type == DBF_ULONG || format->type == DBF_LONG)
|
||||
{
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
if (mbboD->mask)
|
||||
@ -53,7 +54,7 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
mbboDirectRecord *mbboD = (mbboDirectRecord *) record;
|
||||
long val;
|
||||
|
||||
if (format->type == DBF_LONG)
|
||||
if (format->type == DBF_ULONG || format->type == DBF_LONG)
|
||||
{
|
||||
if (mbboD->mask) val = mbboD->rval & mbboD->mask;
|
||||
else val = mbboD->val;
|
||||
@ -67,9 +68,27 @@ static long initRecord (dbCommon *record)
|
||||
mbboDirectRecord *mbboD = (mbboDirectRecord *) record;
|
||||
|
||||
mbboD->mask <<= mbboD->shft;
|
||||
|
||||
/* Workaround for bug in mbboDirect record:
|
||||
Put to VAL overwrites value to 0 if SEVR is INVALID_ALARM
|
||||
Thus first write may send a wrong value.
|
||||
*/
|
||||
mbboD->sevr = 0;
|
||||
return streamInitRecord (record, &mbboD->out, readData, writeData);
|
||||
}
|
||||
|
||||
/* Unfortunately the bug also corrupts the next write to VAL after an I/O error.
|
||||
Thus make sure the record is never left in INVALID_ALARM status.
|
||||
*/
|
||||
|
||||
static long write(dbCommon *record)
|
||||
{
|
||||
long status = streamWrite(record);
|
||||
if (record->nsev == INVALID_ALARM) record->nsev = MAJOR_ALARM;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
@ -83,7 +102,7 @@ struct {
|
||||
streamInit,
|
||||
initRecord,
|
||||
streamGetIointInfo,
|
||||
streamWrite
|
||||
write
|
||||
};
|
||||
|
||||
epicsExportAddress(dset,devmbboDirectStream);
|
||||
|
@ -19,19 +19,20 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <mbboRecord.h>
|
||||
#include <string.h>
|
||||
#include <mbboRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
{
|
||||
mbboRecord *mbbo = (mbboRecord *) record;
|
||||
long val;
|
||||
unsigned long val;
|
||||
int i;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
if (streamScanf (record, format, &val)) return ERROR;
|
||||
@ -76,11 +77,12 @@ static long readData (dbCommon *record, format_t *format)
|
||||
static long writeData (dbCommon *record, format_t *format)
|
||||
{
|
||||
mbboRecord *mbbo = (mbboRecord *) record;
|
||||
long val;
|
||||
unsigned long val;
|
||||
int i;
|
||||
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
{
|
||||
/* print VAL or RVAL ? */
|
||||
|
@ -18,8 +18,8 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <stringinRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
|
@ -18,8 +18,8 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <stringoutRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
|
@ -18,10 +18,10 @@
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
#include "devStream.h"
|
||||
#include <waveformRecord.h>
|
||||
#include <string.h>
|
||||
#include <errlog.h>
|
||||
#include <waveformRecord.h>
|
||||
#include "devStream.h"
|
||||
#include <epicsExport.h>
|
||||
|
||||
static long readData (dbCommon *record, format_t *format)
|
||||
@ -57,6 +57,7 @@ static long readData (dbCommon *record, format_t *format)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
@ -191,6 +192,7 @@ static long writeData (dbCommon *record, format_t *format)
|
||||
return ERROR;
|
||||
break;
|
||||
}
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
|
@ -2,6 +2,7 @@ if (@ARGV[0] == "-3.13") {
|
||||
shift;
|
||||
} else {
|
||||
print "variable(streamDebug, int)\n";
|
||||
print "variable(streamError, int)\n";
|
||||
print "registrar(streamRegistrar)\n";
|
||||
}
|
||||
print "driver(stream)\n";
|
||||
|
@ -91,7 +91,7 @@ proc receiveHandler {sock} {
|
||||
"start" {
|
||||
set wait [checkNum [lindex $l 1]]
|
||||
set ::counter 0
|
||||
after $wait sendAsync $wait [list [lrange $l 2 end-1]]
|
||||
after $wait [list sendAsync $wait "[string range $a [string wordend $a 7] end]"]
|
||||
sendReply $sock "Started\n"
|
||||
}
|
||||
"stop" {
|
||||
@ -133,7 +133,7 @@ proc receiveHandler {sock} {
|
||||
proc sendAsync {wait message} {
|
||||
if {$::counter < 0} return
|
||||
foreach term [array names ::socket] {
|
||||
sendReply $::socket($term) "Message number [incr ::counter] $message\n";
|
||||
sendReply $::socket($term) "Message number [incr ::counter]$message";
|
||||
}
|
||||
after $wait sendAsync $wait [list $message]
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ proc startioc {} {
|
||||
if [info exists asynversion] {
|
||||
puts $fd "require asyn,$asynversion"
|
||||
}
|
||||
puts $fd "require stream2,$streamversion"
|
||||
puts $fd "require stream,$streamversion"
|
||||
} else {
|
||||
puts $fd "#!../O.$env(EPICS_HOST_ARCH)/streamApp"
|
||||
puts $fd "dbLoadDatabase ../O.Common/streamApp.dbd"
|
||||
@ -77,7 +77,9 @@ proc startioc {} {
|
||||
}
|
||||
fconfigure $ioc -blocking yes -buffering none
|
||||
debugmsg "waiting to connect"
|
||||
set timer [after 1000 {puts stderr "\033\[31;7mCannot start IOC.\033\[0m"; exit 1}]
|
||||
vwait sock
|
||||
after cancel $timer
|
||||
}
|
||||
|
||||
set lastcommand ""
|
||||
|
@ -41,12 +41,10 @@ set protocol {
|
||||
set startup {
|
||||
}
|
||||
|
||||
set debug 0
|
||||
|
||||
startioc
|
||||
|
||||
set inf [format %f inf]
|
||||
set nan [format %f nan]
|
||||
if [catch {set nan [format %f nan]}] {set nan nan}
|
||||
|
||||
ioccmd {dbpf DZ:test1.PROC 1}
|
||||
send "3.14159265359\n"
|
||||
|
@ -50,7 +50,7 @@ set protocol {
|
||||
in {in "%{zero|one|two}bla"; out "%d";}
|
||||
out1 {out "%#{zero|one|two}bla";}
|
||||
in1 {in "%#{zero|one|two}bla"; out "%d";}
|
||||
out2 {out "%#{zero=-1|one|two=5}bla";}
|
||||
out2 {out "%#{zero=-1|one|two=5|default=?}bla";}
|
||||
in2 {in "%#{zero=-1|one|two=5}bla"; out "%d";}
|
||||
in3 {in "%{\x00|\r|}bla"; out "%d";}
|
||||
}
|
||||
@ -81,6 +81,8 @@ ioccmd {dbpf DZ:testout2 0}
|
||||
assure "onebla\n"
|
||||
ioccmd {dbpf DZ:testout2 5}
|
||||
assure "twobla\n"
|
||||
ioccmd {dbpf DZ:testout2 17}
|
||||
assure "defaultbla\n"
|
||||
|
||||
ioccmd {dbpf DZ:testin.PROC 1}
|
||||
send "zerobla\n"
|
||||
|
@ -68,15 +68,15 @@ ioccmd {dbpf DZ:lo 12345}
|
||||
assure "12345 12345 012345 3039 003039 11000000111001 11000000111001 111001 !!......!!!..! !!......!!!..!\n"
|
||||
ioccmd {dbpf DZ:lo -1}
|
||||
if {$tcl_platform(machine) == "x86_64"} {
|
||||
assure "-1 -1 -00001 ffffffffffffffff FFFFFFFFFFFFFFFF 1111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111 111111 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
||||
assure "-1 -1 -00001 ffffffffffffffff FFFFFF 11111111111111111111111111111111 11111111111111111111111111111111 111111 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
||||
} else {
|
||||
assure "-1 -1 -00001 ffffffff FFFFFFFF 11111111111111111111111111111111 11111111111111111111111111111111 111111 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
||||
assure "-1 -1 -00001 ffffffff FFFFFF 11111111111111111111111111111111 11111111111111111111111111111111 111111 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
||||
}
|
||||
ioccmd {dbpf DZ:lo -1234}
|
||||
if {$tcl_platform(machine) == "x86_64"} {
|
||||
assure "-1234 -1234 -01234 fffffffffffffb2e FFFFFFFFFFFFFB2E 1111111111111111111111111111111111111111111111111111101100101110 1111111111111111111111111111111111111111111111111111101100101110 101110 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.!!..!.!!!. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.!!..!.!!!.\n"
|
||||
assure "-1234 -1234 -01234 fffffffffffffb2e FFFB2E 11111111111111111111101100101110 11111111111111111111101100101110 101110 !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!. !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!.\n"
|
||||
} else {
|
||||
assure "-1234 -1234 -01234 fffffb2e FFFFFB2E 11111111111111111111101100101110 11111111111111111111101100101110 101110 !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!. !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!.\n"
|
||||
assure "-1234 -1234 -01234 fffffb2e FFFB2E 11111111111111111111101100101110 11111111111111111111101100101110 101110 !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!. !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!.\n"
|
||||
}
|
||||
ioccmd {dbpf DZ:lo 255}
|
||||
assure "255 255 000255 ff 0000FF 11111111 11111111 111111 !!!!!!!! !!!!!!!!\n"
|
||||
|
@ -10,16 +10,19 @@ set records {
|
||||
record (ai, "DZ:test1")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (LINR, "LINEAR")
|
||||
field (INP, "@test.proto test1 device")
|
||||
}
|
||||
record (ai, "DZ:test2")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (LINR, "LINEAR")
|
||||
field (INP, "@test.proto test2 device")
|
||||
}
|
||||
record (ai, "DZ:test3")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (LINR, "LINEAR")
|
||||
field (INP, "@test.proto test3 device")
|
||||
}
|
||||
record (ai, "DZ:test4")
|
||||
@ -30,26 +33,31 @@ set records {
|
||||
record (ai, "DZ:test5")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (LINR, "LINEAR")
|
||||
field (INP, "@test.proto test5 device")
|
||||
}
|
||||
record (ai, "DZ:test6")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (LINR, "LINEAR")
|
||||
field (INP, "@test.proto test6 device")
|
||||
}
|
||||
record (ai, "DZ:test7")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (LINR, "LINEAR")
|
||||
field (INP, "@test.proto test7 device")
|
||||
}
|
||||
record (ai, "DZ:test8")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (LINR, "LINEAR")
|
||||
field (INP, "@test.proto test8 device")
|
||||
}
|
||||
record (ai, "DZ:test9")
|
||||
{
|
||||
field (DTYP, "stream")
|
||||
field (LINR, "LINEAR")
|
||||
field (INP, "@test.proto test9 device")
|
||||
}
|
||||
record (ai, "DZ:test10")
|
||||
|
@ -53,13 +53,22 @@ int main () {
|
||||
}
|
||||
EOF
|
||||
|
||||
g++ -I ../../src ../../src/O.$EPICS_HOST_ARCH/StreamBuffer.o test.cc -o test.exe
|
||||
if [ "$1" = "-sls" ]
|
||||
then
|
||||
O=../../O.*_$EPICS_HOST_ARCH/StreamBuffer.o
|
||||
else
|
||||
O=../../src/O.$EPICS_HOST_ARCH/StreamBuffer.o
|
||||
fi
|
||||
|
||||
for o in $O
|
||||
do
|
||||
g++ -I ../../src $o test.cc -o test.exe
|
||||
test.exe
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo -e "\033[31;7mTest failed.\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
rm test.*
|
||||
echo -e "\033[32mTest passed.\033[0m"
|
||||
|
Reference in New Issue
Block a user