# HG changeset patch
# User etisserant
# Date 1175870968 -7200
# Node ID fe50ada8020bb7f74099097c0d15965bd1ffb3a4
# Parent ad3de87301729b3c7bdbbb4c63940768089d8eb1
Changes in the API:
- No more mandatory callbacks declared for each node anymore
heartbeatError
SDOtimeoutError
initialisation
preOperational
operational
stopped
post_sync
post_TPDO
canSend
- Fill function ptr to declare callbacks
CO_Data.heartbeatError
CO_Data.SDOtimeoutError
CO_Data.initialisation
CO_Data.preOperational
CO_Data.operational
CO_Data.stopped
CO_Data.post_sync
CO_Data.post_TPDO
- CanClose now takes CO_Data* as parameter
- canSend is provided to the stack directly by OS interface, no specific callback.
diff -r ad3de8730172 -r fe50ada8020b doc/canfestival_CAN_interface.svg
--- a/doc/canfestival_CAN_interface.svg Thu Apr 05 10:06:11 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,826 +0,0 @@
-
-
-
diff -r ad3de8730172 -r fe50ada8020b doc/canfestival_OS.png
Binary file doc/canfestival_OS.png has changed
diff -r ad3de8730172 -r fe50ada8020b doc/canfestival_OS.svg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/canfestival_OS.svg Fri Apr 06 16:49:28 2007 +0200
@@ -0,0 +1,1303 @@
+
+
+
diff -r ad3de8730172 -r fe50ada8020b doc/canfestival_OSless.png
Binary file doc/canfestival_OSless.png has changed
diff -r ad3de8730172 -r fe50ada8020b doc/canfestival_OSless.svg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/canfestival_OSless.svg Fri Apr 06 16:49:28 2007 +0200
@@ -0,0 +1,661 @@
+
+
+
diff -r ad3de8730172 -r fe50ada8020b doc/canfestival_overview.png
Binary file doc/canfestival_overview.png has changed
diff -r ad3de8730172 -r fe50ada8020b doc/canfestival_overview.svg
--- a/doc/canfestival_overview.svg Thu Apr 05 10:06:11 2007 +0200
+++ b/doc/canfestival_overview.svg Fri Apr 06 16:49:28 2007 +0200
@@ -7,19 +7,21 @@
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="841.88977pt"
height="595.27557pt"
id="svg2"
sodipodi:version="0.32"
- inkscape:version="0.43"
- sodipodi:docbase="/home/edouard/taf/Pim/workspace_edouard/CanFestival-3/doc"
+ inkscape:version="0.45"
+ sodipodi:docbase="/home/edouard/workspace/CanFestival-3/doc"
sodipodi:docname="canfestival_overview.svg"
version="1.0"
- inkscape:export-filename="canfestival_overview.png"
+ inkscape:export-filename="/home/edouard/workspace/CanFestival-3/doc/canfestival_overview.png"
inkscape:export-xdpi="87.57"
- inkscape:export-ydpi="87.57">
+ inkscape:export-ydpi="87.57"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ sodipodi:modified="true">
+
+
+
HWTargetinterfaces
+ id="tspan12931">interface
-
-
-
- SCHEDULINGtimer.c
-
@@ -357,25 +341,6 @@
id="tspan2259">objaccess.c
HardwareAbstactionLayer
-
sync.c
-
-
- CAN DRIVERINTERFACEcan_xxx.c
- RCV
- TRS
-
-
-
- SYSTEM TIMERSINTERFACEtimers_xxx.c
-
-
-
-
- PERSITANT STORAGEnvram.c
-
-
-
-
- LED INDICATORSled.c
-
-
-
- PERSISTANTSTORAGE INTERFACEnvram_xxx.c
-
-
-
- LEDINTERFACEled_xxx.c
-
(master/slave)
Optional:- NVRAM- LED- CAN LSS supportInterfaces can be provideddirectly by application.
- libcanfestival_$(TARGET).a
+ sodipodi:role="line">libcanfestival_$(CAN_DRIVER).so$(CAN_DRIVER).dll,cyg$(CAN_DRIVER).dll
Mandatory:- Declare nodes callbacks- Open CAN interfaces- Initiate TImersOptional:- Declare some callbacksEach call to the CanFestival API provide a pointer to the related node's CO_Data struct.opened.
+
+
+
+
+ SCHEDULINGtimer.c
+
+
+
+ SYSTEM TIMERSINTERFACEtimers_xxx.c
+
+ libcanfestival_$(TARGET).acanfestival_$(TARGET).lib
+
+
+
+
+
+ OS interfaceunix.corwin32.c
+
+
+ CAN DRIVERINTERFACEcan_xxx.c
+ RCV
+ TRS
+
+ CANinterface
+ Dynamicaly loadedor Linked
diff -r ad3de8730172 -r fe50ada8020b doc/manual/en/manual.odt
Binary file doc/manual/en/manual.odt has changed
diff -r ad3de8730172 -r fe50ada8020b doc/manual/en/manual.pdf
Binary file doc/manual/en/manual.pdf has changed
diff -r ad3de8730172 -r fe50ada8020b drivers/generic/.cvsignore
--- a/drivers/generic/.cvsignore Thu Apr 05 10:06:11 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Makefile
-*.a
diff -r ad3de8730172 -r fe50ada8020b drivers/generic/Makefile.in
--- a/drivers/generic/Makefile.in Thu Apr 05 10:06:11 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-#! gmake
-
-#
-# Copyright (C) 2006 Laurent Bessard
-#
-# This file is part of canfestival, a library implementing the canopen
-# stack
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-CC = SUB_CC
-OPT_CFLAGS = -O2
-CFLAGS = SUB_OPT_CFLAGS
-PROG_CFLAGS = SUB_PROG_CFLAGS
-OS_NAME = SUB_OS_NAME
-ARCH_NAME = SUB_ARCH_NAME
-PREFIX = SUB_PREFIX
-TARGET = SUB_TARGET
-CAN_DRIVER = SUB_CAN_DRIVER
-TIMERS_DRIVER = SUB_TIMERS_DRIVER
-
-INCLUDES = -I../../include -I../../include/$(SUB_TARGET)
-
-OBJS =
-
-# add timers driver if any
-ifneq ($(TIMERS_DRIVER),timers_)
-OBJS += ../$(TIMERS_DRIVER)/$(TIMERS_DRIVER).o
-endif
-
-# add can driver if any
-ifneq ($(CAN_DRIVER),can_)
-OBJS += ../$(CAN_DRIVER)/$(CAN_DRIVER).o
-endif
-
-SRC_HFILES = ../../include/$(TARGET)/applicfg.h
-
-TARGET_HFILES = $(PREFIX)/include/$(TARGET)/applicfg.h
-
-all: driver
-
-driver: $(OBJS)
-
-#../$(TIMERS_DRIVER)/$(TIMERS_DRIVER).o:
-# $(MAKE) -C ../$(TIMERS_DRIVER) driver
-
-#../$(CAN_DRIVER)/$(CAN_DRIVER).o:
-# $(MAKE) -C ../$(CAN_DRIVER) driver
-
-libcanfestival_$(TARGET).a: $(OBJS)
- @echo Building [libcanfestival_$(TARGET).a]
- ar rc $@ $(OBJS)
- ranlib $@
-
-install: libcanfestival_$(TARGET).a
- mkdir -p $(PREFIX)/lib/
- mkdir -p $(PREFIX)/include/canfestival
- cp libcanfestival_$(TARGET).a $(PREFIX)/lib/
- cp $(SRC_HFILES) $(PREFIX)/include/canfestival
-
-uninstall:
- rm -f $(PREFIX)/lib/libcanfestival_$(TARGET).a
- rm -f $(TARGET_HFILES)
-
-clean:
- rm -f libcanfestival_$(TARGET).a
-
-mrproper: clean
-
-
diff -r ad3de8730172 -r fe50ada8020b drivers/timers_unix/timers_unix.c
--- a/drivers/timers_unix/timers_unix.c Thu Apr 05 10:06:11 2007 +0200
+++ b/drivers/timers_unix/timers_unix.c Fri Apr 06 16:49:28 2007 +0200
@@ -54,14 +54,18 @@
void StopTimerLoop(void)
{
+ EnterMutex();
timer_delete (timer);
+ LeaveMutex();
}
void StartTimerLoop(TimerCallback_t init_callback)
{
initTimer();
+ EnterMutex();
// At first, TimeDispatch will call init_callback.
SetAlarm(NULL, 0, init_callback, 0, 0);
+ LeaveMutex();
}
void CreateReceiveTask(CAN_PORT port, TASK_HANDLE* Thread, void* ReceiveLoopPtr)
diff -r ad3de8730172 -r fe50ada8020b drivers/unix/unix.c
--- a/drivers/unix/unix.c Thu Apr 05 10:06:11 2007 +0200
+++ b/drivers/unix/unix.c Fri Apr 06 16:49:28 2007 +0200
@@ -146,7 +146,14 @@
UNS8 canSend(CAN_PORT port, Message *m)
{
- return DLL_CALL(canSend)(((CANPort*)port)->fd, m);
+ if(port){
+ UNS8 res;
+ LeaveMutex();
+ res = DLL_CALL(canSend)(((CANPort*)port)->fd, m);
+ EnterMutex();
+ return res;
+ }
+ return -1;
}
void canReceiveLoop(CAN_PORT port)
@@ -184,17 +191,23 @@
canports[i].d = d;
CreateReceiveTask(&(canports[i]), &canports[i].receiveTask, &canReceiveLoop);
-
+
+ EnterMutex();
+ d->canHandle = (CAN_PORT)&canports[i];
+ LeaveMutex();
return (CAN_PORT)&canports[i];
}
-int canClose(CAN_PORT port)
-{
- ((CANPort*)port)->used = 0;
- int res = DLL_CALL(canClose)(((CANPort*)port)->fd);
-
- WaitReceiveTaskEnd(((CANPort*)port)->receiveTask);
+int canClose(CO_Data * d)
+{
+ EnterMutex();
+ ((CANPort*)d->canHandle)->used = 0;
+ CANPort* tmp = (CANPort*)d->canHandle;
+ d->canHandle = NULL;
+ LeaveMutex();
+
+ int res = DLL_CALL(canClose)(tmp->fd);
+
+ WaitReceiveTaskEnd(tmp->receiveTask);
return res;
}
-
-
diff -r ad3de8730172 -r fe50ada8020b drivers/win32/drivers_win32.cpp
--- a/drivers/win32/drivers_win32.cpp Thu Apr 05 10:06:11 2007 +0200
+++ b/drivers/win32/drivers_win32.cpp Fri Apr 06 16:49:28 2007 +0200
@@ -197,8 +197,12 @@
{
if (fd0 != NULL && s_driver_procs.m_canSend != NULL)
{
+ UNS8 res;
driver_data* data = (driver_data*)fd0;
- if ((*s_driver_procs.m_canSend)(data->inst, m))
+ LeaveMutex();
+ res = (*s_driver_procs.m_canSend)(data->inst, m);
+ EnterMutex();
+ if (res)
return 0;
}
return 1;
@@ -217,6 +221,9 @@
data->inst = inst;
data->continue_receive_thread = true;
CreateReceiveTask(data, &data->receive_thread, &canReceiveLoop);
+ EnterMutex();
+ d->canHandle = data;
+ LeaveMutex();
return data;
}
}
@@ -224,11 +231,14 @@
}
/***************************************************************************/
-int canClose(CAN_PORT fd0)
+int canClose(CO_Data * d)
{
if (fd0 != NULL && s_driver_procs.m_canClose != NULL)
{
- driver_data* data = (driver_data*)fd0;
+ EnterMutex();
+ driver_data* data = (driver_data*)d->canHandle;
+ d->canHandle = NULL;
+ LeaveMutex();
data->continue_receive_thread = false;
WaitReceiveTaskEnd(&data->receive_thread);
(*s_driver_procs.m_canClose)(data->inst);
diff -r ad3de8730172 -r fe50ada8020b examples/TestMasterSlave/Master.c
--- a/examples/TestMasterSlave/Master.c Thu Apr 05 10:06:11 2007 +0200
+++ b/examples/TestMasterSlave/Master.c Fri Apr 06 16:49:28 2007 +0200
@@ -37,15 +37,6 @@
}
/*****************************************************************************/
-// CanSend store message in a FIFO, for Slave
-UNS8 TestMaster_canSend(Message *m)
-{
- eprintf("M->S ");
- print_message(m);
- canSend(MasterCanHandle, m);
- return 0;
-}
-
void TestMaster_initialisation()
{
eprintf("TestMaster_initialisation\n");
diff -r ad3de8730172 -r fe50ada8020b examples/TestMasterSlave/Slave.c
--- a/examples/TestMasterSlave/Slave.c Thu Apr 05 10:06:11 2007 +0200
+++ b/examples/TestMasterSlave/Slave.c Fri Apr 06 16:49:28 2007 +0200
@@ -36,15 +36,6 @@
eprintf("TestSlave_SDOtimeoutError %d\n", line);
}
-/*****************************************************************************/
-UNS8 TestSlave_canSend(Message *m)
-{
- eprintf("S->M ");
- print_message(m);
- canSend(SlaveCanHandle, m);
- return 0;
-}
-
void TestSlave_initialisation()
{
eprintf("TestSlave_initialisation\n");
diff -r ad3de8730172 -r fe50ada8020b examples/TestMasterSlave/TestMasterSlave.c
--- a/examples/TestMasterSlave/TestMasterSlave.c Thu Apr 05 10:06:11 2007 +0200
+++ b/examples/TestMasterSlave/TestMasterSlave.c Fri Apr 06 16:49:28 2007 +0200
@@ -78,9 +78,6 @@
return 0;
}
-CAN_PORT SlaveCanHandle;
-CAN_PORT MasterCanHandle;
-
s_BOARD SlaveBoard = {"0", "500K"};
s_BOARD MasterBoard = {"1", "500K"};
@@ -221,16 +218,34 @@
#endif
// Open CAN devices
if(SlaveBoard.baudrate){
- SlaveCanHandle = canOpen(&SlaveBoard,&TestSlave_Data);
- if(SlaveCanHandle == NULL){
+
+ TestSlave_Data.heartbeatError = TestSlave_heartbeatError;
+ TestSlave_Data.SDOtimeoutError = TestSlave_SDOtimeoutError;
+ TestSlave_Data.initialisation = TestSlave_initialisation;
+ TestSlave_Data.preOperational = TestSlave_preOperational;
+ TestSlave_Data.operational = TestSlave_operational;
+ TestSlave_Data.stopped = TestSlave_stopped;
+ TestSlave_Data.post_sync = TestSlave_post_sync;
+ TestSlave_Data.post_TPDO = TestSlave_post_TPDO;
+
+ if(!canOpen(&SlaveBoard,&TestSlave_Data)){
eprintf("Cannot open Slave Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate);
goto fail_slave;
}
}
if(MasterBoard.baudrate){
- MasterCanHandle = canOpen(&MasterBoard,&TestMaster_Data);
- if(MasterCanHandle == NULL){
+
+ TestMaster_Data.heartbeatError = TestMaster_heartbeatError;
+ TestMaster_Data.SDOtimeoutError = TestMaster_SDOtimeoutError;
+ TestMaster_Data.initialisation = TestMaster_initialisation;
+ TestMaster_Data.preOperational = TestMaster_preOperational;
+ TestMaster_Data.operational = TestMaster_operational;
+ TestMaster_Data.stopped = TestMaster_stopped;
+ TestMaster_Data.post_sync = TestMaster_post_sync;
+ TestMaster_Data.post_TPDO = TestMaster_post_TPDO;
+
+ if(!canOpen(&MasterBoard,&TestMaster_Data)){
eprintf("Cannot open Master Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate);
goto fail_master;
}
@@ -247,9 +262,9 @@
StopTimerLoop();
// Close CAN devices (and can threads)
- if(SlaveBoard.baudrate) canClose(SlaveCanHandle);
+ if(SlaveBoard.baudrate) canClose(&TestSlave_Data);
fail_master:
- if(MasterBoard.baudrate) canClose(MasterCanHandle);
+ if(MasterBoard.baudrate) canClose(&TestMaster_Data);
fail_slave:
diff -r ad3de8730172 -r fe50ada8020b examples/TestMasterSlave/TestMasterSlave.h
--- a/examples/TestMasterSlave/TestMasterSlave.h Thu Apr 05 10:06:11 2007 +0200
+++ b/examples/TestMasterSlave/TestMasterSlave.h Fri Apr 06 16:49:28 2007 +0200
@@ -30,10 +30,6 @@
#include "canfestival.h"
-extern CAN_PORT SlaveCanHandle;
-extern CAN_PORT MasterCanHandle;
-
-
/*
#define CAN_FIFO_LENGTH 100
diff -r ad3de8730172 -r fe50ada8020b examples/gene_SYNC_HCS12/appli.c
--- a/examples/gene_SYNC_HCS12/appli.c Thu Apr 05 10:06:11 2007 +0200
+++ b/examples/gene_SYNC_HCS12/appli.c Fri Apr 06 16:49:28 2007 +0200
@@ -285,14 +285,6 @@
}
//------------------------------------------------------------------------------
-UNS8 gene_SYNC_canSend(Message *m)
-{
- // HCS12 driver function to send the CAN msg
- canMsgTransmit(CAN0, *m);
- return 0;
-}
-
-//------------------------------------------------------------------------------
void gene_SYNC_initialisation()
{
MSG_WAR (0x3F00, "Entering in INIT ", 0);
@@ -395,16 +387,6 @@
IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3, 4 : OFF
}
-//------------------------------------------------------------------------------
-void gene_SYNC_post_sync()
-{
-}
-
-//------------------------------------------------------------------------------
-void gene_SYNC_post_TPDO()
-{
-}
-
// End functions which are part of Canfestival
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
@@ -419,6 +401,13 @@
MSG_WAR(0x3F34, "Entering in the main ", 0);
//----------------------------- INITIALISATION --------------------------------
+ gene_SYNC_Data.heartbeatError = gene_SYNC_heartbeatError;
+ gene_SYNC_Data.SDOtimeoutError = gene_SYNC_SDOtimeoutError;
+ gene_SYNC_Data.initialisation = gene_SYNC_initialisation;
+ gene_SYNC_Data.preOperational = gene_SYNC_preOperational;
+ gene_SYNC_Data.preOperational = gene_SYNC_operational;
+ gene_SYNC_Data.stopped = gene_SYNC_stopped;
+
/* Put the node in Initialisation mode */
MSG_WAR(0x3F35, "Will entering in INIT ", 0);
diff -r ad3de8730172 -r fe50ada8020b examples/win32test/main.c
--- a/examples/win32test/main.c Thu Apr 05 10:06:11 2007 +0200
+++ b/examples/win32test/main.c Fri Apr 06 16:49:28 2007 +0200
@@ -34,48 +34,6 @@
#define uptime_ms_proc (1000*(time()%86400)) // TOD
#endif
-/* required canfestival callbacks. */
-void win32test_SDOtimeoutError(UNS8 line)
- {
- }
-
-void win32test_heartbeatError(UNS8 node_id)
- {
- }
-
-void win32test_initialisation(void)
- {
- }
-
-void win32test_preOperational(void)
- {
- }
-
-void win32test_operational(void)
- {
- }
-
-void win32test_stopped(void)
- {
- }
-
-void win32test_post_sync(void)
- {
- }
-
-void win32test_post_TPDO(void)
- {
- }
-
-static CAN_HANDLE g_MasterCanHandle = NULL;
-
-UNS8 win32test_canSend(Message *m)
- {
- if (g_MasterCanHandle != NULL)
- return canSend(g_MasterCanHandle, m);
- return 1;
- }
-
UNS8 GetChangeStateResults(UNS8 node_id, UNS8 expected_state, unsigned long timeout_ms)
{
unsigned long start_time = 0;
@@ -150,9 +108,7 @@
return 1;
}
- g_MasterCanHandle = canOpen(&MasterBoard,&win32test_Data);
-
- if (g_MasterCanHandle)
+ if (canOpen(&MasterBoard,&win32test_Data))
{
/* Defining the node Id */
setNodeId(&win32test_Data, 0x01);
@@ -239,7 +195,7 @@
setState(&win32test_Data, Stopped);
- canClose(g_MasterCanHandle);
+ canClose(&win32test_Data);
}
return 0;
}
diff -r ad3de8730172 -r fe50ada8020b include/data.h
--- a/include/data.h Thu Apr 05 10:06:11 2007 +0200
+++ b/include/data.h Fri Apr 06 16:49:28 2007 +0200
@@ -88,7 +88,7 @@
/* General */
UNS8 toggle;
- canSend_t canSend;
+ CAN_HANDLE canHandle;
scanIndexOD_t scanIndexOD;
};
@@ -127,7 +127,7 @@
{\
REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(s_transfer_Initializer)\
},\
- &NODE_PREFIX ## _SDOtimeoutError, /* SDOtimeoutError */\
+ _SDOtimeoutError,/*&NODE_PREFIX ## _SDOtimeoutError, /* SDOtimeoutError */\
\
/* State machine*/\
Unknown_state, /* nodeState */\
@@ -140,10 +140,10 @@
0, /* csHeartbeat */\
0 /* csPDO */\
},\
- &NODE_PREFIX ## _initialisation, /* initialisation */\
- &NODE_PREFIX ## _preOperational, /* preOperational */\
- &NODE_PREFIX ## _operational, /* operational */\
- &NODE_PREFIX ## _stopped, /* stopped */\
+ _initialisation,/*&NODE_PREFIX ## _initialisation, /* initialisation */\
+ _preOperational,/*&NODE_PREFIX ## _preOperational, /* preOperational */\
+ _operational,/*&NODE_PREFIX ## _operational, /* operational */\
+ _stopped,/*&NODE_PREFIX ## _stopped, /* stopped */\
\
/* NMT-heartbeat */\
& NODE_PREFIX ## _highestSubIndex_obj1016, /* ConsumerHeartbeatCount */\
@@ -151,7 +151,7 @@
NODE_PREFIX ## _heartBeatTimers, /* ConsumerHeartBeatTimers */\
& NODE_PREFIX ## _obj1017, /* ProducerHeartBeatTime */\
TIMER_NONE, /* ProducerHeartBeatTimer */\
- NODE_PREFIX ## _heartbeatError, /* heartbeatError */\
+ _heartbeatError,/*NODE_PREFIX ## _heartbeatError, /* heartbeatError */\
\
{REPEAT_NMT_MAX_NODE_ID_TIMES(NMTable_Initializer)},\
/* is well initialized at "Unknown_state". Is it ok ? (FD)*/\
@@ -161,8 +161,8 @@
& NODE_PREFIX ## _obj1005, /* COB_ID_Sync */\
& NODE_PREFIX ## _obj1006, /* Sync_Cycle_Period */\
/*& NODE_PREFIX ## _obj1007, */ /* Sync_window_length */\
- NODE_PREFIX ## _post_sync, /* post_sync */\
- NODE_PREFIX ## _post_TPDO, /* post_TPDO */\
+ _post_sync,/*NODE_PREFIX ## _post_sync, /* post_sync */\
+ _post_TPDO,/*NODE_PREFIX ## _post_TPDO, /* post_TPDO */\
\
/* PDO, structure s_process_var */\
{\
@@ -172,7 +172,7 @@
\
/* General */\
0, /* toggle */\
- NODE_PREFIX ## _canSend, /* canSend */\
+ NULL,/*NODE_PREFIX ## _canSend, /* canSend */\
NODE_PREFIX ## _scanIndexOD /* scanIndexOD */\
}
diff -r ad3de8730172 -r fe50ada8020b include/generic/applicfg.h
--- a/include/generic/applicfg.h Thu Apr 05 10:06:11 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
-This file is part of CanFestival, a library implementing CanOpen Stack.
-
-Copyright (C): Edouard TISSERANT and Francis DUPIN
-
-See COPYING file for copyrights details.
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#ifndef __APPLICFG_LINUX__
-#define __APPLICFG_LINUX__
-
-#include
-#include
-
-// Define the architecture : little_endian or big_endian
-// -----------------------------------------------------
-// Test :
-// UNS32 v = 0x1234ABCD;
-// char *data = &v;
-//
-// Result for a little_endian architecture :
-// data[0] = 0xCD;
-// data[1] = 0xAB;
-// data[2] = 0x34;
-// data[3] = 0x12;
-//
-// Result for a big_endian architecture :
-// data[0] = 0x12;
-// data[1] = 0x34;
-// data[2] = 0xAB;
-// data[3] = 0xCD;
-
-// Integers
-#define INTEGER8 char
-#define INTEGER16 short
-#define INTEGER24
-#define INTEGER32 long
-#define INTEGER40
-#define INTEGER48
-#define INTEGER56
-#define INTEGER64
-
-// Unsigned integers
-#define UNS8 unsigned char
-#define UNS16 unsigned short
-#define UNS32 unsigned long
-#define UNS24
-#define UNS40
-#define UNS48
-#define UNS56
-#define UNS64 unsigned long long
-
-// Reals
-#define REAL32 float
-#define REAL64 double
-
-/// Definition of error and warning macros
-// --------------------------------------
-#if defined DEBUG_ERR_CONSOLE_ON || defined DEBUG_WAR_CONSOLE_ON
-#include
-#endif
-
-/// Definition of MSG_ERR
-// ---------------------
-#ifdef DEBUG_ERR_CONSOLE_ON
-# define MSG_ERR(num, str, val)/* \
- printf("%s,%d : 0X%x %s 0X%x \n",__FILE__, __LINE__,num, str, val);*/
-#else
-# define MSG_ERR(num, str, val)
-#endif
-
-/// Definition of MSG_WAR
-// ---------------------
-#ifdef DEBUG_WAR_CONSOLE_ON
-# define MSG_WAR(num, str, val)/* \
- printf("%s,%d : 0X%x %s 0X%x \n",__FILE__, __LINE__,num, str, val);*/
-#else
-# define MSG_WAR(num, str, val)
-#endif
-
-#endif
-
-#define CAN_HANDLE void*
-
-#define MS_TO_TIMEVAL(ms) ms*US_TO_TIMEVAL_FACTOR*1000
-#define US_TO_TIMEVAL(us) us*US_TO_TIMEVAL_FACTOR
-
-#define TASK_HANDLE pthread_t
diff -r ad3de8730172 -r fe50ada8020b include/lifegrd.h
--- a/include/lifegrd.h Thu Apr 05 10:06:11 2007 +0200
+++ b/include/lifegrd.h Fri Apr 06 16:49:28 2007 +0200
@@ -27,6 +27,7 @@
#include
typedef void (*heartbeatError_t)(UNS8);
+void _heartbeatError(UNS8 heartbeatID);
#include "data.h"
diff -r ad3de8730172 -r fe50ada8020b include/sdo.h
--- a/include/sdo.h Thu Apr 05 10:06:11 2007 +0200
+++ b/include/sdo.h Fri Apr 06 16:49:28 2007 +0200
@@ -24,6 +24,8 @@
#define __sdo_h__
typedef void (*SDOtimeoutError_t)(UNS8 line);
+void _SDOtimeoutError (UNS8);
+
struct struct_s_transfer;
#include "timer.h"
diff -r ad3de8730172 -r fe50ada8020b include/states.h
--- a/include/states.h Thu Apr 05 10:06:11 2007 +0200
+++ b/include/states.h Fri Apr 06 16:49:28 2007 +0200
@@ -55,7 +55,7 @@
UNS8 csPDO;
} s_state_communication;
-/** Function that user app must provide
+/** Function that user app can overload
*
*/
typedef void (*initialisation_t)(void);
@@ -63,6 +63,11 @@
typedef void (*operational_t)(void);
typedef void (*stopped_t)(void);
+void _initialisation();
+void _preOperational();
+void _operational();
+void _stopped();
+
#include "data.h"
/************************* prototypes ******************************/
diff -r ad3de8730172 -r fe50ada8020b include/sync.h
--- a/include/sync.h Thu Apr 05 10:06:11 2007 +0200
+++ b/include/sync.h Fri Apr 06 16:49:28 2007 +0200
@@ -28,8 +28,10 @@
void stopSYNC(CO_Data* d);
typedef void (*post_sync_t)(void);
+void _post_sync();
typedef void (*post_TPDO_t)(void);
+void _post_TPDO();
/** transmit a SYNC message on the bus number bus_id
* bus_id is hardware dependant
diff -r ad3de8730172 -r fe50ada8020b include/unix/canfestival.h
--- a/include/unix/canfestival.h Thu Apr 05 10:06:11 2007 +0200
+++ b/include/unix/canfestival.h Fri Apr 06 16:49:28 2007 +0200
@@ -16,6 +16,6 @@
LIB_HANDLE LoadCanDriver(char* driver_name);
UNS8 canSend(CAN_PORT port, Message *m);
CAN_PORT canOpen(s_BOARD *board, CO_Data * d);
-int canClose(CAN_PORT port);
+int canClose(CO_Data * d);
#endif /*UNIX_H_*/
diff -r ad3de8730172 -r fe50ada8020b include/win32/canfestival.h
--- a/include/win32/canfestival.h Thu Apr 05 10:06:11 2007 +0200
+++ b/include/win32/canfestival.h Fri Apr 06 16:49:28 2007 +0200
@@ -34,6 +34,6 @@
LIB_HANDLE LoadCanDriver(char* driver_name);
UNS8 canSend(CAN_PORT port, Message *m);
CAN_PORT canOpen(s_BOARD *board, CO_Data * d);
-int canClose(CAN_PORT port);
+int canClose(CO_Data * d);
#endif /*CANFESTIVAL_H_*/
diff -r ad3de8730172 -r fe50ada8020b objdictgen/objdictedit.py
--- a/objdictgen/objdictedit.py Thu Apr 05 10:06:11 2007 +0200
+++ b/objdictgen/objdictedit.py Fri Apr 06 16:49:28 2007 +0200
@@ -1073,7 +1073,8 @@
event.Skip()
def OnHelpCANFestivalMenu(self, event):
- self.OpenHtmlFrame("CAN Festival Reference", os.path.join(WorkingDirectory, "../doc/canfestival.html"), wx.Size(1000, 600))
+ #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(WorkingDirectory, "../doc/canfestival.html"), wx.Size(1000, 600))
+ os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(WorkingDirectory, "../doc/manual/en/manual.pdf"),16))
event.Skip()
def OnAboutMenu(self, event):
diff -r ad3de8730172 -r fe50ada8020b src/lifegrd.c
--- a/src/lifegrd.c Thu Apr 05 10:06:11 2007 +0200
+++ b/src/lifegrd.c Fri Apr 06 16:49:28 2007 +0200
@@ -22,6 +22,7 @@
#include
#include "lifegrd.h"
+#include "canfestival.h"
/* Prototypes for internals functions */
void ConsumerHearbeatAlarm(CO_Data* d, UNS32 id);
@@ -69,7 +70,7 @@
d->toggle = 1 ;
/* send the nodeguard response. */
MSG_WAR(0x3130, "Sending NMT Nodeguard to master, state: ", d->nodeState);
- (*d->canSend)(&msg );
+ canSend(d->canHandle,&msg );
}
}else{ /* Not a request CAN */
@@ -125,7 +126,7 @@
msg.data[0] = d->nodeState; /* No toggle for heartbeat !*/
/* send the heartbeat */
MSG_WAR(0x3130, "Producing heartbeat: ", d->nodeState);
- (*d->canSend)(&msg );
+ canSend(d->canHandle,&msg );
}else{
d->ProducerHeartBeatTimer = DelAlarm(d->ProducerHeartBeatTimer);
}
@@ -167,3 +168,4 @@
d->ProducerHeartBeatTimer = DelAlarm(d->ProducerHeartBeatTimer);;
}
+void _heartbeatError(UNS8 heartbeatID){}
diff -r ad3de8730172 -r fe50ada8020b src/nmtMaster.c
--- a/src/nmtMaster.c Thu Apr 05 10:06:11 2007 +0200
+++ b/src/nmtMaster.c Fri Apr 06 16:49:28 2007 +0200
@@ -21,6 +21,7 @@
*/
#include "nmtMaster.h"
+#include "canfestival.h"
/******************************************************************************/
UNS8 masterSendNMTstateChange(CO_Data* d, UNS8 Node_ID, UNS8 cs)
@@ -36,7 +37,7 @@
m.data[0] = cs;
m.data[1] = Node_ID;
- return (*d->canSend)(&m);
+ return canSend(d->canHandle,&m);
}
@@ -52,7 +53,7 @@
m.rtr = REQUEST;
m.len = 1;
- return (*d->canSend)(&m);
+ return canSend(d->canHandle,&m);
}
/******************************************************************************/
diff -r ad3de8730172 -r fe50ada8020b src/nmtSlave.c
--- a/src/nmtSlave.c Thu Apr 05 10:06:11 2007 +0200
+++ b/src/nmtSlave.c Fri Apr 06 16:49:28 2007 +0200
@@ -84,6 +84,6 @@
m.len = 1;
m.data[0] = 0x00;
- return (*d->canSend)(&m);
+ return canSend(d->canHandle,&m);
}
diff -r ad3de8730172 -r fe50ada8020b src/pdo.c
--- a/src/pdo.c Thu Apr 05 10:06:11 2007 +0200
+++ b/src/pdo.c Fri Apr 06 16:49:28 2007 +0200
@@ -21,6 +21,7 @@
*/
#include "pdo.h"
#include "objacces.h"
+#include "canfestival.h"
/****************************************************************************/
UNS8 sendPDO(CO_Data* d, s_PDO pdo, UNS8 req)
@@ -51,7 +52,7 @@
MSG_WAR(0x3903," data : ", m.data[i]);
}
- return (*d->canSend)(&m);
+ return canSend(d->canHandle,&m);
} /* end if */
return 0xFF;
}
diff -r ad3de8730172 -r fe50ada8020b src/sdo.c
--- a/src/sdo.c Thu Apr 05 10:06:11 2007 +0200
+++ b/src/sdo.c Fri Apr 06 16:49:28 2007 +0200
@@ -25,6 +25,7 @@
#include "objacces.h"
#include "sdo.h"
+#include "canfestival.h"
/* Uncomment if your compiler does not support inline functions */
#define NO_INLINE
@@ -410,7 +411,7 @@
for (i = 0 ; i < 8 ; i++) {
m.data[i] = sdo.body.data[i];
}
- return (*d->canSend)(&m);
+ return canSend(d->canHandle,&m);
}
/***************************************************************************/
@@ -1330,3 +1331,4 @@
return d->transfers[line].state;
}
+void _SDOtimeoutError (UNS8 line){}
diff -r ad3de8730172 -r fe50ada8020b src/states.c
--- a/src/states.c Thu Apr 05 10:06:11 2007 +0200
+++ b/src/states.c Fri Apr 06 16:49:28 2007 +0200
@@ -207,3 +207,8 @@
/* bDeviceNodeId is defined in the object dictionary. */
*d->bDeviceNodeId = nodeId;
}
+
+void _initialisation(){}
+void _preOperational(){}
+void _operational(){}
+void _stopped(){}
diff -r ad3de8730172 -r fe50ada8020b src/sync.c
--- a/src/sync.c Thu Apr 05 10:06:11 2007 +0200
+++ b/src/sync.c Fri Apr 06 16:49:28 2007 +0200
@@ -23,6 +23,7 @@
#include "data.h"
#include "sync.h"
+#include "canfestival.h"
/* Prototypes for internals functions */
void SyncAlarm(CO_Data* d, UNS32 id);
@@ -83,7 +84,7 @@
m.cob_id.w = cob_id ;
m.rtr = NOT_A_REQUEST;
m.len = 0;
- resultat = (*d->canSend)(&m) ;
+ resultat = canSend(d->canHandle,&m) ;
proceedSYNC(d, &m) ;
return resultat ;
}
@@ -237,3 +238,5 @@
}
+void _post_sync(){}
+void _post_TPDO(){}
diff -r ad3de8730172 -r fe50ada8020b src/timer.c
--- a/src/timer.c Thu Apr 05 10:06:11 2007 +0200
+++ b/src/timer.c Fri Apr 06 16:49:28 2007 +0200
@@ -159,7 +159,8 @@
if (row->state & TIMER_TRIG)
{
row->state &= ~TIMER_TRIG; /* reset trig state (will be free if not periodic) */
- (*row->callback)(row->d, row->id); /* trig ! */
+ if(row->callback)
+ (*row->callback)(row->d, row->id); /* trig ! */
}
}
}