summaryrefslogtreecommitdiff
path: root/lcmodule/source/cnh1605204_ldr_transport_layer
diff options
context:
space:
mode:
Diffstat (limited to 'lcmodule/source/cnh1605204_ldr_transport_layer')
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h1
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c14
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c25
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c38
4 files changed, 31 insertions, 47 deletions
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h
index 25ef644..7399c2f 100644
--- a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h
@@ -17,6 +17,7 @@
* Includes
******************************************************************************/
#include "t_basicdefinitions.h"
+#include "t_protrom_header.h"
/*******************************************************************************
* Types, constants and external variables
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c
index 4e4a1fb..9905069 100644
--- a/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c
@@ -204,7 +204,7 @@ TL_BulkVectorList_t *Do_R15_Bulk_CreateVector(const Communication_t *const Commu
return NULL;
}
- Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + ALIGNED_HEADER_LENGTH;
Packet_p->Payload_p = Packet_p->ExtendedHeader_p + ALIGNED_BULK_EXTENDED_HEADER_LENGTH;
#else
/* packet meta info allocate */
@@ -220,8 +220,8 @@ TL_BulkVectorList_t *Do_R15_Bulk_CreateVector(const Communication_t *const Commu
Packet_p->Buffer_p = NULL;
Packet_p->BufferSize = BULK_BUFFER_SIZE;
SET_PACKET_FLAGS(Packet_p, PACKET_ALLOCATION_STATE_MASK, BUF_ALLOCATED);
- Packet_p->Payload_p = (uint8 *)(HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH + ALIGNED_BULK_EXTENDED_HEADER_LENGTH);
- Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ Packet_p->Payload_p = (uint8 *)(ALIGNED_HEADER_LENGTH + ALIGNED_BULK_EXTENDED_HEADER_LENGTH);
+ Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + ALIGNED_HEADER_LENGTH;
BuffersNr = 0;
do {
@@ -1124,7 +1124,7 @@ static void R15_Bulk_SerializeChunk(Communication_t *Communication_p, PacketMeta
TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p;
uint32 DeltaLength = 0;
- Packet_p->Timer_p = NULL;
+ memset(&(Packet_p->Timer), 0, sizeof(Timer_t));
Packet_p->Resend = 0;
/* set call back function */
Packet_p->CallBack_p = NULL;
@@ -1157,7 +1157,7 @@ static void R15_Bulk_SerializeChunk(Communication_t *Communication_p, PacketMeta
ExtendedHeader.TypeFlags = CMD_BULK_DATA;
/* serialize and calculate extended header */
- Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + ALIGNED_HEADER_LENGTH;
R15_SerializeExtendedHeader(Packet_p->ExtendedHeader_p, Header.Protocol, &ExtendedHeader, &(Header.ExtendedHeaderChecksum));
/* setup header for serialization and calculation */
memcpy(&Packet_p->Header, &Header, HEADER_LENGTH);
@@ -1174,7 +1174,7 @@ static void R15_Bulk_SerializeChunk(Communication_t *Communication_p, PacketMeta
(void *)Packet_p);
} else {
memset(&Packet_p->Header.PayloadChecksum, 0x0, sizeof(uint32));
- R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+ R15_SerializeHeader(Packet_p->Buffer_p, &Packet_p->Header);
SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_PAYLOAD_CRC_CALCULATED);
}
}
@@ -1190,7 +1190,7 @@ static void R15_Bulk_OutHashCallback(const void *const Data_p, uint32 Length, co
PacketMeta_t *Packet_p = (PacketMeta_t *)Param_p;
memcpy(&Packet_p->Header.PayloadChecksum, Hash_p, sizeof(uint32));
- R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+ R15_SerializeHeader(Packet_p->Buffer_p, &Packet_p->Header);
SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_PAYLOAD_CRC_CALCULATED);
}
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c
index 311ca2b..6041965 100644
--- a/lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c
@@ -259,25 +259,18 @@ static ErrorCode_e DispatchCommand(Communication_t *Communication_p, PacketMeta_
CmdData.ApplicationNr = ExtendedHeader.CommandGroup;
CmdData.SessionNr = ExtendedHeader.SessionState >> 2;
CmdData.Payload.Size = Packet_p->Header.PayloadLength;
- CmdData.Payload.Data_p = NULL;
-
- if (0 != CmdData.Payload.Size) {
- CmdData.Payload.Data_p = (uint8 *)malloc(Packet_p->Header.PayloadLength);
-
- if (NULL == CmdData.Payload.Data_p) {
- return E_ALLOCATE_FAILED;
- }
-
- memcpy(CmdData.Payload.Data_p, Packet_p->Payload_p, Packet_p->Header.PayloadLength);
- }
-
- ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ CmdData.Payload.Data_p = Packet_p->Payload_p;
ReturnValue = Communication_p->Do_CEH_Call_Fn(OBJECT_CEH_CALL(Communication_p), &CmdData);
- if (NULL != CmdData.Payload.Data_p) {
- free(CmdData.Payload.Data_p);
- CmdData.Payload.Data_p = NULL;
+ if (E_SUCCESS == ReturnValue) {
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ } else {
+ ErrorCode_e PacketReleaseRet = R15_Network_PacketRelease(Communication_p, Packet_p);
+
+ if (E_SUCCESS != PacketReleaseRet) {
+ A_(printf("command_protocol.c (%d): Failed to release Network packet! Error: %d\n", __LINE__, PacketReleaseRet);)
+ }
}
return ReturnValue;
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c
index dcc5a3a..220ccec 100644
--- a/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c
@@ -35,7 +35,7 @@
/*******************************************************************************
* Declaration of file local functions
******************************************************************************/
-static Timer_t *TimerSet(PacketMeta_t *Packet_p, const SendData_LP_t *const InputData_p, Communication_t *Communication_p);
+static void TimerSet(PacketMeta_t *Packet_p, const SendData_LP_t *const InputData_p, Communication_t *Communication_p);
static void R15_Transport_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p);
#ifdef CFG_ENABLE_LOADER_TYPE
static ErrorCode_e ConfigureDeviceTimeouts(Communication_t *Communication_p);
@@ -187,16 +187,16 @@ ErrorCode_e R15_Transport_Send(Communication_t *Communication_p, void *InputData
Packet_p->Resend = 0;
Packet_p->CallBack_p = NULL;
- Packet_p->Timer_p = TimerSet(Packet_p, InputData_p, Communication_p);
+ TimerSet(Packet_p, InputData_p, Communication_p);
Packet_p->Header = *InputData_p->Header_p;
/* serialize and calculate extended header */
- Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + ALIGNED_HEADER_LENGTH;
R15_SerializeExtendedHeader(Packet_p->ExtendedHeader_p, InputData_p->Header_p->Protocol, InputData_p->ExtendedHeader_p, &(Packet_p->Header.ExtendedHeaderChecksum));
if (Packet_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) {
- Packet_p->Payload_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH + ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH;
+ Packet_p->Payload_p = Packet_p->Buffer_p + ALIGNED_HEADER_LENGTH + ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH;
} else {
- Packet_p->Payload_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH + ALIGNED_BULK_EXTENDED_HEADER_LENGTH;
+ Packet_p->Payload_p = Packet_p->Buffer_p + ALIGNED_HEADER_LENGTH + ALIGNED_BULK_EXTENDED_HEADER_LENGTH;
}
if (NULL != InputData_p->Payload_p) {
@@ -215,12 +215,12 @@ ErrorCode_e R15_Transport_Send(Communication_t *Communication_p, void *InputData
} else {
SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_PAYLOAD_CRC_CALCULATED);
memset(&Packet_p->Header.PayloadChecksum, 0x0, sizeof(uint32));
- R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+ R15_SerializeHeader(Packet_p->Buffer_p, &Packet_p->Header);
(void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
}
} else {
- R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+ R15_SerializeHeader(Packet_p->Buffer_p, &Packet_p->Header);
(void)QUEUE(Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, Packet_p);
}
@@ -290,7 +290,7 @@ static void R15_Transport_OutHashCallback(const void *const Data_p, uint32 Lengt
SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_PAYLOAD_CRC_CALCULATED);
memcpy(&Packet_p->Header.PayloadChecksum, Hash_p, sizeof(uint32));
- R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+ R15_SerializeHeader(Packet_p->Buffer_p, &Packet_p->Header);
(void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
}
@@ -304,26 +304,16 @@ static void R15_Transport_OutHashCallback(const void *const Data_p, uint32 Lengt
*
* @return none.
*/
-static Timer_t *TimerSet(PacketMeta_t *Packet_p, const SendData_LP_t *const InputData_p, Communication_t *Communication_p)
+static void TimerSet(PacketMeta_t *Packet_p, const SendData_LP_t *const InputData_p, Communication_t *Communication_p)
{
- Timer_t *Timer_p = NULL;
-
if (InputData_p->Time > 0) {
- Timer_p = (Timer_t *)malloc(sizeof(Timer_t));
-
- if (NULL == Timer_p) {
- return NULL;
- }
-
/* timer data */
- Timer_p->Time = InputData_p->Time;
- Timer_p->PeriodicalTime = 0;
- Timer_p->HandleFunction_p = (HandleFunction_t)(InputData_p->TimerCallBackFn_p);
- Timer_p->Data_p = (void *)Packet_p;
- Timer_p->Param_p = (void *)Communication_p;
+ Packet_p->Timer.Time = InputData_p->Time;
+ Packet_p->Timer.PeriodicalTime = 0;
+ Packet_p->Timer.HandleFunction_p = (HandleFunction_t)(InputData_p->TimerCallBackFn_p);
+ Packet_p->Timer.Data_p = (void *)Packet_p;
+ Packet_p->Timer.Param_p = (void *)Communication_p;
}
-
- return Timer_p;
}
#ifdef CFG_ENABLE_LOADER_TYPE