Skip to content

Commit

Permalink
Merge pull request COVESA#26 from boschglobal/feat/more-acf-formats
Browse files Browse the repository at this point in the history
Add FlexRay, Lin, Most ACF formats
  • Loading branch information
nayakned authored Aug 5, 2024
2 parents 212c1ca + 7c2d6e1 commit 3992cdb
Show file tree
Hide file tree
Showing 9 changed files with 528 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ add_library(open1722 SHARED
"src/avtp/Utils.c"
"src/avtp/aaf/CommonStream.c"
"src/avtp/aaf/PcmStream.c"
"src/avtp/acf/FlexRay.c"
"src/avtp/acf/Can.c"
"src/avtp/acf/CanBrief.c"
"src/avtp/acf/Lin.c"
"src/avtp/acf/Most.c"
"src/avtp/acf/Common.c"
"src/avtp/acf/Ntscf.c"
"src/avtp/acf/Sensor.c"
Expand Down
99 changes: 99 additions & 0 deletions include/avtp/acf/FlexRay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2024, COVESA
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of COVESA nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**
* @file This files contains functions for de-/serialization of IEEE1722's ACF
* FlexRay PDU formats. For details see IEEE Std. 1722-2016, chapter 9.4.2.
*/

#pragma once

#include <stdint.h>

#include "avtp/Defines.h"
#include "avtp/acf/Common.h"

/** Length of ACF FlexRay header. */
#define AVTP_FLEXRAY_HEADER_LEN (4 * AVTP_QUADLET_SIZE)

/** ACF FlexRay PDU. */
typedef struct {
uint8_t header[AVTP_FLEXRAY_HEADER_LEN];
uint8_t payload[0];
} Avtp_FlexRay_t;

/** Fields of ACF FlexRay PDU. */
typedef enum {
/* ACF common header fields */
AVTP_FLEXRAY_FIELD_ACF_MSG_TYPE = 0,
AVTP_FLEXRAY_FIELD_ACF_MSG_LENGTH,
/* ACF FlexRay header fields */
AVTP_FLEXRAY_FIELD_PAD,
AVTP_FLEXRAY_FIELD_MTV,
AVTP_FLEXRAY_FIELD_FR_BUS_ID,
AVTP_FLEXRAY_FIELD_RESERVED,
AVTP_FLEXRAY_FIELD_CHAN,
AVTP_FLEXRAY_FIELD_STR,
AVTP_FLEXRAY_FIELD_SYN,
AVTP_FLEXRAY_FIELD_PRE,
AVTP_FLEXRAY_FIELD_NFI,
AVTP_FLEXRAY_FIELD_MESSAGE_TIMESTAMP,
AVTP_FLEXRAY_FIELD_FR_FRAME_ID,
AVTP_FLEXRAY_FIELD_RESERVED_2,
AVTP_FLEXRAY_FIELD_CYCLE,
/* Count number of fields for bound checks */
AVTP_FLEXRAY_FIELD_MAX
} Avtp_FlexRayFields_t;

/**
* Initializes an ACF FlexRay PDU.
*
* @param pdu Pointer to the first bit of a 1722 ACF FlexRay PDU.
*/
int Avtp_FlexRay_Init(Avtp_FlexRay_t* pdu);

/**
* Returns the value of an ACF FlexRay PDU field.
*
* @param pdu Pointer to the first bit of an 1722 ACF FlexRay PDU.
* @param field Data field to be read
* @param value Pointer to location to store the value.
* @returns Returns 0 if the data field was successfully read.
*/
int Avtp_FlexRay_GetField(Avtp_FlexRay_t* pdu, Avtp_FlexRayFields_t field, uint64_t* value);

/**
* Sets the value of an ACF FlexRay PDU field.
*
* @param pdu Pointer to the first bit of an 1722 ACF FlexRay PDU.
* @param field Specifies the position of the data field to be read
* @param value Pointer to location to store the value.
* @returns Returns 0 if the data field was successfully set.
*/
int Avtp_FlexRay_SetField(Avtp_FlexRay_t* pdu, Avtp_FlexRayFields_t field, uint64_t value);
92 changes: 92 additions & 0 deletions include/avtp/acf/Lin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2024, COVESA
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of COVESA nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**
* @file This files contains functions for de-/serialization of IEEE1722's ACF
* Lin PDU formats. For details see IEEE Std. 1722-2016, chapter 9.4.5.
*/

#pragma once

#include <stdint.h>

#include "avtp/Defines.h"
#include "avtp/acf/Common.h"

/** Length of ACF Lin header. */
#define AVTP_LIN_HEADER_LEN (3 * AVTP_QUADLET_SIZE)

/** ACF Lin PDU. */
typedef struct {
uint8_t header[AVTP_LIN_HEADER_LEN];
uint8_t payload[0];
} Avtp_Lin_t;


/** Fields of ACF Lin PDU. */
typedef enum {
/* ACF common header fields */
AVTP_LIN_FIELD_ACF_MSG_TYPE = 0,
AVTP_LIN_FIELD_ACF_MSG_LENGTH,
/* ACF Lin header fields */
AVTP_LIN_FIELD_PAD,
AVTP_LIN_FIELD_MTV,
AVTP_LIN_FIELD_LIN_BUS_ID,
AVTP_LIN_FIELD_LIN_IDENTIFIER,
AVTP_LIN_FIELD_MESSAGE_TIMESTAMP,
/* Count number of fields for bound checks */
AVTP_LIN_FIELD_MAX
} Avtp_LinFields_t;

/**
* Initializes an ACF Lin PDU.
*
* @param pdu Pointer to the first bit of a 1722 ACF Lin PDU.
*/
int Avtp_Lin_Init(Avtp_Lin_t* pdu);

/**
* Returns the value of an ACF Lin PDU field.
*
* @param pdu Pointer to the first bit of an 1722 ACF Lin PDU.
* @param field Data field to be read
* @param value Pointer to location to store the value.
* @returns Returns 0 if the data field was successfully read.
*/
int Avtp_Lin_GetField(Avtp_Lin_t* pdu, Avtp_LinFields_t field, uint64_t* value);

/**
* Sets the value of an ACF Lin PDU field.
*
* @param pdu Pointer to the first bit of an 1722 ACF Lin PDU.
* @param field Specifies the position of the data field to be read
* @param value Pointer to location to store the value.
* @returns Returns 0 if the data field was successfully set.
*/
int Avtp_Lin_SetField(Avtp_Lin_t* pdu, Avtp_LinFields_t field, uint64_t value);
97 changes: 97 additions & 0 deletions include/avtp/acf/Most.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2024, COVESA
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of COVESA nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**
* @file This files contains functions for de-/serialization of IEEE1722's ACF
* Most PDU formats. For details see IEEE Std. 1722-2016, chapter 9.4.6.
*/

#pragma once

#include <stdint.h>

#include "avtp/Defines.h"
#include "avtp/acf/Common.h"

/** Length of ACF Most header. */
#define AVTP_MOST_HEADER_LEN (4 * AVTP_QUADLET_SIZE)

/** ACF Most PDU. */
typedef struct {
uint8_t header[AVTP_MOST_HEADER_LEN];
uint8_t payload[0];
} Avtp_Most_t;

/** Fields of ACF Most PDU. */
typedef enum {
/* ACF common header fields */
AVTP_MOST_FIELD_ACF_MSG_TYPE = 0,
AVTP_MOST_FIELD_ACF_MSG_LENGTH,
/* ACF Most header fields */
AVTP_MOST_FIELD_PAD,
AVTP_MOST_FIELD_MTV,
AVTP_MOST_FIELD_MOST_NET_ID,
AVTP_MOST_FIELD_RESERVED,
AVTP_MOST_FIELD_MESSAGE_TIMESTAMP,
AVTP_MOST_FIELD_DEVICE_ID,
AVTP_MOST_FIELD_FBLOCK_ID,
AVTP_MOST_FIELD_INST_ID,
AVTP_MOST_FIELD_FUNC_ID,
AVTP_MOST_FIELD_OP_TYPE,
AVTP_MOST_FIELD_RESERVED_2,
/* Count number of fields for bound checks */
AVTP_MOST_FIELD_MAX
} Avtp_MostFields_t;

/**
* Initializes an ACF Most PDU.
*
* @param pdu Pointer to the first bit of a 1722 ACF Most PDU.
*/
int Avtp_Most_Init(Avtp_Most_t* pdu);

/**
* Returns the value of an ACF Most PDU field.
*
* @param pdu Pointer to the first bit of an 1722 ACF Most PDU.
* @param field Data field to be read
* @param value Pointer to location to store the value.
* @returns Returns 0 if the data field was successfully read.
*/
int Avtp_Most_GetField(Avtp_Most_t* pdu, Avtp_MostFields_t field, uint64_t* value);

/**
* Sets the value of an ACF Most PDU field.
*
* @param pdu Pointer to the first bit of an 1722 ACF Most PDU.
* @param field Specifies the position of the data field to be read
* @param value Pointer to location to store the value.
* @returns Returns 0 if the data field was successfully set.
*/
int Avtp_Most_SetField(Avtp_Most_t* pdu, Avtp_MostFields_t field, uint64_t value);
6 changes: 3 additions & 3 deletions include/avtp/acf/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ typedef enum {
int Avtp_Sensor_Init(Avtp_Sensor_t* sensor_pdu);

/**
* Returns the value of an an ACF Sensor PDU field as specified in the IEEE 1722 Specification.
* Returns the value of an ACF Sensor PDU field as specified in the IEEE 1722 Specification.
*
* @param pdu Pointer to the first bit of an 1722 ACF Sensor PDU.
* @param field Specifies the position of the data field to be read
Expand All @@ -83,12 +83,12 @@ int Avtp_Sensor_Init(Avtp_Sensor_t* sensor_pdu);
int Avtp_Sensor_GetField(Avtp_Sensor_t* sensor_pdu, Avtp_SensorFields_t field, uint64_t* value);

/**
* Sets the value of an an ACF Sensor PDU field as specified in the IEEE 1722 Specification.
* Sets the value of an ACF Sensor PDU field as specified in the IEEE 1722 Specification.
*
* @param pdu Pointer to the first bit of an 1722 ACF Sensor PDU.
* @param field Specifies the position of the data field to be read
* @param value Pointer to location to store the value.
* @returns This function returns 0 if the data field was successfully set in
* the 1722 ACF Sensor PDU.
*/
int Avtp_Sensor_SetField(Avtp_Sensor_t* sensor_pdu, Avtp_SensorFields_t field, uint64_t value);
int Avtp_Sensor_SetField(Avtp_Sensor_t* sensor_pdu, Avtp_SensorFields_t field, uint64_t value);
Loading

0 comments on commit 3992cdb

Please sign in to comment.