op_sar_seg_create_vvec()
Abstract
Creates a new segment whose content is a value vector.
Syntax
op_sar_seg_create_vvec (value_vector, bitrange_list)
| Argument | Type | Description |
|---|---|---|
value_vector |
Vvec_Vector* |
value vector to be used as the bit contents of a segment [Places the value vector into a newly created segment.] |
bitrange_list |
List* |
list of bit-ranges for the bit contents of the segment [The list must consist of bit-ranges that define the packet ownership of the bits in the value vector.] |
Return Type
Packet*
Pointer to a newly created segment containing the value vector as its bit content.
Example
/* When enough bits have been received from the external system to */
/* reconstruct a segment, recreate the SAR segment. */
op_esys_port_vector_get (op_intrpt_esys_port (), vector, OPC_VVEC_VECTOR_END);
/* segments are 384 bits in length. */
if (op_vvec_size_get (vector) == 384)
{
/* all bits are present. */
/* use the bitrange list previously */
/* stored as the 'table of contents' */
/* for the bits of the segment being */
/* created. */
segpk_ptr = op_sar_seg_create_vvec (vector, bitrange_list_ptr);
/* send the segment to higher layer for */
/* reassembly. */
op_pk_send (segpk_ptr, 0);
}
Details
The segment created by this KP, when queried, identifies itself as a segment packet. Also, when passed as an argument to the KP op_pk_type(), the segment identifies itself as a value vector packet. Segments created with this KP may be inserted into other buffers and may be manipulated in the same way as any other Sar segment.
The value vector passed as an argument to op_sar_seg_create_vvec() must be of type bit. The size of the value vector passed as an argument must equal the sum of the “count” properties of each of the bit-ranges contained in the bit-range list. Note that the start_bit property of each bit-range does not refer to the starting element in the value vector, but rather the starting bit’s position in the original packet.
Purpose
Provides a mechanism for creating a segment, which may contain non-contiguous bits from the same packets or bits from separate packets.
Errors
- Recoverable Error: Cannot create segment packet due to mismatch between value vector size and bitrange list counts.
- Recoverable Error: Value vector is invalid.
Reference
- Use the KP op_vvec_create() to create a new value vector
- Use the KP op_sar_bitrange_create() to create a new bit-range
- Use the KP op_prg_list_create() to allocate a new, empty list
- Use the KP op_prg_list_insert() to insert a new element into a list