op_strm_connected()
Abstract
Determines if the specified input or output stream of the surrounding processor is attached to a packet stream object.
Syntax
op_strm_connected (strm_type, strm_index)
| Argument | Type | Description |
|---|---|---|
strm_type |
int |
type of the stream-of-interest [This value is a numeric code which indicates the type of the stream-of-interest (see Table 82 “Stream Type Symbolic Constants“ on page 25); acceptable symbolic constants for this argument are OPC_STRM_IN and OPC_STRM_OUT.] |
strm_index |
int |
numeric index of the input or output stream-of-interest [Stream indices start at 0 and increment by one. There is no upper bound on these indices, but conservation of memory is achieved if they are utilized in a contiguous manner. A value which is negative, or greater than the largest allocated input or output stream index will cause an error.] |
Return Type
Boolean
Boolean value indicating whether the specified stream index is occupied by a packet stream. The returned value is OPC_TRUE if the specified stream is connected, OPC_FALSE otherwise.
Example
/** loop through all input streams, generating an access interrupt for each **/
/* determine the number of allocated input streams */
alloc_instrms = op_strm_max_index_in ();
/* loop through each allocated stream */
for (i = 0; i <= alloc_intstrms; i++)
{
/* if an input stream is connected, and... */
if (op_strm_connected (OPC_STRM_IN, i) == OPC_TRUE)
{
/* if an input stream is connected, access a packet from the source module. */
op_strm_access (i);
/* Collect and forward the packet onto the bus, if one was obtained. */
if (op_strm_empty (i) == OPC_FALSE)
op_pk_send (op_pk_get (i), OUTSTRM_BUS);
}
}
Details
The input and output streams of modules can be connected together, or left unoccupied. In addition, input and output streams may be sparsely connected. As an example, a processor can have four allocated input streams, with only streams 1 and 3 connected. The status of an input or output stream, in terms of being connected, can be determined using this KP.
Out-of-range or negative stream indices will be interpreted as unoccupied inputs and this KP will accordingly return the constant OPC_FALSE, but no error messages will be generated.
Purpose
Provides a mechanism for a process to distinguish between connected and unconnected streams belonging to the surrounding processor or queue. This is important when a certain operation has to be done for every connected input or output stream. A process can loop through all allocated input or output streams (using the KPs op_strm_max_index_in() and op_strm_max_index_out() to determine the loop bounds), and only perform such an operation on those streams that prove to be connected.
Errors
- Program Abort: KP requires process context.
Reference
- Use the KP op_strm_max_index_in() to determine the highest index input stream a module has
- Use the KP op_strm_max_index_out() to determine the highest index output stream a module has
- Use the KP op_strm_access() to force an access interrupt for a stream's source module