--- a/include/can.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/can.h Thu Jan 25 17:36:58 2007 +0100
@@ -31,20 +31,20 @@
*/
typedef struct {
- UNS32 w; // 32 bits
+ UNS32 w; /* 32 bits */
} SHORT_CAN;
/** Can message structure */
typedef struct {
- SHORT_CAN cob_id; // l'ID du mesg
- UNS8 rtr; // remote transmission request. 0 if not rtr,
- // 1 for a rtr message
- UNS8 len; // message length (0 to 8)
- UNS8 data[8]; // data
+ SHORT_CAN cob_id; /* l'ID du mesg */
+ UNS8 rtr; /* remote transmission request. 0 if not rtr,
+ 1 for a rtr message */
+ UNS8 len; /* message length (0 to 8) */
+ UNS8 data[8]; /* data */
} Message;
typedef UNS8 (*canSend_t)(Message *);
-#endif // __can_h__
+#endif /* __can_h__ */
--- a/include/data.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/data.h Thu Jan 25 17:36:58 2007 +0100
@@ -24,8 +24,9 @@
#ifndef __data_h__
#define __data_h__
-// declaration of CO_Data type let us include all necessary headers
-// struct struct_CO_Data can then be defined later
+/* declaration of CO_Data type let us include all necessary headers
+ struct struct_CO_Data can then be defined later
+ */
typedef struct struct_CO_Data CO_Data;
#include <applicfg.h>
@@ -40,9 +41,9 @@
#include "sync.h"
#include "nmtMaster.h"
-// This structurs contains all necessary information for a CanOpen node
+/* This structurs contains all necessary information for a CanOpen node */
struct struct_CO_Data {
- // Object dictionary
+ /* Object dictionary */
UNS8 *bDeviceNodeId;
const indextable *objdict;
UNS8 *count_sync;
@@ -52,12 +53,12 @@
const UNS8 *iam_a_slave;
valueRangeTest_t valueRangeTest;
- // SDO
+ /* SDO */
s_transfer transfers[SDO_MAX_SIMULTANEOUS_TRANSFERTS];
SDOtimeoutError_t SDOtimeoutError;
- //s_sdo_parameter *sdo_parameters;
+ /* s_sdo_parameter *sdo_parameters; */
- // State machine
+ /* State machine */
e_nodeState nodeState;
s_state_communication CurrentCommunicationState;
initialisation_t initialisation;
@@ -65,7 +66,7 @@
operational_t operational;
stopped_t stopped;
- // NMT-heartbeat
+ /* NMT-heartbeat */
UNS8 *ConsumerHeartbeatCount;
UNS32 *ConsumerHeartbeatEntries;
TIMER_HANDLE *ConsumerHeartBeatTimers;
@@ -74,24 +75,24 @@
heartbeatError_t heartbeatError;
e_nodeState NMTable[NMT_MAX_NODE_ID];
- // SYNC
+ /* SYNC */
TIMER_HANDLE syncTimer;
UNS32 *COB_ID_Sync;
UNS32 *Sync_Cycle_Period;
- /*UNS32 *Sync_window_length*/;
+ /*UNS32 *Sync_window_length;;*/
post_sync_t post_sync;
post_TPDO_t post_TPDO;
- // PDO
+ /* PDO */
s_process_var process_var;
- // General
+ /* General */
UNS8 toggle;
canSend_t canSend;
scanIndexOD_t scanIndexOD;
};
-// A macro to initialize the data in client app.
+/* A macro to initialize the data in client app.*/
#define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX) {\
/* Object dictionary*/\
bDeviceNodeId:& NODE_PREFIX ## _bDeviceNodeId,\
@@ -160,6 +161,6 @@
scanIndexOD: NODE_PREFIX ## _scanIndexOD\
}
-#endif // __data_h__
+#endif /* __data_h__ */
--- a/include/def.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/def.h Thu Jan 25 17:36:58 2007 +0100
@@ -54,33 +54,33 @@
#define REQUEST 1
#define NOT_A_REQUEST 0
-/// Misc constants
-// --------------
+/* Misc constants */
+/* -------------- */
/* Should not be modified */
#define Rx 0
#define Tx 1
#define TRUE 1
#define FALSE 0
-//TODO: remove this limitation. do bit granularity mapping
+/* TODO: remove this limitation. do bit granularity mapping */
#define PDO_MAX_LEN 8
/** Status of the SDO transmission
*/
-#define SDO_RESET 0x0 // Transmission not started. Init state.
-#define SDO_FINISHED 0x1 // data are available
-#define SDO_ABORTED_RCV 0x80 // Received an abort message. Data not available
-#define SDO_ABORTED_INTERNAL 0x85 // Aborted but not because of an abort message.
+#define SDO_RESET 0x0 /* Transmission not started. Init state. */
+#define SDO_FINISHED 0x1 /* data are available */
+#define SDO_ABORTED_RCV 0x80 /* Received an abort message. Data not available */
+#define SDO_ABORTED_INTERNAL 0x85 /* Aborted but not because of an abort message. */
#define SDO_DOWNLOAD_IN_PROGRESS 0x2
#define SDO_UPLOAD_IN_PROGRESS 0x3
-// Status of the node during the SDO transfert :
+/* Status of the node during the SDO transfert : */
#define SDO_SERVER 0x1
#define SDO_CLIENT 0x2
#define SDO_UNKNOWN 0x3
/* Function Codes
- ---------------
+ ---------------
defined in the canopen DS301
*/
#define NMT 0x0
@@ -98,8 +98,8 @@
#define SDOrx 0xC
#define NODE_GUARD 0xE
-/// NMT Command Specifier, sent by master to change a slave state
-// -------------------------------------------------------------
+/* NMT Command Specifier, sent by master to change a slave state */
+/* ------------------------------------------------------------- */
/* Should not be modified */
#define NMT_Start_Node 0x01
#define NMT_Stop_Node 0x02
@@ -107,8 +107,8 @@
#define NMT_Reset_Node 0x81
#define NMT_Reset_Comunication 0x82
-/// constantes used in the different state machines
-// -----------------------------------------------
+/* constantes used in the different state machines */
+/* ----------------------------------------------- */
/* Must not be modified */
#define state1 0x01
#define state2 0x02
@@ -122,5 +122,5 @@
#define state10 0x0A
#define state11 0x0B
-#endif // __def_h__
+#endif /* __def_h__ */
--- a/include/lifegrd.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/lifegrd.h Thu Jan 25 17:36:58 2007 +0100
@@ -30,9 +30,9 @@
#include "data.h"
-//*************************************************************************/
-//Functions
-//*************************************************************************/
+/*************************************************************************
+ * Functions
+/*************************************************************************/
/** To read the state of a node
@@ -59,4 +59,4 @@
*/
void proceedNODE_GUARD (CO_Data* d, Message* m);
-#endif //__lifegrd_h__
+#endif /*__lifegrd_h__ */
--- a/include/nmtMaster.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/nmtMaster.h Thu Jan 25 17:36:58 2007 +0100
@@ -61,4 +61,4 @@
void masterRequestNodeState (CO_Data* d, UNS8 nodeId);
-#endif // __nmtMaster_h__
+#endif /* __nmtMaster_h__ */
--- a/include/nmtSlave.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/nmtSlave.h Thu Jan 25 17:36:58 2007 +0100
@@ -42,4 +42,4 @@
UNS8 slaveSendBootUp (CO_Data* d);
-#endif // __nmtSlave_h__
+#endif /* __nmtSlave_h__ */
--- a/include/objacces.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/objacces.h Thu Jan 25 17:36:58 2007 +0100
@@ -42,13 +42,13 @@
-/**
+/*
Print MSG_WAR (s) if error to the access to the object dictionary occurs.
-You must uncomment the lines*/
+You must uncomment the lines
//#define DEBUG_CAN
//#define DEBUG_WAR_CONSOLE_ON
//#define DEBUG_ERR_CONSOLE_ON
-/*in the file objaccess.c
+in the file objaccess.c
sizeDataDict : Size of the data defined in the dictionary
sizeDataGiven : Size data given by the user.
code : error code to print. (SDO abort code. See file def.h)
@@ -60,10 +60,10 @@
UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex,
UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code);
#else
-#define accessDictionaryError(...)
+/*#define accessDictionaryError(...) */
#endif
-/** Reads an entry from the object dictionary.\n
+/* Reads an entry from the object dictionary.\n
* \code
* // Example usage:
* UNS8 *pbData;
@@ -101,7 +101,7 @@
UNS8 checkAccess);
-/** By this function you can write an entry into the object dictionary\n
+/* By this function you can write an entry into the object dictionary\n
* \code
* // Example usage:
* UNS8 B;
@@ -129,7 +129,7 @@
UNS8 checkAccess);
-/** Scan the index of object dictionary. Used only by setODentry and getODentry.
+/* Scan the index of object dictionary. Used only by setODentry and getODentry.
* *errorCode : OD_SUCCESSFUL if index foundor SDO abort code. (See file def.h)
* Return NULL if index not found. Else : return the table part of the object dictionary.
*/
@@ -137,4 +137,4 @@
UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback);
-#endif // __objacces_h__
+#endif /* __objacces_h__ */
--- a/include/objdictdef.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/objdictdef.h Thu Jan 25 17:36:58 2007 +0100
@@ -62,8 +62,9 @@
#define sdo_parameter 0x22
#define identity 0x23
-// CanFestival is using 0x24 to 0xFF to define some types containing a
-// value range (See how it works in objdict.c)
+/* CanFestival is using 0x24 to 0xFF to define some types containing a
+ value range (See how it works in objdict.c)
+ */
@@ -94,19 +95,20 @@
typedef struct td_subindex
{
UNS8 bAccessType;
- UNS8 bDataType; // Defines of what datatype the entry is
- UNS8 size; // The size (in Byte) of the variable
- void* pObject; // This is the pointer of the Variable
+ UNS8 bDataType; /* Defines of what datatype the entry is */
+ UNS8 size; /* The size (in Byte) of the variable */
+ void* pObject; /* This is the pointer of the Variable */
} subindex;
/** Struct for creating entries in the communictaion profile
*/
typedef struct td_indextable
{
- subindex* pSubindex; // Pointer to the subindex
- UNS8 bSubCount; // the count of valid entries for this subindex
- // This count here defines how many memory has been
- // allocated. this memory does not have to be used.
+ subindex* pSubindex; /* Pointer to the subindex */
+ UNS8 bSubCount; /* the count of valid entries for this subindex
+ * This count here defines how many memory has been
+ * allocated. this memory does not have to be used.
+ */
UNS16 index;
} indextable;
@@ -120,14 +122,14 @@
}quick_index;
-//typedef struct struct_CO_Data CO_Data;
+/*typedef struct struct_CO_Data CO_Data; */
typedef UNS32 (*ODCallback_t)(CO_Data* d, const indextable *, UNS8 bSubindex);
typedef const indextable * (*scanIndexOD_t)(UNS16 wIndex, UNS32 * errorCode, ODCallback_t **Callback);
/************************** MACROS *********************************/
-///CANopen usefull helpers
+/* CANopen usefull helpers */
#define GET_NODE_ID(m) (m.cob_id.w & 0x7f)
#define GET_FUNCTION_CODE(m) (m.cob_id.w >> 7)
-#endif // __objdictdef_h__
+#endif /* __objdictdef_h__ */
--- a/include/pdo.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/pdo.h Thu Jan 25 17:36:58 2007 +0100
@@ -30,9 +30,10 @@
Used to store the PDO before the transmission or the reception.
*/
typedef struct struct_s_process_var {
- UNS8 count; // Size of data. Ex : for a PDO of 6 bytes of data, count = 6
- // WARNING s_process_var.data is subject to ENDIANISATION
- // (with respect to CANOPEN_BIG_ENDIAN)
+ UNS8 count; /* Size of data. Ex : for a PDO of 6 bytes of data, count = 6 */
+ /* WARNING s_process_var.data is subject to ENDIANISATION
+ * (with respect to CANOPEN_BIG_ENDIAN)
+ */
UNS8 data[PDO_MAX_LEN];
}s_process_var;
@@ -40,9 +41,9 @@
/** The PDO structure */
typedef struct struct_s_PDO {
- UNS32 cobId; // COB-ID
- UNS8 len; // Number of data transmitted (in data[])
- UNS8 data[8]; // Contain the data
+ UNS32 cobId; /* COB-ID */
+ UNS8 len; /* Number of data transmitted (in data[]) */
+ UNS8 data[8]; /* Contain the data */
}s_PDO;
/** Transmit a PDO data frame on the bus bus_id
--- a/include/sdo.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/sdo.h Thu Jan 25 17:36:58 2007 +0100
@@ -37,46 +37,49 @@
*/
struct struct_s_transfer {
- UNS8 nodeId; //own ID if server, or node ID of the server if client
+ UNS8 nodeId; /*own ID if server, or node ID of the server if client */
- UNS8 whoami; // Takes the values SDO_CLIENT or SDO_SERVER
- UNS8 state; // state of the transmission : Takes the values SDO_...
+ UNS8 whoami; /* Takes the values SDO_CLIENT or SDO_SERVER */
+ UNS8 state; /* state of the transmission : Takes the values SDO_... */
UNS8 toggle;
- UNS32 abortCode; // Sent or received
- // index and subindex of the dictionary where to store
- // (for a received SDO) or to read (for a transmit SDO)
+ UNS32 abortCode; /* Sent or received */
+ /* index and subindex of the dictionary where to store */
+ /* (for a received SDO) or to read (for a transmit SDO) */
UNS16 index;
UNS8 subIndex;
- UNS32 count; // Number of data received or to be sent.
- UNS32 offset; // stack pointer of data[]
- // Used only to tranfer part of a line to or from a SDO.
- // offset is always pointing on the next free cell of data[].
- // WARNING s_transfer.data is subject to ENDIANISATION
- // (with respect to CANOPEN_BIG_ENDIAN)
+ UNS32 count; /* Number of data received or to be sent. */
+ UNS32 offset; /* stack pointer of data[]
+ * Used only to tranfer part of a line to or from a SDO.
+ * offset is always pointing on the next free cell of data[].
+ * WARNING s_transfer.data is subject to ENDIANISATION
+ * (with respect to CANOPEN_BIG_ENDIAN)
+ */
UNS8 data [SDO_MAX_LENGTH_TRANSFERT];
- UNS8 dataType; // Defined in objdictdef.h Value is visible_string
- // if it is a string, any other value if it is not a string,
- // like 0. In fact, it is used only if client.
- TIMER_HANDLE timer; // Time counter to implement a timeout in milliseconds.
- // It is automatically incremented whenever
- // the line state is in SDO_DOWNLOAD_IN_PROGRESS or
- // SDO_UPLOAD_IN_PROGRESS, and reseted to 0
- // when the response SDO have been received.
- SDOCallback_t Callback; // The user callback func to be called at SDO transaction end
+ UNS8 dataType; /* Defined in objdictdef.h Value is visible_string
+ * if it is a string, any other value if it is not a string,
+ * like 0. In fact, it is used only if client.
+ */
+ TIMER_HANDLE timer; /* Time counter to implement a timeout in milliseconds.
+ /* It is automatically incremented whenever
+ /* the line state is in SDO_DOWNLOAD_IN_PROGRESS or
+ /* SDO_UPLOAD_IN_PROGRESS, and reseted to 0
+ /* when the response SDO have been received.
+ */
+ SDOCallback_t Callback; /* The user callback func to be called at SDO transaction end */
};
typedef struct struct_s_transfer s_transfer;
#include "data.h"
-/// The 8 bytes data of the SDO
+/* The 8 bytes data of the SDO */
struct BODY{
UNS8 data[8];
};
-/// The SDO structure ...
+/* The SDO structure ...*/
struct struct_s_SDO {
- UNS8 nodeId; //in any case, Node ID of the server (case sender or receiver).
+ UNS8 nodeId; /*in any case, Node ID of the server (case sender or receiver).*/
struct BODY body;
};
--- a/include/states.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/states.h Thu Jan 25 17:36:58 2007 +0100
@@ -25,11 +25,12 @@
#include <applicfg.h>
-///The nodes states
-//-----------------
-/// values are choosen so, that they can be sent directly
-/// for heartbeat messages...
-/// Must be coded on 7 bits only
+/* The nodes states
+ * -----------------
+ * values are choosen so, that they can be sent directly
+ * for heartbeat messages...
+ * Must be coded on 7 bits only
+ * */
/* Should not be modified */
enum enum_nodeState {
Initialisation = 0x00,
@@ -89,7 +90,7 @@
/** Some stuff to do when the node enter in reset mode
*
*/
-//void initResetMode (CO_Data* d);
+/* void initResetMode (CO_Data* d); */
/** Some stuff to do when the node enter in pre-operational mode
--- a/include/timer.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/timer.h Thu Jan 25 17:36:58 2007 +0100
@@ -29,7 +29,7 @@
#include "data.h"
-// --------- types et constants definitions ---------
+/* --------- types and constants definitions --------- */
#define TIMER_FREE 0
#define TIMER_ARMED 1
#define TIMER_TRIG 2
@@ -42,22 +42,22 @@
struct struct_s_timer_entry {
UNS8 state;
CO_Data* d;
- TimerCallback_t callback; // The callback func.
- UNS32 id; // The callback func.
+ TimerCallback_t callback; /* The callback func. */
+ UNS32 id; /* The callback func. */
TIMEVAL val;
- TIMEVAL interval; // Periodicity
+ TIMEVAL interval; /* Periodicity */
};
typedef struct struct_s_timer_entry s_timer_entry;
-// --------- prototypes ---------
-//#define SetAlarm(d, id, callback, value, period) printf("%s, %d, SetAlarm(%s, %s, %s, %s, %s)\n",__FILE__, __LINE__, #d, #id, #callback, #value, #period); _SetAlarm(d, id, callback, value, period)
+/* --------- prototypes --------- */
+/*#define SetAlarm(d, id, callback, value, period) printf("%s, %d, SetAlarm(%s, %s, %s, %s, %s)\n",__FILE__, __LINE__, #d, #id, #callback, #value, #period); _SetAlarm(d, id, callback, value, period)*/
TIMER_HANDLE SetAlarm(CO_Data* d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period);
TIMER_HANDLE DelAlarm(TIMER_HANDLE handle);
void TimeDispatch(void);
-// --------- to be defined in user app ---------
+/* --------- to be defined in user app ---------*/
void setTimer(TIMEVAL value);
TIMEVAL getElapsedTime(void);
-#endif // #define __timer_h__
+#endif /* #define __timer_h__ */
--- a/include/timers_unix/timerscfg.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/timers_unix/timerscfg.h Thu Jan 25 17:36:58 2007 +0100
@@ -25,8 +25,8 @@
#include <pthread.h>
-// Time unit : us
-// Time resolution : 64bit (~584942 years)
+/* Time unit : us */
+/* Time resolution : 64bit (~584942 years) */
#define TIMEVAL unsigned long long
#define TIMEVAL_MAX ~(TIMEVAL)0
#define MS_TO_TIMEVAL(ms) ms*1000
--- a/include/unix/applicfg.h Thu Jan 25 16:49:51 2007 +0100
+++ b/include/unix/applicfg.h Thu Jan 25 17:36:58 2007 +0100
@@ -29,25 +29,26 @@
#include "cancfg.h"
#include "timerscfg.h"
-// 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;
+/* Define the architecture : little_endian or big_endian
+ -----------------------------------------------------
+ Test :
+ UNS32 v = 0x1234ABCD;
+ char *data = &v;
-// Integers
+ 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
@@ -57,7 +58,7 @@
#define INTEGER56
#define INTEGER64
-// Unsigned integers
+/* Unsigned integers */
#define UNS8 unsigned char
#define UNS16 unsigned short
#define UNS32 unsigned long
@@ -67,18 +68,18 @@
#define UNS56
#define UNS64
-// Reals
+/* Reals */
#define REAL32 float
#define REAL64 double
-/// Definition of error and warning macros
-// --------------------------------------
+/* Definition of error and warning macros */
+/* -------------------------------------- */
#if defined DEBUG_ERR_CONSOLE_ON || defined DEBUG_WAR_CONSOLE_ON
#include <stdio.h>
#endif
-/// Definition of MSG_ERR
-// ---------------------
+/* 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);*/
@@ -86,8 +87,8 @@
# define MSG_ERR(num, str, val)
#endif
-/// Definition of MSG_WAR
-// ---------------------
+/* 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);*/
--- a/src/led.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/led.c Thu Jan 25 17:36:58 2007 +0100
@@ -45,7 +45,7 @@
void led_set_redgreen(CO_Data *d, unsigned char state);
-// 0 = always off, 1 = always on, 2 = flashing
+/* 0 = always off, 1 = always on, 2 = flashing */
static UNS8 led_state_red, led_state_green;
static UNS16 led_sequence_red, led_seq_index_red;
@@ -53,20 +53,20 @@
static UNS8 led_error_code = LED_NO_ERROR;
-const char *led_sequence_table[6] = // up and downs of the sequence
-{
- "01", // flickering
- "01", // blinking
- "100000", // single flash
- "10100000", // double flash
- "1010100000", // triple flash
- "101010100000" // quadruple flash
+const char *led_sequence_table[6] = /* up and downs of the sequence */
+{
+ "01", /* flickering */
+ "01", /* blinking */
+ "100000", /* single flash */
+ "10100000", /* double flash */
+ "1010100000", /* triple flash */
+ "101010100000" /* quadruple flash */
};
void led_set_state(CO_Data *d, int state)
{
-//printf("led_set_state(%x)\n", state);
+/*printf("led_set_state(%x)\n", state); */
switch(state)
{
@@ -103,8 +103,8 @@
{
led_stop_timer();
- //led_set_green(led_state_green);
- //led_set_red(led_state_red);
+ /*led_set_green(led_state_green); */
+ /*led_set_red(led_state_red); */
}
else
@@ -171,15 +171,15 @@
}
led_start_timer(d, 200);
- //led_set_red(led_state_red);
+ /*led_set_red(led_state_red); */
}
if (led_state_green < 2 && led_state_red < 2)
{
led_stop_timer();
- //led_set_green(led_state_green);
- //led_set_red(led_state_red);
+ /*led_set_green(led_state_green); */
+ /*led_set_red(led_state_red); */
}
}
@@ -202,7 +202,7 @@
{
UNS8 bits = 0;
- // RED LED
+ /* RED LED */
if (led_sequence_table[led_sequence_red][led_seq_index_red] == '1')
{
if (led_state_red > 0)
@@ -219,7 +219,7 @@
if (led_seq_index_red > strlen(led_sequence_table[led_sequence_red]))
led_seq_index_red = 0;
- // GREEN LED
+ /* GREEN LED */
if (led_sequence_table[led_sequence_green][led_seq_index_green] == '1')
{
if (led_state_green > 0)
@@ -236,7 +236,7 @@
if (led_seq_index_green > strlen(led_sequence_table[led_sequence_green]))
led_seq_index_green = 0;
- //led_set_redgreen(d, bits);
+ /*led_set_redgreen(d, bits); */
}
--- a/src/lifegrd.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/lifegrd.c Thu Jan 25 17:36:58 2007 +0100
@@ -23,7 +23,7 @@
#include <data.h>
#include "lifegrd.h"
-// Prototypes for internals functions
+/* Prototypes for internals functions */
void ConsumerHearbeatAlarm(CO_Data* d, UNS32 id);
void ProducerHearbeatAlarm(CO_Data* d, UNS32 id);
@@ -36,12 +36,12 @@
}
/*****************************************************************************/
-// The Consumer Timer Callback
+/* The Consumer Timer Callback */
void ConsumerHearbeatAlarm(CO_Data* d, UNS32 id)
{
- //MSG_WAR(0x00, "ConsumerHearbeatAlarm", 0x00);
+ /*MSG_WAR(0x00, "ConsumerHearbeatAlarm", 0x00);*/
- // call heartbeat error with NodeId
+ /* call heartbeat error with NodeId */
(*d->heartbeatError)((UNS8)( ((d->ConsumerHeartbeatEntries[id]) & (UNS32)0x00FF0000) >> (UNS8)16 ));
}
@@ -51,8 +51,8 @@
UNS8 nodeId = (UNS8) GET_NODE_ID((*m));
if((m->rtr == 1) ) /* Notice that only the master can have sent this node guarding request */
- { // Receiving a NMT NodeGuarding (request of the state by the master)
- // only answer to the NMT NodeGuarding request, the master is not checked (not implemented)
+ { /* Receiving a NMT NodeGuarding (request of the state by the master) */
+ /* only answer to the NMT NodeGuarding request, the master is not checked (not implemented) */
if (nodeId == *d->bDeviceNodeId )
{
Message msg;
@@ -67,26 +67,26 @@
}
else
d->toggle = 1 ;
- // send the nodeguard response.
+ /* send the nodeguard response. */
MSG_WAR(0x3130, "Sending NMT Nodeguard to master, state: ", d->nodeState);
(*d->canSend)(&msg );
}
- }else{ // Not a request CAN
+ }else{ /* Not a request CAN */
MSG_WAR(0x3110, "Received NMT nodeId : ", nodeId);
/* the slave's state receievd is stored in the NMTable */
- // The state is stored on 7 bit
+ /* The state is stored on 7 bit */
d->NMTable[nodeId] = (e_nodeState) ((*m).data[0] & 0x7F) ;
/* Boot-Up frame reception */
if ( d->NMTable[nodeId] == Initialisation)
{
- // The device send the boot-up message (Initialisation)
- // to indicate the master that it is entered in pre_operational mode
- // Because the device enter automaticaly in pre_operational mode,
- // the pre_operational mode is stored
-// NMTable[bus_id][nodeId] = Pre_operational;
+ /* The device send the boot-up message (Initialisation) */
+ /* to indicate the master that it is entered in pre_operational mode */
+ /* Because the device enter automaticaly in pre_operational mode, */
+ /* the pre_operational mode is stored */
+/* NMTable[bus_id][nodeId] = Pre_operational; */
MSG_WAR(0x3100, "The NMT is a bootup from node : ", nodeId);
}
@@ -98,7 +98,7 @@
if ( nodeId == ConsummerHeartBeat_nodeId )
{
TIMEVAL time = ( (d->ConsumerHeartbeatEntries[index]) & (UNS32)0x0000FFFF ) ;
- // Renew alarm for next heartbeat.
+ /* Renew alarm for next heartbeat. */
DelAlarm(d->ConsumerHeartBeatTimers[index]);
d->ConsumerHeartBeatTimers[index] = SetAlarm(d, index, &ConsumerHearbeatAlarm, MS_TO_TIMEVAL(time), 0);
}
@@ -108,21 +108,22 @@
}
/*****************************************************************************/
-// The Consumer Timer Callback
+/* The Consumer Timer Callback */
void ProducerHearbeatAlarm(CO_Data* d, UNS32 id)
{
if(*d->ProducerHeartBeatTime)
{
Message msg;
- // Time expired, the heartbeat must be sent immediately
- // generate the correct node-id: this is done by the offset 1792
- // (decimal) and additionaly
- // the node-id of this device.
+ /* Time expired, the heartbeat must be sent immediately
+ * generate the correct node-id: this is done by the offset 1792
+ * (decimal) and additionaly
+ * the node-id of this device.
+ */
msg.cob_id.w = *d->bDeviceNodeId + 0x700;
msg.len = (UNS8)0x01;
msg.rtr = 0;
- msg.data[0] = d->nodeState; // No toggle for heartbeat !
- // send the heartbeat
+ msg.data[0] = d->nodeState; /* No toggle for heartbeat !*/
+ /* send the heartbeat */
MSG_WAR(0x3130, "Producing heartbeat: ", d->nodeState);
(*d->canSend)(&msg );
}else{
@@ -133,14 +134,14 @@
/*****************************************************************************/
void heartbeatInit(CO_Data* d)
{
- UNS8 index; // Index to scan the table of heartbeat consumers
+ UNS8 index; /* Index to scan the table of heartbeat consumers */
d->toggle = 0;
for( index = (UNS8)0x00; index < *d->ConsumerHeartbeatCount; index++ )
{
TIMEVAL time = (UNS16) ( (d->ConsumerHeartbeatEntries[index]) & (UNS32)0x0000FFFF ) ;
- //MSG_WAR(0x3121, "should_time : ", should_time ) ;
+ /* MSG_WAR(0x3121, "should_time : ", should_time ) ; */
if ( time )
{
d->ConsumerHeartBeatTimers[index] = SetAlarm(d, index, &ConsumerHearbeatAlarm, MS_TO_TIMEVAL(time), 0);
--- a/src/nmtMaster.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/nmtMaster.c Thu Jan 25 17:36:58 2007 +0100
@@ -58,13 +58,13 @@
/******************************************************************************/
void masterRequestNodeState(CO_Data* d, UNS8 nodeId)
{
- // FIXME: should warn for bad toggle bit.
+ /* FIXME: should warn for bad toggle bit. */
/* NMTable configuration to indicate that the master is waiting
* for a Node_Guard frame from the slave whose node_id is ID */
- d->NMTable[nodeId] = Unknown_state; // A state that does not exist
+ d->NMTable[nodeId] = Unknown_state; /* A state that does not exist */
- if (nodeId == 0) { // NMT broadcast
+ if (nodeId == 0) { /* NMT broadcast */
UNS8 i = 0;
for (i = 0 ; i < NMT_MAX_NODE_ID ; i++) {
d->NMTable[i] = Unknown_state;
--- a/src/nmtSlave.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/nmtSlave.c Thu Jan 25 17:36:58 2007 +0100
@@ -33,12 +33,12 @@
MSG_WAR(0x3400, "NMT received. for node : ", (*m).data[1]);
- // Check if this NMT-message is for this node
- // byte 1 = 0 : all the nodes are concerned (broadcast)
+ /* Check if this NMT-message is for this node */
+ /* byte 1 = 0 : all the nodes are concerned (broadcast) */
if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == *d->bDeviceNodeId ) ){
- switch( (*m).data[0]){ // command specifier (cs)
+ switch( (*m).data[0]){ /* command specifier (cs) */
case NMT_Start_Node:
if ( (d->nodeState == Pre_operational) || (d->nodeState == Stopped) )
setState(d,Operational);
@@ -64,9 +64,9 @@
setState(d,Initialisation);
break;
- }// end switch
+ }/* end switch */
- }// end if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == bDeviceNodeId ) )
+ }/* end if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == bDeviceNodeId ) ) */
}
}
--- a/src/objacces.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/objacces.c Thu Jan 25 17:36:58 2007 +0100
@@ -20,8 +20,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-//#define DEBUG_WAR_CONSOLE_ON
-//#define DEBUG_ERR_CONSOLE_ON
+/* #define DEBUG_WAR_CONSOLE_ON */
+/* #define DEBUG_ERR_CONSOLE_ON */
#include "objacces.h"
@@ -70,7 +70,7 @@
UNS8 * pExpectedSize,
UNS8 * pDataType,
UNS8 checkAccess)
-{ // DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails.
+{ /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */
UNS32 errorCode;
UNS8 szData;
const indextable *ptrTable;
@@ -81,7 +81,7 @@
if (errorCode != OD_SUCCESSFUL)
return errorCode;
if( ptrTable->bSubCount <= bSubindex ) {
- // Subindex not found
+ /* Subindex not found */
accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX);
return OD_NO_SUCH_SUBINDEX;
}
@@ -97,11 +97,11 @@
if( *pExpectedSize == 0 ||
*pExpectedSize == szData ||
- (*pDataType == visible_string && *pExpectedSize < szData)) {// We allow to fetch a shorter string than expected
+ (*pDataType == visible_string && *pExpectedSize < szData)) {/* We allow to fetch a shorter string than expected */
# ifdef CANOPEN_BIG_ENDIAN
if(*pDataType > boolean && *pDataType < visible_string) {
- // data must be transmited with low byte first
+ /* data must be transmited with low byte first */
UNS8 i, j = 0;
MSG_WAR(boolean, "data type ", *pDataType);
MSG_WAR(visible_string, "data type ", *pDataType);
@@ -111,7 +111,7 @@
((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
}
}
- else // It it is a visible string no endianisation to perform
+ else /* It it is a visible string no endianisation to perform */
memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
# else
memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
@@ -119,7 +119,7 @@
*pExpectedSize = szData;
#if 0
- // Me laisser ça, please ! (FD)
+ /* Me laisser ça, please ! (FD) */
{
UNS8 i;
for (i = 0 ; i < 10 ; i++) {
@@ -131,7 +131,7 @@
#endif
return OD_SUCCESSFUL;
}
- else { // Error !
+ else { /* Error ! */
*pExpectedSize = szData;
accessDictionaryError(wIndex, bSubindex, szData,
*pExpectedSize, OD_LENGTH_DATA_INVALID);
@@ -157,7 +157,7 @@
return errorCode;
if( ptrTable->bSubCount <= bSubindex ) {
- // Subindex not found
+ /* Subindex not found */
accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX);
return OD_NO_SUCH_SUBINDEX;
}
@@ -173,13 +173,13 @@
if( *pExpectedSize == 0 ||
*pExpectedSize == szData ||
- (dataType == visible_string && *pExpectedSize < szData)) // We allow to store a shorter string than entry size
+ (dataType == visible_string && *pExpectedSize < szData)) /* We allow to store a shorter string than entry size */
{
#ifdef CANOPEN_BIG_ENDIAN
if(dataType > boolean && dataType < visible_string)
{
- // we invert the data source directly. This let us do range testing without
- // additional temp variable
+ /* we invert the data source directly. This let us do range testing without */
+ /* additional temp variable */
UNS8 i;
for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1) ; i++)
{
@@ -197,13 +197,13 @@
memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize);
*pExpectedSize = szData;
- // Callbacks
+ /* Callbacks */
if(Callback && Callback[bSubindex]){
(*Callback[bSubindex])(d, ptrTable, bSubindex);
}
- // TODO : Store dans NVRAM
- // if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVED)
+ /* TODO : Store dans NVRAM */
+ /* if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVED) */
return OD_SUCCESSFUL;
}else{
*pExpectedSize = szData;
--- a/src/pdo.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/pdo.c Thu Jan 25 17:36:58 2007 +0100
@@ -30,13 +30,13 @@
Message m;
/* Message copy for sending */
- m.cob_id.w = pdo.cobId & 0x7FF; // Because the cobId is 11 bytes length
+ m.cob_id.w = pdo.cobId & 0x7FF; /* Because the cobId is 11 bytes length */
if ( req == NOT_A_REQUEST ) {
UNS8 i;
m.rtr = NOT_A_REQUEST;
m.len = pdo.len;
- //memcpy(&m.data, &pdo.data, m.len);
- // This Memcpy depends on packing structure. Avoid
+ /* memcpy(&m.data, &pdo.data, m.len); */
+ /* This Memcpy depends on packing structure. Avoid */
for (i = 0 ; i < pdo.len ; i++)
m.data[i] = pdo.data[i];
}
@@ -52,12 +52,12 @@
}
return (*d->canSend)(&m);
- } // end if
+ } /* end if */
return 0xFF;
}
/***************************************************************************/
-UNS8 PDOmGR(CO_Data* d, UNS32 cobId) //PDO Manager
+UNS8 PDOmGR(CO_Data* d, UNS32 cobId) /* PDO Manager */
{
UNS8 res;
UNS8 i;
@@ -69,8 +69,8 @@
preparation of the message to send */
pdo.cobId = cobId;
pdo.len = d->process_var.count;
- //memcpy(&(pdo.data), &(process_var.data), pdo.len);
- // Ce memcpy devrait être portable
+ /* memcpy(&(pdo.data), &(process_var.data), pdo.len); */
+ /* Ce memcpy devrait être portable */
for ( i = 0 ; i < pdo.len ; i++)
pdo.data[i] = d->process_var.data[i];
@@ -81,14 +81,14 @@
/**************************************************************************/
UNS8 buildPDO(CO_Data* d, UNS16 index)
-{ // DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails.
+{ /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */
UNS16 ind;
UNS8 subInd;
- UNS8 * pMappingCount = NULL; // count of mapped objects...
- // pointer to the var which is mapped to a pdo
-// void * pMappedAppObject = NULL;
- // pointer fo the var which holds the mapping parameter of an mapping entry
+ UNS8 * pMappingCount = NULL; /* count of mapped objects... */
+ /* pointer to the var which is mapped to a pdo */
+/* void * pMappedAppObject = NULL; */
+ /* pointer fo the var which holds the mapping parameter of an mapping entry */
UNS32 * pMappingParameter = NULL;
UNS8 Size;
@@ -118,13 +118,13 @@
pMappingCount = (d->objdict + offsetObjdict + ind)->pSubindex[0].pObject;
MSG_WAR(0x3912, "Nb maped objects : ",* pMappingCount);
MSG_WAR(0x3913, " at index : ", 0x1A00 + ind);
- while (subInd < *pMappingCount) { // Loop on mapped variables
+ while (subInd < *pMappingCount) { /* Loop on mapped variables */
/* get mapping parameters */
pMappingParameter = (d->objdict + offsetObjdict + ind)->pSubindex[subInd + 1].pObject;
MSG_WAR(0x3914, "Get the mapping at index : ", (UNS16)0x1A00 + ind);
MSG_WAR(0x3915, " subIndex : ", subInd + 1);
MSG_WAR(0x3916, " value : ", *(UNS32 *)pMappingParameter);
- // Get the mapped variable
+ /* Get the mapped variable */
Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
objDict = getODentry(d, (UNS16)((*pMappingParameter) >> 16),
(UNS8)(((*pMappingParameter) >> 8 ) & 0x000000FF),
@@ -140,7 +140,7 @@
offset += Size;
d->process_var.count = offset;
subInd++;
- }// end Loop on mapped variables
+ }/* end Loop on mapped variables */
}
return 0;
}
@@ -154,8 +154,8 @@
UNS8 err;
MSG_WAR(0x3930, "sendPDOrequest ",0);
- // Sending the request only if the cobid have been found on the PDO receive
- // part dictionary
+ /* Sending the request only if the cobid have been found on the PDO receive */
+ /* part dictionary */
offset = d->firstIndex->PDO_RCV;
lastIndex = d->lastIndex->PDO_RCV;
if (offset)
@@ -182,14 +182,14 @@
UNS8 proceedPDO(CO_Data* d, Message *m)
{
UNS8 numPdo;
- UNS8 numMap; // Number of the mapped varable
+ UNS8 numMap; /* Number of the mapped varable */
UNS8 i;
- UNS8 * pMappingCount = NULL; // count of mapped objects...
- // pointer to the var which is mapped to a pdo...
-// void * pMappedAppObject = NULL;
- // pointer fo the var which holds the mapping parameter of an mapping entry
+ UNS8 * pMappingCount = NULL; /* count of mapped objects... */
+ /* pointer to the var which is mapped to a pdo... */
+/* void * pMappedAppObject = NULL; */
+ /* pointer fo the var which holds the mapping parameter of an mapping entry */
UNS32 * pMappingParameter = NULL;
- UNS8 * pTransmissionType = NULL; // pointer to the transmission type
+ UNS8 * pTransmissionType = NULL; /* pointer to the transmission type */
UNS32 * pwCobId = NULL;
UNS8 Size;
UNS8 dataType;
@@ -204,7 +204,7 @@
offset = 0x00;
numPdo = 0;
numMap = 0;
- if((*m).rtr == NOT_A_REQUEST ) { // The PDO received is not a request.
+ if((*m).rtr == NOT_A_REQUEST ) { /* The PDO received is not a request. */
offsetObjdict = d->firstIndex->PDO_RCV;
lastIndex = d->lastIndex->PDO_RCV;
@@ -215,8 +215,8 @@
switch( status ) {
case state1: /* data are stored in process_var array */
- //memcpy(&(process_var.data), &m->data, (*m).len);
- // Ce memcpy devrait être portable.
+ /* memcpy(&(process_var.data), &m->data, (*m).len); */
+ /* Ce memcpy devrait être portable. */
for ( i = 0 ; i < m->len ; i++)
d->process_var.data[i] = m->data[i];
d->process_var.count = (*m).len;
@@ -228,15 +228,15 @@
/* get CobId of the dictionary correspondant to the received PDO */
pwCobId = d->objdict[offsetObjdict].pSubindex[1].pObject;
/* check the CobId coherance */
- //*pwCobId is the cobId read in the dictionary at the state 3
+ /*pwCobId is the cobId read in the dictionary at the state 3 */
if ( *pwCobId == (*m).cob_id.w ){
- // The cobId is recognized
+ /* The cobId is recognized */
status = state4;
MSG_WAR(0x3936, "cobId found at index ", 0x1400 + numPdo);
break;
}
else {
- // cobId received does not match with those write in the dictionnary
+ /* cobId received does not match with those write in the dictionnary */
numPdo++;
offsetObjdict++;
status = state2;
@@ -244,7 +244,7 @@
}
case state4: /* get mapped objects number */
- // The cobId of the message received has been found in the dictionnary.
+ /* The cobId of the message received has been found in the dictionnary. */
offsetObjdict = d->firstIndex->PDO_RCV_MAP;
lastIndex = d->lastIndex->PDO_RCV_MAP;
pMappingCount = (d->objdict + offsetObjdict + numPdo)->pSubindex[0].pObject;
@@ -255,10 +255,10 @@
MSG_ERR(0x1937, "Couldn't get mapping parameter : ", numMap + 1);
return 0xFF;
}
- // Get the addresse of the mapped variable.
- // detail of *pMappingParameter :
- // The 16 hight bits contains the index, the medium 8 bits contains the subindex,
- // and the lower 8 bits contains the size of the mapped variable.
+ /* Get the addresse of the mapped variable. */
+ /* detail of *pMappingParameter : */
+ /* The 16 hight bits contains the index, the medium 8 bits contains the subindex, */
+ /* and the lower 8 bits contains the size of the mapped variable. */
Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
@@ -276,18 +276,18 @@
MSG_WAR(0x3942, "Variable updated with value received by PDO cobid : ", m->cob_id.w);
MSG_WAR(0x3943, " Mapped at index : ", (*pMappingParameter) >> 16);
MSG_WAR(0x3944, " subindex : ", ((*pMappingParameter) >> 8 ) & 0xFF);
-// MSG_WAR(0x3945, " data : ",*((UNS32 *)pMappedAppObject));
+ /* MSG_WAR(0x3945, " data : ",*((UNS32 *)pMappedAppObject)); */
offset += Size;
numMap++;
- } // end loop while on mapped variables
+ } /* end loop while on mapped variables */
offset=0x00;
numMap = 0;
return 0;
- }// end switch status
- }// end while
- }// end if Donnees
+ }/* end switch status */
+ }/* end while */
+ }/* end if Donnees */
else if ((*m).rtr == REQUEST ){
@@ -322,7 +322,7 @@
break;
}
else {
- // The requested PDO is not to send on request. So, does nothing.
+ /* The requested PDO is not to send on request. So, does nothing. */
MSG_WAR(0x2947, "PDO is not to send on request : ", m->cob_id.w);
return 0xFF;
}
@@ -334,7 +334,7 @@
numMap = 0;
while (numMap < *pMappingCount) {
pMappingParameter = (d->objdict + offsetObjdict + numPdo)->pSubindex[numMap + 1].pObject;
- // Get the mapped variable
+ /* Get the mapped variable */
Size = ((UNS8)(((*pMappingParameter) & 0xFF) >> 3));
objDict = getODentry( d, (UNS16)((*pMappingParameter) >> (UNS8)16),
(UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & 0xFF),
@@ -349,13 +349,13 @@
d->process_var.count = offset;
numMap++;
- } // end while
- PDOmGR( d, *pwCobId ); // Transmit the PDO
+ } /* end while */
+ PDOmGR( d, *pwCobId ); /* Transmit the PDO */
return 0;
- }// end switch status
- }// end while
- }// end if Requete
+ }/* end switch status */
+ }/* end while */
+ }/* end if Requete */
return 0;
}
@@ -363,12 +363,14 @@
+#if 0
+
/*********************************************************************/
/* TODO : reimplement this using CallBacks */
/*********************************************************************/
-/*
+
UNS8 sendPDOevent( CO_Data* d, void * variable )
-{ // DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails.
+{ /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */
UNS32 objDict = 0;
UNS8 ind, sub_ind;
UNS8 status;
@@ -376,7 +378,7 @@
UNS8 * pMappingCount = NULL;
UNS32 * pMappingParameter = NULL;
void * pMappedAppObject = NULL;
- UNS8 * pTransmissionType = NULL; // pointer to the transmission type
+ UNS8 * pTransmissionType = NULL; /* pointer to the transmission type */
UNS32 * pwCobId = NULL;
UNS8 * pSize;
UNS8 size;
@@ -391,8 +393,8 @@
pSize = &size;
status = state1;
- // look for the index and subindex where the variable is mapped
- // Then, send the pdo which contains the variable.
+ /* look for the index and subindex where the variable is mapped */
+ /* Then, send the pdo which contains the variable. */
MSG_WAR (0x3960, "sendPDOevent", 0);
offsetObjdictPrm = d->firstIndex->PDO_TRS;
@@ -401,9 +403,9 @@
lastIndex = d->lastIndex->PDO_TRS_MAP;
if (offsetObjdictPrm && offsetObjdict)
- // Loop on PDO Transmit
+ /* Loop on PDO Transmit */
while(offsetObjdict <= lastIndex){
- // Check the transmission mode
+ /* Check the transmission mode */
pTransmissionType = d->objdict[offsetObjdictPrm].pSubindex[2].pObject;
if (*pTransmissionType != TRANS_EVENT) {
ind++;
@@ -412,10 +414,10 @@
continue;
}
pMappingCount = d->objdict[offsetObjdict].pSubindex[0].pObject;
- numMap = 1; // mapped variable
+ numMap = 1; /* mapped variable */
while (numMap <= *pMappingCount) {
pMappingParameter = d->objdict[offsetObjdict].pSubindex[numMap].pObject;
- // Get the variable
+ /* Get the variable */
objDict = getODentry( d,
(UNS16)((*pMappingParameter) >> 16),
(UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF),
@@ -434,20 +436,20 @@
MSG_WAR(0x3964, " subIndex : ",
((*pMappingParameter) >> 8 ) & 0x000000FF);
buildPDO(d, 0x1800 + ind);
- // Get the cobId
+ /* Get the cobId */
pwCobId = d->objdict[offsetObjdictPrm].pSubindex[1].pObject;
- PDOmGR( d, *pwCobId ); // Send the PDO
+ PDOmGR( d, *pwCobId ); /* Send the PDO */
return 0;
}
numMap++;
- } // End loop on mapped variable
+ } /* End loop on mapped variable */
ind++;
offsetObjdict++;
offsetObjdictPrm++;
- } // End loop while on PDO
+ } /* End loop while on PDO */
MSG_WAR(0x2965, "Variable not found in a PDO to send on event", 0);
return 0xFF;
}
-*/
+#endif
--- a/src/sdo.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/sdo.c Thu Jan 25 17:36:58 2007 +0100
@@ -20,25 +20,34 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-//#define DEBUG_WAR_CONSOLE_ON
-//#define DEBUG_ERR_CONSOLE_ON
+/* #define DEBUG_WAR_CONSOLE_ON */
+/* #define DEBUG_ERR_CONSOLE_ON */
#include "objacces.h"
#include "sdo.h"
+/* Uncomment if your compiler does not support inline functions */
+ #define NO_INLINE
+
+#ifdef NO_INLINE
+ #define INLINE
+#else
+ #define INLINE inline
+#endif
+
/*Internals prototypes*/
/** Called by writeNetworkDict */
-inline UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
+INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback);
/** Called by readNetworkDict */
-inline UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex,
+INLINE UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex,
UNS8 dataType, SDOCallback_t Callback);
/***************************************************************************/
-// SDO (un)packing macros
+/* SDO (un)packing macros */
/** Returns the command specifier (cs, ccs, scs) from the first byte of the SDO
*/
@@ -74,6 +83,7 @@
/** Returns the subIndex from the byte 3 of the SDO
*/
+
#define getSDOsubIndex(byte3) (byte3)
/***************************************************************************
@@ -85,14 +95,14 @@
MSG_WAR(0x2A02, "server node : ", d->transfers[id].nodeId);
MSG_WAR(0x2A02, " index : ", d->transfers[id].index);
MSG_WAR(0x2A02, " subIndex : ", d->transfers[id].subIndex);
- // Reset timer handler
+ /* Reset timer handler */
d->transfers[id].timer = TIMER_NONE;
- // Call the user function to inform of the problem.
+ /* Call the user function to inform of the problem.*/
(*d->SDOtimeoutError)(id);
- // Sending a SDO abort
+ /* Sending a SDO abort */
sendSDOabort(d, d->transfers[id].whoami,
d->transfers[id].index, d->transfers[id].subIndex, SDOABT_TIMED_OUT);
- // Reset the line
+ /* Reset the line*/
resetSDOline(d, id);
}
@@ -157,7 +167,7 @@
d->transfers[line].count = size;
d->transfers[line].offset = 0;
#if 0
- // Me laisser ça, please ! (FD)
+ /*Me laisser ça, please ! (FD)*/
{
UNS8 i;
for (i = 0 ; i < 10 ; i++) {
@@ -213,7 +223,7 @@
UNS8 err;
UNS8 line;
err = getSDOlineOnUse( d, nodeId, whoami, &line );
- if (!err) // If a line on use have been found.
+ if (!err) /* If a line on use have been found.*/
MSG_WAR(0x3A20, "FailedSDO : line found : ", line);
if ((! err) && (whoami == SDO_SERVER)) {
resetSDOline( d, line );
@@ -274,8 +284,8 @@
*line = i;
d->transfers[i].whoami = whoami;
return 0;
- } // end if
- } // end for
+ } /* end if */
+ } /* end for */
MSG_ERR(0x1A25, "Too many SDO in progress. Aborted.", i);
return 0xFF;
}
@@ -314,7 +324,7 @@
/***************************************************************************/
UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes)
{
- if (d->transfers[line].count == 0) // if received initiate SDO protocol with e=0 and s=0
+ if (d->transfers[line].count == 0) /* if received initiate SDO protocol with e=0 and s=0 */
* nbBytes = 0;
else
* nbBytes = d->transfers[line].count - d->transfers[line].offset;
@@ -398,7 +408,7 @@
/* message copy for sending */
m.cob_id.w = *pwCobId;
m.rtr = NOT_A_REQUEST;
- //the length of SDO must be 8
+ /* the length of SDO must be 8 */
m.len = 8;
for (i = 0 ; i < 8 ; i++) {
m.data[i] = sdo.body.data[i];
@@ -414,12 +424,12 @@
MSG_WAR(0x2A50,"Sending SDO abort ", abortCode);
sdo.nodeId = *d->bDeviceNodeId;
sdo.body.data[0] = 0x80;
- // Index
- sdo.body.data[1] = index & 0xFF; // LSB
- sdo.body.data[2] = (index >> 8) & 0xFF; // MSB
- // Subindex
+ /* Index */
+ sdo.body.data[1] = index & 0xFF; /* LSB */
+ sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
+ /* Subindex */
sdo.body.data[3] = subIndex;
- // Data
+ /* Data */
sdo.body.data[4] = (UNS8)(abortCode & 0xFF);
sdo.body.data[5] = (UNS8)((abortCode >> 8) & 0xFF);
sdo.body.data[6] = (UNS8)((abortCode >> 16) & 0xFF);
@@ -434,12 +444,12 @@
{
UNS8 err;
UNS8 line;
- UNS8 nbBytes; // received or to be transmited.
- UNS8 nodeId = 0; // The node from which the SDO is received
+ UNS8 nbBytes; /* received or to be transmited. */
+ UNS8 nodeId = 0; /* The node from which the SDO is received */
UNS8 *pNodeId = NULL;
- UNS8 whoami = SDO_UNKNOWN; // SDO_SERVER or SDO_CLIENT.
- UNS32 errorCode; // while reading or writing in the local object dictionary.
- s_SDO sdo; // SDO to transmit
+ UNS8 whoami = SDO_UNKNOWN; /* SDO_SERVER or SDO_CLIENT.*/
+ UNS32 errorCode; /* while reading or writing in the local object dictionary.*/
+ s_SDO sdo; /* SDO to transmit */
UNS16 index;
UNS8 subIndex;
UNS32 abortCode;
@@ -454,8 +464,8 @@
MSG_WAR(0x3A60, "proceedSDO ", 0);
whoami = SDO_UNKNOWN;
- // Looking for the cobId in the object dictionary.
- // Am-I a server ?
+ /* Looking for the cobId in the object dictionary. */
+ /* Am-I a server ? */
offset = d->firstIndex->SDO_SVR;
lastIndex = d->lastIndex->SDO_SVR;
j = 0;
@@ -468,16 +478,16 @@
if ( *pCobId == (*m).cob_id.w ) {
whoami = SDO_SERVER;
MSG_WAR(0x3A62, "proceedSDO. I am server. index : ", 0x1200 + j);
- // In case of server, the node id of the client may be unknown. So we put the index minus offset
- // 0x1200 where the cobid received is defined.
+ /* In case of server, the node id of the client may be unknown. So we put the index minus offset */
+ /* 0x1200 where the cobid received is defined. */
nodeId = j;
break;
}
j++;
offset++;
- } // end while
+ } /* end while */
if (whoami == SDO_UNKNOWN) {
- // Am-I client ?
+ /* Am-I client ? */
offset = d->firstIndex->SDO_CLT;
lastIndex = d->lastIndex->SDO_CLT;
j = 0;
@@ -486,10 +496,10 @@
MSG_ERR(0x1A63, "Subindex 3 not found at index ", 0x1280 + j);
return 0xFF;
}
- // a) Looking for the cobid received.
+ /* a) Looking for the cobid received. */
pCobId = d->objdict[offset].pSubindex[2].pObject;
if (*pCobId == (*m).cob_id.w ) {
- // b) cobid found, so reading the node id of the server.
+ /* b) cobid found, so reading the node id of the server. */
pNodeId = d->objdict[offset].pSubindex[3].pObject;
whoami = SDO_CLIENT;
nodeId = *pNodeId;
@@ -499,13 +509,13 @@
}
j++;
offset++;
- } // end while
+ } /* end while */
}
if (whoami == SDO_UNKNOWN) {
- return 0xFF;// This SDO was not for us !
- }
-
- // Test if the size of the SDO is ok
+ return 0xFF;/* This SDO was not for us ! */
+ }
+
+ /* Test if the size of the SDO is ok */
if ( (*m).len != 8) {
MSG_ERR(0x1A67, "Error size SDO. CobId : ", (*m).cob_id.w);
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_GENERAL_ERROR);
@@ -519,16 +529,16 @@
MSG_WAR(0x3A69, "I am SERVER. Received SDO cobId : ", (*m).cob_id.w);
}
- // Testing the command specifier
- // Allowed : cs = 0, 1, 2, 3, 4. (= all except those for block tranfert).
- // cs = other : Not allowed -> abort.
+ /* Testing the command specifier */
+ /* Allowed : cs = 0, 1, 2, 3, 4. (= all except those for block tranfert). */
+ /* cs = other : Not allowed -> abort. */
switch (getSDOcs(m->data[0])) {
case 0:
- // I am SERVER
+ /* I am SERVER */
if (whoami == SDO_SERVER) {
- // Receiving a download segment data.
- // A SDO transfert should have been yet initiated.
+ /* Receiving a download segment data. */
+ /* A SDO transfert should have been yet initiated. */
err = getSDOlineOnUse( d, nodeId, whoami, &line );
if (!err)
err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS;
@@ -538,52 +548,52 @@
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
return 0xFF;
}
- // Reset the wathdog
+ /* Reset the wathdog */
RestartSDO_TIMER(line)
MSG_WAR(0x3A71, "Received SDO download segment defined at index 0x1200 + ", nodeId);
index = d->transfers[line].index;
subIndex = d->transfers[line].subIndex;
- // Toggle test.
+ /* Toggle test. */
if (d->transfers[line].toggle != getSDOt(m->data[0])) {
MSG_ERR(0x1A72, "SDO error : Toggle error : ", getSDOt(m->data[0]));
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED);
return 0xFF;
}
- // Nb of data to be downloaded
+ /* Nb of data to be downloaded */
nbBytes = 7 - getSDOn3(m->data[0]);
- // Store the data in the transfert structure.
+ /* Store the data in the transfert structure. */
err = SDOtoLine(d, line, nbBytes, (*m).data + 1);
if (err) {
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
return 0xFF;
}
- // Sending the SDO response, CS = 1
- sdo.nodeId = *d->bDeviceNodeId; // The node id of the server, (here it is the sender).
+ /* Sending the SDO response, CS = 1 */
+ sdo.nodeId = *d->bDeviceNodeId; /* The node id of the server, (here it is the sender). */
sdo.body.data[0] = (1 << 5) | (d->transfers[line].toggle << 4);
for (i = 1 ; i < 8 ; i++)
sdo.body.data[i] = 0;
MSG_WAR(0x3A73, "SDO. Send response to download request defined at index 0x1200 + ", nodeId);
sendSDO(d, whoami, sdo);
- // Inverting the toggle for the next segment.
+ /* Inverting the toggle for the next segment. */
d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
- // If it was the last segment,
+ /* If it was the last segment, */
if (getSDOc(m->data[0])) {
- // Transfering line data to object dictionary.
- // The code does not use the "d" of initiate frame. So it is safe if e=s=0
+ /* Transfering line data to object dictionary. */
+ /* The code does not use the "d" of initiate frame. So it is safe if e=s=0 */
errorCode = SDOlineToObjdict(d, line);
if (errorCode) {
MSG_ERR(0x1A54, "SDO error : Unable to copy the data in the object dictionary", 0);
failedSDO(d, nodeId, whoami, index, subIndex, errorCode);
return 0xFF;
}
- // Release of the line
+ /* Release of the line */
resetSDOline(d, line);
MSG_WAR(0x3A74, "SDO. End of download defined at index 0x1200 + ", nodeId);
}
- } // end if SERVER
- else { // if CLIENT
- // I am CLIENT
- // It is a request for a previous upload segment. We should find a line opened for this.
+ } /* end if SERVER */
+ else { /* if CLIENT */
+ /* I am CLIENT */
+ /* It is a request for a previous upload segment. We should find a line opened for this.*/
err = getSDOlineOnUse( d, nodeId, whoami, &line);
if (!err)
err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS;
@@ -592,38 +602,38 @@
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
return 0xFF;
}
- // Reset the wathdog
+ /* Reset the wathdog */
RestartSDO_TIMER(line)
index = d->transfers[line].index;
subIndex = d->transfers[line].subIndex;
- // test of the toggle;
+ /* test of the toggle; */
if (d->transfers[line].toggle != getSDOt(m->data[0])) {
MSG_ERR(0x1A76, "SDO error : Received segment response Toggle error. from nodeId", nodeId);
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED);
return 0xFF;
}
- // nb of data to be uploaded
+ /* nb of data to be uploaded */
nbBytes = 7 - getSDOn3(m->data[0]);
- // Storing the data in the line structure.
+ /* Storing the data in the line structure. */
err = SDOtoLine(d, line, nbBytes, (*m).data + 1);
if (err) {
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
return 0xFF;
}
- // Inverting the toggle for the next segment.
+ /* Inverting the toggle for the next segment. */
d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
- // If it was the last segment,
+ /* If it was the last segment,*/
if ( getSDOc(m->data[0])) {
- // Put in state finished
- // The code is safe for the case e=s=0 in initiate frame.
+ /* Put in state finished */
+ /* The code is safe for the case e=s=0 in initiate frame. */
StopSDO_TIMER(line)
d->transfers[line].state = SDO_FINISHED;
if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId);
MSG_WAR(0x3A77, "SDO. End of upload from node : ", nodeId);
}
- else { // more segments to receive
- // Sending the request for the next segment.
+ else { /* more segments to receive */
+ /* Sending the request for the next segment. */
sdo.nodeId = nodeId;
sdo.body.data[0] = (3 << 5) | (d->transfers[line].toggle << 4);
for (i = 1 ; i < 8 ; i++)
@@ -631,12 +641,12 @@
sendSDO(d, whoami, sdo);
MSG_WAR(0x3A78, "SDO send upload segment request to nodeId", nodeId);
}
- } // End if CLIENT
+ } /* End if CLIENT */
break;
case 1:
- // I am SERVER
- // Receive of an initiate download
+ /* I am SERVER */
+ /* Receive of an initiate download */
if (whoami == SDO_SERVER) {
index = getSDOindex(m->data[1],m->data[2]);
subIndex = getSDOsubIndex(m->data[3]);
@@ -645,15 +655,15 @@
MSG_WAR(0x3A80, "Writing at index : ", index);
MSG_WAR(0x3A80, "Writing at subIndex : ", subIndex);
- // Search if a SDO transfert have been yet initiated
+ /* Search if a SDO transfert have been yet initiated */
err = getSDOlineOnUse( d, nodeId, whoami, &line );
if (! err) {
MSG_ERR(0x1A81, "SDO error : Transmission yet started.", 0);
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR);
return 0xFF;
}
- // No line on use. Great !
- // Try to open a new line.
+ /* No line on use. Great ! */
+ /* Try to open a new line. */
err = getSDOfreeLine( d, whoami, &line );
if (err) {
MSG_ERR(0x1A82, "SDO error : No line free, too many SDO in progress. Aborted.", 0);
@@ -662,10 +672,10 @@
}
initSDOline(d, line, nodeId, index, subIndex, SDO_DOWNLOAD_IN_PROGRESS);
- if (getSDOe(m->data[0])) { // If SDO expedited
- // nb of data to be downloaded
+ if (getSDOe(m->data[0])) { /* If SDO expedited */
+ /* nb of data to be downloaded */
nbBytes = 4 - getSDOn2(m->data[0]);
- // Storing the data in the line structure.
+ /* Storing the data in the line structure. */
d->transfers[line].count = nbBytes;
err = SDOtoLine(d, line, nbBytes, (*m).data + 4);
@@ -674,23 +684,23 @@
return 0xFF;
}
- // SDO expedited -> transfert finished. Data can be stored in the dictionary.
- // The line will be reseted when it is downloading in the dictionary.
+ /* SDO expedited -> transfert finished. Data can be stored in the dictionary. */
+ /* The line will be reseted when it is downloading in the dictionary. */
MSG_WAR(0x3A83, "SDO Initiate Download is an expedited transfert. Finished.: ", nodeId);
- // Transfering line data to object dictionary.
+ /* Transfering line data to object dictionary. */
errorCode = SDOlineToObjdict(d, line);
if (errorCode) {
MSG_ERR(0x1A84, "SDO error : Unable to copy the data in the object dictionary", 0);
failedSDO(d, nodeId, whoami, index, subIndex, errorCode);
return 0xFF;
}
- // Release of the line.
+ /* Release of the line. */
resetSDOline(d, line);
}
- else {// So, if it is not an expedited transfert
+ else {/* So, if it is not an expedited transfert */
if (getSDOs(m->data[0])) {
- // TODO : if e and s = 0, not reading m->data[4] but put nbBytes = 0
- nbBytes = m->data[4]; // Transfert limited to 255 bytes.
+ /* TODO : if e and s = 0, not reading m->data[4] but put nbBytes = 0 */
+ nbBytes = m->data[4]; /* Transfert limited to 255 bytes. */
err = setSDOlineRestBytes(d, nodeId, nbBytes);
if (err) {
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
@@ -698,19 +708,19 @@
}
}
}
- //Sending a SDO, cs=3
- sdo.nodeId = *d->bDeviceNodeId; // The node id of the server, (here it is the sender).
+ /*Sending a SDO, cs=3*/
+ sdo.nodeId = *d->bDeviceNodeId; /* The node id of the server, (here it is the sender).*/
sdo.body.data[0] = 3 << 5;
- sdo.body.data[1] = index & 0xFF; // LSB
- sdo.body.data[2] = (index >> 8) & 0xFF; // MSB
+ sdo.body.data[1] = index & 0xFF; /* LSB */
+ sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
sdo.body.data[3] = subIndex;
for (i = 4 ; i < 8 ; i++)
sdo.body.data[i] = 0;
sendSDO(d, whoami, sdo);
- } // end if I am SERVER
+ } /* end if I am SERVER */
else {
- // I am CLIENT
- // It is a response for a previous download segment. We should find a line opened for this.
+ /* I am CLIENT */
+ /* It is a response for a previous download segment. We should find a line opened for this. */
err = getSDOlineOnUse( d, nodeId, whoami, &line);
if (!err)
err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS;
@@ -719,18 +729,18 @@
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
return 0xFF;
}
- // Reset the wathdog
+ /* Reset the wathdog */
RestartSDO_TIMER(line)
index = d->transfers[line].index;
subIndex = d->transfers[line].subIndex;
- // test of the toggle;
+ /* test of the toggle; */
if (d->transfers[line].toggle != getSDOt(m->data[0])) {
MSG_ERR(0x1A86, "SDO error : Received segment response Toggle error. from nodeId", nodeId);
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED);
return 0xFF;
}
- // End transmission or downloading next segment. We need to know if it will be the last one.
+ /* End transmission or downloading next segment. We need to know if it will be the last one. */
getSDOlineRestBytes(d, line, &nbBytes);
if (nbBytes == 0) {
MSG_WAR(0x3A87, "SDO End download. segment response received. OK. from nodeId", nodeId);
@@ -739,12 +749,12 @@
if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId);
return 0x00;
}
- // At least one transfer to send.
+ /* At least one transfer to send. */
if (nbBytes > 7) {
- // several segments to download.
- // code to send the next segment. (cs = 0; c = 0)
+ /* several segments to download.*/
+ /* code to send the next segment. (cs = 0; c = 0) */
d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
- sdo.nodeId = nodeId; // The server node Id;
+ sdo.nodeId = nodeId; /* The server node Id; */
sdo.body.data[0] = (d->transfers[line].toggle << 4);
err = lineToSDO(d, line, 7, sdo.body.data + 1);
if (err) {
@@ -753,10 +763,10 @@
}
}
else {
- // Last segment.
- // code to send the last segment. (cs = 0; c = 1)
+ /* Last segment. */
+ /* code to send the last segment. (cs = 0; c = 1)*/
d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
- sdo.nodeId = nodeId; // The server node Id;
+ sdo.nodeId = nodeId; /* The server node Id; */
sdo.body.data[0] = (d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1;
err = lineToSDO(d, line, nbBytes, sdo.body.data + 1);
if (err) {
@@ -768,12 +778,12 @@
}
MSG_WAR(0x3A88, "SDO sending download segment to nodeId", nodeId);
sendSDO(d, whoami, sdo);
- } // end if I am a CLIENT
+ } /* end if I am a CLIENT */
break;
case 2:
- // I am SERVER
- // Receive of an initiate upload.
+ /* I am SERVER */
+ /* Receive of an initiate upload.*/
if (whoami == SDO_SERVER) {
index = getSDOindex(m->data[1],m->data[2]);
subIndex = getSDOsubIndex(m->data[3]);
@@ -781,7 +791,7 @@
nodeId);
MSG_WAR(0x3A90, "Reading at index : ", index);
MSG_WAR(0x3A91, "Reading at subIndex : ", subIndex);
- // Search if a SDO transfert have been yet initiated
+ /* Search if a SDO transfert have been yet initiated*/
err = getSDOlineOnUse( d, nodeId, whoami, &line );
if (! err) {
MSG_ERR(0x1A92, "SDO error : Transmission yet started at line : ", line);
@@ -789,8 +799,8 @@
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR);
return 0xFF;
}
- // No line on use. Great !
- // Try to open a new line.
+ /* No line on use. Great !*/
+ /* Try to open a new line.*/
err = getSDOfreeLine( d, whoami, &line );
if (err) {
MSG_ERR(0x1A71, "SDO error : No line free, too many SDO in progress. Aborted.", 0);
@@ -798,7 +808,7 @@
return 0xFF;
}
initSDOline(d, line, nodeId, index, subIndex, SDO_UPLOAD_IN_PROGRESS);
- // Transfer data from dictionary to the line structure.
+ /* Transfer data from dictionary to the line structure. */
errorCode = objdictToSDOline(d, line);
if (errorCode) {
@@ -807,29 +817,29 @@
failedSDO(d, nodeId, whoami, index, subIndex, errorCode);
return 0xFF;
}
- // Preparing the response.
- getSDOlineRestBytes(d, line, &nbBytes); // Nb bytes to transfer ?
- sdo.nodeId = nodeId; // The server node Id;
+ /* Preparing the response.*/
+ getSDOlineRestBytes(d, line, &nbBytes); /* Nb bytes to transfer ? */
+ sdo.nodeId = nodeId; /* The server node Id; */
if (nbBytes > 4) {
- // normal transfert. (segmented).
- // code to send the initiate upload response. (cs = 2)
+ /* normal transfert. (segmented). */
+ /* code to send the initiate upload response. (cs = 2) */
sdo.body.data[0] = (2 << 5) | 1;
- sdo.body.data[1] = index & 0xFF; // LSB
- sdo.body.data[2] = (index >> 8) & 0xFF; // MSB
+ sdo.body.data[1] = index & 0xFF; /* LSB */
+ sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
sdo.body.data[3] = subIndex;
- sdo.body.data[4] = nbBytes; // Limitation of canfestival2 : Max tranfert is 256 bytes.
- // It takes too much memory to upgrate to 2^32 because the size of data is also coded
- // in the object dictionary, at every index and subindex.
+ sdo.body.data[4] = nbBytes; /* Limitation of canfestival2 : Max tranfert is 256 bytes.*/
+ /* It takes too much memory to upgrate to 2^32 because the size of data is also coded */
+ /* in the object dictionary, at every index and subindex. */
for (i = 5 ; i < 8 ; i++)
sdo.body.data[i] = 0;
MSG_WAR(0x3A95, "SDO. Sending normal upload initiate response defined at index 0x1200 + ", nodeId);
sendSDO(d, whoami, sdo);
}
else {
- // Expedited upload. (cs = 2 ; e = 1)
+ /* Expedited upload. (cs = 2 ; e = 1) */
sdo.body.data[0] = (2 << 5) | ((4 - nbBytes) << 2) | 3;
- sdo.body.data[1] = index & 0xFF; // LSB
- sdo.body.data[2] = (index >> 8) & 0xFF; // MSB
+ sdo.body.data[1] = index & 0xFF; /* LSB */
+ sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
sdo.body.data[3] = subIndex;
err = lineToSDO(d, line, nbBytes, sdo.body.data + 4);
if (err) {
@@ -841,14 +851,14 @@
MSG_WAR(0x3A96, "SDO. Sending expedited upload initiate response defined at index 0x1200 + ",
nodeId);
sendSDO(d, whoami, sdo);
- // Release the line.
+ /* Release the line.*/
resetSDOline(d, line);
}
- } // end if I am SERVER
+ } /* end if I am SERVER*/
else {
- // I am CLIENT
- // It is the response for the previous initiate upload request.
- // We should find a line opened for this.
+ /* I am CLIENT */
+ /* It is the response for the previous initiate upload request.*/
+ /* We should find a line opened for this. */
err = getSDOlineOnUse( d, nodeId, whoami, &line);
if (!err)
err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS;
@@ -857,21 +867,21 @@
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
return 0xFF;
}
- // Reset the wathdog
+ /* Reset the wathdog */
RestartSDO_TIMER(line)
index = d->transfers[line].index;
subIndex = d->transfers[line].subIndex;
- if (getSDOe(m->data[0])) { // If SDO expedited
- // nb of data to be uploaded
+ if (getSDOe(m->data[0])) { /* If SDO expedited */
+ /* nb of data to be uploaded */
nbBytes = 4 - getSDOn2(m->data[0]);
- // Storing the data in the line structure.
+ /* Storing the data in the line structure. */
err = SDOtoLine(d, line, nbBytes, (*m).data + 4);
if (err) {
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
return 0xFF;
}
- // SDO expedited -> transfert finished. data are available via getReadResultNetworkDict().
+ /* SDO expedited -> transfert finished. data are available via getReadResultNetworkDict(). */
MSG_WAR(0x3A98, "SDO expedited upload finished. Response received from node : ", nodeId);
StopSDO_TIMER(line)
d->transfers[line].count = nbBytes;
@@ -879,17 +889,17 @@
if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId);
return 0;
}
- else { // So, if it is not an expedited transfert
- // Storing the nb of data to receive.
+ else { /* So, if it is not an expedited transfert */
+ /* Storing the nb of data to receive. */
if (getSDOs(m->data[0])) {
- nbBytes = m->data[4]; // Remember the limitation to 255 bytes to transfert
+ nbBytes = m->data[4]; /* Remember the limitation to 255 bytes to transfert */
err = setSDOlineRestBytes(d, line, nbBytes);
if (err) {
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
return 0xFF;
}
}
- // Requesting next segment. (cs = 3)
+ /* Requesting next segment. (cs = 3) */
sdo.nodeId = nodeId;
sdo.body.data[0] = 3 << 5;
for (i = 1 ; i < 8 ; i++)
@@ -897,14 +907,14 @@
MSG_WAR(0x3A99, "SDO. Sending upload segment request to node : ", nodeId);
sendSDO(d, whoami, sdo);
}
- } // End if CLIENT
+ } /* End if CLIENT */
break;
case 3:
- // I am SERVER
+ /* I am SERVER */
if (whoami == SDO_SERVER) {
- // Receiving a upload segment.
- // A SDO transfert should have been yet initiated.
+ /* Receiving a upload segment. */
+ /* A SDO transfert should have been yet initiated. */
err = getSDOlineOnUse( d, nodeId, whoami, &line );
if (!err)
err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS;
@@ -914,38 +924,38 @@
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
return 0xFF;
}
- // Reset the wathdog
+ /* Reset the wathdog */
RestartSDO_TIMER(line)
MSG_WAR(0x3AA1, "Received SDO upload segment defined at index 0x1200 + ", nodeId);
index = d->transfers[line].index;
subIndex = d->transfers[line].subIndex;
- // Toggle test.
+ /* Toggle test.*/
if (d->transfers[line].toggle != getSDOt(m->data[0])) {
MSG_ERR(0x1AA2, "SDO error : Toggle error : ", getSDOt(m->data[0]));
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED);
return 0xFF;
}
- // Uploading next segment. We need to know if it will be the last one.
+ /* Uploading next segment. We need to know if it will be the last one. */
getSDOlineRestBytes(d, line, &nbBytes);
if (nbBytes > 7) {
- // The segment to transfer is not the last one.
- // code to send the next segment. (cs = 0; c = 0)
- sdo.nodeId = nodeId; // The server node Id;
+ /* The segment to transfer is not the last one.*/
+ /* code to send the next segment. (cs = 0; c = 0) */
+ sdo.nodeId = nodeId; /* The server node Id; */
sdo.body.data[0] = (d->transfers[line].toggle << 4);
err = lineToSDO(d, line, 7, sdo.body.data + 1);
if (err) {
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
return 0xFF;
}
- // Inverting the toggle for the next tranfert.
+ /* Inverting the toggle for the next tranfert. */
d->transfers[line].toggle = ! d->transfers[line].toggle & 1;
MSG_WAR(0x3AA3, "SDO. Sending upload segment defined at index 0x1200 + ", nodeId);
sendSDO(d, whoami, sdo);
}
else {
- // Last segment.
- // code to send the last segment. (cs = 0; c = 1)
- sdo.nodeId = nodeId; // The server node Id;
+ /* Last segment. */
+ /* code to send the last segment. (cs = 0; c = 1) */
+ sdo.nodeId = nodeId; /* The server node Id; */
sdo.body.data[0] = (d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1;
err = lineToSDO(d, line, nbBytes, sdo.body.data + 1);
if (err) {
@@ -956,14 +966,14 @@
sdo.body.data[i] = 0;
MSG_WAR(0x3AA4, "SDO. Sending last upload segment defined at index 0x1200 + ", nodeId);
sendSDO(d, whoami, sdo);
- // Release the line
+ /* Release the line */
resetSDOline(d, line);
}
- } // end if SERVER
+ } /* end if SERVER*/
else {
- // I am CLIENT
- // It is the response for the previous initiate download request.
- // We should find a line opened for this.
+ /* I am CLIENT */
+ /* It is the response for the previous initiate download request. */
+ /* We should find a line opened for this. */
err = getSDOlineOnUse( d, nodeId, whoami, &line);
if (!err)
err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS;
@@ -972,11 +982,11 @@
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR);
return 0xFF;
}
- // Reset the wathdog
+ /* Reset the wathdog */
RestartSDO_TIMER(line)
index = d->transfers[line].index;
subIndex = d->transfers[line].subIndex;
- // End transmission or requesting next segment.
+ /* End transmission or requesting next segment. */
getSDOlineRestBytes(d, line, &nbBytes);
if (nbBytes == 0) {
MSG_WAR(0x3AA6, "SDO End download expedited. Response received. from nodeId", nodeId);
@@ -986,9 +996,9 @@
return 0x00;
}
if (nbBytes > 7) {
- // more than one request to send
- // code to send the next segment. (cs = 0; c = 0)
- sdo.nodeId = nodeId; // The server node Id;
+ /* more than one request to send */
+ /* code to send the next segment. (cs = 0; c = 0) */
+ sdo.nodeId = nodeId; /* The server node Id; */
sdo.body.data[0] = (d->transfers[line].toggle << 4);
err = lineToSDO(d, line, 7, sdo.body.data + 1);
if (err) {
@@ -997,9 +1007,9 @@
}
}
else {
- // Last segment.
- // code to send the last segment. (cs = 0; c = 1)
- sdo.nodeId = nodeId; // The server node Id;
+ /* Last segment.*/
+ /* code to send the last segment. (cs = 0; c = 1) */
+ sdo.nodeId = nodeId; /* The server node Id; */
sdo.body.data[0] = (d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1;
err = lineToSDO(d, line, nbBytes, sdo.body.data + 1);
if (err) {
@@ -1012,7 +1022,7 @@
MSG_WAR(0x3AA7, "SDO sending download segment to nodeId", nodeId);
sendSDO(d, whoami, sdo);
- } // end if I am a CLIENT
+ } /* end if I am a CLIENT */
break;
case 4:
@@ -1020,8 +1030,8 @@
(m->data[5] << 8) |
(m->data[6] << 16) |
(m->data[7] << 24);
- // Received SDO abort.
- // Looking for the line concerned.
+ /* Received SDO abort. */
+ /* Looking for the line concerned. */
if (whoami == SDO_SERVER) {
err = getSDOlineOnUse( d, nodeId, whoami, &line );
if (!err) {
@@ -1030,13 +1040,13 @@
}
else
MSG_WAR(0x3AA9, "SD0. Received SDO abort. No line found. Code : ", abortCode);
- // Tips : The end user has no way to know that the server node has received an abort SDO.
- // Its is ok, I think.
+ /* Tips : The end user has no way to know that the server node has received an abort SDO. */
+ /* Its is ok, I think.*/
}
- else { // If I am CLIENT
+ else { /* If I am CLIENT */
err = getSDOlineOnUse( d, nodeId, whoami, &line );
if (!err) {
- // The line *must* be released by the core program.
+ /* The line *must* be released by the core program. */
StopSDO_TIMER(line)
d->transfers[line].state = SDO_ABORTED_RCV;
MSG_WAR(0x3AB0, "SD0. Received SDO abort. Line state ABORTED. Code : ", abortCode);
@@ -1046,22 +1056,22 @@
}
break;
default:
- // Error : Unknown cs
+ /* Error : Unknown cs */
MSG_ERR(0x1AB2, "SDO. Received unknown command specifier : ", getSDOcs(m->data[0]));
return 0xFF;
- } // End switch
+ } /* End switch */
return 0;
}
/*******************************************************************)******/
-inline UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
+INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback)
{
UNS8 err;
UNS8 SDOfound = 0;
UNS8 line;
- s_SDO sdo; // SDO to transmit
+ s_SDO sdo; /* SDO to transmit */
UNS8 i, j;
UNS8 * pSize;
UNS8 size;
@@ -1076,19 +1086,19 @@
MSG_WAR(0x3AC2, " subIndex : ", subIndex);
MSG_WAR(0x3AC3, " nb bytes : ", count);
- // Verify that there is no SDO communication yet.
+ /* Verify that there is no SDO communication yet. */
err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
if (!err) {
MSG_ERR(0x1AC4, "SDO error : Communication yet established. with node : ", nodeId);
return 0xFF;
}
- // Taking the line ...
+ /* Taking the line ... */
err = getSDOfreeLine( d, SDO_CLIENT, &line );
if (err) {
MSG_ERR(0x1AC5, "SDO error : No line free, too many SDO in progress. Aborted for node : ", nodeId);
return (0xFF);
}
- // Check which SDO to use to communicate with the node
+ /* Check which SDO to use to communicate with the node */
offset = d->firstIndex->SDO_CLT;
lastIndex = d->lastIndex->SDO_CLT;
if (offset == 0) {
@@ -1101,7 +1111,7 @@
MSG_ERR(0x1AC8, "Subindex 3 not found at index ", 0x1280 + i);
return 0xFF;
}
- // looking for the nodeId server
+ /* looking for the nodeId server */
pNodeIdServer = d->objdict[offset].pSubindex[3].pObject;
nodeIdServer = *pNodeIdServer;
MSG_WAR(0x1AD2, "index : ", 0x1280 + i);
@@ -1113,7 +1123,7 @@
}
offset++;
i++;
- } // end while
+ } /* end while */
if (!SDOfound) {
MSG_ERR(0x1AC9, "SDO. Error. No client found to communicate with node : ", nodeId);
return 0xFF;
@@ -1123,39 +1133,39 @@
d->transfers[line].count = count;
d->transfers[line].dataType = dataType;
- // Copy data to transfers structure.
+ /* Copy data to transfers structure. */
for (j = 0 ; j < count ; j++) {
# ifdef CANOPEN_BIG_ENDIAN
if (dataType == 0)
d->transfers[line].data[count - 1 - j] = ((char *)data)[j];
- else // String of bytes.
+ else /* String of bytes. */
d->transfers[line].data[j] = ((char *)data)[j];
# else
d->transfers[line].data[j] = ((char *)data)[j];
# endif
}
- // Send the SDO to the server. Initiate download, cs=1.
+ /* Send the SDO to the server. Initiate download, cs=1. */
sdo.nodeId = nodeId;
- if (count <= 4) { // Expedited transfert
+ if (count <= 4) { /* Expedited transfert */
sdo.body.data[0] = (1 << 5) | ((4 - count) << 2) | 3;
for (i = 4 ; i < 8 ; i++)
sdo.body.data[i] = d->transfers[line].data[i - 4];
d->transfers[line].offset = count;
}
- else { // Normal transfert
+ else { /* Normal transfert */
sdo.body.data[0] = (1 << 5) | 1;
- sdo.body.data[4] = count; // nb of byte to transmit. Max = 255. (canfestival2 limitation).
+ sdo.body.data[4] = count; /* nb of byte to transmit. Max = 255. (canfestival2 limitation). */
for (i = 5 ; i < 8 ; i++)
sdo.body.data[i] = 0;
}
- sdo.body.data[1] = index & 0xFF; // LSB
- sdo.body.data[2] = (index >> 8) & 0xFF; // MSB
+ sdo.body.data[1] = index & 0xFF; /* LSB */
+ sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
sdo.body.data[3] = subIndex;
err = sendSDO(d, SDO_CLIENT, sdo);
if (err) {
MSG_ERR(0x1AD1, "SDO. Error while sending SDO to node : ", nodeId);
- // release the line
+ /* release the line */
resetSDOline(d, line);
return 0xFF;
}
@@ -1181,7 +1191,7 @@
/***************************************************************************/
-inline UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback)
+INLINE UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback)
{
UNS8 err;
UNS8 SDOfound = 0;
@@ -1189,7 +1199,7 @@
UNS8 line;
UNS8 * pSize;
UNS8 size;
- s_SDO sdo; // SDO to transmit
+ s_SDO sdo; /* SDO to transmit */
UNS8 *pNodeIdServer;
UNS8 nodeIdServer;
UNS16 offset;
@@ -1200,13 +1210,13 @@
MSG_WAR(0x3AD7, " subIndex : ", subIndex);
- // Verify that there is no SDO communication yet.
+ /* Verify that there is no SDO communication yet. */
err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
if (!err) {
MSG_ERR(0x1AD8, "SDO error : Communication yet established. with node : ", nodeId);
return 0xFF;
}
- // Taking the line ...
+ /* Taking the line ... */
err = getSDOfreeLine( d, SDO_CLIENT, &line );
if (err) {
MSG_ERR(0x1AD9, "SDO error : No line free, too many SDO in progress. Aborted for node : ", nodeId);
@@ -1215,7 +1225,7 @@
else
MSG_WAR(0x3AE0, "Transmission on line : ", line);
- // Check which SDO to use to communicate with the node
+ /* Check which SDO to use to communicate with the node */
offset = d->firstIndex->SDO_CLT;
lastIndex = d->lastIndex->SDO_CLT;
if (offset == 0) {
@@ -1228,7 +1238,7 @@
MSG_ERR(0x1AE2, "Subindex 3 not found at index ", 0x1280 + i);
return 0xFF;
}
- // looking for the nodeId server
+ /* looking for the nodeId server */
pNodeIdServer = d->objdict[offset].pSubindex[3].pObject;
nodeIdServer = *pNodeIdServer;
@@ -1238,7 +1248,7 @@
}
offset++;
i++;
- } // end while
+ } /* end while */
if (!SDOfound) {
MSG_ERR(0x1AE3, "SDO. Error. No client found to communicate with node : ", nodeId);
return 0xFF;
@@ -1247,18 +1257,18 @@
initSDOline(d, line, nodeId, index, subIndex, SDO_UPLOAD_IN_PROGRESS);
getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
sdo.nodeId = nodeId;
- // Send the SDO to the server. Initiate upload, cs=2.
+ /* Send the SDO to the server. Initiate upload, cs=2. */
d->transfers[line].dataType = dataType;
sdo.body.data[0] = (2 << 5);
- sdo.body.data[1] = index & 0xFF; // LSB
- sdo.body.data[2] = (index >> 8) & 0xFF; // MSB
+ sdo.body.data[1] = index & 0xFF; /* LSB */
+ sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
sdo.body.data[3] = subIndex;
for (i = 4 ; i < 8 ; i++)
sdo.body.data[i] = 0;
err = sendSDO(d, SDO_CLIENT, sdo);
if (err) {
MSG_ERR(0x1AE5, "SDO. Error while sending SDO to node : ", nodeId);
- // release the line
+ /* release the line */
resetSDOline(d, line);
return 0xFF;
}
@@ -1289,7 +1299,7 @@
UNS8 line;
* size = 0;
- // Looking for the line tranfert.
+ /* Looking for the line tranfert. */
err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
if (err) {
MSG_ERR(0x1AF0, "SDO error : No line found for communication with node : ", nodeId);
@@ -1298,13 +1308,13 @@
if (d->transfers[line].state != SDO_FINISHED)
return d->transfers[line].state;
- // Transfert is finished. Put the value in the data.
+ /* Transfert is finished. Put the value in the data. */
* size = d->transfers[line].count;
for ( i = 0 ; i < *size ; i++) {
# ifdef CANOPEN_BIG_ENDIAN
if (d->transfers[line].dataType != visible_string)
( (char *) data)[*size - 1 - i] = d->transfers[line].data[i];
- else // String of bytes.
+ else /* String of bytes. */
( (char *) data)[i] = d->transfers[line].data[i];
# else
( (char *) data)[i] = d->transfers[line].data[i];
@@ -1321,7 +1331,7 @@
UNS8 err;
* abortCode = 0;
- // Looking for the line tranfert.
+ /* Looking for the line tranfert. */
err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line);
if (err) {
MSG_ERR(0x1AF1, "SDO error : No line found for communication with node : ", nodeId);
--- a/src/states.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/states.c Thu Jan 25 17:36:58 2007 +0100
@@ -31,7 +31,7 @@
#define led_set_state(a,b)
#endif
-// Prototypes for internals functions
+/* Prototypes for internals functions */
void switchCommunicationState(CO_Data* d,
s_state_communication *newCommunicationState);
@@ -50,7 +50,7 @@
if(d->CurrentCommunicationState.csSYNC)
proceedSYNC(d,m);
break;
- //case TIME_STAMP:
+ /* case TIME_STAMP: */
case PDO1tx:
case PDO1rx:
case PDO2tx:
@@ -104,7 +104,7 @@
StartOrStop(csSDO, None, resetSDO(d))
StartOrStop(csSYNC, startSYNC(d), stopSYNC(d))
StartOrStop(csHeartbeat, heartbeatInit(d), heartbeatStop(d))
-// StartOrStop(Emergency,,)
+/* StartOrStop(Emergency,,) */
StartOrStop(csPDO, None, None)
StartOrStop(csBoot_Up, None, slaveSendBootUp(d))
}
@@ -116,31 +116,19 @@
switch( newState ){
case Initialisation:
{
- s_state_communication newCommunicationState = {
- csBoot_Up: 1,
- csSDO: 0,
- csEmergency: 0,
- csSYNC: 0,
- csHeartbeat: 0,
- csPDO: 0};
- // This will force a second loop for the state switch
+ s_state_communication newCommunicationState = {1, 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.
+ /* call user app related state func. */
(*d->initialisation)();
}
break;
case Pre_operational:
{
- s_state_communication newCommunicationState = {
- csBoot_Up: 0,
- csSDO: 1,
- csEmergency: 1,
- csSYNC: 1,
- csHeartbeat: 1,
- csPDO: 0};
+ s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 0};
d->nodeState = Pre_operational;
newState = Pre_operational;
switchCommunicationState(d, &newCommunicationState);
@@ -151,13 +139,7 @@
case Operational:
if(d->nodeState == Initialisation) return 0xFF;
{
- s_state_communication newCommunicationState = {
- csBoot_Up: 0,
- csSDO: 1,
- csEmergency: 1,
- csSYNC: 1,
- csHeartbeat: 1,
- csPDO: 1};
+ s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 1};
d->nodeState = Operational;
newState = Operational;
switchCommunicationState(d, &newCommunicationState);
@@ -168,13 +150,7 @@
case Stopped:
if(d->nodeState == Initialisation) return 0xFF;
{
- s_state_communication newCommunicationState = {
- csBoot_Up: 0,
- csSDO: 0,
- csEmergency: 0,
- csSYNC: 0,
- csHeartbeat: 1,
- csPDO: 0};
+ s_state_communication newCommunicationState = {0, 0, 0, 0, 1, 0};
d->nodeState = Stopped;
newState = Stopped;
switchCommunicationState(d, &newCommunicationState);
@@ -184,7 +160,7 @@
default:
return 0xFF;
- }//end switch case
+ }/* end switch case */
led_set_state(d, newState);
}
@@ -202,20 +178,20 @@
{
UNS16 offset = d->firstIndex->SDO_SVR;
if(offset){
- //cob_id_client = 0x600 + nodeId;
+ /* cob_id_client = 0x600 + nodeId; */
*(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + nodeId;
- //cob_id_server = 0x580 + nodeId;
+ /* cob_id_server = 0x580 + nodeId; */
*(UNS32*)d->objdict[offset].pSubindex[2].pObject = 0x580 + nodeId;
- // node Id client. As we do not know the value, we put the node Id Server
- //*(UNS8*)d->objdict[offset].pSubindex[3].pObject = nodeId;
+ /* node Id client. As we do not know the value, we put the node Id Server */
+ /* *(UNS8*)d->objdict[offset].pSubindex[3].pObject = nodeId; */
}
- // ** Initialize the server(s) SDO parameters
- // Remember that only one SDO server is allowed, defined at index 0x1200
+ /* ** Initialize the server(s) SDO parameters */
+ /* Remember that only one SDO server is allowed, defined at index 0x1200 */
- // ** Initialize the client(s) SDO parameters
- // Nothing to initialize (no default values required by the DS 401)
- // ** Initialize the receive PDO communication parameters. Only for 0x1400 to 0x1403
+ /* ** Initialize the client(s) SDO parameters */
+ /* Nothing to initialize (no default values required by the DS 401) */
+ /* ** Initialize the receive PDO communication parameters. Only for 0x1400 to 0x1403 */
{
UNS8 i = 0;
UNS16 offset = d->firstIndex->PDO_RCV;
@@ -228,7 +204,7 @@
offset ++;
}
}
- // ** Initialize the transmit PDO communication parameters. Only for 0x1800 to 0x1803
+ /* ** Initialize the transmit PDO communication parameters. Only for 0x1800 to 0x1803 */
{
UNS8 i = 0;
UNS16 offset = d->firstIndex->PDO_TRS;
@@ -242,6 +218,6 @@
offset ++;
}
}
- // bDeviceNodeId is defined in the object dictionary.
+ /* bDeviceNodeId is defined in the object dictionary. */
*d->bDeviceNodeId = nodeId;
}
--- a/src/sync.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/sync.c Thu Jan 25 17:36:58 2007 +0100
@@ -20,10 +20,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
#include "data.h"
#include "sync.h"
-// Prototypes for internals functions
+/* Prototypes for internals functions */
void SyncAlarm(CO_Data* d, UNS32 id);
UNS32 OnCOB_ID_SyncUpdate(CO_Data* d, const indextable * unsused_indextable,
UNS8 unsused_bSubindex);
@@ -37,7 +38,7 @@
}
/*****************************************************************************/
-// This is called when Index 0x1005 is updated.
+/* This is called when Index 0x1005 is updated.*/
UNS32 OnCOB_ID_SyncUpdate(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex)
{
startSYNC(d);
@@ -58,7 +59,7 @@
{
d->syncTimer = SetAlarm(
d,
- 0/*No id needed*/,
+ 0 /*No id needed*/,
&SyncAlarm,
US_TO_TIMEVAL(*d->Sync_Cycle_Period),
US_TO_TIMEVAL(*d->Sync_Cycle_Period));
@@ -91,17 +92,15 @@
UNS8 proceedSYNC(CO_Data* d, Message *m)
{
- MSG_WAR(0x3002, "SYNC received. Proceed. ", 0);
-
- UNS8 pdoNum, // number of the actual processed pdo-nr.
- prp_j;
-
- const UNS8 * pMappingCount = NULL; // count of mapped objects...
- // pointer to the var which is mapped to a pdo
-// void * pMappedAppObject = NULL;
- // pointer fo the var which holds the mapping parameter of an mapping entry
+ UNS8 pdoNum, /* number of the actual processed pdo-nr. */
+ prp_j;
+
+ const UNS8 * pMappingCount = NULL; /* count of mapped objects...*/
+ /* pointer to the var which is mapped to a pdo */
+ /* void * pMappedAppObject = NULL; */
+ /* pointer fo the var which holds the mapping parameter of an mapping entry */
UNS32 * pMappingParameter = NULL;
- // pointer to the transmissiontype...
+ /* pointer to the transmissiontype...*/
UNS8 * pTransmissionType = NULL;
UNS32 * pwCobId = NULL;
@@ -113,16 +112,19 @@
UNS8 offset;
UNS8 status;
UNS8 sizeData;
- pSize = &size;
UNS32 objDict;
- status = state3;
- pdoNum=0x00;
- prp_j=0x00;
- offset = 0x00;
UNS16 offsetObjdict;
UNS16 offsetObjdictMap;
UNS16 lastIndex;
-
+
+ pSize = &size;
+ status = state3;
+ pdoNum = 0x00;
+ prp_j = 0x00;
+ offset = 0x00;
+
+ MSG_WAR(0x3002, "SYNC received. Proceed. ", 0);
+
/* only operational state allows PDO transmission */
if( d->nodeState != Operational )
return 0;
@@ -185,7 +187,7 @@
case state9: /* get data to transmit */
index = (UNS16)((*pMappingParameter) >> 16);
subIndex = (UNS8)(( (*pMappingParameter) >> (UNS8)8 ) & (UNS32)0x000000FF);
- // <<3 because in *pMappingParameter the size is in bits
+ /* <<3 because in *pMappingParameter the size is in bits */
sizeData = (UNS8) ((*pMappingParameter & (UNS32)0x000000FF) >> 3) ;
objDict = getODentry(d, index, subIndex, (void *)&d->process_var.data[offset], &sizeData, &dataType, 0 );
@@ -228,9 +230,9 @@
default:
MSG_ERR(0x1019,"Unknown state has been reached : %d",status);
return 0xFF;
- }// end switch case
+ }/* end switch case */
- }// end while( prp_i<dict_cstes.max_count_of_PDO_transmit )
+ }/* end while( prp_i<dict_cstes.max_count_of_PDO_transmit ) */
(*d->post_TPDO)();
--- a/src/timer.c Thu Jan 25 16:49:51 2007 +0100
+++ b/src/timer.c Thu Jan 25 17:36:58 2007 +0100
@@ -20,35 +20,35 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-//#define DEBUG_WAR_CONSOLE_ON
-//#define DEBUG_ERR_CONSOLE_ON
+/* #define DEBUG_WAR_CONSOLE_ON */
+/* #define DEBUG_ERR_CONSOLE_ON */
#include <applicfg.h>
#include "timer.h"
-// --------- The timer table ---------
+/* --------- The timer table --------- */
s_timer_entry timers[MAX_NB_TIMER] = {{TIMER_FREE, NULL, NULL, 0, 0, 0},};
-//
+
TIMEVAL total_sleep_time = TIMEVAL_MAX;
TIMER_HANDLE last_timer_raw = -1;
#define minval(a,b) ((a<b)?a:b)
-// --------- Use this to declare a new alarm ---------
+/* --------- Use this to declare a new alarm --------- */
TIMER_HANDLE SetAlarm(CO_Data* d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period)
{
- //printf("SetAlarm(UNS32 id=%d, TimerCallback_t callback=%x, TIMEVAL value=%d, TIMEVAL period=%d)\n", id, callback, value, period);
+ /*printf("SetAlarm(UNS32 id=%d, TimerCallback_t callback=%x, TIMEVAL value=%d, TIMEVAL period=%d)\n", id, callback, value, period); */
TIMER_HANDLE i;
TIMER_HANDLE row_number = TIMER_NONE;
- // in order to decide new timer setting we have to run over all timer rows
+ /* in order to decide new timer setting we have to run over all timer rows */
for(i=0; i <= last_timer_raw + 1 && i < MAX_NB_TIMER; i++)
{
s_timer_entry *row = (timers+i);
- if (callback && // if something to store
- row->state == TIMER_FREE) // and empty row
- { // just store
+ if (callback && /* if something to store */
+ row->state == TIMER_FREE) /* and empty row */
+ { /* just store */
row->callback = callback;
row->d = d;
row->id = id;
@@ -60,30 +60,33 @@
}
}
- if (row_number != TIMER_NONE) // if successfull
+ if (row_number != TIMER_NONE) /* if successfull **/
{
+ TIMEVAL real_timer_value;
+ TIMEVAL elapsed_time;
+
if (row_number == last_timer_raw + 1) last_timer_raw++;
- // set next wakeup alarm if new entry is sooner than others, or if it is alone
- TIMEVAL real_timer_value = minval(value, TIMEVAL_MAX);
- TIMEVAL elapsed_time = getElapsedTime();
+ /* set next wakeup alarm if new entry is sooner than others, or if it is alone */
+ real_timer_value = minval(value, TIMEVAL_MAX);
+ elapsed_time = getElapsedTime();
- //printf("elapsed_time=%d real_timer_value=%d total_sleep_time=%d\n", elapsed_time, real_timer_value, total_sleep_time);
+ /*printf("elapsed_time=%d real_timer_value=%d total_sleep_time=%d\n", elapsed_time, real_timer_value, total_sleep_time); */
if (total_sleep_time > elapsed_time && total_sleep_time - elapsed_time > real_timer_value)
{
total_sleep_time = elapsed_time + real_timer_value;
setTimer(real_timer_value);
}
- //printf("SetAlarm() return %d\n", row_number);
+ /*printf("SetAlarm() return %d\n", row_number); */
return row_number;
}
return TIMER_NONE;
}
-// --------- Use this to remove an alarm ---------
+/* --------- Use this to remove an alarm --------- */
TIMER_HANDLE DelAlarm(TIMER_HANDLE handle)
{
- // Quick and dirty. system timer will continue to be trigged, but no action will be preformed.
+ /* Quick and dirty. system timer will continue to be trigged, but no action will be preformed. */
MSG_WAR(0x3320, "DelAlarm. handle = ", handle);
if(handle != TIMER_NONE)
{
@@ -97,66 +100,66 @@
}
-// --------- TimeDispatch is called on each timer expiration ---------
+/* --------- TimeDispatch is called on each timer expiration --------- */
void TimeDispatch()
{
TIMER_HANDLE i;
- TIMEVAL next_wakeup = TIMEVAL_MAX; // used to compute when should normaly occur next wakeup
- // First run : change timer state depending on time
- // Get time since timer signal
+ TIMEVAL next_wakeup = TIMEVAL_MAX; /* used to compute when should normaly occur next wakeup */
+ /* First run : change timer state depending on time */
+ /* Get time since timer signal */
TIMEVAL overrun = getElapsedTime();
TIMEVAL real_total_sleep_time = total_sleep_time + overrun;
- //printf("total_sleep_time %d + overrun %d\n", total_sleep_time , overrun);
+ /*printf("total_sleep_time %d + overrun %d\n", total_sleep_time , overrun); */
for(i=0; i <= last_timer_raw; i++)
{
s_timer_entry *row = (timers+i);
- if (row->state & TIMER_ARMED) // if row is active
+ if (row->state & TIMER_ARMED) /* if row is active */
{
- if (row->val <= real_total_sleep_time) // to be trigged
+ if (row->val <= real_total_sleep_time) /* to be trigged */
{
- //printf("row->val(%d) <= (%d)real_total_sleep_time\n", row->val, real_total_sleep_time);
- if (!row->interval) // if simply outdated
+ /*printf("row->val(%d) <= (%d)real_total_sleep_time\n", row->val, real_total_sleep_time); */
+ if (!row->interval) /* if simply outdated */
{
- row->state = TIMER_TRIG; // ask for trig
+ row->state = TIMER_TRIG; /* ask for trig */
}
- else // or period have expired
+ else /* or period have expired */
{
- // set val as interval, with overrun correction
+ /* set val as interval, with overrun correction */
row->val = row->interval - (overrun % row->interval);
- row->state = TIMER_TRIG_PERIOD; // ask for trig, periodic
- // Check if this new timer value is the soonest
+ row->state = TIMER_TRIG_PERIOD; /* ask for trig, periodic */
+ /* Check if this new timer value is the soonest */
next_wakeup = minval(row->val,next_wakeup);
}
}
else
{
- // Each armed timer value in decremented.
+ /* Each armed timer value in decremented. */
row->val -= real_total_sleep_time;
- // Check if this new timer value is the soonest
+ /* Check if this new timer value is the soonest */
next_wakeup = minval(row->val,next_wakeup);
}
}
}
- // Remember how much time we should sleep.
+ /* Remember how much time we should sleep. */
total_sleep_time = next_wakeup;
- // Set timer to soonest occurence
+ /* Set timer to soonest occurence */
setTimer(next_wakeup);
- // Then trig them or not.
+ /* Then trig them or not. */
for(i=0; i<=last_timer_raw; i++)
{
s_timer_entry *row = (timers+i);
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 !
+ row->state &= ~TIMER_TRIG; /* reset trig state (will be free if not periodic) */
+ (*row->callback)(row->d, row->id); /* trig ! */
}
}
}