As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
Concerned callbacks :
initialisation
preOperational
operational
stopped
heartbeatError
post_sync
post_TPDO
post_SlaveBootup
storeODSubIndex
post_emcy
--- a/examples/DS401_Master/TestMasterMicroMod.c Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/DS401_Master/TestMasterMicroMod.c Fri Feb 01 18:06:55 2008 +0100
@@ -42,7 +42,7 @@
/*****************************************************************************/
-void TestMaster_heartbeatError(UNS8 heartbeatID)
+void TestMaster_heartbeatError(CO_Data* d, UNS8 heartbeatID)
{
eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
}
@@ -52,7 +52,7 @@
* - setup master RPDO 1 to receive TPDO 1 from id 0x40
* - setup master TPDO 1 to send RPDO 1 to id 0x40
********************************************************/
-void TestMaster_initialisation()
+void TestMaster_initialisation(CO_Data* d)
{
UNS32 PDO1_COBID = 0x0180 + slavenodeid;
UNS32 PDO2_COBID = 0x0200 + slavenodeid;
@@ -303,7 +303,7 @@
}
-void TestMaster_preOperational()
+void TestMaster_preOperational(CO_Data* d)
{
eprintf("TestMaster_preOperational\n");
@@ -311,17 +311,17 @@
}
-void TestMaster_operational()
+void TestMaster_operational(CO_Data* d)
{
eprintf("TestMaster_operational\n");
}
-void TestMaster_stopped()
+void TestMaster_stopped(CO_Data* d)
{
eprintf("TestMaster_stopped\n");
}
-void TestMaster_post_sync()
+void TestMaster_post_sync(CO_Data* d)
{
DO++;
@@ -345,7 +345,7 @@
eprintf("MicroMod Analogue In8: %d\n", AI8);
}
-void TestMaster_post_TPDO()
+void TestMaster_post_TPDO(CO_Data* d)
{
// eprintf("TestMaster_post_TPDO\n");
}
--- a/examples/DS401_Slave_Gui/CallBack.cpp Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/DS401_Slave_Gui/CallBack.cpp Fri Feb 01 18:06:55 2008 +0100
@@ -35,32 +35,32 @@
extern wxTextCtrl *textLog;
/*****************************************************************************/
-void Call_heartbeatError(UNS8 heartbeatID)
+void Call_heartbeatError(CO_Data* d, UNS8 heartbeatID)
{
//*textLog << wxT("HeartbeatError\n");
}
-void Call_initialisation()
+void Call_initialisation(CO_Data* d)
{
//*textLog << wxT("Initialisation\n");
}
-void Call_preOperational()
+void Call_preOperational(CO_Data* d)
{
//*textLog << wxT("PreOperational\n");
}
-void Call_operational()
+void Call_operational(CO_Data* d)
{
//*textLog << wxT("Operational\n");
}
-void Call_stopped()
+void Call_stopped(CO_Data* d)
{
//*textLog << wxT("Stopped\n");
}
-void Call_post_sync()
+void Call_post_sync(CO_Data* d)
{
//*textLog << wxT("Post_sync\n");
printf("POST SYNC:\n");
@@ -68,12 +68,12 @@
printf(" Read_Input: %x \n Analogue_Input1: %d \n Analogue_Input2: %d \n", Read_Inputs_8_Bit[0], Read_Analogue_Input_16_Bit[0], Read_Analogue_Input_16_Bit[1]);
}
-void Call_post_TPDO()
+void Call_post_TPDO(CO_Data* d)
{
//*textLog << wxT("Post_TPDO\n");
}
-void Call_storeODSubIndex(UNS16 wIndex, UNS8 bSubindex)
+void Call_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex)
{
printf("StoreODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex);
//*textLog << wxT("StoreODSubIndex :\n");
--- a/examples/DS401_Slave_Gui/CallBack.h Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/DS401_Slave_Gui/CallBack.h Fri Feb 01 18:06:55 2008 +0100
@@ -6,17 +6,17 @@
#include "ObjDict.h"
}
-void Call_heartbeatError(UNS8);
+void Call_heartbeatError(CO_Data* d, UNS8);
UNS8 Call_canSend(Message *);
-void Call_initialisation(void);
-void Call_preOperational(void);
-void Call_operational(void);
-void Call_stopped(void);
+void Call_initialisation(CO_Data* d);
+void Call_preOperational(CO_Data* d);
+void Call_operational(CO_Data* d);
+void Call_stopped(CO_Data* d);
-void Call_post_sync(void);
-void Call_post_TPDO(void);
-void Call_storeODSubIndex(UNS16 wIndex, UNS8 bSubindex);
+void Call_post_sync(CO_Data* d);
+void Call_post_TPDO(CO_Data* d);
+void Call_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
#endif /*CALLBACK_H_*/
--- a/examples/TestMasterMicroMod/TestMasterMicroMod.c Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/TestMasterMicroMod/TestMasterMicroMod.c Fri Feb 01 18:06:55 2008 +0100
@@ -42,7 +42,7 @@
/*****************************************************************************/
-void TestMaster_heartbeatError(UNS8 heartbeatID)
+void TestMaster_heartbeatError(CO_Data* d, UNS8 heartbeatID)
{
eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
}
@@ -52,7 +52,7 @@
* - setup master RPDO 1 to receive TPDO 1 from id 0x40
* - setup master TPDO 1 to send RPDO 1 to id 0x40
********************************************************/
-void TestMaster_initialisation()
+void TestMaster_initialisation(CO_Data* d)
{
UNS32 PDO1_COBID = 0x0180 + slavenodeid;
UNS32 PDO2_COBID = 0x0200 + slavenodeid;
@@ -303,7 +303,7 @@
}
-void TestMaster_preOperational()
+void TestMaster_preOperational(CO_Data* d)
{
eprintf("TestMaster_preOperational\n");
@@ -311,24 +311,24 @@
}
-void TestMaster_operational()
+void TestMaster_operational(CO_Data* d)
{
eprintf("TestMaster_operational\n");
}
-void TestMaster_stopped()
+void TestMaster_stopped(CO_Data* d)
{
eprintf("TestMaster_stopped\n");
}
-void TestMaster_post_sync()
+void TestMaster_post_sync(CO_Data* d)
{
DO++;
eprintf("MicroMod Digital Out: %2.2x\n",DO);
eprintf("MicroMod Digital In (by bit): DI1: %2.2x DI2: %2.2x DI3: %2.2x DI4: %2.2x DI5: %2.2x DI6: %2.2x DI7: %2.2x DI8: %2.2x\n",DI1,DI2,DI3,DI4,DI5,DI6,DI7,DI8);
}
-void TestMaster_post_TPDO()
+void TestMaster_post_TPDO(CO_Data* d)
{
// eprintf("TestMaster_post_TPDO\n");
}
--- a/examples/TestMasterSlave/Master.c Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/TestMasterSlave/Master.c Fri Feb 01 18:06:55 2008 +0100
@@ -25,7 +25,7 @@
#include "TestMasterSlave.h"
/*****************************************************************************/
-void TestMaster_heartbeatError(UNS8 heartbeatID)
+void TestMaster_heartbeatError(CO_Data* d, UNS8 heartbeatID)
{
eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
}
@@ -35,7 +35,7 @@
* - setup master RPDO 1 to receive TPDO 1 from id 2
* - setup master RPDO 2 to receive TPDO 2 from id 2
********************************************************/
-void TestMaster_initialisation()
+void TestMaster_initialisation(CO_Data* d)
{
UNS32 PDO1_COBID = 0x0182;
UNS32 PDO2_COBID = 0x0282;
@@ -239,11 +239,11 @@
/* First ask if there is a node with an invalid nodeID.
- * If FastScan is activated it is used to put the node in the state “configuration”.
+ * If FastScan is activated it is used to put the node in the state “configuration?.
* If FastScan is not activated, identification services are used to identify the node.
* Then switch mode service is used to put it in configuration state.
* Next all the inquire and configuration services are used.
- * Finally, the node LSS state is restored to “waiting” and all the process is repeated
+ * Finally, the node LSS state is restored to “waiting? and all the process is repeated
* again until there isn't any node with a invalid nodeID.
* */
static void ConfigureLSSNode(CO_Data* d)
@@ -344,7 +344,7 @@
}
#endif
-void TestMaster_preOperational()
+void TestMaster_preOperational(CO_Data* d)
{
eprintf("TestMaster_preOperational\n");
#ifdef CO_ENABLE_LSS
@@ -354,17 +354,17 @@
#endif
}
-void TestMaster_operational()
+void TestMaster_operational(CO_Data* d)
{
eprintf("TestMaster_operational\n");
}
-void TestMaster_stopped()
+void TestMaster_stopped(CO_Data* d)
{
eprintf("TestMaster_stopped\n");
}
-void TestMaster_post_sync()
+void TestMaster_post_sync(CO_Data* d)
{
eprintf("TestMaster_post_sync\n");
eprintf("Master: %d %d %d %d %d %d %d %d %d %x %x %d %d\n",
@@ -383,7 +383,7 @@
MasterMap13);
}
-void TestMaster_post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg)
+void TestMaster_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
{
eprintf("Master received EMCY message. Node: %2.2x ErrorCode: %4.4x ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
}
@@ -403,7 +403,7 @@
static int MasterSyncCount = 0;
-void TestMaster_post_TPDO()
+void TestMaster_post_TPDO(CO_Data* d)
{
eprintf("TestMaster_post_TPDO MasterSyncCount = %d \n", MasterSyncCount);
//
@@ -490,7 +490,7 @@
MasterSyncCount++;
}
-void TestMaster_post_SlaveBootup(UNS8 nodeid)
+void TestMaster_post_SlaveBootup(CO_Data* d, UNS8 nodeid)
{
eprintf("TestMaster_post_SlaveBootup %x\n", nodeid);
--- a/examples/TestMasterSlave/Master.h Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/TestMasterSlave/Master.h Fri Feb 01 18:06:55 2008 +0100
@@ -1,15 +1,15 @@
#include "TestMaster.h"
-void TestMaster_heartbeatError(UNS8);
+void TestMaster_heartbeatError(CO_Data* d, UNS8);
UNS8 TestMaster_canSend(Message *);
-void TestMaster_initialisation(void);
-void TestMaster_preOperational(void);
-void TestMaster_operational(void);
-void TestMaster_stopped(void);
+void TestMaster_initialisation(CO_Data* d);
+void TestMaster_preOperational(CO_Data* d);
+void TestMaster_operational(CO_Data* d);
+void TestMaster_stopped(CO_Data* d);
-void TestMaster_post_sync(void);
-void TestMaster_post_TPDO(void);
-void TestMaster_post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg);
-void TestMaster_post_SlaveBootup(UNS8 nodeid);
+void TestMaster_post_sync(CO_Data* d);
+void TestMaster_post_TPDO(CO_Data* d);
+void TestMaster_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
+void TestMaster_post_SlaveBootup(CO_Data* d, UNS8 nodeid);
--- a/examples/TestMasterSlave/Slave.c Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/TestMasterSlave/Slave.c Fri Feb 01 18:06:55 2008 +0100
@@ -26,32 +26,32 @@
extern s_BOARD SlaveBoard;
/*****************************************************************************/
-void TestSlave_heartbeatError(UNS8 heartbeatID)
+void TestSlave_heartbeatError(CO_Data* d, UNS8 heartbeatID)
{
eprintf("TestSlave_heartbeatError %d\n", heartbeatID);
}
-void TestSlave_initialisation()
+void TestSlave_initialisation(CO_Data* d)
{
eprintf("TestSlave_initialisation\n");
}
-void TestSlave_preOperational()
+void TestSlave_preOperational(CO_Data* d)
{
eprintf("TestSlave_preOperational\n");
}
-void TestSlave_operational()
+void TestSlave_operational(CO_Data* d)
{
eprintf("TestSlave_operational\n");
}
-void TestSlave_stopped()
+void TestSlave_stopped(CO_Data* d)
{
eprintf("TestSlave_stopped\n");
}
-void TestSlave_post_sync()
+void TestSlave_post_sync(CO_Data* d)
{
eprintf("TestSlave_post_sync\n");
@@ -83,7 +83,7 @@
SlaveMap13);
}
-void TestSlave_post_TPDO()
+void TestSlave_post_TPDO(CO_Data* d)
{
SlaveMap13 += 1;
eprintf("TestSlave_post_TPDO\n");
@@ -96,7 +96,7 @@
}
}
-void TestSlave_storeODSubIndex(UNS16 wIndex, UNS8 bSubindex)
+void TestSlave_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex)
{
/*TODO :
* - call getODEntry for index and subindex,
@@ -110,7 +110,7 @@
eprintf("TestSlave_storeODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex);
}
-void TestSlave_post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg)
+void TestSlave_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
{
eprintf("Slave received EMCY message. Node: %2.2x ErrorCode: %4.4x ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
}
--- a/examples/TestMasterSlave/Slave.h Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/TestMasterSlave/Slave.h Fri Feb 01 18:06:55 2008 +0100
@@ -1,17 +1,17 @@
#include "TestSlave.h"
-void TestSlave_heartbeatError(UNS8);
+void TestSlave_heartbeatError(CO_Data* d, UNS8);
UNS8 TestSlave_canSend(Message *);
-void TestSlave_initialisation(void);
-void TestSlave_preOperational(void);
-void TestSlave_operational(void);
-void TestSlave_stopped(void);
+void TestSlave_initialisation(CO_Data* d);
+void TestSlave_preOperational(CO_Data* d);
+void TestSlave_operational(CO_Data* d);
+void TestSlave_stopped(CO_Data* d);
-void TestSlave_post_sync(void);
-void TestSlave_post_TPDO(void);
-void TestSlave_storeODSubIndex(UNS16 wIndex, UNS8 bSubindex);
-void TestSlave_post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg);
+void TestSlave_post_sync(CO_Data* d);
+void TestSlave_post_TPDO(CO_Data* d);
+void TestSlave_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
+void TestSlave_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
void TestSlave_StoreConfiguration(UNS8 *error, UNS8 *spec_error);
void TestSlave_ChangeBaudRate(char *baudrate);
--- a/examples/gene_SYNC_HCS12/appli.c Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/gene_SYNC_HCS12/appli.c Fri Feb 01 18:06:55 2008 +0100
@@ -262,14 +262,14 @@
// FUNCTIONS WHICH ARE PART OF CANFESTIVAL and *must* be implemented here.
//------------------------------------------------------------------------------
-void gene_SYNC_heartbeatError( UNS8 heartbeatID )
+void gene_SYNC_heartbeatError(CO_Data* d, UNS8 heartbeatID )
{
MSG_ERR(0x1F00, "HeartBeat not received from node : ", heartbeatID);
}
//------------------------------------------------------------------------------
-void gene_SYNC_initialisation()
+void gene_SYNC_initialisation(CO_Data* d)
{
MSG_WAR (0x3F00, "Entering in INIT ", 0);
initSensor();
@@ -281,7 +281,7 @@
//------------------------------------------------------------------------------
-void gene_SYNC_preOperational()
+void gene_SYNC_preOperational(CO_Data* d)
{
MSG_WAR (0x3F01, "Entering in PRE-OPERATIONAL ", 0);
IO_PORTS_8(PORTB) &= ~ 0x03; // leds 0, 1 : ON
@@ -311,7 +311,7 @@
//------------------------------------------------------------------------------
-void gene_SYNC_operational()
+void gene_SYNC_operational(CO_Data* d)
{
MSG_WAR (0x3F02, "Entering in OPERATIONAL ", 0);
IO_PORTS_8(PORTB) &= ~ 0x07; // leds 0, 1, 2 : ON
@@ -365,7 +365,7 @@
}
//------------------------------------------------------------------------------
-void gene_SYNC_stopped()
+void gene_SYNC_stopped(CO_Data* d)
{
MSG_WAR (0x3F02, "Entering in STOPPED ", 0);
IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3, 4 : OFF
--- a/examples/gene_SYNC_HCS12/objdict.h Fri Feb 01 18:01:36 2008 +0100
+++ b/examples/gene_SYNC_HCS12/objdict.h Fri Feb 01 18:06:55 2008 +0100
@@ -8,17 +8,17 @@
const indextable * gene_SYNC_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks);
/* prototypes of function to be filled by app. */
-void gene_SYNC_heartbeatError(UNS8);
+void gene_SYNC_heartbeatError(CO_Data* d, UNS8);
UNS8 gene_SYNC_canSend(Message *);
-void gene_SYNC_initialisation(void);
-void gene_SYNC_preOperational(void);
-void gene_SYNC_operational(void);
-void gene_SYNC_stopped(void);
+void gene_SYNC_initialisation(CO_Data* d);
+void gene_SYNC_preOperational(CO_Data* d);
+void gene_SYNC_operational(CO_Data* d);
+void gene_SYNC_stopped(CO_Data* d);
-void gene_SYNC_post_sync(void);
-void gene_SYNC_post_TPDO(void);
+void gene_SYNC_post_sync(CO_Data* d);
+void gene_SYNC_post_TPDO(CO_Data* d);
/* Master node data struct */
extern CO_Data gene_SYNC_Data;
--- a/include/emcy.h Fri Feb 01 18:01:36 2008 +0100
+++ b/include/emcy.h Fri Feb 01 18:06:55 2008 +0100
@@ -52,8 +52,8 @@
#include "data.h"
-typedef void (*post_emcy_t)(UNS8 nodeID, UNS16 errCode, UNS8 errReg);
-void _post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg);
+typedef void (*post_emcy_t)(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
+void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg);
/*************************************************************************
* Functions
--- a/include/lifegrd.h Fri Feb 01 18:01:36 2008 +0100
+++ b/include/lifegrd.h Fri Feb 01 18:06:55 2008 +0100
@@ -26,11 +26,11 @@
#include <applicfg.h>
-typedef void (*heartbeatError_t)(UNS8);
-void _heartbeatError(UNS8 heartbeatID);
+typedef void (*heartbeatError_t)(CO_Data*, UNS8);
+void _heartbeatError(CO_Data* d, UNS8 heartbeatID);
-typedef void (*post_SlaveBootup_t)(UNS8);
-void _post_SlaveBootup(UNS8 SlaveID);
+typedef void (*post_SlaveBootup_t)(CO_Data*, UNS8);
+void _post_SlaveBootup(CO_Data* d, UNS8 SlaveID);
#include "data.h"
--- a/include/objacces.h Fri Feb 01 18:01:36 2008 +0100
+++ b/include/objacces.h Fri Feb 01 18:06:55 2008 +0100
@@ -37,12 +37,8 @@
#include <applicfg.h>
typedef UNS32 (*valueRangeTest_t)(UNS8 typeValue, void *Value);
-typedef void (* storeODSubIndex_t)(UNS16 wIndex, UNS8 bSubindex);
-void _storeODSubIndex (UNS16 wIndex, UNS8 bSubindex);
-
-#include "data.h"
-
-
+typedef void (* storeODSubIndex_t)(CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
+void _storeODSubIndex (CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
/*
Print MSG_WAR (s) if error to the access to the object dictionary occurs.
--- a/include/states.h Fri Feb 01 18:01:36 2008 +0100
+++ b/include/states.h Fri Feb 01 18:06:55 2008 +0100
@@ -62,15 +62,15 @@
/** Function that user app can overload
*
*/
-typedef void (*initialisation_t)(void);
-typedef void (*preOperational_t)(void);
-typedef void (*operational_t)(void);
-typedef void (*stopped_t)(void);
+typedef void (*initialisation_t)(CO_Data*);
+typedef void (*preOperational_t)(CO_Data*);
+typedef void (*operational_t)(CO_Data*);
+typedef void (*stopped_t)(CO_Data*);
-void _initialisation(void);
-void _preOperational(void);
-void _operational(void);
-void _stopped(void);
+void _initialisation(CO_Data*);
+void _preOperational(CO_Data*);
+void _operational(CO_Data*);
+void _stopped(CO_Data*);
#include "data.h"
--- a/include/sync.h Fri Feb 01 18:01:36 2008 +0100
+++ b/include/sync.h Fri Feb 01 18:06:55 2008 +0100
@@ -27,11 +27,11 @@
void stopSYNC(CO_Data* d);
-typedef void (*post_sync_t)(void);
-void _post_sync(void);
+typedef void (*post_sync_t)(CO_Data*);
+void _post_sync(CO_Data* d);
-typedef void (*post_TPDO_t)(void);
-void _post_TPDO(void);
+typedef void (*post_TPDO_t)(CO_Data*);
+void _post_TPDO(CO_Data* d);
/** transmit a SYNC message and trigger sync TPDOs
*/
--- a/src/dcf.c Fri Feb 01 18:01:36 2008 +0100
+++ b/src/dcf.c Fri Feb 01 18:06:55 2008 +0100
@@ -34,9 +34,7 @@
*/
-#include "objacces.h"
-#include "sdo.h"
-#include "dcf.h"
+#include "data.h"
#include "sysdep.h"
extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
@@ -161,20 +159,15 @@
* and execute the bootup callback. */
d->dcf_odentry->pSubindex[nodeId].bAccessType&=~DCF_TO_SEND;
d->dcf_request--;
- (*d->post_SlaveBootup)(nodeId);
+ (*d->post_SlaveBootup)(d, nodeId);
}
}
/* Check the next element*/
- //nodeId++;
nodeId=(nodeId+1) % d->dcf_odentry->bSubCount;
if(nodeId==d->dcf_odentry->bSubCount)nodeId=1;
d->dcf_cursor = NULL;
}
-
- //DCF_finish:
- /* Switch Master to preOperational state */
-
- //(*d->preOperational)();
+
}
--- a/src/emcy.c Fri Feb 01 18:01:36 2008 +0100
+++ b/src/emcy.c Fri Feb 01 18:06:55 2008 +0100
@@ -242,7 +242,7 @@
nodeID = UNS16_LE(m->cob_id) & 0x7F;
errCode = m->data[0] | ((UNS16)m->data[1] << 8);
errReg = m->data[2];
- (*d->post_emcy)(nodeID, errCode, errReg);
-}
-
-void _post_emcy(UNS8 nodeID, UNS16 errCode, UNS8 errReg){}
+ (*d->post_emcy)(d, nodeID, errCode, errReg);
+}
+
+void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg){}
--- a/src/lifegrd.c Fri Feb 01 18:01:36 2008 +0100
+++ b/src/lifegrd.c Fri Feb 01 18:06:55 2008 +0100
@@ -74,7 +74,7 @@
/* -> avoid deleting re-assigned timer if message is received too late*/
d->ConsumerHeartBeatTimers[id]=TIMER_NONE;
/*! call heartbeat error with NodeId */
- (*d->heartbeatError)((UNS8)( ((d->ConsumerHeartbeatEntries[id]) & (UNS32)0x00FF0000) >> (UNS8)16 ));
+ (*d->heartbeatError)(d, (UNS8)( ((d->ConsumerHeartbeatEntries[id]) & (UNS32)0x00FF0000) >> (UNS8)16 ));
}
/*!
@@ -142,7 +142,7 @@
if(!send_consise_dcf(d,nodeId)){
/* call post SlaveBootup with NodeId */
- (*d->post_SlaveBootup)(nodeId);
+ (*d->post_SlaveBootup)(d, nodeId);
}
}
@@ -260,5 +260,5 @@
**
** @param heartbeatID
**/
-void _heartbeatError(UNS8 heartbeatID){}
-void _post_SlaveBootup(UNS8 SlaveID){}
+void _heartbeatError(CO_Data* d, UNS8 heartbeatID){}
+void _post_SlaveBootup(CO_Data* d, UNS8 SlaveID){}
--- a/src/objacces.c Fri Feb 01 18:01:36 2008 +0100
+++ b/src/objacces.c Fri Feb 01 18:06:55 2008 +0100
@@ -38,7 +38,7 @@
/* #define DEBUG_ERR_CONSOLE_ON */
-#include "objacces.h"
+#include "data.h"
/*!
@@ -325,7 +325,7 @@
/* TODO : Store dans NVRAM */
if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVE){
- (*d->storeODSubIndex)(wIndex, bSubindex);
+ (*d->storeODSubIndex)(d, wIndex, bSubindex);
}
return OD_SUCCESSFUL;
}else{
@@ -433,4 +433,4 @@
** @param wIndex
** @param bSubindex
**/
-void _storeODSubIndex (UNS16 wIndex, UNS8 bSubindex){}
+void _storeODSubIndex (CO_Data* d, UNS16 wIndex, UNS8 bSubindex){}
--- a/src/sdo.c Fri Feb 01 18:01:36 2008 +0100
+++ b/src/sdo.c Fri Feb 01 18:06:55 2008 +0100
@@ -32,9 +32,7 @@
/* #define DEBUG_WAR_CONSOLE_ON */
/* #define DEBUG_ERR_CONSOLE_ON */
-#include "objacces.h"
-#include "sdo.h"
-#include "canfestival.h"
+#include "data.h"
#include "sysdep.h"
/* Uncomment if your compiler does not support inline functions */
@@ -519,7 +517,7 @@
MSG_ERR(0x1A42, "SendSDO : No SDO server found", 0);
return 0xFF;
}
- pwCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject;
+ pwCobId = (UNS16*) d->objdict[offset].pSubindex[2].pObject;
MSG_WAR(0x3A41, "I am server. cobId : ", *pwCobId);
}
else { /*case client*/
--- a/src/states.c Fri Feb 01 18:01:36 2008 +0100
+++ b/src/states.c Fri Feb 01 18:06:55 2008 +0100
@@ -29,14 +29,7 @@
**
*/
-#include "states.h"
-#include "def.h"
-#include "dcf.h"
-#include "nmtSlave.h"
-#include "emcy.h"
-#ifdef CO_ENABLE_LSS
-#include "lss.h"
-#endif
+#include "data.h"
#include "sysdep.h"
/** Prototypes for internals functions */
@@ -164,38 +157,34 @@
**/
UNS8 setState(CO_Data* d, e_nodeState newState)
{
- while(newState != d->nodeState){
+ if(newState != d->nodeState){
switch( newState ){
case Initialisation:
{
s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0, 0};
- /* This will force a second loop for the state switch */
d->nodeState = Initialisation;
- newState = Pre_operational;
- switchCommunicationState(d, &newCommunicationState);
- /* call user app related state func. */
- (*d->initialisation)();
-
- }
- break;
+ switchCommunicationState(d, &newCommunicationState);
+ /* call user app init callback now. */
+ /* d->initialisation MUST NOT CALL SetState */
+ (*d->initialisation)(d);
+ }
+
+ /* Automatic transition - No break statement ! */
+ /* Transition from Initialisation to Pre_operational */
+ /* is automatic as defined in DS301. */
+ /* App don't have to call SetState(d, Pre_operational) */
case Pre_operational:
{
s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 0, 1};
d->nodeState = Pre_operational;
- newState = Pre_operational;
switchCommunicationState(d, &newCommunicationState);
if (!(*(d->iam_a_slave)))
{
- //send_consise_dcf(d,0x01);
masterSendNMTstateChange (d, 0, NMT_Reset_Node);
- (*d->preOperational)();
}
- else
- {
- (*d->preOperational)();
- }
+ (*d->preOperational)(d);
}
break;
@@ -206,7 +195,7 @@
d->nodeState = Operational;
newState = Operational;
switchCommunicationState(d, &newCommunicationState);
- (*d->operational)();
+ (*d->operational)(d);
}
break;
@@ -217,7 +206,7 @@
d->nodeState = Stopped;
newState = Stopped;
switchCommunicationState(d, &newCommunicationState);
- (*d->stopped)();
+ (*d->stopped)(d);
}
break;
#ifdef CO_ENABLE_LSS
@@ -230,13 +219,12 @@
}
break;
#endif
-
- default:
- return 0xFF;
}/* end switch case */
}
- return 0;
+ /* d->nodeState contains the final state */
+ /* may not be the requested state */
+ return d->nodeState;
}
/*!
@@ -327,7 +315,7 @@
*d->bDeviceNodeId = nodeId;
}
-void _initialisation(){}
-void _preOperational(){}
-void _operational(){}
-void _stopped(){}
+void _initialisation(CO_Data* d){}
+void _preOperational(CO_Data* d){}
+void _operational(CO_Data* d){}
+void _stopped(CO_Data* d){}
--- a/src/sync.c Fri Feb 01 18:01:36 2008 +0100
+++ b/src/sync.c Fri Feb 01 18:06:55 2008 +0100
@@ -170,7 +170,7 @@
MSG_WAR(0x3002, "SYNC received. Proceed. ", 0);
- (*d->post_sync)();
+ (*d->post_sync)(d);
/* only operational state allows PDO transmission */
if(! d->CurrentCommunicationState.csPDO)
@@ -179,12 +179,12 @@
res = _sendPDOevent(d, 1 /*isSyncEvent*/ );
/*Call user app callback*/
- (*d->post_TPDO)();
+ (*d->post_TPDO)(d);
return res;
}
-void _post_sync(){}
-void _post_TPDO(){}
+void _post_sync(CO_Data* d){}
+void _post_TPDO(CO_Data* d){}