Add rudimentary option to place an emergency message in the out mailbox
parent
829dde8b11
commit
39a4ab1d39
12
soes/esc.h
12
soes/esc.h
|
@ -209,6 +209,7 @@
|
|||
#define COE_DEFAULTLENGTH 0x0a
|
||||
#define COE_HEADERSIZE 0x0a
|
||||
#define COE_SEGMENTHEADERSIZE 0x03
|
||||
#define COE_EMERGENCY 0x01
|
||||
#define COE_SDOREQUEST 0x02
|
||||
#define COE_SDORESPONSE 0x03
|
||||
#define COE_SDOINFORMATION 0x08
|
||||
|
@ -572,6 +573,17 @@ typedef struct CC_PACKED
|
|||
} _MBXerr;
|
||||
CC_PACKED_END
|
||||
|
||||
CC_PACKED_BEGIN
|
||||
typedef struct CC_PACKED CC_ALIGNED(4)
|
||||
{
|
||||
_MBXh mbxheader;
|
||||
_COEh coeheader;
|
||||
uint16_t errorcode;
|
||||
uint8_t errorregister;
|
||||
uint8_t data[5];
|
||||
} _COEemc;
|
||||
CC_PACKED_END
|
||||
|
||||
CC_PACKED_BEGIN
|
||||
typedef struct CC_PACKED CC_ALIGNED(4)
|
||||
{
|
||||
|
|
|
@ -1841,3 +1841,35 @@ uint8_t COE_maxSub (uint16_t index)
|
|||
maxsub = OBJ_VALUE_FETCH (maxsub, SDOobjects[nidx].objdesc[0]);
|
||||
return maxsub;
|
||||
}
|
||||
|
||||
/** Throw an emergency message
|
||||
*
|
||||
* @param[in] errorcode = error code
|
||||
* @param[in] errorregister = error register
|
||||
* @param[in] data = payload
|
||||
* @return 0= if we succeed, -1 if mailbox was in use
|
||||
*/
|
||||
int COE_throwEmergency (uint16_t errorcode, uint8_t errorregister, uint8_t data[5])
|
||||
{
|
||||
uint8_t MBXout;
|
||||
_COEemc *coeemc;
|
||||
|
||||
MBXout = ESC_claimbuffer ();
|
||||
if (MBXout)
|
||||
{
|
||||
coeemc = (_COEemc *) &MBX[MBXout * ESC_MBXSIZE];
|
||||
coeemc->mbxheader.length = htoes (COE_DEFAULTLENGTH);
|
||||
coeemc->mbxheader.mbxtype = MBXCOE;
|
||||
coeemc->coeheader.numberservice =
|
||||
htoes ((0 & 0x01f) | (COE_EMERGENCY << 12));
|
||||
coeemc->errorcode = htoes (errorcode);
|
||||
coeemc->errorregister = errorregister;
|
||||
copy2mbx (data, coeemc->data, 5);
|
||||
MBXcontrol[MBXout].state = MBXstate_outreq;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ void COE_initDefaultValues (void);
|
|||
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);
|
||||
int COE_throwEmergency (uint16_t errorcode, uint8_t errorregister, uint8_t data[5]);
|
||||
|
||||
extern uint32_t ESC_download_post_objecthandler (uint16_t index, uint8_t subindex, uint16_t flags);
|
||||
extern uint32_t ESC_download_pre_objecthandler (uint16_t index,
|
||||
|
|
Loading…
Reference in New Issue