hci_pd_deliver
The usage for this command is hci_pd_deliver
data code
(code
is required and usually
0). Data must not contain nulls.
This is used in lieu of the hci_pd_accept command to return data and a code, usually 0, to the system engine. If this command is used, then the data in the inbound buffer must be exhausted by the hci_pd_ignore command.
hci_pd_ignore_input
hci_pd_ignore_input len
hci_pd_ignore_input -all
hci_pd_ignore_input -until target
This discards input from the beginning of the input buffer. Specify the amount of data to discard in one of these ways:
- A fixed-length prefix is discarded.
- All of the input is discarded.
- All of the input up to, but not including the character target, is discarded.
The possible formats for the target argument are a single, non-backslash character by itself. It can also be a backslash followed by a number (0-prefix for octal, x-prefix for hex).
These targets are equivalent:
- A
- \0101
- \x41
- \65
Currently, these are the only character formats understood by the third form of hci_pd_ignore_input.
Discarding input changes the data underlying regions of the input buffer. Because field extents are represented as input regions, using this command changes the data underlying a particular region.
For example, suppose you have recognized a message and therefore know that
field foo
happens in region {5 5}
of the input. If the first three characters of the input are
discarded using any of this command’s forms, then the field now happens in region
{2 5}
of the input.
If an attempt is made to access the contents of field foo
without taking into account the discarded prefix, then the
incorrect data is given.
This function returns the amount of data that remains in the input
buffer. In the case of the -all
option, zero (0)
returns.
If the amount to discard is more than exists in the input buffer, then the system discards the entire input buffer and does not signal an error (zero returns).
This might happen, for example, if the target specified with the
-until
option does not happen in the input
buffer. It could also happen if len is greater than the amount of data in the
buffer.
Examples
These examples show the common uses of hci_pd_ignore_input.
To discard all the buffered input when a failure to match any phrase happens:
proc hci_pd.read {info} {
hci_pd_receive {... {no-match forget-it}}
}
proc forget-it {info} {
hci_pd_ignore_input -all
}
To scan for a recognizable start-of-message character when a phrase-match failure happens:
define phrase foo;
"[";
field data = variable-array\
(or(letter,digit,<cr>;));
"]";
end phrase;
proc hci_pd.read {info} {
hci_pd_receive {... {no-match bummer}}
}
proc bummer {info} {
hci_pd_ignore_input -until {[} }