52 if(d->CurrentCommunicationState.csSYNC)
55 if(d->CurrentCommunicationState.csEmergency)
73 if (d->CurrentCommunicationState.csPDO)
78 if (d->CurrentCommunicationState.csSDO)
82 if (d->CurrentCommunicationState.csHeartbeat || !(*(d->iam_a_slave)))
88 (m->
data[0]== NMT_Enter_Bootloader) )
93 if (*(d->iam_a_slave))
99 if (!d->CurrentCommunicationState.csLSS)
break;
100 if ((*(d->iam_a_slave)) && cob_id==MLSS_ADRESS)
102 proceedLSS_Slave(d,m);
104 else if(!(*(d->iam_a_slave)) && cob_id==SLSS_ADRESS)
106 proceedLSS_Master(d,m);
115#define StartOrStop(CommType, FuncStart, FuncStop) \
116 if(newCommunicationState->CommType && d->CurrentCommunicationState.CommType == 0){\
117 MSG_WAR(0x9999,#FuncStart, 9999);\
118 d->CurrentCommunicationState.CommType = 1;\
120 }else if(!newCommunicationState->CommType && d->CurrentCommunicationState.CommType == 1){\
121 MSG_WAR(0x9999,#FuncStop, 9999);\
122 d->CurrentCommunicationState.CommType = 0;\
136 StartOrStop(csLSS, startLSS(d), stopLSS(d))
138 StartOrStop(csSDO, None,
resetSDO(d))
163 if(newState != d->nodeState){
165 case Mode_Patient_Control:
168 d->nodeState = Mode_Patient_Control;
176 d->nodeState = Mode_X_Manual;
184 d->nodeState = Mode_Y_Manual;
192 d->nodeState = Waiting;
201 d->nodeState = Stopped;
207 case Mode_Patient_Manual:
210 d->nodeState = Mode_Patient_Manual;
215 case Mode_Produce_X_Manual:
218 d->nodeState = Mode_Produce_X_Manual;
227 d->nodeState = Mode_Record_X;
252 return *d->bDeviceNodeId;
263 UNS16 offset = d->firstIndex->SDO_SVR;
266 d->lss_transfer.nodeID = nodeId;
267 *d->bDeviceNodeId = nodeId;
271 *d->bDeviceNodeId = nodeId;
276 if(!(nodeId > 0 && nodeId <= 127))
278 MSG_WAR(0x2D01,
"Invalid NodeID",nodeId);
288 *(
UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + nodeId;
294 *(
UNS32*)d->objdict[offset].pSubindex[2].pObject = 0x580 + nodeId;
308 UNS16 offset = d->firstIndex->PDO_TRS;
309 UNS16 lastIndex = d->lastIndex->PDO_TRS;
310 UNS32 cobID[] = {0x180, 0x280, 0x380, 0x480};
312 if( offset )
while ((offset <= lastIndex) && (i < 4))
315 *(
UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId;
322 if((*d->error_cobid == *d->bDeviceNodeId + 0x80)||(*d->bDeviceNodeId==0xFF))
323 *d->error_cobid = nodeId + 0x80;
326 *d->bDeviceNodeId = nodeId;
#define UNS8
Unsigned int8 representation in CANFest.
#define UNS16
Unsigned int16 representation in CANFest.
#define MSG_WAR(num, str, val)
Definition of MSG_WAR.
#define UNS32
Unsigned int32 representation in CANFest.
UNS8 processBOOT(CO_Data *d, Message *m)
Initializes node ID and serial number data in the object dictionary.
void proceedEMCY(CO_Data *d, Message *m)
This function is responsible to process an EMCY canopen-message.
void emergencyStop(CO_Data *d)
Stop EMCY producer and consumer.
void emergencyInit(CO_Data *d)
Start EMCY consumer and producer.
void heartbeatStop(CO_Data *d)
Stop heartbeat consumer and producer.
void processNODE_GUARD(CO_Data *d, Message *m)
This function is responsible to process a canopen-message which seams to be an NMT Error Control Mess...
void heartbeatInit(CO_Data *d)
Start heartbeat consumer and producer with respect to 0x1016 and 0x1017 object dictionary entries.
void processNMTstateChange(CO_Data *d, Message *m)
Manage the reception of a NMT message from the master.
UNS8 slaveSendBootUp(CO_Data *d)
Transmit the boot-Up frame when the slave is moving from initialization state to pre_operational stat...
UNS8 processPDO(CO_Data *d, Message *m)
Compute a PDO frame reception bus_id is hardware dependant.
void PDOInit(CO_Data *d)
Initialize PDO feature.
void PDOStop(CO_Data *d)
Stop PDO feature.
void resetSDO(CO_Data *d)
Reset all SDO buffers.
UNS8 processSDO(CO_Data *d, Message *m)
Treat a SDO frame reception call the function sendSDO.
UNS8 setState(CO_Data *d, e_nodeState newState)
Change the state of the node.
UNS8 getNodeId(CO_Data *d)
Returns the nodId.
void _mode_X_Manual(CO_Data *d)
Function that user app can overload.
void _waiting(CO_Data *d)
Function that user app can overload.
void _stopped(CO_Data *d)
Function that user app can overload.
void _mode_Patient_Control(CO_Data *d)
Function that user app can overload.
void switchCommunicationState(CO_Data *d, s_state_communication *newCommunicationState)
<BRIEF> switchCommunicationState
e_nodeState getState(CO_Data *d)
Returns the state of the node.
void _mode_Y_Manual(CO_Data *d)
Function that user app can overload.
void setNodeId(CO_Data *d, UNS8 nodeId)
Define the node ID. Initialize the object dictionary.
void _mode_Patient_Manual(CO_Data *d)
Function that user app can overload.
void startSYNC(CO_Data *d)
<BRIEF> startSYNC
void stopSYNC(CO_Data *d)
<BRIEF> stopSYNC
UNS8 processSYNC(CO_Data *d, Message *m)
This function is called when the node is receiving a SYNC message (cob-id = 0x80).
void canDispatch(CO_Data *d, Message *m)
Called by driver/app when receiving messages.
This structure contains all necessary informations to define a CANOpen node.