CORDET Framework - C2 Implementation
|
Default implementation of the packet interface of CrFwPckt.h
.
More...
Go to the source code of this file.
Macros | |
#define | CR_FW_MAX_PACKET_LENGTH 100 |
Maximum length of a packet expressed in number of bytes (see CrFwPacket.h ). More... | |
#define | CR_FW_MAX_PCKT_LENGTH 100 |
The maximum size in number of bytes of a packet. | |
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... | |
CrFwPcktLength_t | CrFwPcktGetLength (CrFwPckt_t pckt) |
Return the length (in number of bytes) of a packet. 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... | |
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 | 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... | |
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... | |
char * | 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... | |
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... | |
Variables | |
static char | pcktArray [CR_FW_MAX_NOF_PCKTS *CR_FW_MAX_PCKT_LENGTH] |
The array holding the packets. More... | |
static CrFwBool_t | pcktInUse [CR_FW_MAX_NOF_PCKTS] = {0} |
The array holding the "in use" status of the packets. More... | |
static CrFwCounterU2_t | nOfAllocatedPckts = 0 |
The number of currently allocated packets. More... | |
static const CrFwPcktLength_t | offsetLength = 0 |
Offset of the length field in a packet. | |
static const CrFwPcktLength_t | offsetCmdRepType = 4 |
Offset of the flag defining the type of packet (1 for a command, 2 for a report) | |
static const CrFwPcktLength_t | offsetTimeStamp = 8 |
Offset of the time stamp field in a packet. | |
static const CrFwPcktLength_t | offsetServType = 12 |
Offset of the service type field in a packet. | |
static const CrFwPcktLength_t | offsetServSubType = 16 |
Offset of the service sub-type field in a packet. | |
static const CrFwPcktLength_t | offsetDest = 20 |
Offset of the destination field in a packet. | |
static const CrFwPcktLength_t | offsetSrc = 24 |
Offset of the source field in a packet. | |
static const CrFwPcktLength_t | offsetDiscriminant = 28 |
Offset of the discriminant field in a packet. | |
static const CrFwPcktLength_t | offsetSeqCnt = 32 |
Offset of the sequence counter field in a packet. | |
static const CrFwPcktLength_t | offsetCmdRepId = 36 |
Offset of the command or report identifier in a packet. | |
static const CrFwPcktLength_t | offsetAcceptAckLev = 40 |
Offset of the acceptance acknowledge level field in a packet. | |
static const CrFwPcktLength_t | offsetStartAckLev = 44 |
Offset of the start acknowledge level field in a packet. | |
static const CrFwPcktLength_t | offsetProgressAckLev = 48 |
Offset of the progress acknowledge level field in a packet. | |
static const CrFwPcktLength_t | offsetTermAckLev = 52 |
Offset of the termination acknowledge level field in a packet. | |
static const CrFwPcktLength_t | offsetGroup = 56 |
Offset of the group in a packet. | |
static const CrFwPcktLength_t | offsetPar = 60 |
Offset of the parameter area in a packet. | |
Default implementation of the packet interface of CrFwPckt.h
.
The implementation of this interface is one of the adaptation points of the CORDET Framework. This file provides a default implementation which is primarily intended to support testing. It is expected that applications will provide their own implementation. Application will therefore normally replace this file with their own file providing their application-specific implementation.
This implementation pre-allocates the memory for a predefined number of packets of fixed size. Packets can be either "in use" or "not in use". A packet is in use if it has been requested through a call to CrFwPcktMake
and has not yet been released through a call to CrFwPcktRelease
.
The implementation provided in this file uses global data structures to hold the pool of pre-allocated packets.
A packet encapsulates a command or a report and it holds all the attributes of the command or report. The layout of a packet is defined by the value of the offsetYyy
constants which defines the offset within a packet at which attribute "Yyy" is stored.
The setter functions for the packet attributes assume that the packet length is adequate to hold the attributes. Compliance with this constraint is not checked by the setter functions. Its violation may result in memory corruption.
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 cordetfw-examples/src/CrConfigDemoSlave1/CrFwPckt.c.
#define CR_FW_MAX_PACKET_LENGTH 100 |
Maximum length of a packet expressed in number of bytes (see CrFwPacket.h
).
The value of this constant must be smaller than the range of the CrFwPcktLength_t
integer type.
Definition at line 57 of file cordetfw-examples/src/CrConfigDemoSlave1/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 311 of file cordetfw-examples/src/CrConfigDemoSlave1/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 209 of file cordetfw-examples/src/CrConfigDemoSlave1/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 287 of file cordetfw-examples/src/CrConfigDemoSlave1/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 245 of file cordetfw-examples/src/CrConfigDemoSlave1/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 370 of file cordetfw-examples/src/CrConfigDemoSlave1/CrFwPckt.c.
CrFwPcktLength_t CrFwPcktGetLength | ( | CrFwPckt_t | pckt | ) |
Return the length (in number of bytes) of a packet.
pckt | the packet. |
Definition at line 204 of file cordetfw-examples/src/CrConfigDemoSlave1/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 199 of file cordetfw-examples/src/CrConfigDemoSlave1/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 194 of file cordetfw-examples/src/CrConfigDemoSlave1/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 359 of file cordetfw-examples/src/CrConfigDemoSlave1/CrFwPckt.c.
char* 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 354 of file cordetfw-examples/src/CrConfigDemoSlave1/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 221 of file cordetfw-examples/src/CrConfigDemoSlave1/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 275 of file cordetfw-examples/src/CrConfigDemoSlave1/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 263 of file cordetfw-examples/src/CrConfigDemoSlave1/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 299 of file cordetfw-examples/src/CrConfigDemoSlave1/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 233 of file cordetfw-examples/src/CrConfigDemoSlave1/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 330 of file cordetfw-examples/src/CrConfigDemoSlave1/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 174 of file cordetfw-examples/src/CrConfigDemoSlave1/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 342 of file cordetfw-examples/src/CrConfigDemoSlave1/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 336 of file cordetfw-examples/src/CrConfigDemoSlave1/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 348 of file cordetfw-examples/src/CrConfigDemoSlave1/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 127 of file cordetfw-examples/src/CrConfigDemoSlave1/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 154 of file cordetfw-examples/src/CrConfigDemoSlave1/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 317 of file cordetfw-examples/src/CrConfigDemoSlave1/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 305 of file cordetfw-examples/src/CrConfigDemoSlave1/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 215 of file cordetfw-examples/src/CrConfigDemoSlave1/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 281 of file cordetfw-examples/src/CrConfigDemoSlave1/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 251 of file cordetfw-examples/src/CrConfigDemoSlave1/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 364 of file cordetfw-examples/src/CrConfigDemoSlave1/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 227 of file cordetfw-examples/src/CrConfigDemoSlave1/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 269 of file cordetfw-examples/src/CrConfigDemoSlave1/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 257 of file cordetfw-examples/src/CrConfigDemoSlave1/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 293 of file cordetfw-examples/src/CrConfigDemoSlave1/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 239 of file cordetfw-examples/src/CrConfigDemoSlave1/CrFwPckt.c.
|
static |
The number of currently allocated packets.
Definition at line 76 of file cordetfw-examples/src/CrConfigDemoSlave1/CrFwPckt.c.
|
static |
The array holding the packets.
Packets are stored in this array in blocks of size CR_FW_MAX_PCKT_LENGTH.
Definition at line 66 of file cordetfw-examples/src/CrConfigDemoSlave1/CrFwPckt.c.
|
static |
The array holding the "in use" status of the packets.
A packet is in use if it has been requested through a call to the "make" function and has not yet been released through a call to the "release" function.
Definition at line 73 of file cordetfw-examples/src/CrConfigDemoSlave1/CrFwPckt.c.