From 4dae139e02676ddcc97544f91c87248141d2477a Mon Sep 17 00:00:00 2001 From: xmarvla Date: Wed, 9 May 2012 10:38:57 +0200 Subject: Dump command on UART channels sometimes fails. Correct the Write Request handling on the host in the LCM bulk protocol. Fix build with Visual Studio for development purposes. ST-Ericsson ID: 432407 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: I3bbae61cace9a24ba59d634bcfda7fd0a9c683eb Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/58237 Tested-by: Aleksandar GASOSKI Tested-by: Vlatko STENKOSKI Reviewed-by: Vlatko PISTOLOV Tested-by: Vlatko PISTOLOV --- lcmodule/source/LCM.vcproj | 4 -- .../source/bulk_protocol.c | 46 +++++++++++++++++++--- .../source/r15_network_layer.c | 6 +++ .../include/r_communication_service.h | 1 + .../source/communication_service.c | 14 +++++-- source/LCDriver.vcproj | 4 -- source/LCM/include/t_bulk_protocol.h | 2 + source/LcmInterface.cpp | 4 +- source/LcmInterface.h | 2 + 9 files changed, 64 insertions(+), 19 deletions(-) diff --git a/lcmodule/source/LCM.vcproj b/lcmodule/source/LCM.vcproj index ae70436..f2edfc6 100644 --- a/lcmodule/source/LCM.vcproj +++ b/lcmodule/source/LCM.vcproj @@ -373,10 +373,6 @@ RelativePath=".\cnh1606344_ldr_communication_module\source\communication_service.c" > - - 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 d8c5d04..689cd28 100644 --- a/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c +++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c @@ -468,8 +468,8 @@ ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Pac { ErrorCode_e ReturnValue = E_SUCCESS; BulkExtendedHeader_t ExtendedHeader = {0}; -#ifdef CFG_ENABLE_LOADER_TYPE TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p; +#ifdef CFG_ENABLE_LOADER_TYPE TL_BulkVectorList_t *PreviousBulkVector_p = &(R15_TRANSPORT(Communication_p)->PreviousBulkVector); uint32 ChunksCount = 0; uint8 ChunksList[MAX_BULK_TL_PROCESSES]; @@ -520,11 +520,45 @@ ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Pac case CMD_BULK_WRITE: if (NULL != R15_TRANSPORT(Communication_p)->BulkCommandCallback_p) { - BulkCommandReqCallback_t pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p; - pcbf(Communication_p->Object_p, ExtendedHeader.Session, ExtendedHeader.ChunkSize, ExtendedHeader.Offset, ExtendedHeader.Length, FALSE); + if ((NULL != BulkVector_p) && (ExtendedHeader.Session <= BulkVector_p->SessionId)) { + if (WAIT_CHUNKS == BulkVector_p->State) { + /* Read Request already sent to the loader, but probably it was not received correctly, + or the timeout in the loader for the Write Request Packet is too short. */ + uint32 ChunkId = 0; + uint8 ChunksList[MAX_BULK_TL_PROCESSES] = {0}; + + A_(printf("bulk_protocol.c (%d): Write Request packet Received. Session %d already started! Read Request ignored in Loader!\n", __LINE__, ExtendedHeader.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_Bulk_GetListOfReceivedChunks(BulkVector_p, &ChunkId, ChunksList); + R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = R15_Bulk_GetTimerChunkRetransmision(Communication_p, R15_TIMEOUTS(Communication_p)->TBDR, (HandleFunction_t)R15_Bulk_ReadChunkCallBack); + + if (0 != ChunkId) { + ReturnValue = R15_Bulk_SendReadRequest(Communication_p, BulkVector_p, ChunkId, ChunksList, NULL); + } else { + ReturnValue = R15_Bulk_SendReadRequest(Communication_p, BulkVector_p, 0, NULL, (void *)R15_Bulk_ReadChunkCallBack); + } + } else if (SEND_READ_REQUEST == BulkVector_p->State) { + /* Write Request received from the loader and the LCM is in process of sending of Read Request packet. + Probably the timeout in the loader for the Write Request Packet is too short. Packet will be ignored! */ + A_(printf("bulk_protocol.c (%d): Write Request packet will be Ignored. Session %d already started! ReadRequest in process of sending!\n", __LINE__, ExtendedHeader.Session);) + } else { + /* Write Request received from the loader and it is still being processed by LCM. + Probably the timeout in the loader for the Write Request Packet is too short. Packet will be ignored! */ + A_(printf("bulk_protocol.c (%d): Write Request packet will be Ignored. Session %d already started! Problem Undefined!\n", __LINE__, ExtendedHeader.Session);) + } + } else { + BulkCommandReqCallback_t pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p; + pcbf(Communication_p->Object_p, ExtendedHeader.Session, ExtendedHeader.ChunkSize, ExtendedHeader.Offset, ExtendedHeader.Length, FALSE); + } } - /* release the buffer for undefined command */ + /* release the buffer for Bulk Write command */ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p); break; #endif @@ -532,13 +566,13 @@ ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Pac case CMD_BULK_STATUS: // not implemented. A_(printf("bulk_protocol.c (%d): ** Not implemented bulk command! **\n", __LINE__);) - /* release the buffer for unimplemented command */ + /* release the buffer for Bulk Status command */ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p); break; default: A_(printf("bulk_protocol.c (%d): ** Undefined bulk command! **\n", __LINE__);) - /* release the buffer for undefined command */ + /* Undefined Bulk command!!! Release the buffer. */ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p); break; } 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 b74cb4a..e0f1760 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 @@ -230,6 +230,7 @@ ErrorCode_e R15_Network_ReceiverHandler(Communication_t *Communication_p) ReqData - In_p->RecBackupData, R15_Network_ReadCallback, Communication_p->CommunicationDevice_p)) { /* Read failed! Return to previous state. */ + A_(printf("r15_network_layer.c (%d) R15_Network_ReceiverHandler() Read Failed!\n", __LINE__);) In_p->ReqData = ReqData; In_p->ReqBuffOffset = ReqBufferOffset; Communication_p->BackupCommBufferSize = In_p->RecBackupData; @@ -274,6 +275,7 @@ ErrorCode_e R15_Network_ReceiverHandler(Communication_t *Communication_p) In_p->Target_p + ReqBufferOffset, ReqData, R15_Network_ReadCallback, Communication_p->CommunicationDevice_p)) { /* Read failed! Return to previous state. */ + A_(printf("r15_network_layer.c (%d) R15_Network_ReceiverHandler() Read Failed!\n", __LINE__);) In_p->ReqData = ReqData; In_p->ReqBuffOffset = ReqBufferOffset; } @@ -293,6 +295,8 @@ ErrorCode_e R15_Network_ReceiverHandler(Communication_t *Communication_p) In_p->ReqBuffOffset = 0; #ifdef CFG_ENABLE_LOADER_TYPE + A_(printf("r15_network_layer.c (%d) R15_Network_ReceiverHandler() Receive Error ! \n\n", __LINE__);) + if (E_SUCCESS == Communication_p->CommunicationDevice_p->Read(In_p->Target_p, ALIGNED_HEADER_LENGTH, R15_Network_ReadCallback, Communication_p->CommunicationDevice_p)) { @@ -354,6 +358,7 @@ StartTramsmitter: Out_p->State = SEND_HEADER; } else { //Do_CommunicationInternalErrorHandler(E_RETRANSMITION_FAILED); + A_(printf("r15_network_layer.c (%d) Packet Retransmission Failed! Polling will stop!\n", __LINE__);) ReturnValue = E_RETRANSMITION_FAILED; break; } @@ -742,6 +747,7 @@ static ErrorCode_e R15_Network_ReceiveHeader(const Communication_t *const Commun A_(static uint8 print_header = 1;) if (In_p->RecData == 0) { + A_(printf("r15_network_layer.c (%d) Synchronize for Receiving Header!\n", __LINE__);) In_p->ReqData = ALIGNED_HEADER_LENGTH; In_p->Target_p = In_p->Scratch; In_p->ReqBuffOffset = 0; diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h index e012feb..2403713 100644 --- a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h +++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h @@ -58,6 +58,7 @@ extern Communication_t *GlobalCommunication_p; extern Communication_t DebugCommunication; +extern char LCM_CurrentVersion[]; /******************************************************************************* * Declaration of functions diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c index 775b5bf..54ff332 100644 --- a/lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c +++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c @@ -34,10 +34,6 @@ #include "r_z_transport.h" #endif - -extern char LCM_CurrentVersion[]; - - /******************************************************************************* * File scope types, constants and variables ******************************************************************************/ @@ -46,6 +42,16 @@ extern char LCM_CurrentVersion[]; Communication_t GlobalCommunication = {0}; Communication_t *GlobalCommunication_p = &GlobalCommunication; +#if !(defined(__MINGW32__) || defined(__linux__) || defined(__APPLE__)) +#ifdef CFG_ENABLE_LOADER_TYPE +#ifndef MACH_TYPE_STN8500 +char LCM_CurrentVersion[] = ""; // Generate Empty String for Loader Builds on ClearCase +#endif // MACH_TYPE_STN8500 +#else +char LCM_CurrentVersion[] = "TestBuild"; // Generate Test String for unofficial builds in Windows environment +#endif // CFG_ENABLE_LOADER_TYPE +#endif // __MINGW32__ || __linux__ || __APPLE__ + static FamilyDescriptor_t ProtocolFamilies[] = { { R15_Family_Init, diff --git a/source/LCDriver.vcproj b/source/LCDriver.vcproj index ef7e7c4..44672e4 100644 --- a/source/LCDriver.vcproj +++ b/source/LCDriver.vcproj @@ -537,10 +537,6 @@ RelativePath=".\LCDriverThread.cpp" > - -