Hi Christian,
@init is normally used to initialize output records (before EPICS starts
e.g the scan threads). Normally, input records do not need any special
initialization but do the same as during normal operation. Instead of
@init, you may simply use field(PINI,"YES").
That you see the output three times looks like you have already
PINI="YES", correct? Then you see:
1: @init handler
2: PINI run
3: @mismatch handler of the PINI run
Note that your @mismatch handler sends another output. Only if the
@mismatch handler starts with an 'in' command, the previous mismatching
input will be re-parsed. But still the record is INVALID because of the
original failure. This may not be what you want. Also a handler does not
call another handler, thus a failure in @init does not call @mismatch.
Also do not mistake @init as the protocol for the PINI run. @init runs
before PINI (during init_record). PINI on the other hand is a normal
record scanning using the normal protocol.
The different type of replies make the situation complicated. So if I
understand right, you get either 3 bytes + float + byte + checksum or
EOT (0x04)?
In the current version, StreamDevice can handle non-existing fields
using %?... (which return 0 if there is no matching input).
Thus you can try something like this:
readSegDuration {
out 0x04 0x30 0x30 0x31 0x31 0x64, "\$1", 0x05;
in "%*{\x04|\?\?\?}%?f%*?c%?1.0<xor>";
}
This reads first either a EOT or three arbitrary characters, then it
reads a floating point number if there is any, then a byte if there is
any and then the checksum if there is any. Thus when it gets only a 0x04
byte, it will initialize the record to 0.
Can you give some examples of the input strings (with explanation)? Does
the device use terminators or fixed-length strings?
Best regards,
Dirk
On 01.04.2013 19:00, Christian Roehrig wrote:
Hello,
I have a temperature controller that can run an 8 segment program. Each segment can have the type ramp, dwell, or end. Depending on the segment type querying the ramp rate, dwell duration, or end action may return a valid response or it may return just a EOT character. When the ioc boots, I want the records to rea in the current parameter values, so I use the @INIT protocol. However, when the parameter is not currently valid because of the segment type, the record fails to initialize properly. Here is an example of on of the protocols I use.
readSegDuration {
out 0x04 0x30 0x30 0x31 0x31 0x64, "\$1", 0x05;
in "%*c%*c%*c%f%*c%1.0<xor>";
@init {
out 0x04 0x30 0x30 0x31 0x31 0x64, "\$1", 0x05;
in "%*c%*c%*c%f%*c%1.0<xor>";
}
@mismatch {
out 0x04 0x30 0x30 0x31 0x31 0x64, "\$1", 0x05;
in 0x04;
}
}
Here is the output at the ioc prompt.
2013/04/01 11:37:31.170 /dev/ttyS0 write 8
0011d8
04 30 30 31 31 64 38 05
2013/04/01 11:37:31.195 /dev/ttyS0 read 1
04
2013/04/01 11:37:31.495 L0 2dev:ET2k:1:ReadSeg8Dur: Input "" does not match format %f
2013/04/01 11:37:31.495 /dev/ttyS0 write 8
0011d8
04 30 30 31 31 64 38 05
2013/04/01 11:37:31.520 /dev/ttyS0 read 1
04
2013/04/01 11:37:31.820 _main_ 2dev:ET2k:1:ReadSeg8Dur: @init handler failed
2013/04/01 11:37:31.820 _main_ 2dev:ET2k:1:ReadSeg8Dur: Record initialization failed
2013/04/01 11:37:31.820 /dev/ttyS0 write 8
0011d8
04 30 30 31 31 64 38 05
2013/04/01 11:37:31.838 /dev/ttyS0 read 1
04
So it looks like it sends out the command to read the duration parameter (0011d8) and reads back the EOT character, which fails to match the expected input. It then sends the command again and gets the same response, which causes record initialization to fail. Then for some reason, the command is sent a third time.
My question is, can Stream Device handle a situation like this? If so, how should I change my protocol? Would it be better to remove the @INIT section and included a manual "Init" PV with a sequence record that could cause all of the other records to process once after iocInit completes?
Chris Roehrig
- References:
- Stream Device errors and record initialization Christian Roehrig
- Navigate by Date:
- Prev:
EPICS Qt Framework SVN repository Ricardo Fernandes
- Next:
Tektronix DMM 4050 device support Pavel Maslov
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
<2013>
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Stream Device errors and record initialization Christian Roehrig
- Next:
EPICS device driver support for Tektronix AFG3000C Tang, Johnny Y.
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
<2013>
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|