Bugfix against latest CTT 2.0.34

Fixed various big endian conversions. MBX error behaviour adapted to
specification
pull/11/head
ArthurKetels 2016-01-27 22:14:36 +01:00
parent 139aebd7d1
commit 10c7f5191f
3 changed files with 13 additions and 15 deletions

View File

@ -572,16 +572,9 @@ uint8_t ESC_mbxprocess (void)
{
ESC_readmbx ();
ESCvar.SM[0].MBXstat = 0;
if (etohs (MB->header.length) < 6)
if (etohs (MB->header.length) == 0)
{
if (etohs (MB->header.length) == 0)
{
MBX_error (MBXERR_INVALIDHEADER);
}
else
{
MBX_error (MBXERR_SIZETOOSHORT);
}
MBX_error (MBXERR_INVALIDHEADER);
/* drop mailbox */
MBXcontrol[0].state = MBXstate_idle;
}
@ -843,7 +836,6 @@ void ESC_state (void)
switch (as)
{
case INIT_TO_INIT:
case BOOT_TO_BOOT:
case PREOP_TO_PREOP:
case OP_TO_OP:
{
@ -857,6 +849,7 @@ void ESC_state (void)
break;
}
case INIT_TO_BOOT:
case BOOT_TO_BOOT:
{
/* get station address */
ESC_address ();

View File

@ -161,6 +161,7 @@
#define COE_VALUEINFO_DEFAULT 0x10
#define COE_VALUEINFO_MINIMUM 0x20
#define COE_VALUEINFO_MAXIMUM 0x40
#define COE_MINIMUM_LENGTH 8
#define MBXHSIZE sizeof(_MBXh)
#define MBXDSIZE MBXSIZE-MBXHSIZE

View File

@ -90,6 +90,7 @@ uint16_t sizeTXPDO (void)
if (SDO1C13[sic].data)
{
hobj = *((uint16_t *) SDO1C13[sic].data);
hobj = htoes(hobj);
}
else
{
@ -136,6 +137,7 @@ uint16_t sizeRXPDO (void)
if (SDO1C12[sic].data)
{
hobj = *((uint16_t *) SDO1C12[sic].data);
hobj = htoes(hobj);
}
else
{
@ -440,15 +442,15 @@ void SDO_download (void)
else
{
/* normal upload */
size = (etohs (coesdo->size) & 0xffff);
size = (etohl (coesdo->size) & 0xffff);
mbxdata = (&(coesdo->size)) + 1;
}
actsize = ((objd + nsub)->bitlength + 7) >> 3;
if (actsize == size)
{
copy2mbx (mbxdata, (objd + nsub)->data, size);
if (ESC_pre_objecthandler (index, subindex))
{
copy2mbx (mbxdata, (objd + nsub)->data, size);
MBXout = ESC_claimbuffer ();
if (MBXout)
{
@ -463,9 +465,9 @@ void SDO_download (void)
coeres->size = htoel (0);
MBXcontrol[MBXout].state = MBXstate_outreq;
}
/* external object write handler */
ESC_objecthandler (index, subindex);
}
/* external object write handler */
ESC_objecthandler (index, subindex);
}
else
{
@ -818,12 +820,14 @@ void ESC_coeprocess (void)
mbh = (_MBXh *) &MBX[0];
if (mbh->mbxtype == MBXCOE)
{
if (mbh->length < 8)
if (etohs (mbh->length) < COE_MINIMUM_LENGTH)
{
MBX_error (MBXERR_INVALIDSIZE);
}
else
{
ESCvar.xoe = MBXCOE;
}
}
}
if ((ESCvar.xoe == (MBXCOE + MBXODL)) && (!ESCvar.mbxoutpost))