Skip to content

Commit

Permalink
Update 'gXcp.MtaPtr' in XcpReadMta() and XcpWriteMta(). (#47)
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
KecMic authored Mar 12, 2024
1 parent c62d712 commit 81d63e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/xcpLite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 81d63e1

Please sign in to comment.