From 81d63e16f6b9500a822d23995617e1e1e273675d Mon Sep 17 00:00:00 2001 From: Michael <32579394+KecMic@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:58:11 +0100 Subject: [PATCH] Update 'gXcp.MtaPtr' in XcpReadMta() and XcpWriteMta(). (#47) Bug was introduced in V5.4 with commit 832e0da. In case of multiple consecutive CC_UPLOAD requests from CANape, XcpReadMta() has to update 'gXcp.MtaPtr'. An example sequence sent by CANape would be: CC_SET_MTA -> CC_UPLOAD -> CC_UPLOAD. In case of multiple consecutive CC_DOWNLOAD requests from CANape, XcpWriteMta() has to update 'gXcp.MtaPtr'. An example sequence sent by CANape would be: CC_SET_MTA -> CC_DOWNLOAD -> CC_DOWNLOAD. Also corrected comment above XcpReadMta(). --- src/xcpLite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xcpLite.c b/src/xcpLite.c index 7b6018d..df1ad4b 100644 --- a/src/xcpLite.c +++ b/src/xcpLite.c @@ -372,13 +372,14 @@ static uint8_t XcpWriteMta( uint8_t size, const uint8_t* data ) if (gXcp.MtaExt == 0x00) { if (gXcp.MtaPtr == NULL) return CRC_ACCESS_DENIED; memcpy(gXcp.MtaPtr, data, size); + gXcp.MtaPtr += size; return 0; // Ok } return CRC_ACCESS_DENIED; // Access violation } -// Read n bytes. Copying of size bytes from data to gXcp.MtaPtr +// Read n bytes. Copying of size bytes from gXcp.MtaPtr to data static uint8_t XcpReadMta( uint8_t size, uint8_t* data ) { // Ext=0x01 Relativ addressing @@ -401,6 +402,7 @@ static uint8_t XcpReadMta( uint8_t size, uint8_t* data ) if (gXcp.MtaExt == 0x00) { if (gXcp.MtaPtr == NULL) return CRC_ACCESS_DENIED; memcpy(data, gXcp.MtaPtr, size); + gXcp.MtaPtr += size; return 0; // Ok }