src/states.c
author etisserant
Sat, 12 May 2007 22:43:30 +0200
changeset 192 9dd6f17ef7e5
parent 183 4cddad17c81f
child 195 1510dd61ead0
permissions -rw-r--r--
Wolfgang enhancements for RT-socket-CAN support
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
#include "states.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#include "def.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
#include "nmtSlave.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    28
/* Prototypes for internals functions */
53
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
    29
void switchCommunicationState(CO_Data* d, 
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
    30
	s_state_communication *newCommunicationState);
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
    31
	
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
    32
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
e_nodeState getState(CO_Data* d)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
  return d->nodeState;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
53
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
    38
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
void canDispatch(CO_Data* d, Message *m)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
	 switch(m->cob_id.w >> 7)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
		case SYNC:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    44
			if(d->CurrentCommunicationState.csSYNC)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    45
				proceedSYNC(d,m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
			break;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    47
		/* case TIME_STAMP: */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
		case PDO1tx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
		case PDO1rx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
		case PDO2tx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
		case PDO2rx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
		case PDO3tx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
		case PDO3rx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
		case PDO4tx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
		case PDO4rx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
			if (d->CurrentCommunicationState.csPDO)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
				proceedPDO(d,m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
		case SDOtx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
		case SDOrx:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
			if (d->CurrentCommunicationState.csSDO)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
				proceedSDO(d,m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
		case NODE_GUARD:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    65
			if (d->CurrentCommunicationState.csHeartbeat)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    66
				proceedNODE_GUARD(d,m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
		case NMT:
88
b6e0b91d073a pointer bogue for *(d->iam_a_slave)
frdupin
parents: 71
diff changeset
    69
			if (*(d->iam_a_slave))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
			{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
				proceedNMTstateChange(d,m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
			}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
#define StartOrStop(CommType, FuncStart, FuncStop) \
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
	if(newCommunicationState->CommType && !d->CurrentCommunicationState.CommType){\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
		MSG_ERR(0x9999,#FuncStart, 9999);\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
		d->CurrentCommunicationState.CommType = 1;\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
		FuncStart;\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
	}else if(!newCommunicationState->CommType && d->CurrentCommunicationState.CommType){\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
		MSG_ERR(0x9999,#FuncStop, 9999);\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
		d->CurrentCommunicationState.CommType = 0;\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
		FuncStop;\
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
#define None
53
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
    87
	
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
    88
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
void switchCommunicationState(CO_Data* d, s_state_communication *newCommunicationState)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
	StartOrStop(csSDO,	None,		resetSDO(d))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
	StartOrStop(csSYNC,	startSYNC(d),		stopSYNC(d))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
	StartOrStop(csHeartbeat,	heartbeatInit(d),	heartbeatStop(d))
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    94
/*	StartOrStop(Emergency,,) */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
	StartOrStop(csPDO,	None,	None)
14
1fbdf88163b3 d?placement de l'envoi du bootup
dejoigny
parents: 0
diff changeset
    96
	StartOrStop(csBoot_Up,	None,	slaveSendBootUp(d))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
53
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
    99
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
UNS8 setState(CO_Data* d, e_nodeState newState)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
{
183
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   102
	UNS16 wIndex = 0x1F22;
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   103
	const indextable *ptrTable;
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   104
  	ODCallback_t *Callback;
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   105
	UNS32 errorCode;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
	while(newState != d->nodeState){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
		switch( newState ){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
			case Initialisation:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
			{
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   110
				s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0};
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   111
				/* This will force a second loop for the state switch */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
				d->nodeState = Initialisation;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
				newState = Pre_operational;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
				switchCommunicationState(d, &newCommunicationState);
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   115
				/* call user app related state func. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
				(*d->initialisation)();
178
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   117
				
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
			}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
								
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
			case Pre_operational:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
			{
178
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   123
				
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   124
				s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 0};
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
				d->nodeState = Pre_operational;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
				newState = Pre_operational;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
				switchCommunicationState(d, &newCommunicationState);
178
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   128
				if (!(*(d->iam_a_slave)))
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   129
				{
183
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   130
					ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   131
  					
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   132
  					if (errorCode != OD_SUCCESSFUL)
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   133
  						{
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   134
  							(*d->preOperational)();
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   135
  						}
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   136
					else
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   137
						{
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   138
							UNS32 res;
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   139
							res = decompo_dcf(d,0x01);
4cddad17c81f Test if index 1F22 exists for Master OD (Concise DCF)
greg
parents: 178
diff changeset
   140
						}				
178
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   141
				}
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   142
				else 
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   143
				{
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   144
					(*d->preOperational)();
01d81faa3350 Add concise DCF support
greg
parents: 152
diff changeset
   145
				}
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
			}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   147
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
								
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
			case Operational:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
			if(d->nodeState == Initialisation) return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
			{
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   152
				s_state_communication newCommunicationState = {0, 1, 1, 1, 1, 1};
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
				d->nodeState = Operational;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
				newState = Operational;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
				switchCommunicationState(d, &newCommunicationState);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
				(*d->operational)();
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
			}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
						
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
			case Stopped:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
			if(d->nodeState == Initialisation) return 0xFF;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
			{
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   163
				s_state_communication newCommunicationState = {0, 0, 0, 0, 1, 0};
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
				d->nodeState = Stopped;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
				newState = Stopped;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
				switchCommunicationState(d, &newCommunicationState);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
				(*d->stopped)();
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
			}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
			
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
			default:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
				return 0xFF;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   173
		}/* end switch case */
94
bdf4c86be6b2 Removed all non-supported and uncontrolled source code. Please refer to CVS version "Before_..." to see old code.
etisserant
parents: 88
diff changeset
   174
	
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
	return 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
53
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
   179
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   180
UNS8 getNodeId(CO_Data* d)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   181
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   182
  return *d->bDeviceNodeId;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   183
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   184
53
73bc47a0db55 Add prototypes
frdupin
parents: 14
diff changeset
   185
/*****************************************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   186
void setNodeId(CO_Data* d, UNS8 nodeId)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
  UNS16 offset = d->firstIndex->SDO_SVR;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
  if(offset){
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   190
      /* cob_id_client = 0x600 + nodeId; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
      *(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + nodeId;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   192
      /* cob_id_server = 0x580 + nodeId; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
      *(UNS32*)d->objdict[offset].pSubindex[2].pObject = 0x580 + nodeId;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   194
      /* node Id client. As we do not know the value, we put the node Id Server */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   195
      /* *(UNS8*)d->objdict[offset].pSubindex[3].pObject = nodeId; */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   197
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   198
  /* ** Initialize the server(s) SDO parameters */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   199
  /* Remember that only one SDO server is allowed, defined at index 0x1200 */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
 
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   201
  /* ** Initialize the client(s) SDO parameters  */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   202
  /* Nothing to initialize (no default values required by the DS 401) */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   203
  /* ** Initialize the receive PDO communication parameters. Only for 0x1400 to 0x1403 */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   204
  {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   205
    UNS8 i = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
    UNS16 offset = d->firstIndex->PDO_RCV;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
    UNS16 lastIndex = d->lastIndex->PDO_RCV;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
    UNS32 cobID[] = {0x200, 0x300, 0x400, 0x500};
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
    if( offset ) while( (offset <= lastIndex) && (i < 4)) {
152
5e14844e5756 Now, setNodeId does change TPDO and RPDO CobId without testing previous CobId in order to avoid confusion. Standard does not says when 'default value' should be applied. See DS301 - Object 1400h - 15FFh: Receive PDO Communication Parameter page 108.
etisserant
parents: 149
diff changeset
   210
      //if(*(UNS32*)d->objdict[offset].pSubindex[1].pObject == cobID[i] + *d->bDeviceNodeId)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
	      *(UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
      i ++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
      offset ++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
  }
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   216
  /* ** Initialize the transmit PDO communication parameters. Only for 0x1800 to 0x1803 */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   217
  {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   218
    UNS8 i = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
    UNS16 offset = d->firstIndex->PDO_TRS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   220
    UNS16 lastIndex = d->lastIndex->PDO_TRS;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
    UNS32 cobID[] = {0x180, 0x280, 0x380, 0x480};
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   222
    i = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
    if( offset ) while ((offset <= lastIndex) && (i < 4)) {
152
5e14844e5756 Now, setNodeId does change TPDO and RPDO CobId without testing previous CobId in order to avoid confusion. Standard does not says when 'default value' should be applied. See DS301 - Object 1400h - 15FFh: Receive PDO Communication Parameter page 108.
etisserant
parents: 149
diff changeset
   224
      //if(*(UNS32*)d->objdict[offset].pSubindex[1].pObject == cobID[i] + *d->bDeviceNodeId)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
	      *(UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   226
      i ++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   227
      offset ++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   228
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   229
  }
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
   230
  /* bDeviceNodeId is defined in the object dictionary. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   231
  *d->bDeviceNodeId = nodeId;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   232
}
149
fe50ada8020b Changes in the API:
etisserant
parents: 94
diff changeset
   233
fe50ada8020b Changes in the API:
etisserant
parents: 94
diff changeset
   234
void _initialisation(){}
fe50ada8020b Changes in the API:
etisserant
parents: 94
diff changeset
   235
void _preOperational(){}
fe50ada8020b Changes in the API:
etisserant
parents: 94
diff changeset
   236
void _operational(){}
fe50ada8020b Changes in the API:
etisserant
parents: 94
diff changeset
   237
void _stopped(){}