From 7500cbd59a6faa7dd69b278d7a02da2c8fa96060 Mon Sep 17 00:00:00 2001 From: Zoran Ancevski Date: Fri, 9 Dec 2011 13:48:52 +0100 Subject: Stability improvements Bug fixing for retransmission. Change header search algorithm ST-Ericsson ID: 369904 ST-Ericsson FOSS-OUT ID: NA Change-Id: If0926da184dfefefcaad0d4e97080de283b7aabd Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/40280 Tested-by: Cvetko MLADENOVSKI Tested-by: Aleksandar GASOSKI Reviewed-by: Vlatko PISTOLOV Tested-by: Vlatko PISTOLOV --- lcmodule/source/LCM.rc | 6 +- .../source/bulk_protocol.c | 25 ++++++- .../include/t_r15_network_layer.h | 12 ++-- .../source/r15_network_layer.c | 77 ++++++++++++++++++---- source/LCDriver.rc | 6 +- 5 files changed, 99 insertions(+), 27 deletions(-) diff --git a/lcmodule/source/LCM.rc b/lcmodule/source/LCM.rc index 16c2409..9cbe9af 100644 --- a/lcmodule/source/LCM.rc +++ b/lcmodule/source/LCM.rc @@ -69,15 +69,15 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "Comments", "Build date: 2011-11-18" + VALUE "Comments", "Build date: 2011-12-09" VALUE "CompanyName", "STEricsson AB" VALUE "FileDescription", "LCM Dynamic Link Library" VALUE "FileVersion", "1, 0, 0, 1" VALUE "InternalName", "Loader Communication Module" VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2011" - VALUE "PrivateBuild", "Change-Id: Ib80d54f56d6be1b9aaf64e29b3f9e3cffb748faf" + VALUE "PrivateBuild", "Change-Id: If0926da184dfefefcaad0d4e97080de283b7aabd" VALUE "ProductName", "CXA1104507 Loader Communication Module" - VALUE "ProductVersion", "PX2" + VALUE "ProductVersion", "PX3" END END BLOCK "VarFileInfo" 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 1d776c6..42d3cae 100644 --- a/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c +++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c @@ -116,6 +116,7 @@ uint32 Do_R15_Bulk_OpenSession(const Communication_t *const Communication_p, con if (MAX_BULK_TL_PROCESSES != VectorCounter) { if (R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Status != BULK_SESSION_IDLE) { + A_(printf("bulk_protocol.c (%d): bulk error \n", __LINE__);) VectorCounter = BULK_ERROR; } else { R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Status = BULK_SESSION_OPEN; @@ -128,10 +129,11 @@ uint32 Do_R15_Bulk_OpenSession(const Communication_t *const Communication_p, con R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0; } } else { + A_(printf("bulk_protocol.c (%d): bulk error \n", __LINE__);) VectorCounter = BULK_ERROR; } - A_(printf("bulk_protocol.c (%d): Opened Bulk session(%d)with VId(%d)\n", __LINE__, SessionId, VectorCounter);) + B_(printf("bulk_protocol.c (%d): Opened Bulk session(%d)with VId(%d)\n", __LINE__, SessionId, VectorCounter);) return VectorCounter; } @@ -432,6 +434,12 @@ ErrorCode_e Do_R15_Bulk_CloseSession(Communication_t *Communication_p, TL_BulkVe /* Verify that the requested bulk session is started. */ VERIFY(NULL != BulkVector_p, E_FAILED_TO_CLOSE_BULK_SESSION); + /* Try to release the timer for the bulk read request */ + if (R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey > 0) { + (void)TIMER(Communication_p, TimerRelease_Fn)(OBJECT_TIMER(Communication_p), R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey); + R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0; + } + R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p = NULL; C_(printf("bulk_protocol.c (%d): Bulk session(%d) closed! \n", __LINE__, BulkVector_p->SessionId);) @@ -477,7 +485,10 @@ ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Pac A_(printf("bulk_protocol.c (%d): Session is not opened(%d) or wrong session(%d)! \n", __LINE__, R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p, ExtendedHeader.Session);) if ((CMD_BULK_DATA == (ExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT)) && - NULL != PreviousBulkVector_p) { + (NULL != PreviousBulkVector_p) && + (BulkVector_p->SessionId <= ExtendedHeader.Session)) { + + A_(printf("bulk_protocol.c (%d): New session started \n", __LINE__);) // make the list of received chunks R15_Bulk_GetListOfReceivedChunks(PreviousBulkVector_p, &ChunksCount, ChunksList); // send read ACK for previous session @@ -955,6 +966,9 @@ ErrorCode_e R15_Bulk_Process_Write(Communication_t *Communication_p, TL_BulkVect /* Wait for all chunks in the current session to be send before closing the current session and notifying start of the new session */ if (R15_Bulk_SessionTxDone(BulkVector_p)) { + /* save the current bulk vector before bulk session is closed */ + memcpy(&(R15_TRANSPORT(Communication_p))->PreviousBulkVector, BulkVector_p, sizeof(TL_BulkVectorList_t)); + // notify session end BulkCommandReqCallback_t pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p; pcbf(Communication_p->Object_p, BulkVector_p->SessionId, BulkVector_p->ChunkSize, BulkVector_p->Offset, BulkVector_p->Length, TRUE); @@ -1177,6 +1191,11 @@ static void R15_Bulk_ReadChunkCallBack(Communication_t *Communication_p, const v { TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p; + if(NULL == BulkVector_p) { + A_(printf("bulk_protocol.c(%d) Bulk Vector released! \n", __LINE__);) + return; + } + if (BULK_SESSION_FINISHED != BulkVector_p->Status) { uint32 ChunkId = 0; uint8 ChunksList[MAX_BULK_TL_PROCESSES] = {0}; @@ -1184,6 +1203,8 @@ static void R15_Bulk_ReadChunkCallBack(Communication_t *Communication_p, const v R15_Bulk_GetListOfReceivedChunks(BulkVector_p, &ChunkId, ChunksList); BulkVector_p->State = WAIT_CHUNKS; + A_(printf("bulk_protocol.c(%d) Timer Retransmission \n", __LINE__);) + (void)R15_Bulk_SendReadRequest(Communication_p, BulkVector_p, ChunkId, ChunksList, NULL); } } diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_network_layer.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_network_layer.h index efd9270..7c4f6e1 100644 --- a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_network_layer.h +++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_network_layer.h @@ -158,11 +158,13 @@ typedef enum { /** Defined state of the transmitter */ typedef enum { - SEND_IDLE, /**< Transmiter idle state.*/ - SEND_HEADER, /**< Transmiter send header and extended header. */ - SENDING_HEADER, /**< Transmiter is in process sending the header and extended header. */ - SEND_PAYLOAD, /**< Transmiter send payload. */ - SENDING_PAYLOAD /**< Transmiter is in process sending payload.*/ + SEND_IDLE, /**< Transmitter idle state.*/ + SEND_HEADER, /**< Transmitter send header. */ + SENDING_HEADER, /**< Transmitter is in process sending header. */ + SEND_EX_HEADER, /**< Transmitter send extended header. */ + SENDING_EX_HEADER, /**< Transmitter is in process sending extended header. */ + SEND_PAYLOAD, /**< Transmitter send payload. */ + SENDING_PAYLOAD /**< Transmitter is in process sending payload.*/ } R15_OutboundState_t; /** diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c index c56586c..7bc4dad 100644 --- a/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c +++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c @@ -314,12 +314,13 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) { ErrorCode_e ReturnValue = E_SUCCESS; R15_Outbound_t *Out_p = &(R15_NETWORK(Communication_p)->Outbound); - uint8 *HeaderStartInBuffer_p = NULL; + uint8 *HeaderStartInBuffer_p = NULL; + uint8 *ExHeaderStartInBuffer_p = NULL; boolean IsBufferContinuous = FALSE; + uint32 ContinuousBufferLength = 0; boolean RegisterRetransmission = FALSE; - uint32 ContinuousBufferLength = 0; - uint32 ExtHdrLen = 0; - uint32 Aligned_Length = 0; + uint32 ExtHdrLen = 0; + uint32 Aligned_Length = 0; if (!Do_CriticalSection_Enter(Out_p->TxCriticalSection)) { return ReturnValue; @@ -345,6 +346,7 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) case SEND_HEADER: HeaderStartInBuffer_p = Out_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER; +#ifdef CFG_ENABLE_LOADER_TYPE if (Out_p->Packet_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) { ExtHdrLen = ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH; } else { @@ -370,10 +372,13 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) ContinuousBufferLength = ALIGNED_HEADER_LENGTH + ExtHdrLen; Out_p->State = SENDING_HEADER; } +#else + ContinuousBufferLength = ALIGNED_HEADER_LENGTH; + Out_p->State = SENDING_HEADER; +#endif if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write((Out_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER), - ContinuousBufferLength, - R15_Network_WriteCallback, Communication_p->CommunicationDevice_p)) { + ContinuousBufferLength, R15_Network_WriteCallback, Communication_p->CommunicationDevice_p)) { C_(printf("r15_network_layer.c (%d) Header Sent to comm device! \n", __LINE__);) } else { Out_p->State = SEND_HEADER; @@ -385,6 +390,36 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) case SENDING_HEADER: /* nothing to do, wait until sending is finished and state changed by write callback */ break; + case SEND_EX_HEADER: + ExHeaderStartInBuffer_p = Out_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH; + + if (Out_p->Packet_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) { + ExtHdrLen = ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH; + } else { + ExtHdrLen = ALIGNED_BULK_EXTENDED_HEADER_LENGTH; + } + + if (Out_p->Packet_p->Header.PayloadLength != 0) { + Out_p->State = SENDING_EX_HEADER; + } else { + /* if there is no payload, just go directly to SENDING_PAYLOAD state */ + Out_p->State = SENDING_PAYLOAD; + RegisterRetransmission = TRUE; + } + + if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write(ExHeaderStartInBuffer_p, ExtHdrLen, + R15_Network_WriteCallback, Communication_p->CommunicationDevice_p)) { + C_(printf("r15_network_layer.c (%d) ExHeader Sent to comm device! \n", __LINE__);) + } else { + Out_p->State = SEND_EX_HEADER; + RegisterRetransmission = FALSE; + C_(printf("r15_network_layer.c (%d) Error sending ex_header to comm device! \n", __LINE__);) + } + + break; + case SENDING_EX_HEADER: + /* nothing to do, wait until sending is finished and state changed by write callback */ + break; case SEND_PAYLOAD: Out_p->State = SENDING_PAYLOAD; @@ -620,6 +655,8 @@ void R15_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Pa B_(printf("r15_network_layer.c (%d): Device write finished!! \n", __LINE__);) if (SENDING_HEADER == Out_p->State) { + Out_p->State = SEND_EX_HEADER; + } else if (SENDING_EX_HEADER == Out_p->State) { Out_p->State = SEND_PAYLOAD; } else if (SENDING_PAYLOAD == Out_p->State) { if (NULL == Out_p->Packet_p->Timer_p) { @@ -653,6 +690,7 @@ void R15_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Pa static ErrorCode_e R15_Network_ReceiveHeader(const Communication_t *const Communication_p) { R15_Inbound_t *In_p = &(R15_NETWORK(Communication_p)->Inbound); + A_(static uint8 print_header = 1;) if (In_p->RecData == 0) { In_p->ReqData = ALIGNED_HEADER_LENGTH; @@ -661,8 +699,9 @@ static ErrorCode_e R15_Network_ReceiveHeader(const Communication_t *const Commun } else { if (R15_IsReceivedHeader(In_p)) { if (R15_IsValidHeader(In_p->Scratch)) { - R15_DeserializeHeader(&In_p->Header, In_p->Scratch); + A_(print_header = 1;) + R15_DeserializeHeader(&In_p->Header, In_p->Scratch); In_p->Target_p += ALIGNED_HEADER_LENGTH; if (In_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) { @@ -678,14 +717,15 @@ static ErrorCode_e R15_Network_ReceiveHeader(const Communication_t *const Commun } } else { A_( - uint32 Counter = 0; - - printf("Invalid header! "); + if(print_header) { + uint32 Counter = 0; + printf("Invalid header! \n"); - for (Counter = 0; Counter < 16; Counter++) { - printf(" %02X", In_p->Scratch[Counter]); - } - printf("\n\n"); + for (Counter = 0; Counter < 16; Counter++) { + printf(" %02X", In_p->Scratch[Counter]); + } + printf("\n\n"); + } ) } } @@ -765,6 +805,15 @@ static ErrorCode_e R15_Network_ReceiveExtendedHeader(Communication_t *Communicat C_(printf("r15_network_layer.c (%d) ReqData(%d) RecData(%d) \n", __LINE__, In_p->ReqData, In_p->RecData);) } } else { + A_( + uint32 Counter = 0; + printf("Invalid exheader! \n"); + + for (Counter = 0; Counter < 16; Counter++) { + printf(" %02X", In_p->Target_p[Counter]); + } + printf("\n\n"); + ) RESET_INBOUND(In_p, RECEIVE_HEADER); SYNC_HEADER(In_p, ALIGNED_HEADER_LENGTH, In_p->Scratch); } diff --git a/source/LCDriver.rc b/source/LCDriver.rc index 7537f6f..7b35aa5 100644 --- a/source/LCDriver.rc +++ b/source/LCDriver.rc @@ -81,15 +81,15 @@ BEGIN BEGIN BLOCK "000904b0" BEGIN - VALUE "Comments", "Build date: 2011-11-18" + VALUE "Comments", "Build date: 2011-12-09" VALUE "CompanyName", "STEricsson AB" VALUE "FileDescription", "LCDriver Dynamic Link Library" VALUE "FileVersion", "1, 0, 0, 1" VALUE "InternalName", "Loader Communication Driver" VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2011" - VALUE "PrivateBuild", "Change-Id: Ib80d54f56d6be1b9aaf64e29b3f9e3cffb748faf" + VALUE "PrivateBuild", "Change-Id: If0926da184dfefefcaad0d4e97080de283b7aabd" VALUE "ProductName", "CXC 173 0865, LCDriver DLL" - VALUE "ProductVersion", "PU2" + VALUE "ProductVersion", "PU3" END END BLOCK "VarFileInfo" -- cgit v1.2.3