From 6698451097d61ff1ab94fe44e51fa82375538c76 Mon Sep 17 00:00:00 2001 From: nier Date: Sat, 8 Oct 2011 18:43:19 +0200 Subject: [PATCH] starting on a solution to make com and pdur to work with j1939tp --- communication/Com/Com.c | 30 +++++++++++++++++++++++++++++- communication/Com/Com_Com.c | 9 +++++++++ communication/Com/Com_Internal.h | 5 +++++ communication/PduR/PduR_J1939Tp.c | 8 ++++++++ include/Com_Com.h | 4 +++- include/PduR_J1939Tp.h | 3 +++ 6 files changed, 57 insertions(+), 2 deletions(-) diff --git a/communication/Com/Com.c b/communication/Com/Com.c index d8af8c90..50b06735 100644 --- a/communication/Com/Com.c +++ b/communication/Com/Com.c @@ -31,6 +31,10 @@ #include "debug.h" + + +extern Com_BufferPduStateType Com_BufferPduState[]; + /* TODO: Better way to get endianness across all compilers? */ static const uint32_t endianness_test = 0xdeadbeefU; ComSignalEndianess_type Com_SystemEndianness; @@ -165,7 +169,9 @@ void Com_Init(const Com_ConfigType *config ) { } } } - + for (uint16 i = 0; i < COM_N_IPDUS; i++) { + Com_BufferPduState[i].currentPosition = 0; + } // An error occurred. if (failure) { @@ -197,3 +203,25 @@ void Com_IpduGroupStop(Com_PduGroupIdType IpduGroupId) { } } } + +/** + * + * @param PduId + * @param PduInfoPtr + * @param RetryInfoPtr not supported + * @param TxDataCntPtr + * @return + */ +BufReq_ReturnType Com_CopyTxData(PduIdType PduId, PduInfoType* PduInfoPtr, RetryInfoType* RetryInfoPtr, PduLengthType* TxDataCntPtr) { + imask_t state; + Irq_Save(state); + if (PduInfoPtr->SduLength != 0) { + Com_BufferPduState[PduId].locked = true; + } + memcpy(PduInfoPtr->SduDataPtr,Com_Arc_Config.ComIPdu[PduId].ComIPduDataPtr + Com_BufferPduState[PduId].currentPosition, PduInfoPtr->SduLength); + Com_BufferPduState[PduId].currentPosition += PduInfoPtr->SduLength; + const ComIPdu_type *IPdu = GET_IPdu(PduId); + *TxDataCntPtr = IPdu->ComIPduSize - Com_BufferPduState[PduId].currentPosition; + Irq_Restore(state); + return BUFREQ_OK; +} diff --git a/communication/Com/Com_Com.c b/communication/Com/Com_Com.c index 770c7b01..2b173654 100644 --- a/communication/Com/Com_Com.c +++ b/communication/Com/Com_Com.c @@ -31,6 +31,7 @@ #include "Det.h" #include "Cpu.h" +Com_BufferPduStateType Com_BufferPduState[COM_N_IPDUS]; uint8 Com_SendSignal(Com_SignalIdType SignalId, const void *SignalDataPtr) { VALIDATE_SIGNAL(SignalId, 0x0a, E_NOT_OK); @@ -200,8 +201,13 @@ void Com_RxIndication(PduIdType ComRxPduId, const PduInfoType* PduInfoPtr) { } void Com_TxConfirmation(PduIdType ComTxPduId) { + imask_t state; + Irq_Save(state); PDU_ID_CHECK(ComTxPduId, 0x15); + Com_BufferPduState[ComTxPduId].locked = false; + Com_BufferPduState[ComTxPduId].currentPosition = 0; (void)ComTxPduId; // Nothing to be done. This is just to avoid Lint warning. + Irq_Restore(state); } @@ -270,3 +276,6 @@ void Com_ReceiveShadowSignal(Com_SignalIdType SignalId, void *SignalDataPtr) { // Com_CopyData(SignalDataPtr, Arc_GroupSignal->Com_Arc_ShadowBuffer, GroupSignal->ComBitSize, 0, GroupSignal->ComBitPosition); Com_ReadSignalDataFromPduBuffer(SignalId, TRUE, SignalDataPtr, (void *)Arc_GroupSignal->Com_Arc_ShadowBuffer); } + + + diff --git a/communication/Com/Com_Internal.h b/communication/Com/Com_Internal.h index 147ab348..36b213da 100644 --- a/communication/Com/Com_Internal.h +++ b/communication/Com/Com_Internal.h @@ -24,6 +24,11 @@ #include "Com_Arc_Types.h" +typedef struct { + PduLengthType currentPosition; + boolean locked; +} Com_BufferPduStateType; + extern const Com_ConfigType *ComConfig; extern Com_Arc_Config_type Com_Arc_Config; diff --git a/communication/PduR/PduR_J1939Tp.c b/communication/PduR/PduR_J1939Tp.c index e2d12cec..b99fb6dc 100644 --- a/communication/PduR/PduR_J1939Tp.c +++ b/communication/PduR/PduR_J1939Tp.c @@ -42,5 +42,13 @@ void PduR_J1939TpTxConfirmation(PduIdType J1939TpTxId, NotifResultType Result) { PduR_ARC_TxConfirmation(J1939TpTxId, Result, 0x0f); } +/* autosar 4 api */ +BufReq_ReturnType PduR_J1939TpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr) { +#if PDUR_COM_SUPPORT == STD_OFF + return BUFREQ_NOT_OK; +#endif + const PduRRoutingPath_type *route = PduRConfig->RoutingPaths[id]; + return Com_CopyTxData(route->SrcModule, info,0 ,availableDataPtr); +} #endif diff --git a/include/Com_Com.h b/include/Com_Com.h index dc42a874..d18411a7 100644 --- a/include/Com_Com.h +++ b/include/Com_Com.h @@ -36,7 +36,6 @@ void Com_TriggerIPduSend(PduIdType ComTxPduId); void Com_RxIndication(PduIdType ComRxPduId, const PduInfoType* PduInfoPtr); void Com_TxConfirmation(PduIdType ComTxPduId); - /* Signal Groups */ Std_ReturnType Com_SendSignalGroup(Com_SignalGroupIdType SignalGroupId); @@ -46,4 +45,7 @@ void Com_UpdateShadowSignal(Com_SignalIdType SignalId, const void *SignalDataPtr void Com_ReceiveShadowSignal(Com_SignalIdType SignalId, void *SignalDataPtr); +/* Autosar 4 Api */ +BufReq_ReturnType Com_CopyTxData(PduIdType PduId, PduInfoType* PduInfoPtr, RetryInfoType* RetryInfoPtr, PduLengthType* TxDataCntPtr); + #endif /* COM_COM_H_ */ diff --git a/include/PduR_J1939Tp.h b/include/PduR_J1939Tp.h index 5bf5ad15..e0b1deb6 100644 --- a/include/PduR_J1939Tp.h +++ b/include/PduR_J1939Tp.h @@ -27,6 +27,9 @@ void PduR_J1939TpTxConfirmation(PduIdType CanTpTxPduId, NotifResultType Result); BufReq_ReturnType PduR_J1939TpStartOfReception(PduIdType id, PduLengthType TpSduLength, PduLengthType* bufferSizePtr); void PduR_J1939TpRxIndication(PduIdType id, NotifResultType Result); +/* autosar 4 api */ +BufReq_ReturnType PduR_J1939TpCopyTxData(PduIdType id, PduInfoType* info, RetryInfoType* retry, PduLengthType* availableDataPtr); + #endif #endif /* PDUR_CANTP_H_ */ -- 2.39.2