CORDET Framework - C2 Implementation
|
Interface for creating and accessing a report or command packet. More...
Go to the source code of this file.
Functions | |
CrFwPckt_t | CrFwPcktMake (CrFwPcktLength_t pcktLength) |
Make function for command or report packets. More... | |
void | CrFwPcktRelease (CrFwPckt_t pckt) |
Release function for command or report packets. More... | |
CrFwBool_t | CrFwPcktIsAvail (CrFwPcktLength_t pcktLength) |
Check whether a packet of a specified length is available. More... | |
CrFwCounterU2_t | CrFwPcktGetNOfAllocated () |
Return the number of packets which are currently allocated. More... | |
CrFwPcktLength_t | CrFwPcktGetMaxLength () |
Return the maximum length of a packet in number of bytes. More... | |
CrFwCmdRepType_t | CrFwPcktGetCmdRepType (CrFwPckt_t pckt) |
Return the type of a packet (either a command packet or a report packet). More... | |
void | CrFwPcktSetCmdRepType (CrFwPckt_t pckt, CrFwCmdRepType_t type) |
Set the type of a packet (either a command packet or a report packet). More... | |
CrFwPcktLength_t | CrFwPcktGetLength (CrFwPckt_t pckt) |
Return the length (in number of bytes) of a packet. More... | |
CrFwSeqCnt_t | CrFwPcktGetSeqCnt (CrFwPckt_t pckt) |
Return the sequence counter of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetSeqCnt (CrFwPckt_t pckt, CrFwSeqCnt_t seqCnt) |
Set the sequence counter of the command or report encapsulated in a packet. More... | |
CrFwTimeStamp_t | CrFwPcktGetTimeStamp (CrFwPckt_t pckt) |
Return the time stamp of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetTimeStamp (CrFwPckt_t pckt, CrFwTimeStamp_t timeStamp) |
Set the time stamp of the command or report encapsulated in a packet. More... | |
CrFwDiscriminant_t | CrFwPcktGetDiscriminant (CrFwPckt_t pckt) |
Return the discriminant of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetDiscriminant (CrFwPckt_t pckt, CrFwDiscriminant_t discriminant) |
Set the discriminant of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetServType (CrFwPckt_t pckt, CrFwServType_t servType) |
Set the service type of the command or report encapsulated in a packet. More... | |
CrFwServType_t | CrFwPcktGetServType (CrFwPckt_t pckt) |
Return the service type of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetServSubType (CrFwPckt_t pckt, CrFwServSubType_t servSubType) |
Set the service sub-type of the command or report encapsulated in a packet. More... | |
CrFwServSubType_t | CrFwPcktGetServSubType (CrFwPckt_t pckt) |
Return the service sub-type of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetGroup (CrFwPckt_t pckt, CrFwGroup_t group) |
Set the group of the command/report encapsulated in a packet. More... | |
CrFwGroup_t | CrFwPcktGetGroup (CrFwPckt_t pckt) |
Return the group of the command/report encapsulated in a packet. More... | |
void | CrFwPcktSetDest (CrFwPckt_t pckt, CrFwDestSrc_t dest) |
Set the destination of the command or report encapsulated in a packet. More... | |
CrFwDestSrc_t | CrFwPcktGetDest (CrFwPckt_t pckt) |
Return the destination of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetSrc (CrFwPckt_t pckt, CrFwDestSrc_t src) |
Set the source of the command or report encapsulated in a packet. More... | |
CrFwDestSrc_t | CrFwPcktGetSrc (CrFwPckt_t pckt) |
Return the source of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetCmdRepId (CrFwPckt_t pckt, CrFwInstanceId_t id) |
Set the command or report identifier in the command or report encapsulated in a packet. More... | |
CrFwInstanceId_t | CrFwPcktGetCmdRepId (CrFwPckt_t pckt) |
Return the command or report identifier of the command or report encapsulated in a packet. More... | |
CrFwCrc_t | CrFwPcktComputeCrc (CrFwPckt_t pckt) |
Compute the CRC in the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetCrc (CrFwPckt_t pckt, CrFwCrc_t crc) |
Set the CRC in the command or report encapsulated in a packet. More... | |
CrFwCrc_t | CrFwPcktGetCrc (CrFwPckt_t pckt) |
Return the CRC of the command or report encapsulated in a packet. More... | |
void | CrFwPcktSetAckLevel (CrFwPckt_t pckt, CrFwBool_t accept, CrFwBool_t start, CrFwBool_t progress, CrFwBool_t term) |
Set the acknowledge level for the command encapsulated in a packet. More... | |
CrFwBool_t | CrFwPcktIsAcceptAck (CrFwPckt_t pckt) |
Return the acknowledge level for command acceptance for the command encapsulated in the packet. More... | |
CrFwBool_t | CrFwPcktIsStartAck (CrFwPckt_t pckt) |
Return the acknowledge level for command start for the command encapsulated in the packet. More... | |
CrFwBool_t | CrFwPcktIsProgressAck (CrFwPckt_t pckt) |
Return the acknowledge level for command progress for the command encapsulated in the packet. More... | |
CrFwBool_t | CrFwPcktIsTermAck (CrFwPckt_t pckt) |
Return the acknowledge level for command termination for the command encapsulated in the packet. More... | |
CrFwPckt_t | CrFwPcktGetParStart (CrFwPckt_t pckt) |
Return the start address of the packet's parameter area. More... | |
CrFwPcktLength_t | CrFwPcktGetParLength (CrFwPckt_t pckt) |
Return the length in bytes of the packet's parameter area. More... | |
Interface for creating and accessing a report or command packet.
An application instantiated from the CORDET Framework interacts with other framework applications by exchanging with them commands and reports. When commands and reports travel from one application to another, they take the form of packets.
A packet is an ordered sequence of bytes which contain all the information required to reconstruct a report or a command. Although the exact layout of packets is not defined at framework level, the framework defines, through this header file, an interface for creating and accessing the data in a packet.
This interface defines a packet factory, namely a function which allows a new packet to be created and an existing packet to be released.
A packet encapsulates either a command or a report. This interface defines functions through which the attributes of the encapsulated command or report can be retrieved from a packet or can be set in a packet. For attributes other than the command or report parameters, getter and setter functions are defined. For the command or report parameters, getter functions are provided which return: the start address of the parameter area of the packet and its size. The parameter area is the part of a packet which is reserved to the storage of the parameters of the command or report encapsulated by the packet.
In general, the implementation of this interface is entirely application-specific but a simple default implementation is provided in CrFwPckt.c
. This default implementation is primarily intended for testing and demonstration purposes.
This file is part of the CORDET Framework.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
For information on alternative licensing, please contact P&P Software GmbH.
Definition in file CrFwPckt.h.
CrFwCrc_t CrFwPcktComputeCrc | ( | CrFwPckt_t | pckt | ) |
Compute the CRC in the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 247 of file CrFwPckt.c.
CrFwInstanceId_t CrFwPcktGetCmdRepId | ( | CrFwPckt_t | pckt | ) |
Return the command or report identifier of the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 339 of file CrFwPckt.c.
CrFwCmdRepType_t CrFwPcktGetCmdRepType | ( | CrFwPckt_t | pckt | ) |
Return the type of a packet (either a command packet or a report packet).
pckt | the packet |
Definition at line 211 of file CrFwPckt.c.
CrFwCrc_t CrFwPcktGetCrc | ( | CrFwPckt_t | pckt | ) |
Return the CRC of the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 263 of file CrFwPckt.c.
CrFwDestSrc_t CrFwPcktGetDest | ( | CrFwPckt_t | pckt | ) |
Return the destination of the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 315 of file CrFwPckt.c.
CrFwDiscriminant_t CrFwPcktGetDiscriminant | ( | CrFwPckt_t | pckt | ) |
Return the discriminant of the command or report encapsulated in a packet.
Not all commands and reports have a discriminant field. If the argument packet holds a command or report which does not have a discriminant field, the behaviour of this function is undefined.
pckt | the packet. |
Definition at line 273 of file CrFwPckt.c.
CrFwGroup_t CrFwPcktGetGroup | ( | CrFwPckt_t | pckt | ) |
Return the group of the command/report encapsulated in a packet.
pckt | the packet. |
Definition at line 398 of file CrFwPckt.c.
CrFwPcktLength_t CrFwPcktGetLength | ( | CrFwPckt_t | pckt | ) |
Return the length (in number of bytes) of a packet.
pckt | the packet. |
Definition at line 206 of file CrFwPckt.c.
CrFwPcktLength_t CrFwPcktGetMaxLength | ( | ) |
Return the maximum length of a packet in number of bytes.
Some implementation may restrict the maximum length of a packet. This function allows this maximum length to be retrieved. If the function returns a value of zero, then no restriction on the length of a packet is defined by the implementation.
Definition at line 201 of file CrFwPckt.c.
CrFwCounterU2_t CrFwPcktGetNOfAllocated | ( | ) |
Return the number of packets which are currently allocated.
This function returns the number of packets which have been successfully allocated through calls to CrFwPcktMake
and have not yet been released through calls to CrFwPcktRelease
.
Definition at line 196 of file CrFwPckt.c.
CrFwPcktLength_t CrFwPcktGetParLength | ( | CrFwPckt_t | pckt | ) |
Return the length in bytes of the packet's parameter area.
The parameter area is the part of a packet which is reserved to the storage of the parameters of the command or report encapsulated by the packet. The parameter area consists of an uninterrupted sequence of bytes. The start address of the parameter area is returned by function CrFwPcktGetParStart
.
pckt | a packet encapsulating a command or a report. |
Definition at line 387 of file CrFwPckt.c.
CrFwPckt_t CrFwPcktGetParStart | ( | CrFwPckt_t | pckt | ) |
Return the start address of the packet's parameter area.
The parameter area is the part of a packet which is reserved to the storage of the parameters of the command or report encapsulated by the packet. The parameter area consists of an uninterrupted sequence of bytes. The size of the parameter area is returned by function CrFwPcktGetParLength
.
pckt | a packet encapsulating a command or a report. |
Definition at line 382 of file CrFwPckt.c.
CrFwSeqCnt_t CrFwPcktGetSeqCnt | ( | CrFwPckt_t | pckt | ) |
Return the sequence counter of the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 223 of file CrFwPckt.c.
CrFwServSubType_t CrFwPcktGetServSubType | ( | CrFwPckt_t | pckt | ) |
Return the service sub-type of the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 303 of file CrFwPckt.c.
CrFwServType_t CrFwPcktGetServType | ( | CrFwPckt_t | pckt | ) |
Return the service type of the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 291 of file CrFwPckt.c.
CrFwDestSrc_t CrFwPcktGetSrc | ( | CrFwPckt_t | pckt | ) |
Return the source of the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 327 of file CrFwPckt.c.
CrFwTimeStamp_t CrFwPcktGetTimeStamp | ( | CrFwPckt_t | pckt | ) |
Return the time stamp of the command or report encapsulated in a packet.
pckt | the packet. |
Definition at line 235 of file CrFwPckt.c.
CrFwBool_t CrFwPcktIsAcceptAck | ( | CrFwPckt_t | pckt | ) |
Return the acknowledge level for command acceptance for the command encapsulated in the packet.
If the packet does not hold a command, the behaviour of the function is undefined.
pckt | a packet encapsulating a command. |
Definition at line 358 of file CrFwPckt.c.
CrFwBool_t CrFwPcktIsAvail | ( | CrFwPcktLength_t | pcktLength | ) |
Check whether a packet of a specified length is available.
A packet of length L is available if a call to function CrFwPcktMake
with argument L would return a non-NULL value. Applications typically implement the CrFwPckt.h
interface to manage a pool of pre-allocated memory from which packets are allocated using function CrFwPcktMake
and are released using function CrFwPcktRelease
. This function does not change the state of the pool from which the packets are allocated. It only verifies whether the allocation of a packet of a given length would be possible at the time the function is called.
The packet length must be a positive integer. If a negative or a zero value is used, the function returns false.
pcktLength | the length of the packet in bytes (a positive integer) |
Definition at line 176 of file CrFwPckt.c.
CrFwBool_t CrFwPcktIsProgressAck | ( | CrFwPckt_t | pckt | ) |
Return the acknowledge level for command progress for the command encapsulated in the packet.
If the packet does not hold a command, the behaviour of the function is undefined.
pckt | a packet encapsulating a command. |
Definition at line 370 of file CrFwPckt.c.
CrFwBool_t CrFwPcktIsStartAck | ( | CrFwPckt_t | pckt | ) |
Return the acknowledge level for command start for the command encapsulated in the packet.
If the packet does not hold a command, the behaviour of the function is undefined.
pckt | a packet encapsulating a command. |
Definition at line 364 of file CrFwPckt.c.
CrFwBool_t CrFwPcktIsTermAck | ( | CrFwPckt_t | pckt | ) |
Return the acknowledge level for command termination for the command encapsulated in the packet.
If the packet does not hold a command, the behaviour of the function is undefined.
pckt | a packet encapsulating a command. |
Definition at line 376 of file CrFwPckt.c.
CrFwPckt_t CrFwPcktMake | ( | CrFwPcktLength_t | pcktLength | ) |
Make function for command or report packets.
This function returns an unconfigured packet of the specified length. An unconfigured packet of length L consists of a sequence of L bytes. The function allocates the memory for the packet and returns a pointer to the allocated memory.
The memory allocated to the packet remains reserved to the packet until the packet is released through a call to function CrFwPcktRelease
. The content of the packet returned by this function is undefined. The way the memory is allocated and released is implementation-specific.
If the allocation of the memory for the new packet failed, the function returns NULL. Depending on the implementation, allocation memory failure may result in the application error code being set to crPcktAllocationFail
.
The packet length must be a positive integer. If a negative or a zero value is used, the function returns NULL. Depending on the implementation, this may also result in the application error code being set to crPcktAllocationFail
.
pcktLength | the length of the packet in bytes (a positive integer) |
Definition at line 129 of file CrFwPckt.c.
void CrFwPcktRelease | ( | CrFwPckt_t | pckt | ) |
Release function for command or report packets.
The argument of this function must be a packet which was created using function CrFwPcktMake
. This function releases the memory which was allocated to the argument packet. After this function is called, the argument packet cannot be used.
An attempt to release a packet which had already been released, or to release a non-existent packet results in the application error code being set to: crPcktRelErr
.
pckt | the packet to be released |
Definition at line 156 of file CrFwPckt.c.
void CrFwPcktSetAckLevel | ( | CrFwPckt_t | pckt, |
CrFwBool_t | accept, | ||
CrFwBool_t | start, | ||
CrFwBool_t | progress, | ||
CrFwBool_t | term | ||
) |
Set the acknowledge level for the command encapsulated in a packet.
If the packet on which this function is called does not encapsulate a command, nothing is done.
pckt | the packet. |
accept | 1 if acknowledge of command acceptance is desired, 0 otherwise. |
start | 1 if acknowledge of command start is desired, 0 otherwise. |
progress | 1 if acknowledge of command progress is desired, 0 otherwise. |
term | 1 if acknowledge of command acceptance termination is desired, 0 otherwise. |
Definition at line 345 of file CrFwPckt.c.
void CrFwPcktSetCmdRepId | ( | CrFwPckt_t | pckt, |
CrFwInstanceId_t | id | ||
) |
Set the command or report identifier in the command or report encapsulated in a packet.
pckt | the packet. |
id | the command or report identifier. |
Definition at line 333 of file CrFwPckt.c.
void CrFwPcktSetCmdRepType | ( | CrFwPckt_t | pckt, |
CrFwCmdRepType_t | type | ||
) |
Set the type of a packet (either a command packet or a report packet).
pckt | the packet |
type | the type of the entity (a command or a report) encapsulated by the packet. |
Definition at line 217 of file CrFwPckt.c.
void CrFwPcktSetCrc | ( | CrFwPckt_t | pckt, |
CrFwCrc_t | crc | ||
) |
Set the CRC in the command or report encapsulated in a packet.
pckt | the packet. |
crc | the command or report CRC. |
Definition at line 253 of file CrFwPckt.c.
void CrFwPcktSetDest | ( | CrFwPckt_t | pckt, |
CrFwDestSrc_t | dest | ||
) |
Set the destination of the command or report encapsulated in a packet.
pckt | the packet. |
dest | the destination of the packet. |
Definition at line 309 of file CrFwPckt.c.
void CrFwPcktSetDiscriminant | ( | CrFwPckt_t | pckt, |
CrFwDiscriminant_t | discriminant | ||
) |
Set the discriminant of the command or report encapsulated in a packet.
Not all commands and reports have a discriminant field. If the argument packet holds a command or report which does not have a discriminant field, the behaviour of this function is undefined.
pckt | the packet. |
discriminant | the discriminant. |
Definition at line 279 of file CrFwPckt.c.
void CrFwPcktSetGroup | ( | CrFwPckt_t | pckt, |
CrFwGroup_t | group | ||
) |
Set the group of the command/report encapsulated in a packet.
pckt | the packet. |
group | the destination or source group of the packet. |
Definition at line 392 of file CrFwPckt.c.
void CrFwPcktSetSeqCnt | ( | CrFwPckt_t | pckt, |
CrFwSeqCnt_t | seqCnt | ||
) |
Set the sequence counter of the command or report encapsulated in a packet.
pckt | the packet. |
seqCnt | the sequence counter. |
Definition at line 229 of file CrFwPckt.c.
void CrFwPcktSetServSubType | ( | CrFwPckt_t | pckt, |
CrFwServSubType_t | servSubType | ||
) |
Set the service sub-type of the command or report encapsulated in a packet.
pckt | the packet. |
servSubType | the service sub-type. |
Definition at line 297 of file CrFwPckt.c.
void CrFwPcktSetServType | ( | CrFwPckt_t | pckt, |
CrFwServType_t | servType | ||
) |
Set the service type of the command or report encapsulated in a packet.
pckt | the packet. |
servType | the service type. |
Definition at line 285 of file CrFwPckt.c.
void CrFwPcktSetSrc | ( | CrFwPckt_t | pckt, |
CrFwDestSrc_t | src | ||
) |
Set the source of the command or report encapsulated in a packet.
pckt | the packet. |
src | the source of the packet. |
Definition at line 321 of file CrFwPckt.c.
void CrFwPcktSetTimeStamp | ( | CrFwPckt_t | pckt, |
CrFwTimeStamp_t | timeStamp | ||
) |
Set the time stamp of the command or report encapsulated in a packet.
pckt | the packet. |
timeStamp | the time stamp. |
Definition at line 241 of file CrFwPckt.c.