XDK API  3.6.0
Documentation
Files | Functions
XProtocol

API to encode and decode xProtocol frames. More...

+ Collaboration diagram for XProtocol:

Files

file  BCDS_XProtocol.h
 

Functions

 BCDS_DEPRECATED (Retcode_T xProtocol_Init(void))
 Initializes the xProtocol module. More...
 
 BCDS_DEPRECATED (Retcode_T xProtocol_EncodeFrame(const uint8_t *data, uint32_t dataLength, uint32_t maxFrameLength, uint8_t *frame, uint32_t *frameLength))
 Encodes an xProtocol frame. More...
 
 BCDS_DEPRECATED (Retcode_T xProtocol_DecodeFrame(const uint8_t *frame, uint32_t frameLength, uint32_t maxDataLength, uint8_t *data, uint32_t *dataLength))
 Decodes an xProtocol frame. More...
 
 BCDS_DEPRECATED (Retcode_T xProtocol_IsCompleteFrame(const uint8_t *frame, uint32_t frameLength, const uint8_t **lastCheckPosition))
 Check if an xProtocol frame is complete. More...
 
 BCDS_DEPRECATED (Retcode_T xProtocol_GetPayloadLength(const uint8_t *frame, uint32_t frameLength, uint32_t *payloadLength))
 Determine the payload length. More...
 
Retcode_T XProtocol_DecodeFrame (const uint8_t *frame, uint32_t frameLength, uint32_t maxDataLength, uint8_t *data, uint32_t *dataLength)
 Decodes an xProtocol frame. More...
 
Retcode_T XProtocol_EncodeFrame (const uint8_t *data, uint32_t dataLength, uint32_t maxFrameLength, uint8_t *frame, uint32_t *frameLength)
 Encodes an xProtocol frame. More...
 
Retcode_T XProtocol_GetPayloadLength (const uint8_t *frame, uint32_t frameLength, uint32_t *payloadLength)
 Determine the payload length. More...
 
Retcode_T XProtocol_Init (void)
 Initializes the xProtocol module. More...
 
Retcode_T XProtocol_IsCompleteFrame (const uint8_t *frame, uint32_t frameLength, const uint8_t **lastCheckPosition)
 Check if an xProtocol frame is complete. More...
 

Detailed Description

Frame format

SD CS Payload ED
1B 2B N Bytes 1B

SD - Start Delimiter

CS - Checksum

ED - End Delimiter

Any occurrence of SD or ED in CS or payload will be escaped (after the checksum calculation). The special character to escape (ESC) SDs and EDs is escaped as well.

The following table shows how escaping is done:

Symbol Hex Value Escape Symbol Hex Value
SD 0xC0 ESC_SD 0xDBDC
ED 0xC9 ESC_ED 0xDBDE
ESC 0xDB ESC_ESC 0xDBDD

The complete protocol definition can be found here: https://bcds01.de.bosch.com/wiki/display/BSA/xProtocol

Function Documentation

BCDS_DEPRECATED ( Retcode_T   xProtocol_Initvoid)
Deprecated:
since version vxx.xx.xx, replaced by XProtocol_Init
BCDS_DEPRECATED ( Retcode_T   xProtocol_EncodeFrameconst uint8_t *data, uint32_t dataLength, uint32_t maxFrameLength, uint8_t *frame, uint32_t *frameLength)
Deprecated:
since version vxx.xx.xx, replaced by XProtocol_EncodeFrame
Parameters
[in]datapointer to buffer which contains data from higher level protocols, which must not be NULL
dataLengthlength of data buffer
maxFrameLengthmaximum number of bytes the frame buffer can hold
[out]framepointer to buffer which is supposed to hold the encoded frame, which must not be NULL
[out]frameLengthlength of the encoded frame
Return values
RETCODE_SUCCESSdata encoding to frame successfull
RETCODE_NULL_POINTERif data, frame or frameLength is NULL
RETCODE_XPROTOCOL_FRAME_BUFFER_TOO_SMALLencoded frame does not fit in frame buffer
RETCODE_XPROTOCOL_DATA_EXCEEDES_MAX_PAYLOAD_LENGTHpayload length would exceed the maximum length
BCDS_DEPRECATED ( Retcode_T   xProtocol_DecodeFrameconst uint8_t *frame, uint32_t frameLength, uint32_t maxDataLength, uint8_t *data, uint32_t *dataLength)
Deprecated:
since version vxx.xx.xx, replaced by XProtocol_DecodeFrame
Parameters
[in]framepointer to buffer which contains an encoded frame, which must not be NULL.
frameLengthlength of frame buffer
maxDataLengthmaximum number of bytes the data buffer can hold
[out]datapointer to buffer which is supposed to hold the decoded data, which must not be NULL
[out]dataLengthlength of data buffer
Return values
RETCODE_SUCCESSframe decoding successfull
RETCODE_NULL_POINTERif data, frame or dataLength is NULL
RETCODE_XPROTOCOL_DATA_BUFFER_TOO_SMALLdecoded frame does not fit in data buffer
RETCODE_XPROTOCOL_INTEGRITY_FAILEDthe frame's checksum is wrong
RETCODE_XPROTOCOL_START_DELIMITER_MISSINGframe does not contain a start delimiter
RETCODE_XPROTOCOL_END_DELIMITER_MISSINGframe does not contain an end delimiter
BCDS_DEPRECATED ( Retcode_T   xProtocol_IsCompleteFrameconst uint8_t *frame, uint32_t frameLength, const uint8_t **lastCheckPosition)
Deprecated:
since version vxx.xx.xx, replaced by XProtocol_IsCompleteFrame
Parameters
[in]framepointer to buffer which contains an, possibly incomplete, encoded frame, which must not be NULL
frameLengthlength of frame buffer
[in,out]lastCheckPositionlast position within the frame which has been checked. If this function is called the first time on a frame, lastCheckPosition must be initialized to `frame'. Subsequent calls to XProtocol_IsCompleteFrame for the same frame will use and update that parameter, to avoid checking the bytes of the frame over and over again. This is only meant as a performance optimization. If performance is not an issue, then that field may be set to NULL.
Return values
RETCODE_SUCCESSframe buffer contains complete xProtocol frame
RETCODE_NULL_POINTERif frame pointer is NULL
RETCODE_XPROTOCOL_FRAME_NOT_COMPLETE_YETxProtocol is not complete yet
RETCODE_XPROTOCOL_DATA_EXCEEDES_MAX_PAYLOAD_LENGTHpayload length would exceed the maximum length
BCDS_DEPRECATED ( Retcode_T   xProtocol_GetPayloadLengthconst uint8_t *frame, uint32_t frameLength, uint32_t *payloadLength)
Deprecated:
since version vxx.xx.xx, replaced by XProtocol_GetPayloadLength
Parameters
[in]framepointer to buffer which contains an, possibly incomplete, encoded frame, which must not be NULL
frameLengthlength of frame buffer
[out]payloadLengthlength of payload, must not be NULL
Return values
RETCODE_SUCCESSpayloadLength contains payload length
RETCODE_NULL_POINTERif frame pointer or payloadLength is NULL
Retcode_T XProtocol_DecodeFrame ( const uint8_t *  frame,
uint32_t  frameLength,
uint32_t  maxDataLength,
uint8_t *  data,
uint32_t *  dataLength 
)
Parameters
[in]framepointer to buffer which contains an encoded frame, which must not be NULL.
frameLengthlength of frame buffer
maxDataLengthmaximum number of bytes the data buffer can hold
[out]datapointer to buffer which is supposed to hold the decoded data, which must not be NULL
[out]dataLengthlength of data buffer
Return values
RETCODE_SUCCESSframe decoding successfull
RETCODE_NULL_POINTERif data, frame or dataLength is NULL
RETCODE_XPROTOCOL_DATA_BUFFER_TOO_SMALLdecoded frame does not fit in data buffer
RETCODE_XPROTOCOL_INTEGRITY_FAILEDthe frame's checksum is wrong
RETCODE_XPROTOCOL_START_DELIMITER_MISSINGframe does not contain a start delimiter
RETCODE_XPROTOCOL_END_DELIMITER_MISSINGframe does not contain an end delimiter
Retcode_T XProtocol_EncodeFrame ( const uint8_t *  data,
uint32_t  dataLength,
uint32_t  maxFrameLength,
uint8_t *  frame,
uint32_t *  frameLength 
)
Parameters
[in]datapointer to buffer which contains data from higher level protocols, which must not be NULL
dataLengthlength of data buffer
maxFrameLengthmaximum number of bytes the frame buffer can hold
[out]framepointer to buffer which is supposed to hold the encoded frame, which must not be NULL
[out]frameLengthlength of the encoded frame
Return values
RETCODE_SUCCESSdata encoding to frame successfull
RETCODE_NULL_POINTERif data, frame or frameLength is NULL
RETCODE_XPROTOCOL_FRAME_BUFFER_TOO_SMALLencoded frame does not fit in frame buffer
RETCODE_XPROTOCOL_DATA_EXCEEDES_MAX_PAYLOAD_LENGTHpayload length would exceed the maximum length
Retcode_T XProtocol_GetPayloadLength ( const uint8_t *  frame,
uint32_t  frameLength,
uint32_t *  payloadLength 
)
Parameters
[in]framepointer to buffer which contains an, possibly incomplete, encoded frame, which must not be NULL
frameLengthlength of frame buffer
[out]payloadLengthlength of payload, must not be NULL
Return values
RETCODE_SUCCESSpayloadLength contains payload length
RETCODE_NULL_POINTERif frame pointer or payloadLength is NULL
Retcode_T XProtocol_Init ( void  )
Retcode_T XProtocol_IsCompleteFrame ( const uint8_t *  frame,
uint32_t  frameLength,
const uint8_t **  lastCheckPosition 
)
Parameters
[in]framepointer to buffer which contains an, possibly incomplete, encoded frame, which must not be NULL
frameLengthlength of frame buffer
[in,out]lastCheckPositionlast position within the frame which has been checked. If this function is called the first time on a frame, lastCheckPosition must be initialized to `frame'. Subsequent calls to XProtocol_IsCompleteFrame for the same frame will use and update that parameter, to avoid checking the bytes of the frame over and over again. This is only meant as a performance optimization. If performance is not an issue, then that field may be set to NULL.
Return values
RETCODE_SUCCESSframe buffer contains complete xProtocol frame
RETCODE_NULL_POINTERif frame pointer is NULL
RETCODE_XPROTOCOL_FRAME_NOT_COMPLETE_YETxProtocol is not complete yet
RETCODE_XPROTOCOL_DATA_EXCEEDES_MAX_PAYLOAD_LENGTHpayload length would exceed the maximum length

All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:53 by doxygen 1.8.8