examples/TestMasterSlave/Master.c
author Edouard Tisserant
Thu, 24 Jan 2019 13:53:01 +0100
changeset 808 de1fc3261f21
parent 664 a03f0aa7d219
permissions -rw-r--r--
Adding -fPIC isn't necessary of xeno-config is set correctly. Backed out changeset b9f1fcda7d30
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
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents: 378
diff changeset
    27
extern s_BOARD MasterBoard;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
/*****************************************************************************/
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
    29
void TestMaster_heartbeatError(CO_Data* d, UNS8 heartbeatID)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
	eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    34
/********************************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    35
 * ConfigureSlaveNode is responsible to
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    36
 *  - 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
    37
 *  - 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
    38
 ********************************************************/
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
    39
void TestMaster_initialisation(CO_Data* d)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
{
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    41
	UNS32 PDO1_COBID = 0x0182; 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    42
	UNS32 PDO2_COBID = 0x0282;
540
6857b6ffb7a7 Removed some warnings.
etisserant
parents: 496
diff changeset
    43
	UNS32 size = sizeof(UNS32); 
362
1134fc19aa74 Added FastScan support to the LSS services.
groke6
parents: 349
diff changeset
    44
	UNS32 SINC_cicle=0;
1134fc19aa74 Added FastScan support to the LSS services.
groke6
parents: 349
diff changeset
    45
	UNS8 data_type = 0;
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    46
	
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
	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
    48
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    49
	/*****************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    50
	 * 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
    51
	 *****************************************/
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
    52
	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
    53
			0x1400, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    54
			0x01, /*UNS8 subind*/ 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    55
			&PDO1_COBID, /*void * pSourceData,*/ 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    56
			&size, /* UNS8 * pExpectedSize*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    57
			RW);  /* UNS8 checkAccess */
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    58
			
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
    59
	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
    60
			0x1401, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    61
			0x01, /*UNS8 subind*/ 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    62
			&PDO2_COBID, /*void * pSourceData,*/ 
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    63
			&size, /* UNS8 * pExpectedSize*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    64
			RW);  /* UNS8 checkAccess */
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents: 378
diff changeset
    65
					
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    66
}
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    67
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    68
// Step counts number of times ConfigureSlaveNode is called
454
bc000083297a - add RTAI support
greg
parents: 381
diff changeset
    69
static int init_step = 0;
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    70
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    71
/*Froward declaration*/
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    72
static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId);
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    73
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    74
/**/
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    75
static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    76
{
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    77
	UNS32 abortCode;	
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    78
	if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    79
		eprintf("Master : Failed in initializing slave %2.2x, step %d, AbortCode :%4.4x \n", nodeId, init_step, abortCode);
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    80
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    81
	/* Finalise last SDO transfer with this node */
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    82
	closeSDOtransfer(&TestMaster_Data, nodeId, SDO_CLIENT);
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    83
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    84
	ConfigureSlaveNode(d, nodeId);
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    85
}
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
    86
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    87
/********************************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    88
 * ConfigureSlaveNode is responsible to
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents: 378
diff changeset
    89
 *  - setup slave TPDO 1 transmit type
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents: 378
diff changeset
    90
 *  - setup slave TPDO 2 transmit type
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    91
 *  - switch to operational mode
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    92
 *  - send NMT to slave
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    93
 ********************************************************
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    94
 * This an example of :
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    95
 * 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
    96
 * 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
    97
 ********************************************************
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents: 378
diff changeset
    98
 * This is called first by TestMaster_post_SlaveBootup
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
    99
 * 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
   100
 * finished.
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   101
 ********************************************************/
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   102
 
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   103
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
   104
{
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   105
	/* Master configure heartbeat producer time at 1000 ms 
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   106
	 * for slave node-id 0x02 by DCF concise */
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   107
	 
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   108
	UNS8 Transmission_Type = 0x01;
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   109
	UNS8 res;
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   110
	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
   111
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   112
	switch(++init_step){
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   113
		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
   114
			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
   115
			res = writeNetworkDictCallBack (d, /*CO_Data* d*/
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   116
					nodeId, /*UNS8 nodeId*/
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   117
					0x1800, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   118
					0x02, /*UNS8 subindex*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   119
					1, /*UNS8 count*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   120
					0, /*UNS8 dataType*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   121
					&Transmission_Type,/*void *data*/
664
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   122
					CheckSDOAndContinue, /*SDOCallback_t Callback*/
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   123
                    0); /* use block mode */
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   124
					break;
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   125
		
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   126
		case 2:	/*Second step*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   127
			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
   128
			writeNetworkDictCallBack (d, /*CO_Data* d*/
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   129
					nodeId, /*UNS8 nodeId*/
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   130
					0x1801, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   131
					0x02, /*UNS16 index*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   132
					1, /*UNS8 count*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   133
					0, /*UNS8 dataType*/
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   134
					&Transmission_Type,/*void *data*/
664
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   135
					CheckSDOAndContinue, /*SDOCallback_t Callback*/
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   136
                    0); /* use block mode */
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   137
					break;
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   138
		case 3: 
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   139
		
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   140
		/****************************** START *******************************/
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
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
			/* 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
   143
			setState(d, Operational);
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   144
		 
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   145
			/* 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
   146
			masterSendNMTstateChange (d, nodeId, NMT_Start_Node);
179
763b6d32c1a6 Master configure slave's heartbeat producer time by concise DCF.
greg
parents: 175
diff changeset
   147
			
154
1b3165f2d17d Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents: 149
diff changeset
   148
	}
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents: 284
diff changeset
   151
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
   152
void TestMaster_preOperational(CO_Data* d)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
	eprintf("TestMaster_preOperational\n");
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
   157
void TestMaster_operational(CO_Data* d)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
	eprintf("TestMaster_operational\n");
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
   162
void TestMaster_stopped(CO_Data* d)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
	eprintf("TestMaster_stopped\n");
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
   167
void TestMaster_post_sync(CO_Data* d)
0
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_sync\n");
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   170
	eprintf("Master: %d %d %d %d %d %d %d %d %d %x %x %d %d\n",
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   171
		MasterMap1,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   172
		MasterMap2,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   173
		MasterMap3, 
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   174
		MasterMap4,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   175
		MasterMap5,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   176
		MasterMap6,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   177
		MasterMap7,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   178
		MasterMap8,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   179
		MasterMap9,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   180
		MasterMap10,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   181
		MasterMap11,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   182
		MasterMap12,
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   183
		MasterMap13);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   184
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
   186
void TestMaster_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
284
24bf3d692993 Implemented EMCY objects.
luis
parents: 236
diff changeset
   187
{
24bf3d692993 Implemented EMCY objects.
luis
parents: 236
diff changeset
   188
	eprintf("Master received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
24bf3d692993 Implemented EMCY objects.
luis
parents: 236
diff changeset
   189
}
24bf3d692993 Implemented EMCY objects.
luis
parents: 236
diff changeset
   190
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
char query_result = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
char waiting_answer = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   194
static void CheckSDO(CO_Data* d, UNS8 nodeId)
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   195
{
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   196
	UNS32 abortCode;	
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   197
	if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   198
		eprintf("Master : Failed in changing Slave's transmit type AbortCode :%4.4x \n", abortCode);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   199
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   200
	/* Finalise last SDO transfer with this node */
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   201
	closeSDOtransfer(&TestMaster_Data, nodeId, SDO_CLIENT);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   202
}
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   203
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   204
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   205
static int MasterSyncCount = 0;
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
   206
void TestMaster_post_TPDO(CO_Data* d)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
{
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   208
	eprintf("TestMaster_post_TPDO MasterSyncCount = %d \n", MasterSyncCount);
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   209
	if(MasterSyncCount % 17 == 0){
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   210
		eprintf("Master : Ask RTR PDO (0x1402)\n");
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   211
		sendPDOrequest(&TestMaster_Data, 0x1402 );
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   212
		sendPDOrequest(&TestMaster_Data, 0x1403 );
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   213
	}
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   214
	if(MasterSyncCount % 50 == 0){
592
b98df76c6fd5 fix warnings with msvc compiler
greg
parents: 540
diff changeset
   215
		UNS8 transmitiontype;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   216
		eprintf("Master : Change slave's transmit type to 0xFF\n");
592
b98df76c6fd5 fix warnings with msvc compiler
greg
parents: 540
diff changeset
   217
		transmitiontype = 0xFF;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   218
		writeNetworkDictCallBack (&TestMaster_Data, /*CO_Data* d*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   219
					2, /*UNS8 nodeId*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   220
					0x1802, /*UNS16 index*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   221
					0x02, /*UNS16 index*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   222
					1, /*UNS8 count*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   223
					0, /*UNS8 dataType*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   224
					&transmitiontype,/*void *data*/
664
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   225
					CheckSDO, /*SDOCallback_t Callback*/
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   226
                    0); /* use block mode */
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   227
	}   
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   228
	if(MasterSyncCount % 50 == 25){
592
b98df76c6fd5 fix warnings with msvc compiler
greg
parents: 540
diff changeset
   229
		UNS8 transmitiontype = 0x00;
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   230
		eprintf("Master : Change slave's transmit type to 0x00\n");
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   231
		writeNetworkDictCallBack (&TestMaster_Data, /*CO_Data* d*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   232
					2, /*UNS8 nodeId*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   233
					0x1802, /*UNS16 index*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   234
					0x02, /*UNS16 index*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   235
					1, /*UNS8 count*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   236
					0, /*UNS8 dataType*/
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   237
					&transmitiontype,/*void *data*/
664
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   238
					CheckSDO, /*SDOCallback_t Callback*/
a03f0aa7d219 CHANGE: SDO block mode added, without CRC support
fbeaulier
parents: 592
diff changeset
   239
                    0); /* use block mode */
236
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   240
	}
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   241
	MasterSyncCount++;
905677ed00f3 Full preliminary implementation of TPDO transmit type:
etisserant
parents: 201
diff changeset
   242
}
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents: 284
diff changeset
   243
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 362
diff changeset
   244
void TestMaster_post_SlaveBootup(CO_Data* d, UNS8 nodeid)
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents: 284
diff changeset
   245
{
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents: 284
diff changeset
   246
	eprintf("TestMaster_post_SlaveBootup %x\n", nodeid);
362
1134fc19aa74 Added FastScan support to the LSS services.
groke6
parents: 349
diff changeset
   247
	
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents: 378
diff changeset
   248
	ConfigureSlaveNode(d, nodeid);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents: 378
diff changeset
   249
}