fix access check when downloading to RxPDO or TxPDO

The access type field is a bitfield and may have additional bits
set. Use only read/write permission bits to verify access.
pull/51/head
Hans-Erik Floryd 2019-01-30 18:53:00 +01:00
parent 45f5c616ca
commit c66a5efb32
1 changed files with 5 additions and 4 deletions

View File

@ -466,9 +466,10 @@ void SDO_download (void)
if (nsub >= 0)
{
objd = SDOobjects[nidx].objdesc;
if (((objd + nsub)->access == ATYPE_RW) ||
(((objd + nsub)->access == ATYPE_RWpre)
&& ((ESCvar.ALstatus & 0x0f) == ESCpreop)))
uint8_t access = (objd + nsub)->access & 0x3f;
uint8_t state = ESCvar.ALstatus & 0x0f;
if (access == ATYPE_RW ||
(access == ATYPE_RWpre && state == ESCpreop))
{
/* expedited? */
if (coesdo->command & COE_EXPEDITED_INDICATOR)
@ -513,7 +514,7 @@ void SDO_download (void)
}
else
{
if ((objd + nsub)->access == ATYPE_RWpre)
if (access == ATYPE_RWpre)
{
SDO_abort (index, subindex, ABORT_NOTINTHISSTATE);
}