Hello Dehong,
Is your record "I/O Intr"? I assume so because your STATUS protocol does
not have any out command.
In that case and if you set InTerminator = CR LF, you should actually
get 2 messages and the record should be processed twice. Thus at the
end, your record will have the correct value.
Skipping intermediate results is tricky on the protocol level, because
how should StreamDevice know that no more input is about to come? What
if the gap between the messages is sometimes so big, that you actually
get 2 messages?
But In case you really always get a double message as below and want to
read the second value only you can skip the first one:
in "BOS%*d,P=%*dEOS\r\nBOS%d,P=%(otherrecord)dEOS\r\n"
In case you may have an arbitrary number of messages connected and
always want to skip all but the last, things become tricky. I have to
make up a PCRE. The idea is to do a greedy search for everything up to
"BOS" and then read the data. I will send you the PCRE later.
Dirk
On 22.08.2013 21:17, Zhang, Dehong wrote:
Hi Dirk and Friends,
(Sorry if you get this 2 times. I had a wrong address with my previous
send)
I run into 2 little problems: I wait for the hardware to send a
message like
"BOS123456,P=987654EOS\r\n".
Here BOS is my starting label and EOS the ending label.
Due to timing, which I cannot control, sometimes I would receive 2
messages
together, like:
"BOS123456,P=987654EOS\r\nBOS345,P=987649EOS\r\n".
Here the first one was sent when the state was still changing, the
second one
was sent when the state stablizes. But the time in between is so short
that the
2 messages just come out as one. How can I skip the first match, only
get the
second/last match?
My protocal is like:
InTerminator = CR;
OutTerminator = CR LF;
ReplyTimeout = 800;
ReadTimeout = 100;
WriteTimeout = 100;
ExtraInput = Ignore;
# Reports from the controller
STATUS { ReplyTimeout = 50; ReadTimeout = 10; InTerminator =; in
"%.1/BOS([0-9,P=]*EOS)/"; }
I tried to use the "$" anchor, but cannot get it to work -- maybe
because "$" is a special
character in streamdevice.
Related to this, sometimes the time in between is not so short that
the 2 messages
do come out separately, but the time in between is short enough so
that my stringin
record misses the second message. How can I avoid this? Tune the
ReplyTimeout,
ReadTimeout and InTerminator?
Thank you for your advice. Best regards,
Dehong