examples/TestMasterSlave/Master.c
author greg
Mon, 30 Apr 2007 16:56:21 +0200
changeset 176 5d57fe1e3a5b
parent 175 e255529b6f7d
child 179 763b6d32c1a6
permissions -rw-r--r--
Support for DCF (DS-302)
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 "Master.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#include "Slave.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
#include "TestMasterSlave.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
/*****************************************************************************/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
void TestMaster_heartbeatError(UNS8 heartbeatID)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
	eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    33
/********************************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    34
 * ConfigureSlaveNode is responsible to
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    35
 *  - setup master RPDO 1 to receive TPDO 1 from id 2
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    36
 *  - setup master RPDO 2 to receive TPDO 2 from id 2
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    37
 ********************************************************/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
void TestMaster_initialisation()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
{
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    40
	UNS32 PDO1_COBID = 0x0182; 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    41
	UNS32 PDO2_COBID = 0x0282;
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    42
	UNS8 size = sizeof(UNS32); 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    43
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    44
	eprintf("TestMaster_initialisation\n");
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    45
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    46
	/*****************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    47
	 * Define RPDOs to match slave ID=2 TPDOs*
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    48
	 *****************************************/
175
e255529b6f7d Added writeLocalDict and readLocalDict, that have to be called from application instead of getODEntry and setODEntry. Fix potential endianization problem.
etisserant
parents: 172
diff changeset
    49
	writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    50
			0x1400, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    51
			0x01, /*UNS8 subind*/ 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    52
			&PDO1_COBID, /*void * pSourceData,*/ 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    53
			&size, /* UNS8 * pExpectedSize*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    54
			RW);  /* UNS8 checkAccess */
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    55
			
175
e255529b6f7d Added writeLocalDict and readLocalDict, that have to be called from application instead of getODEntry and setODEntry. Fix potential endianization problem.
etisserant
parents: 172
diff changeset
    56
	writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    57
			0x1401, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    58
			0x01, /*UNS8 subind*/ 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    59
			&PDO2_COBID, /*void * pSourceData,*/ 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    60
			&size, /* UNS8 * pExpectedSize*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    61
			RW);  /* UNS8 checkAccess */
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    62
}
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    63
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    64
/********************************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    65
 * ConfigureSlaveNode is responsible to
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    66
 *  - setup slave TPDO 1 transmit time
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    67
 *  - setup slave TPDO 2 transmit time
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    68
 *  - switch to operational mode
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    69
 *  - send NMT to slave
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    70
 ********************************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    71
 * This an example of :
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    72
 * Network Dictionary Access (SDO) with Callback 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    73
 * Slave node state change request (NMT) 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    74
 ********************************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    75
 * This is called first by TestMaster_preOperational
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    76
 * then it called again each time a SDO exchange is
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    77
 * finished.
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    78
 ********************************************************/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    79
static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId)
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    80
{
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    81
	// Step counts number of times ConfigureSlaveNode is called
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    82
	static step = 1;
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    83
	
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    84
	UNS8 Transmission_Type = 0x01; 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    85
	UNS32 abortCode;
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    86
	UNS8 res;
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    87
	eprintf("Master : ConfigureSlaveNode %2.2x\n", nodeId);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    88
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    89
	switch(step++){
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    90
		case 1: /*First step : setup Slave's TPDO 1 to be transmitted on SYNC*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    91
			eprintf("Master : set slave %2.2x TPDO 1 transmit type\n", nodeId);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    92
			res = writeNetworkDictCallBack (d, /*CO_Data* d*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    93
					*TestSlave_Data.bDeviceNodeId, /*UNS8 nodeId*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    94
					0x1800, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    95
					0x02, /*UNS8 subindex*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    96
					1, /*UNS8 count*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    97
					0, /*UNS8 dataType*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    98
					&Transmission_Type,/*void *data*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    99
					ConfigureSlaveNode); /*SDOCallback_t Callback*/			break;
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   100
		case 2:	/*Second step*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   101
			/*check and warn for previous slave OD access error*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   102
			if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   103
				eprintf("Master : Couldn't set slave %2.2x TPDO 1 transmit type. AbortCode :%4.4x \n", nodeId, abortCode);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   104
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   105
			/* Finalise last SDO transfer with this node */
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   106
			closeSDOtransfer(&TestMaster_Data,
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   107
					*TestSlave_Data.bDeviceNodeId,
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   108
					SDO_CLIENT);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   109
					
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   110
			/*Setup Slave's TPDO 1 to be transmitted on SYNC*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   111
			eprintf("Master : set slave %2.2x TPDO 2 transmit type\n", nodeId);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   112
			writeNetworkDictCallBack (d, /*CO_Data* d*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   113
					*TestSlave_Data.bDeviceNodeId, /*UNS8 nodeId*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   114
					0x1801, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   115
					0x02, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   116
					1, /*UNS8 count*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   117
					0, /*UNS8 dataType*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   118
					&Transmission_Type,/*void *data*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   119
					ConfigureSlaveNode); /*SDOCallback_t Callback*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   120
			break;
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   121
		case 3: /*Last step*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   122
			/*check and warn for previous slave OD access error*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   123
			if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   124
				eprintf("Master : Couldn't set slave %2.2x TPDO 2 transmit type. AbortCode :%4.4x \n", nodeId, abortCode);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   125
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   126
			/* Finalise last SDO transfer with this node */
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   127
			closeSDOtransfer(&TestMaster_Data,
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   128
					*TestSlave_Data.bDeviceNodeId,
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   129
					SDO_CLIENT);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   130
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   131
			/* Put the master in operational mode */
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   132
			setState(d, Operational);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   133
			  
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   134
			/* Ask slave node to go in operational mode */
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   135
			masterSendNMTstateChange (d, nodeId, NMT_Start_Node);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   136
	}
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   137
			
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
void TestMaster_preOperational()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
{
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   142
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
	eprintf("TestMaster_preOperational\n");
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   144
	ConfigureSlaveNode(&TestMaster_Data, 2);
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
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
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
void TestMaster_operational()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
	eprintf("TestMaster_operational\n");
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
void TestMaster_stopped()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
	eprintf("TestMaster_stopped\n");
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
void TestMaster_post_sync()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
	eprintf("TestMaster_post_sync\n");
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
	eprintf("Master: %d %d %d %d\n",MasterMap1, MasterMap2, MasterMap3, MasterMap4);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
char query_result = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
char waiting_answer = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
void TestMaster_post_TPDO()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
	eprintf("TestMaster_post_TPDO\n");
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
//	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
//		char zero = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   173
//		if(MasterMap4 > 0x80){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   174
//			writeNetworkDict (
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
//				&TestMaster_Data,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
//				TestSlave_Data->bDeviceNodeId,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
//				0x2002,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
//				0x00,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   179
//				1,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   180
//				0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   181
//				&zero); 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   182
//		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   183
//	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   184
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
	if(waiting_answer){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   186
		UNS32 abortCode;			
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
		UNS8 size;			
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
		switch(getReadResultNetworkDict (
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
			&TestMaster_Data, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
			*TestSlave_Data.bDeviceNodeId,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
			&query_result,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
			&size,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
			&abortCode))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   195
			case SDO_FINISHED:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
				/* Do something with result here !!*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   197
				eprintf("Got SDO answer (0x2002, 0x00), %d %d\n",query_result,size);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   198
			case SDO_ABORTED_RCV:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   199
			case SDO_ABORTED_INTERNAL:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
			case SDO_RESET:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
				waiting_answer = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   202
				closeSDOtransfer(
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   203
					&TestMaster_Data,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   204
					*TestSlave_Data.	bDeviceNodeId,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   205
					SDO_CLIENT);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
			case SDO_DOWNLOAD_IN_PROGRESS:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
			case SDO_UPLOAD_IN_PROGRESS:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
	}else if(MasterMap1 % 10 == 0){
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
		readNetworkDict (
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
			&TestMaster_Data,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
			*TestSlave_Data.bDeviceNodeId,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
			0x2002,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   216
			0x00,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   217
			0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   218
		waiting_answer = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   220
		
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
}