diff --git a/ls-bus-guide/headers/fmi3LsBusUtil.h b/ls-bus-guide/headers/fmi3LsBusUtil.h index fc900e2..329fa02 100644 --- a/ls-bus-guide/headers/fmi3LsBusUtil.h +++ b/ls-bus-guide/headers/fmi3LsBusUtil.h @@ -39,19 +39,23 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- */ -#include "fmi3LsBus.h" #include +#include "fmi3LsBus.h" + + #ifdef __cplusplus extern "C" { #endif /** - * This data type holds information to read and write bus operations to\from - * a buffer variable via utility maros such as \ref FMI3_LS_BUS_BUFFER_WRITE and - * \ref FMI3_LS_BUS_READ_NEXT_OPERATION. Variables of this type should be initialized - * by \ref FMI3_LS_BUS_BUFFER_INFO_INIT and resetted by \ref FMI3_LS_BUS_BUFFER_INFO_RESET. + * \brief This data type holds information to read and write bus operations to/from + * a buffer variable via utility macros such as \ref FMI3_LS_BUS_BUFFER_WRITE and + * \ref FMI3_LS_BUS_READ_NEXT_OPERATION. + * + * Variables of this type should be initialized using \ref FMI3_LS_BUS_BUFFER_INFO_INIT + * and reset with \ref FMI3_LS_BUS_BUFFER_INFO_RESET. */ typedef struct { @@ -65,18 +69,20 @@ typedef struct /** - * \brief Initializes a variable of type \ref fmi3LsBusUtilBufferInfo - * + * \brief Initializes a variable of type \ref fmi3LsBusUtilBufferInfo. + * * This macro should be used to initialize variables of type \ref fmi3LsBusUtilBufferInfo. * * Example: + * \code * fmi3UInt8 buffer[2048]; * fmi3LsBusUtilBufferInfo bufferInfo; * FMI3_LS_BUS_BUFFER_INFO_INIT(&bufferInfo, buffer, sizeof(buffer)); - * - * \param[in] Pointer to variable of type \ref fmi3LsBusUtilBufferInfo. - * \param[in] Pointer to buffer variable. - * \param[in] Size of the buffer variable. + * \endcode + * + * \param[in] BufferInfo Pointer to variable of type \ref fmi3LsBusUtilBufferInfo. + * \param[in] Buffer Pointer to buffer variable. + * \param[in] Size Size of the buffer variable. */ #define FMI3_LS_BUS_BUFFER_INFO_INIT(BufferInfo, Buffer, Size) \ do \ @@ -91,14 +97,13 @@ typedef struct while (0) /** - * \brief Resets a variable of type \ref fmi3LsBusUtilBufferInfo + * \brief Resets a variable of type \ref fmi3LsBusUtilBufferInfo. * * This macro should be used to reset variables of type \ref fmi3LsBusUtilBufferInfo. - * Read and write positions are set to the buffer start address. - * The Variable must be initialize via ref FMI3_LS_BUS_BUFFER_INFO_INIT before + * Read and write positions are set to the buffer start address. + * The Variable must have been initialized using \ref FMI3_LS_BUS_BUFFER_INFO_INIT before. * - * - * \param Pointer to variable of type \ref fmi3LsBusUtilBufferInfo. + * \param[in] BufferInfo Pointer to variable of type \ref fmi3LsBusUtilBufferInfo. */ #define FMI3_LS_BUS_BUFFER_INFO_RESET(BufferInfo) \ do \ @@ -110,19 +115,19 @@ typedef struct while (0) /** - * \brief Writes data to a buffer variable. Existing data will be overwitten. + * \brief Writes data to a buffer variable. Existing data will be overwritten. * - * \param Pointer to variable of type \ref fmi3LsBusUtilBufferInfo. - * \param Pointer to buffer variable. - * \param Size of the buffer variable. + * \param[in] BufferInfo Pointer to variable of type \ref fmi3LsBusUtilBufferInfo. + * \param[in] Data Pointer to data to be written. + * \param[in] DataLength Size of the data to be written. */ -#define FMI3_LS_BUS_BUFFER_WRITE(BufferInfo, data, dataLength) \ +#define FMI3_LS_BUS_BUFFER_WRITE(BufferInfo, Data, DataLength) \ do \ { \ - if ((dataLength) <= (BufferInfo)->size) \ + if ((DataLength) <= (BufferInfo)->size) \ { \ - memcpy((bufferInfo)->start, (data), (dataLength)); \ - (bufferInfo)->writePos = (bufferInfo)->start + (dataLength); \ + memcpy((bufferInfo)->start, (Data), (DataLength)); \ + (bufferInfo)->writePos = (bufferInfo)->start + (DataLength); \ (bufferInfo)->readPos = (bufferInfo)->start; \ (bufferInfo)->status = fmi3True; \ } \ @@ -134,24 +139,56 @@ typedef struct while (0) /** - * \brief Reads next bus operation from buffer. + * \brief Reads the next bus operation from a buffer. * * Example: + * \code * fmi3LsBusOperationHeader* nextOperation; - * while(FMI3_LS_BUS_READ_NEXT_OPERATION(BufferInfo,nextOperation)) + * while (FMI3_LS_BUS_READ_NEXT_OPERATION(BufferInfo, nextOperation)) * { * ... * } + * \endcode * - * \param[in] Pointer to variable of type \ref fmi3LsBusUtilBufferInfo. - * \param[out] Pointer of type \ref fmi3LsBusOperationHeader* set by the macro - * to the address where the next bus operation can be read from. - * \return fmi3True if a new operation is available else fmi3False. + * \param[in] BufferInfo Pointer to variable of type \ref fmi3LsBusUtilBufferInfo. + * \param[out] Operation Pointer of type \ref fmi3LsBusOperationHeader* set by the macro + * to the address where the next bus operation can be read from. + * \return fmi3True if a new operation is available, otherwise fmi3False. */ -#define FMI3_LS_BUS_READ_NEXT_OPERATION(BufferInfo, Operation) \ - (((BufferInfo)->writePos - (BufferInfo)->readPos) > sizeof(fmi3LsBusOperationHeader) && \ - ((BufferInfo)->writePos - (BufferInfo)->readPos) >= ((fmi3LsBusOperationHeader*)(BufferInfo)->readPos)->length) \ - ? (Operation = (fmi3LsBusOperationHeader*)(BufferInfo)->readPos, (BufferInfo)->readPos += Operation->length), \ +#define FMI3_LS_BUS_READ_NEXT_OPERATION(BufferInfo, Operation) \ + ((fmi3UInt32)((BufferInfo)->writePos - (BufferInfo)->readPos) > sizeof(fmi3LsBusOperationHeader) && \ + (fmi3UInt32)((BufferInfo)->writePos - (BufferInfo)->readPos) >= ((fmi3LsBusOperationHeader*)(BufferInfo)->readPos)->length) \ + ? ((Operation) = (fmi3LsBusOperationHeader*)(BufferInfo)->readPos, (BufferInfo)->readPos += (Operation)->length), \ + fmi3True : fmi3False\ + + /** + * \brief Reads the next bus operation directly from a raw buffer. + * + * Example: + * \code + * fmi3SetBinary(..., const size_t valueSizes[], const fmi3Binary values[], ...) + * { + * fmi3LsBusOperationHeader* nextOperation; + * size_t readPos = 0; + * ... + * while (FMI3_LS_BUS_READ_NEXT_OPERATION_DIRECT(values[i], valueSizes[i], readPos, nextOperation)) + * { + * ... + * } + * } + * \endcode + * + * \param[in] Buffer Pointer to buffer variable of type fmi3Binary. + * \param[in] BufferLength The length of the data in the buffer. + * \param[in,out] ReadPos Variable to hold the current read position. + * \param[out] Operation Pointer of type \ref fmi3LsBusOperationHeader* set by the macro + * to the address where the next bus operation can be read from. + * \return fmi3True if a new operation is available, otherwise fmi3False. + */ +#define FMI3_LS_BUS_READ_NEXT_OPERATION_DIRECT(Buffer, BufferLength, ReadPos, Operation) \ + (((BufferLength) - (ReadPos)) > sizeof(fmi3LsBusOperationHeader) && \ + ((BufferLength) - (ReadPos)) >= ((fmi3LsBusOperationHeader*)((Buffer) + (ReadPos)))->length) \ + ? ((Operation) = (fmi3LsBusOperationHeader*)((Buffer) + (ReadPos)), (ReadPos) += (Operation)->length), \ fmi3True : fmi3False\ diff --git a/ls-bus-guide/headers/fmi3LsBusUtilCan.h b/ls-bus-guide/headers/fmi3LsBusUtilCan.h index 79770ba..6b75286 100644 --- a/ls-bus-guide/headers/fmi3LsBusUtilCan.h +++ b/ls-bus-guide/headers/fmi3LsBusUtilCan.h @@ -47,19 +47,19 @@ extern "C" #include "fmi3LsBusUtil.h" /** - * \brief Creates a CAN transmit operation + * \brief Creates a CAN transmit operation. * * This macro can be used to create a CAN transmit operation. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo. - * \param[in] CAN message ID \ref fmi3LsBusCanId. - * \param[in] CAN message ID type (standard\extended) \ref fmi3LsBusCanIde. - * \param[in] Remote Transmission Request \ref fmi3LsBusCanRtr. - * \param[in] Message data length \ref fmi3LsBusCanDataLength. - * \param[in] Message data \ref fmi3LsBusCanDataLength. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] ID CAN message ID (\ref fmi3LsBusCanId). + * \param[in] Ide CAN message ID type (standard/extended) (\ref fmi3LsBusCanIde). + * \param[in] Rtr Remote Transmission Request (\ref fmi3LsBusCanRtr). + * \param[in] DataLength Message data length (\ref fmi3LsBusCanDataLength). + * \param[in] Data Message data (\ref fmi3LsBusCanDataLength). */ #define FMI3_LS_BUS_CAN_CREATE_OP_CAN_TRANSMIT(BufferInfo, ID, Ide, Rtr, DataLength, Data) \ do \ @@ -71,13 +71,13 @@ extern "C" sizeof(fmi3LsBusCanIde) + \ sizeof(fmi3LsBusCanRtr) + \ sizeof(fmi3LsBusCanDataLength) + \ - DataLength; \ + (DataLength); \ _op.id = (ID); \ _op.ide = (Ide); \ _op.rtr = (Rtr); \ \ _op.dataLength = (DataLength); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length - (DataLength)); \ (BufferInfo)->writePos += _op.header.length - (DataLength); \ @@ -93,20 +93,20 @@ extern "C" while (0) /** - * \brief Creates a CAN FD transmit operation + * \brief Creates a CAN FD transmit operation. * * This macro can be used to create a CAN FD transmit operation. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo. - * \param[in] CAN message ID \ref fmi3LsBusCanId. - * \param[in] CAN message ID type (standard\extended) \ref fmi3LsBusCanIde. - * \param[in] Bit Rate Switch \ref fmi3LsBusCanBrs. - * \param[in] Error State Indicator \ref fmi3LsBusCanEsi. - * \param[in] Message data length \ref fmi3LsBusCanDataLength. - * \param[in] Message data \ref fmi3LsBusCanDataLength. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] ID CAN message ID (\ref fmi3LsBusCanId). + * \param[in] Ide CAN message ID type (standard\extended) (\ref fmi3LsBusCanIde). + * \param[in] Brs Bit Rate Switch (\ref fmi3LsBusCanBrs). + * \param[in] Esi Error State Indicator (\ref fmi3LsBusCanEsi). + * \param[in] DataLength Message data length (\ref fmi3LsBusCanDataLength). + * \param[in] Data Message data (\ref fmi3LsBusCanDataLength). */ #define FMI3_LS_BUS_CAN_CREATE_OP_CAN_FD_TRANSMIT(BufferInfo, ID, Ide, Brs, Esi, DataLength, Data) \ do \ @@ -115,14 +115,14 @@ extern "C" _op.header.type = FMI3_LS_BUS_CAN_OP_CANFD_TRANSMIT; \ _op.header.length = sizeof(fmi3LsBusOperationHeader) + sizeof(fmi3LsBusCanId) + sizeof(fmi3LsBusCanIde) + \ sizeof(fmi3LsBusCanBrs) + sizeof(fmi3LsBusCanEsi) + sizeof(fmi3LsBusCanDataLength) + \ - DataLength; \ + (DataLength); \ _op.id = (ID); \ _op.ide = (Ide); \ _op.brs = (Brs); \ _op.esi = (Esi); \ \ _op.dataLength = (DataLength); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length - (DataLength)); \ (BufferInfo)->writePos += _op.header.length - (DataLength); \ @@ -138,22 +138,22 @@ extern "C" while (0) /** - * \brief Creates a CAN XL transmit operation + * \brief Creates a CAN XL transmit operation. * * This macro can be used to create a CAN XL transmit operation. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo. - * \param[in] CAN message ID \ref fmi3LsBusCanId. - * \param[in] CAN message ID type (standard\extended) \ref fmi3LsBusCanIde. - * \param[in] Simple Extended Content \ref fmi3LsBusCanSec. - * \param[in] Service Data Unit Type \ref fmi3LsBusCanSdt. - * \param[in] Virtual CAN Network ID \ref fmi3LsBusCanVcId. - * \param[in] Acceptance Field \ref fmi3LsBusCanAf. - * \param[in] Message data length \ref fmi3LsBusCanDataLength. - * \param[in] Message data \ref fmi3LsBusCanDataLength. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] ID CAN message ID (\ref fmi3LsBusCanId). + * \param[in] Ide CAN message ID type (standard/extended) (\ref fmi3LsBusCanIde). + * \param[in] Sec Simple Extended Content (\ref fmi3LsBusCanSec). + * \param[in] Sdt Service Data Unit Type (\ref fmi3LsBusCanSdt). + * \param[in] VcId Virtual CAN Network ID (\ref fmi3LsBusCanVcId). + * \param[in] Af Acceptance Field (\ref fmi3LsBusCanAf). + * \param[in] DataLength Message data length (\ref fmi3LsBusCanDataLength). + * \param[in] Data Message data (\ref fmi3LsBusCanDataLength). */ #define FMI3_LS_BUS_CAN_CREATE_OP_CAN_XL_TRANSMIT(BufferInfo, ID, Ide, Sec, Sdt, VcId, Af, DataLength, Data) \ do \ @@ -162,7 +162,7 @@ extern "C" _op.header.type = FMI3_LS_BUS_CAN_OP_CANXL_TRANSMIT; \ _op.header.length = sizeof(fmi3LsBusOperationHeader) + sizeof(fmi3LsBusCanId) + sizeof(fmi3LsBusCanIde) + \ sizeof(fmi3LsBusCanSec) + sizeof(fmi3LsBusCanSdt) + sizeof(fmi3LsBusCanVcId) + \ - sizeof(fmi3LsBusCanVcId) + sizeof(fmi3LsBusCanDataLength) + DataLength; \ + sizeof(fmi3LsBusCanVcId) + sizeof(fmi3LsBusCanDataLength) + (DataLength); \ _op.id = (ID); \ _op.ide = (Ide); \ _op.sec = (Sec); \ @@ -171,7 +171,7 @@ extern "C" _op.af = (Af); \ \ _op.dataLength = (DataLength); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length - (DataLength)); \ (BufferInfo)->writePos += _op.header.length - (DataLength); \ @@ -187,49 +187,50 @@ extern "C" while (0) /** - * \brief Creates a CAN confirm operation + * \brief Creates a CAN confirm operation. * * This macro can be used to create a CAN confirm operation. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo - * \param[in] CAN message ID \ref fmi3LsBusCanId. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] ID CAN message ID (\ref fmi3LsBusCanId). */ -#define FMI3_LS_BUS_CAN_CREATE_OP_CONFIRM(BufferInfo, ID) \ - do \ - { \ - fmi3LsBusCanOperationConfirm _op; \ - _op.header.type = FMI3_LS_BUS_CAN_OP_CONFIRM; \ - _op.header.length = sizeof(fmi3LsBusOperationHeader) + \ - sizeof(fmi3LsBusCanId); \ - _op.id = (ID); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ - { \ - memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ - (BufferInfo)->writePos += _op.header.length; \ - (BufferInfo)->status = fmi3True; \ - } \ - else \ - { \ - (BufferInfo)->status = fmi3False; \ - } \ - } \ +#define FMI3_LS_BUS_CAN_CREATE_OP_CONFIRM(BufferInfo, ID) \ + do \ + { \ + fmi3LsBusCanOperationConfirm _op; \ + _op.header.type = FMI3_LS_BUS_CAN_OP_CONFIRM; \ + _op.header.length = sizeof(fmi3LsBusOperationHeader) + \ + sizeof(fmi3LsBusCanId); \ + _op.id = (ID); \ + \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ + { \ + memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ + (BufferInfo)->writePos += _op.header.length; \ + (BufferInfo)->status = fmi3True; \ + } \ + else \ + { \ + (BufferInfo)->status = fmi3False; \ + } \ + } \ while (0) /** - * \brief Creates a CAN configuration operation for baudrate setting + * \brief Creates a CAN configuration operation for the baud rate setting. * - * This macro can be used to create a CAN configuration operation for baudrate setting. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * This macro can be used to create a CAN configuration operation for the baud rate setting. + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo - * \param[in] The baudrate \ref fmi3LsBusCanBaudrate. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] BaudRate The baud rate (\ref fmi3LsBusCanBaudrate). */ -#define FMI3_LS_BUS_CAN_CREATE_OP_CONFIGURATION_CAN_BAUDRATE(BufferInfo, Baudrate) \ +#define FMI3_LS_BUS_CAN_CREATE_OP_CONFIGURATION_CAN_BAUDRATE(BufferInfo, BaudRate) \ do \ { \ fmi3LsBusOperationCanConfiguration _op; \ @@ -238,8 +239,9 @@ extern "C" sizeof(fmi3LsBusCanConfigParameterType) + \ sizeof(fmi3LsBusCanBaudrate); \ _op.parameterType = FMI3_LS_BUS_CAN_CONFIG_PARAM_TYPE_CAN_BAUDRATE; \ - _op.baudrate = (Baudrate); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + _op.baudrate = (BaudRate); \ + \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ (BufferInfo)->writePos += _op.header.length; \ @@ -253,17 +255,17 @@ extern "C" while (0) /** - * \brief Creates a CAN configuration operation for CAN FD baudrate setting + * \brief Creates a CAN configuration operation for the CAN FD baud rate setting. * - * This macro can be used to create a CAN configuration operation for CAN FD baudrate setting. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * This macro can be used to create a CAN configuration operation for the CAN FD baud rate setting. + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo - * \param[in] The baudrate \ref fmi3LsBusCanBaudrate. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] BaudRate The baud rate (\ref fmi3LsBusCanBaudrate). */ -#define FMI3_LS_BUS_CAN_CREATE_OP_CONFIGURATION_CAN_FD_BAUDRATE(BufferInfo, Baudrate) \ +#define FMI3_LS_BUS_CAN_CREATE_OP_CONFIGURATION_CAN_FD_BAUDRATE(BufferInfo, BaudRate) \ do \ { \ fmi3LsBusOperationCanConfiguration _op; \ @@ -271,11 +273,12 @@ extern "C" _op.header.length = \ sizeof(fmi3LsBusOperationHeader) + sizeof(fmi3LsBusCanConfigParameterType) + sizeof(fmi3LsBusCanBaudrate); \ _op.parameterType = FMI3_LS_BUS_CAN_CONFIG_PARAM_TYPE_CANFD_BAUDRATE; \ - _op.baudrate = (Baudrate); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + _op.baudrate = (BaudRate); \ + \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ - (BufferInfo)->writePos += _op.header.length; \ \ + (BufferInfo)->writePos += _op.header.length; \ (BufferInfo)->status = fmi3True; \ } \ else \ @@ -286,17 +289,17 @@ extern "C" while (0) /** - * \brief Creates a CAN configuration operation for CAN XL baudrate setting + * \brief Creates a CAN configuration operation for the CAN XL baud rate setting. * - * This macro can be used to create a CAN configuration operation for CAN XL baudrate setting. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * This macro can be used to create a CAN configuration operation for the CAN XL baud rate setting. + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo - * \param[in] The baudrate \ref fmi3LsBusCanBaudrate. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] BaudRate The baud rate (\ref fmi3LsBusCanBaudrate). */ -#define FMI3_LS_BUS_CAN_CREATE_OP_CONFIGURATION_CAN_XL_BAUDRATE(BufferInfo, Baudrate) \ +#define FMI3_LS_BUS_CAN_CREATE_OP_CONFIGURATION_CAN_XL_BAUDRATE(BufferInfo, BaudRate) \ do \ { \ fmi3LsBusOperationCanConfiguration _op; \ @@ -304,8 +307,9 @@ extern "C" _op.header.length = \ sizeof(fmi3LsBusOperationHeader) + sizeof(fmi3LsBusCanConfigParameterType) + sizeof(fmi3LsBusCanBaudrate); \ _op.parameterType = FMI3_LS_BUS_CAN_CONFIG_PARAM_TYPE_CANXL_BAUDRATE; \ - _op.baudrate = (Baudrate); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + _op.baudrate = (BaudRate); \ + \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ (BufferInfo)->writePos += _op.header.length; \ @@ -319,15 +323,15 @@ extern "C" while (0) /** - * \brief Creates a CAN configuration operation for arbitration lost behavior options setting + * \brief Creates a CAN configuration operation for the arbitration lost behavior setting. * - * This macro can be used to create a CAN configuration operation for Options setting. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * This macro can be used to create a CAN configuration operation for the arbitration lost behavior setting. + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo - * \param[in] The baudrate \ref fmi3LsBusCanBaudrate. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] ArbitrationLostBehavior The arbitration lost behavior (\ref fmi3LsBusCanArbitrationLostBehavior). */ #define FMI3_LS_BUS_CAN_CREATE_OP_CONFIGURATION_ARBITRATION_LOST_BEHAVIOR(BufferInfo, ArbitrationLostBehavior) \ do \ @@ -339,7 +343,7 @@ extern "C" _op.parameterType = FMI3_LS_BUS_CAN_CONFIG_PARAM_TYPE_ARBITRATION_LOST_BEHAVIOR; \ _op.arbitrationLostBehavior = (ArbitrationLostBehavior); \ \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ (BufferInfo)->writePos += _op.header.length; \ @@ -353,51 +357,52 @@ extern "C" while (0) /** - * \brief Creates a CAN arbitration lost operation + * \brief Creates a CAN arbitration lost operation. * * This macro can be used to create a CAN arbitration lost operation. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo - * \param[in] CAN message ID \ref fmi3LsBusCanId. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] ID CAN message ID (\ref fmi3LsBusCanId). */ -#define FMI3_LS_BUS_CAN_CREATE_OP_ARBITRATION_LOST(BufferInfo, ID) \ - do \ - { \ - fmi3LsBusCanOperationArbitrationLost _op; \ - _op.header.type = FMI3_LS_BUS_CAN_OP_ARBITRATION_LOST; \ - _op.header.length = sizeof(fmi3LsBusOperationHeader) + sizeof(fmi3LsBusCanId); \ - _op.id = (ID); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ - { \ - memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ - (BufferInfo)->writePos += _op.header.length; \ - (BufferInfo)->status = fmi3True; \ - } \ - else \ - { \ - (BufferInfo)->status = fmi3False; \ - } \ - } \ +#define FMI3_LS_BUS_CAN_CREATE_OP_ARBITRATION_LOST(BufferInfo, ID) \ + do \ + { \ + fmi3LsBusCanOperationArbitrationLost _op; \ + _op.header.type = FMI3_LS_BUS_CAN_OP_ARBITRATION_LOST; \ + _op.header.length = sizeof(fmi3LsBusOperationHeader) + sizeof(fmi3LsBusCanId); \ + _op.id = (ID); \ + \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ + { \ + memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ + (BufferInfo)->writePos += _op.header.length; \ + (BufferInfo)->status = fmi3True; \ + } \ + else \ + { \ + (BufferInfo)->status = fmi3False; \ + } \ + } \ while (0) /** - * \brief Creates a CAN bus error operation + * \brief Creates a CAN bus error operation. * * This macro can be used to create a CAN bus error operation. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo - * \param[in] CAN message ID \ref fmi3LsBusCanId. - * \param[in] Error Code \ref fmi3LsBusCanErrorCode. - * \param[in] Error Flag \ref fmi3LsBusCanErrorFlag. - * \param[in] Is Sender \ref fmi3LsBusCanIsSender. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] ID CAN message ID (\ref fmi3LsBusCanId). + * \param[in] ErrorCode Error Code (\ref fmi3LsBusCanErrorCode). + * \param[in] ErrorFlag Error Flag (\ref fmi3LsBusCanErrorFlag). + * \param[in] IsSender Is Sender (\ref fmi3LsBusCanIsSender). */ -#define FMI3_LS_BUS_CAN_CREATE_OP_BUS_ERROR(BufferInfo, ErrorCode, ErrorFlag, IsSender) \ +#define FMI3_LS_BUS_CAN_CREATE_OP_BUS_ERROR(BufferInfo, ID, ErrorCode, ErrorFlag, IsSender) \ do \ { \ fmi3LsBusCanOperationBusError _op; \ @@ -409,7 +414,8 @@ extern "C" _op.errorCode = (ErrorCode); \ _op.errorFlag = (ErrorFlag); \ _op.isSender = (IsSender); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ (BufferInfo)->writePos += _op.header.length; \ @@ -423,15 +429,15 @@ extern "C" while (0) /** - * \brief Creates a CAN status operation + * \brief Creates a CAN status operation. * * This macro can be used to create a CAN status operation. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo - * \param[in] Status Kind \ref fmi3LsBusCanStatusKind. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] Status Status Kind (\ref fmi3LsBusCanStatusKind). */ #define FMI3_LS_BUS_CAN_CREATE_OP_STATUS(BufferInfo, Status) \ do \ @@ -440,7 +446,8 @@ extern "C" _op.header.type = FMI3_LS_BUS_CAN_OP_STATUS; \ _op.header.length = sizeof(fmi3LsBusOperationHeader) + sizeof(fmi3LsBusCanStatusKind); \ _op.status = (Status); \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ + \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ { \ memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ (BufferInfo)->writePos += _op.header.length; \ @@ -454,33 +461,33 @@ extern "C" while (0) /** - * \brief Creates a CAN wakeup operation + * \brief Creates a CAN wakeup operation. * * This macro can be used to create a CAN wakeup operation. - * The argumnts are serialized according to the fmi-ls-bus specification and written to the buffer + * The arguments are serialized according to the fmi-ls-bus specification and written to the buffer * described by the argument 'BufferInfo'. If there is no enough buffer space available, the 'status' * variable of the argument 'BufferInfo' is set to fmi3False. * - * \param[in] Pointer to \ref fmi3LsBusUtilBufferInfo. + * \param[in] BufferInfo Pointer to \ref fmi3LsBusUtilBufferInfo. */ -#define FMI3_LS_BUS_CAN_CREATE_OP_WAKEUP(BufferInfo) \ - do \ - { \ - fmi3LsBusCanOperationWakeup _op; \ - _op.header.type = FMI3_LS_BUS_CAN_OP_WAKEUP; \ - _op.header.length = sizeof(fmi3LsBusOperationHeader); \ - \ - if (_op.header.length <= ((BufferInfo)->end - (BufferInfo)->writePos)) \ - { \ - memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ - (BufferInfo)->writePos += _op.header.length; \ - (BufferInfo)->status = fmi3True; \ - } \ - else \ - { \ - (BufferInfo)->status = fmi3False; \ - } \ - } \ +#define FMI3_LS_BUS_CAN_CREATE_OP_WAKEUP(BufferInfo) \ + do \ + { \ + fmi3LsBusCanOperationWakeup _op; \ + _op.header.type = FMI3_LS_BUS_CAN_OP_WAKEUP; \ + _op.header.length = sizeof(fmi3LsBusOperationHeader); \ + \ + if (_op.header.length <= (fmi3UInt32)((BufferInfo)->end - (BufferInfo)->writePos)) \ + { \ + memcpy((BufferInfo)->writePos, &_op, _op.header.length); \ + (BufferInfo)->writePos += _op.header.length; \ + (BufferInfo)->status = fmi3True; \ + } \ + else \ + { \ + (BufferInfo)->status = fmi3False; \ + } \ + } \ while (0) #ifdef __cplusplus