/** * \file * struct which represent LinDescriptionFile (source) */ #include #include "ldf.h" extern struct ProtoInterface; /*=================================================================== ======= TYPES ======================================================= ====================================================================*/ /** \defgroup LDFstruct LDF structure */ /** \{ */ #define SLAVENODESATTRIBUTES_BUFFER_INIT_SIZE 16 /**< Initsize for LIN_Nodes::slaveNodesAttributesDef buffer. */ #define CONFIGURED_NADS_BUFFER_INIT_SIZE 5 /**< Initsize for LIN_SlaveNodeAttributesDef::configuredNADs buffer. */ #define CONFIGURED_FRAMES_BUFFER_INIT_SIZE 5 /**< Initsize for LIN_SlaveNodeAttributesDef::configuredFrames buffer. */ #define SIGNALSDEF_BUFFER_INIT_SIZE 30 /**< Initsize for LDFstruct::LIN_signals buffer. */ #define SIGNAL_SUBSCRIBERS_BUFFER_INIT_SIZE 5 /**< Initsize for LIN_signals::subscriberNodes buffer. */ #define FRAMEDEF_BUFFER_INIT_SIZE (FRAMEID_MAX_NR) /**< Initsize for LDFstruct::LIN_frames buffer. */ #define FRAMEIDS_BUFFER_INIT_SIZE 2 #define INCLUDEDSIGNALS_BUFFER_INIT_SIZE 16 #define SIGNALENCODINGTYPES_BUFFER_INIT_SIZE 64 #define SIGNALENCODINGDATA_BUFFER_INIT_SIZE 5 /** \} */ /*=================================================================== ======= FUNCTIONS =================================================== ====================================================================*/ /** \addtogroup LDFstruct */ /** \{ */ int LDF_init(LDFstruct *ldfp, struct ProtoInterface *protoInterfacep, const char *compositeConfigurationNamep) { int okf = TRUE; ldfp->protoInterfacep = protoInterfacep; ldfp->compositeConfigurationNamep = compositeConfigurationNamep; ldfp->protocolVersionMajor = 0; ldfp->protocolVersionMinor = 0; ldfp->languageVersionMajor = 0; ldfp->languageVersionMinor = 0; ldfp->speed = 0; ldfp->postfixChannelName[0] = '\0'; ldfp->nodes.masterNodeIdent[0] = '\0'; ldfp->nodes.timebase = 0; ldfp->nodes.jitter = 0; okf = (okf && bufferVector_init(&ldfp->nodes.slaveNodesAttributesDef, sizeof(struct LIN_SlaveNodeAttributesDef), SLAVENODESATTRIBUTES_BUFFER_INIT_SIZE, protoInterfacep)); okf = (okf && bufferVector_init(&ldfp->LIN_signals, sizeof(struct LIN_SignalDef), SIGNALSDEF_BUFFER_INIT_SIZE, protoInterfacep)); okf = (okf && bufferVector_init(&ldfp->LIN_frames, sizeof(struct LIN_FrameDef), FRAMEDEF_BUFFER_INIT_SIZE, protoInterfacep)); okf = (okf && bufferVector_init(&ldfp->LIN_signalEncodingTypes, sizeof(struct LIN_SignalEncodingType), SIGNALENCODINGTYPES_BUFFER_INIT_SIZE, protoInterfacep)); return okf; } void LDF_destroy(LDFstruct *ldfp) { struct { BufferVector *bufferp; void (*destroyFunctionp)(void *); } *actBufferp, destroyBuffersArray[] = { { &ldfp->nodes.slaveNodesAttributesDef, LDF_slaveNodeAttributesDefEntry_destroy }, { &ldfp->LIN_signals , LDF_signalDefEntry_destroy }, { &ldfp->LIN_frames , LDF_frameDefEntry_destroy }, { &ldfp->LIN_signalEncodingTypes , LDF_signalEncodingTypeEntry_destroy }, { NULL , NULL }, }; void *entryp = NULL; ldfp->protoInterfacep = NULL; ldfp->compositeConfigurationNamep = NULL; ldfp->protocolVersionMajor = 0; ldfp->protocolVersionMinor = 0; ldfp->languageVersionMajor = 0; ldfp->languageVersionMinor = 0; ldfp->speed = 0; ldfp->postfixChannelName[0] = '\0'; ldfp->nodes.masterNodeIdent[0] = '\0'; ldfp->nodes.timebase = 0; ldfp->nodes.jitter = 0; actBufferp = destroyBuffersArray; while (actBufferp->bufferp) { while (entryp = bufferVector_getElementRef(actBufferp->bufferp, 0)) { actBufferp->destroyFunctionp(entryp); bufferVector_skip(actBufferp->bufferp, 1); } bufferVector_destroy(actBufferp->bufferp); actBufferp++; } } /** \} */ /** \defgroup LDF_processing LDF Processing * \ingroup LDFstruct */ /** \{ */ int LDF_slaveNodeAttributesDefEntry_init(LDFstruct *ldfp, struct LIN_SlaveNodeAttributesDef *slaveNodeAttributesDefp) { slaveNodeAttributesDefp->slaveNodeValid = SLAVENODEDEF_INVALID; slaveNodeAttributesDefp->nodeIdent[MAX_STRING_LEN + 1] = '\0'; slaveNodeAttributesDefp->compositeNodePos = 0; slaveNodeAttributesDefp->linProtocolVersionMajor = 0; slaveNodeAttributesDefp->linProtocolVersionMinor = 0; slaveNodeAttributesDefp->initNAD = 0; if (FALSE == bufferVector_init(&slaveNodeAttributesDefp->configuredNADs, sizeof(struct ConfiguredNAD), CONFIGURED_NADS_BUFFER_INIT_SIZE, ldfp->protoInterfacep)) return FALSE; slaveNodeAttributesDefp->supplierID = 0; slaveNodeAttributesDefp->functionID = 0; slaveNodeAttributesDefp->variantID = 0; slaveNodeAttributesDefp->responseErrorSignalPos = 0; if (FALSE == bufferVector_init(&slaveNodeAttributesDefp->configuredFrames, sizeof(struct ConfiguredFrame), CONFIGURED_FRAMES_BUFFER_INIT_SIZE, ldfp->protoInterfacep)) return FALSE; return TRUE; } void LDF_slaveNodeAttributesDefEntry_destroy(struct LIN_SlaveNodeAttributesDef *slaveNodeAttributesDefp) { struct ConfiguredNAD *configuredNADp = NULL; struct ConfiguredFrame *configuredFramep = NULL; slaveNodeAttributesDefp->slaveNodeValid = SLAVENODEDEF_INVALID; slaveNodeAttributesDefp->nodeIdent[MAX_STRING_LEN + 1] = '\0'; slaveNodeAttributesDefp->compositeNodePos = 0; slaveNodeAttributesDefp->linProtocolVersionMajor = 0; slaveNodeAttributesDefp->linProtocolVersionMinor = 0; slaveNodeAttributesDefp->initNAD = 0; while (configuredNADp = (struct ConfiguredNAD*) bufferVector_getElementRef(&slaveNodeAttributesDefp->configuredNADs, 0)) { LDF_configuredNADEntry_destroy(configuredNADp); bufferVector_skip(&slaveNodeAttributesDefp->configuredNADs, 1); } bufferVector_destroy(&slaveNodeAttributesDefp->configuredNADs); slaveNodeAttributesDefp->supplierID = 0; slaveNodeAttributesDefp->functionID = 0; slaveNodeAttributesDefp->variantID = 0; slaveNodeAttributesDefp->responseErrorSignalPos = 0; while (configuredFramep = (struct ConfiguredFrame*) bufferVector_getElementRef(&slaveNodeAttributesDefp->configuredFrames, 0)) { LDF_configuredFrameEntry_destroy(configuredFramep); bufferVector_skip(&slaveNodeAttributesDefp->configuredFrames, 1); } bufferVector_destroy(&slaveNodeAttributesDefp->configuredFrames); } int LDF_configuredFrameEntry_init(LDFstruct *ldfp, struct ConfiguredFrame *configuredFramep) { configuredFramep->frameIdentPos = 0; configuredFramep->messageID = 0; return TRUE; } void LDF_configuredFrameEntry_destroy(struct ConfiguredFrame *configuredFramep) { configuredFramep->frameIdentPos = 0; configuredFramep->messageID = 0; } int LDF_signalDefEntry_init(LDFstruct *ldfp, struct LIN_SignalDef *signalDefp) { signalDefp->signalValid = SIGNALDEFINTION_INVALID; signalDefp->signalIdent[0] = '\0'; signalDefp->sizeBits = 0; signalDefp->byteArrayf = FALSE; signalDefp->publisherIdentPos = 0; signalDefp->signalEncodingTypePos = 0; if (FALSE == bufferVector_init(&signalDefp->subscriberNodes, sizeof(size_t), SIGNAL_SUBSCRIBERS_BUFFER_INIT_SIZE, ldfp->protoInterfacep)) return FALSE; return TRUE; } void LDF_signalDefEntry_destroy(struct LIN_SignalDef *signalDefp) { signalDefp->signalValid = SIGNALDEFINTION_INVALID; signalDefp->signalIdent[0] = '\0'; signalDefp->sizeBits = 0; signalDefp->byteArrayf = FALSE; signalDefp->publisherIdentPos = 0; signalDefp->signalEncodingTypePos = 0; bufferVector_destroy(&signalDefp->subscriberNodes); } int LDF_frameDefEntry_init(LDFstruct *ldfp, struct LIN_FrameDef *frameDefp) { frameDefp->frameValidf = FALSE; frameDefp->frameIdent[MAX_STRING_LEN + 1] = '\0'; if (FALSE == bufferVector_init(&frameDefp->frameIDs, sizeof(struct LIN_FrameID), FRAMEIDS_BUFFER_INIT_SIZE, ldfp->protoInterfacep)) return FALSE; frameDefp->frameType = FRAMETYPE_NOTDEFINED; frameDefp->checksumType = CHECKSUMTYPE_NOTDEFINED; frameDefp->frameSize = 0; frameDefp->publisherIdentPos = 0; if (FALSE == bufferVector_init(&frameDefp->includedData, sizeof(union LIN_IncludedData), INCLUDEDSIGNALS_BUFFER_INIT_SIZE, ldfp->protoInterfacep)) return FALSE; return TRUE; } INLINE void LDF_includedDataEntry_destroy(union LIN_IncludedData *datap) { /*nothing to do*/ } void LDF_frameDefEntry_destroy(struct LIN_FrameDef *frameDefp) { struct LIN_FrameID *frameIDp = NULL; union LIN_IncludedData *includedDatap = NULL; frameDefp->frameValidf = FALSE; frameDefp->frameIdent[MAX_STRING_LEN + 1] = '\0'; while (frameIDp = bufferVector_getElementRef(&frameDefp->frameIDs, 0)) { LDF_frameIDEntry_destroy(frameIDp); bufferVector_skip(&frameDefp->frameIDs, 1); } bufferVector_destroy(&frameDefp->frameIDs); frameDefp->frameType = FRAMETYPE_NOTDEFINED; frameDefp->checksumType = CHECKSUMTYPE_NOTDEFINED; frameDefp->frameSize = 0; frameDefp->publisherIdentPos = 0; while (includedDatap = bufferVector_getElementRef(&frameDefp->includedData, 0)) { LDF_includedDataEntry_destroy(includedDatap); bufferVector_skip(&frameDefp->includedData, 1); } bufferVector_destroy(&frameDefp->includedData); } int LDF_frameIDEntry_init(LDFstruct *ldfp, struct LIN_FrameID *frameIDp) { frameIDp->id = 0; frameIDp->startTimeRef = 0; frameIDp->endTimeRef = 0; return TRUE; } void LDF_frameIDEntry_destroy(struct LIN_FrameID *frameIDp) { frameIDp->id = 0; frameIDp->startTimeRef = 0; frameIDp->endTimeRef = 0; } int LDF_includedSignalEntry_init(LDFstruct *ldfp, struct LIN_IncludedSignal *signalp) { signalp->signalIdentPos = 0; signalp->signalOffset = 0; return TRUE; } void LDF_includedSignalEntry_destroy(struct LIN_IncludedSignal *signalp) { signalp->signalIdentPos = 0; signalp->signalOffset = 0; } int LDF_includedFrameEntry_init(LDFstruct *ldfp, struct LIN_IncludedFrame *framep) { framep->frameIdentPos = 0; return TRUE; } void LDF_includedFrameEntry_destroy(struct LIN_IncludedFrame *framep) { framep->frameIdentPos = 0; } int LDF_signalEncodingTypeEntry_init(LDFstruct *ldfp, struct LIN_SignalEncodingType *encodingTypep) { encodingTypep->signalEncodingTypeValidf = FALSE; encodingTypep->encodingIdent[0] = '\0'; if (FALSE == bufferVector_init(&encodingTypep->signalEncodingData, sizeof(struct SignalEncodingData), SIGNALENCODINGDATA_BUFFER_INIT_SIZE, ldfp->protoInterfacep)) return FALSE; return TRUE; } void LDF_signalEncodingTypeEntry_destroy(struct LIN_SignalEncodingType *encodingTypep) { struct SignalEncodingData * encodingDatap = NULL; encodingTypep->signalEncodingTypeValidf = FALSE; encodingTypep->encodingIdent[0] = '\0'; while (encodingDatap = bufferVector_getElementRef(&encodingTypep->signalEncodingData, 0)) { LDF_encodingDataEntry_destroy(encodingDatap); bufferVector_skip(&encodingTypep->signalEncodingData, 1); } bufferVector_destroy(&encodingTypep->signalEncodingData); } int LDF_encodingDataEntry_init(LDFstruct *ldfp, struct SignalEncodingData *encodingDatap) { encodingDatap->encodingType = SIGNALENCODING_INVALID; /*if (encodingType == SIGNALENCODING_LOGICVALUE) { encodingDatap->encodingData.logic.signalValue = 0; encodingDatap->encodingData.logic.textInfo[0] = '\0'; } else if (encodingType == SIGNALENCODING_PHYSICALRANGE) { encodingDatap->encodingData.range.minValue = 0; encodingDatap->encodingData.range.maxValue = 0; encodingDatap->encodingData.range.scale = 0; encodingDatap->encodingData.range.offset = 0; encodingDatap->encodingData.range.textInfo[0] = '\0'; }*/ return TRUE; } void LDF_encodingDataEntry_destroy(struct SignalEncodingData *encodingDatap) { encodingDatap->encodingType = SIGNALENCODING_INVALID; } int LDF_nodeIdentFind(LDFstruct *ldfp, const char *identString, size_t *posp) { struct LIN_SlaveNodeAttributesDef *slaveNodeAttributesDefp = NULL; size_t n = 1; if (strncmp(ldfp->nodes.masterNodeIdent, identString, MAX_STRING_LEN + 1) == 0) { *posp = 0; return TRUE; } while (slaveNodeAttributesDefp = LDF_slaveNodeAttributesDef_getRef(ldfp, n)) { if (strncmp(slaveNodeAttributesDefp->nodeIdent, identString, MAX_STRING_LEN + 1) == 0) { *posp = n; return TRUE; } n++; } return FALSE; } int LDF_nodeIdentFindCreate(LDFstruct *ldfp, const char *identString, size_t *posp) { struct LIN_SlaveNodeAttributesDef *slaveNodeAttributesDefp = NULL; if (FALSE == LDF_nodeIdentFind(ldfp, identString, posp)) { slaveNodeAttributesDefp = bufferVector_appendEmptyElements(&ldfp->nodes.slaveNodesAttributesDef, 1); if (slaveNodeAttributesDefp == NULL || FALSE == LDF_slaveNodeAttributesDefEntry_init(ldfp, slaveNodeAttributesDefp)) return FALSE; strncpy(slaveNodeAttributesDefp->nodeIdent, identString, MAX_STRING_LEN + 1); slaveNodeAttributesDefp->nodeIdent[MAX_STRING_LEN + 1] = '\0'; *posp = bufferVector_getActSize(&ldfp->nodes.slaveNodesAttributesDef) - 1 + 1; /* +1 because masternode is defined to be at pos==0 => first slave node is at pos==1*/ } return TRUE; } char* LDF_nodeIdentGet(LDFstruct *ldfp, size_t pos) { struct LIN_SlaveNodeAttributesDef *slaveNodeAttributesDefp = NULL; if (pos == 0) return ldfp->nodes.masterNodeIdent; if (slaveNodeAttributesDefp = LDF_slaveNodeAttributesDef_getRef(ldfp, pos)) return slaveNodeAttributesDefp->nodeIdent; else return NULL; } int LDF_signalIdentFind(LDFstruct *ldfp, const char *identString, size_t *posp) { struct LIN_SignalDef *linSignalDefp = NULL; size_t n = 0; while (linSignalDefp = LDF_signalDef_getRef(ldfp, n)) { if (strncmp(linSignalDefp->signalIdent, identString, MAX_STRING_LEN + 1) == 0) { *posp = n; return TRUE; } n++; } return FALSE; } int LDF_signalIdentFindCreate(LDFstruct *ldfp, const char *identString, size_t *posp) { struct LIN_SignalDef *signalDefp = NULL; if (FALSE == LDF_signalIdentFind(ldfp, identString, posp)) { signalDefp = bufferVector_appendEmptyElements(&ldfp->LIN_signals, 1); if (signalDefp == NULL || FALSE == LDF_signalDefEntry_init(ldfp, signalDefp)) return FALSE; strncpy(signalDefp->signalIdent, identString, MAX_STRING_LEN + 1); signalDefp->signalIdent[MAX_STRING_LEN + 1] = '\0'; *posp = bufferVector_getActSize(&ldfp->LIN_signals) - 1; } return TRUE; } char* LDF_signalIdentGet(LDFstruct* ldfp, size_t pos) { struct LIN_SignalDef *linSignalDefp = NULL; if (linSignalDefp = LDF_signalDef_getRef(ldfp, pos)) return linSignalDefp->signalIdent; else return NULL; } int LDF_nodeFind_ByConfiguredNADTimeref(LDFstruct *ldfp, unsigned char configuredNAD, unsigned int timeRef, size_t *startPosp) { size_t nNodeDef = *startPosp; /*masternode has pos = 0*/ size_t nConfigureNAD = 0; struct LIN_SlaveNodeAttributesDef *slaveNodeAttributesDefp = NULL; struct ConfiguredNAD *configureNADp = NULL; if (nNodeDef == 0) nNodeDef = 1; while (slaveNodeAttributesDefp = LDF_slaveNodeAttributesDef_getRef(ldfp, nNodeDef)) { if (slaveNodeAttributesDefp->slaveNodeValid == SLAVENODEDEF_NODEVALID) { nConfigureNAD = 0; while (configureNADp = (struct ConfiguredNAD*) bufferVector_getElementRefConst(&slaveNodeAttributesDefp->configuredNADs, nConfigureNAD)) { if ((configureNADp->configuredNAD == configuredNAD || configuredNAD == NAD_BROADCAST) && configureNADp->startTimeRef <= timeRef && (configureNADp->endTimeRef == 0 || configureNADp->endTimeRef > timeRef)) { *startPosp = nNodeDef; return TRUE; } nConfigureNAD++; } } nNodeDef++; } return FALSE; } int LDF_nodeFind_ByInitNAD(LDFstruct *ldfp, unsigned char initNAD, size_t *posp) { struct LIN_SlaveNodeAttributesDef *slaveNodeAttributesDefp = NULL; size_t posNodes = 1; while (slaveNodeAttributesDefp = LDF_slaveNodeAttributesDef_getRef(ldfp, posNodes)) { if (slaveNodeAttributesDefp->slaveNodeValid == SLAVENODEDEF_NODEVALID && slaveNodeAttributesDefp->initNAD == initNAD) { *posp = posNodes; return TRUE; } posNodes++; } return FALSE; } int LDF_configuredNAD_append(LDFstruct *ldfp, struct LIN_SlaveNodeAttributesDef *slaveNodeAttributesDefp, unsigned char configuredNAD, TimeRef timeRef) { struct ConfiguredNAD *configureNADp = NULL; struct BufferVector *configueredNADBufferp = &slaveNodeAttributesDefp->configuredNADs; size_t pos; /*if a previous entry already exist => change its endTimeRef value*/ if (pos = bufferVector_getActSize(configueredNADBufferp)) { configureNADp = (struct ConfiguredNAD*) bufferVector_getElementRef(configueredNADBufferp, pos - 1); configureNADp->endTimeRef = timeRef; } configureNADp = (struct ConfiguredNAD*) bufferVector_appendEmptyElements(configueredNADBufferp, 1); if (configureNADp == NULL || FALSE == LDF_configuredNADEntry_init(ldfp, configureNADp)) return FALSE; configureNADp->configuredNAD = configuredNAD; configureNADp->startTimeRef = timeRef; configureNADp->endTimeRef = 0; return TRUE; } int LDF_frameIdentFind(LDFstruct *ldfp, const char *identString, size_t *posp) { struct LIN_FrameDef *frameDefp = NULL; size_t n = 0; while (frameDefp = LDF_frameDef_getRef(ldfp, n)) { if (strncmp(frameDefp->frameIdent, identString, MAX_STRING_LEN + 1) == 0) { *posp = n; return TRUE; } n++; } return FALSE; } int LDF_frameIdentFindCreate(LDFstruct *ldfp, const char *identString, size_t *posp) { struct LIN_FrameDef *frameDefp = NULL; if (FALSE == LDF_frameIdentFind(ldfp, identString, posp)) { frameDefp = bufferVector_appendEmptyElements(&ldfp->LIN_frames, 1); if (frameDefp == NULL || FALSE == LDF_frameDefEntry_init(ldfp, frameDefp)) return FALSE; strncpy(frameDefp->frameIdent, identString, MAX_STRING_LEN + 1); frameDefp->frameIdent[MAX_STRING_LEN + 1] = '\0'; *posp = bufferVector_getActSize(&ldfp->LIN_frames) - 1; } return TRUE; } char* LDF_frameIdentGet(LDFstruct* ldfp, size_t pos) { struct LIN_FrameDef *frameDefp = NULL; if (frameDefp = LDF_frameDef_getRef(ldfp, pos)) return frameDefp->frameIdent; else return NULL; } int LDF_frameFind_ByIdTimeref(LDFstruct *ldfp, unsigned char frameID, unsigned int timeRef, size_t *posp) { size_t nFrameDef = 0; size_t nFrameID = 0; struct LIN_FrameDef *frameDefp = NULL; struct LIN_FrameID *frameIDp = NULL; while (frameDefp = LDF_frameDef_getRef(ldfp, nFrameDef)) { if (frameDefp->frameValidf) { nFrameID = 0; while (frameIDp = (struct LIN_FrameID*) bufferVector_getElementRefConst(&frameDefp->frameIDs, nFrameID)) { if (frameIDp->id == frameID && LDF_timeRefCheck(timeRef, frameIDp->startTimeRef, frameIDp->endTimeRef)) { *posp = nFrameDef; return TRUE; } nFrameID++; } } nFrameDef++; } return FALSE; } int LDF_frameID_append(LDFstruct *ldfp, struct LIN_FrameDef *frameDefp, unsigned char id, TimeRef timeRef) { struct LIN_FrameID *frameIDp = NULL; struct BufferVector *frameIdBufferp = &frameDefp->frameIDs; size_t pos; /*if a entry already exist => change its endTimeRef value*/ if (pos = bufferVector_getActSize(frameIdBufferp)) { frameIDp = (struct LIN_FrameID*) bufferVector_getElementRef(frameIdBufferp, pos - 1); frameIDp->endTimeRef = timeRef; } frameIDp = (struct LIN_FrameID*) bufferVector_appendEmptyElements(frameIdBufferp, 1); if (frameIDp == NULL || FALSE == LDF_frameIDEntry_init(ldfp, frameIDp)) return FALSE; frameIDp->id = id; frameIDp->startTimeRef = timeRef; frameIDp->endTimeRef = 0; return TRUE; } int LDF_signalEncodingTypeIdentFind(LDFstruct *ldfp, const char *identString, size_t *posp) { struct LIN_SignalEncodingType *encodingTypep = NULL; size_t n = 0; while (encodingTypep = LDF_signalEncodingTypeDef_getRef(ldfp, n)) { if (strncmp(encodingTypep->encodingIdent, identString, MAX_STRING_LEN + 1) == 0) { *posp = n; return TRUE; } n++; } return FALSE; } int LDF_signalEncodingTypeIdentFindCreate(LDFstruct *ldfp, const char *identString, size_t *posp) { struct LIN_SignalEncodingType *encodingTypep = NULL; if (FALSE == LDF_signalEncodingTypeIdentFind(ldfp, identString, posp)) { encodingTypep = bufferVector_appendEmptyElements(&ldfp->LIN_signalEncodingTypes, 1); if (encodingTypep == NULL || FALSE == LDF_signalEncodingTypeEntry_init(ldfp, encodingTypep)) return FALSE; strncpy(encodingTypep->encodingIdent, identString, MAX_STRING_LEN + 1); encodingTypep->encodingIdent[MAX_STRING_LEN + 1] = '\0'; *posp = bufferVector_getActSize(&ldfp->LIN_signalEncodingTypes) - 1; } return TRUE; } char* LDF_signalEncodingTypeIdentGet(LDFstruct* ldfp, size_t pos) { struct LIN_SignalEncodingType *encodingTypep = NULL; if (encodingTypep = LDF_signalEncodingTypeDef_getRef(ldfp, pos)) return encodingTypep->encodingIdent; else return NULL; } struct SignalEncodingData* LDF_signalEncodingData_getRef_byRawValue(LDFstruct *ldfp, size_t signalEncodingTypePos, unsigned short rawValue) { struct LIN_SignalEncodingType *encodingTypep = NULL; struct SignalEncodingData *encodingDatap = NULL; size_t n = 0; encodingTypep = LDF_signalEncodingTypeDef_getRef(ldfp, signalEncodingTypePos); if (encodingTypep == NULL || encodingTypep->signalEncodingTypeValidf == FALSE) return NULL; while (encodingDatap = bufferVector_getElementRef(&encodingTypep->signalEncodingData, n)) { if (encodingDatap->encodingType == SIGNALENCODING_BCDVALUE || encodingDatap->encodingType == SIGNALENCODING_ASCIIVALUE || (encodingDatap->encodingType == SIGNALENCODING_LOGICVALUE && encodingDatap->encodingData.logic.signalValue == rawValue) || (encodingDatap->encodingType == SIGNALENCODING_PHYSICALRANGE && encodingDatap->encodingData.range.minValue <= rawValue && encodingDatap->encodingData.range.maxValue >= rawValue)) return encodingDatap; n++; } return NULL; } struct SignalEncodingData* LDF_signalEncodingData_getRef_withoutRawValue(LDFstruct *ldfp, size_t signalEncodingTypePos) { struct LIN_SignalEncodingType *encodingTypep = NULL; struct SignalEncodingData *encodingDatap = NULL; size_t n = 0; encodingTypep = LDF_signalEncodingTypeDef_getRef(ldfp, signalEncodingTypePos); if (encodingTypep == NULL || encodingTypep->signalEncodingTypeValidf == FALSE) return NULL; while (encodingDatap = bufferVector_getElementRef(&encodingTypep->signalEncodingData, n)) { if (encodingDatap->encodingType == SIGNALENCODING_BCDVALUE || encodingDatap->encodingType == SIGNALENCODING_ASCIIVALUE) return encodingDatap; n++; } return NULL; } /** \} */