update objecthandler and hooks

Replace isCA with a set of flags to hold more data.

The pre_object_download_hook should return a COE abort code which is
an unsigned 32-bit value.
pull/52/head
Hans-Erik Floryd 2019-04-02 21:26:46 +02:00
parent 236a02bfb4
commit d204255ad3
4 changed files with 14 additions and 14 deletions

View File

@ -33,9 +33,9 @@ uint32_t ESC_pre_objecthandler (uint16_t index,
uint8_t subindex,
void * data,
size_t size,
bool isCA)
uint16_t flags)
{
int abort = 0;
uint32_t abort = 0;
if (IS_RXPDO (index) ||
IS_TXPDO (index) ||
@ -54,7 +54,7 @@ uint32_t ESC_pre_objecthandler (uint16_t index,
subindex,
data,
size,
isCA);
flags);
}
return abort;
@ -66,11 +66,11 @@ uint32_t ESC_pre_objecthandler (uint16_t index,
* @param[in] index = index of SDO download request to handle
* @param[in] sub-index = sub-index of SDO download request to handle
*/
void ESC_objecthandler (uint16_t index, uint8_t subindex, bool isCA)
void ESC_objecthandler (uint16_t index, uint8_t subindex, uint16_t flags)
{
if (ESCvar.post_object_download_hook != NULL)
{
(ESCvar.post_object_download_hook)(index, subindex, isCA);
(ESCvar.post_object_download_hook)(index, subindex, flags);
}
}

View File

@ -243,7 +243,7 @@ typedef struct esc_cfg
void (*post_state_change_hook) (uint8_t * as, uint8_t * an);
void (*application_hook) (void);
void (*safeoutput_override) (void);
int (*pre_object_download_hook) (uint16_t index,
uint32_t (*pre_object_download_hook) (uint16_t index,
uint8_t subindex,
void * data,
size_t size,
@ -358,7 +358,7 @@ typedef struct
void (*post_state_change_hook) (uint8_t * as, uint8_t * an);
void (*application_hook) (void);
void (*safeoutput_override) (void);
int (*pre_object_download_hook) (uint16_t index,
uint32_t (*pre_object_download_hook) (uint16_t index,
uint8_t subindex,
void * data,
size_t size,

View File

@ -388,7 +388,7 @@ void SDO_download (void)
if (nsub >= 0)
{
objd = SDOobjects[nidx].objdesc;
uint8_t access = (objd + nsub)->access & 0x3f;
uint8_t access = (objd + nsub)->flags & 0x3f;
uint8_t state = ESCvar.ALstatus & 0x0f;
if (access == ATYPE_RW ||
(access == ATYPE_RWpre && state == ESCpreop))
@ -413,7 +413,7 @@ void SDO_download (void)
subindex,
mbxdata,
size,
false
(objd + nsub)->flags
);
if (abort == 0)
{
@ -433,7 +433,7 @@ void SDO_download (void)
MBXcontrol[MBXout].state = MBXstate_outreq;
}
/* external object write handler */
ESC_objecthandler (index, subindex, false);
ESC_objecthandler (index, subindex, (objd + nsub)->flags);
}
else
{
@ -755,7 +755,7 @@ void SDO_geted (void)
COE_VALUEINFO_OBJECT + COE_VALUEINFO_MAPPABLE;
coel->datatype = htoes ((objd + nsub)->datatype);
coel->bitlength = htoes ((objd + nsub)->bitlength);
coel->access = htoes ((objd + nsub)->access);
coel->access = htoes ((objd + nsub)->flags);
s = (uint8_t *) (objd + nsub)->name;
d = (uint8_t *) &(coel->name);
while (*s && (n < (ESC_MBXDSIZE - 0x10)))

View File

@ -19,7 +19,7 @@ typedef struct CC_PACKED
uint16_t subindex;
uint16_t datatype;
uint16_t bitlength;
uint16_t access;
uint16_t flags;
const char *name;
uint64_t value;
void *data;
@ -106,12 +106,12 @@ void COE_pdoPack (uint8_t * buffer, int nmappings, _SMmap * sm);
void COE_pdoUnpack (uint8_t * buffer, int nmappings, _SMmap * sm);
uint8_t COE_maxSub (uint16_t index);
extern void ESC_objecthandler (uint16_t index, uint8_t subindex, bool isCA);
extern void ESC_objecthandler (uint16_t index, uint8_t subindex, uint16_t flags);
extern uint32_t ESC_pre_objecthandler (uint16_t index,
uint8_t subindex,
void * data,
size_t size,
bool isCA);
uint16_t flags);
extern const _objectlist SDOobjects[];
#endif