examples/TestMasterSlaveLSS/SlaveA.c
author Edouard Tisserant
Wed, 13 Jun 2012 19:07:41 +0200
changeset 738 396839c5d70f
parent 517 003679edc437
permissions -rw-r--r--
Merged Francois BEAULIER's changes
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     1
/*
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     3
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     5
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     6
See COPYING file for copyrights details.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     7
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    12
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    16
Lesser General Public License for more details.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    17
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    21
*/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    22
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    23
#include "SlaveA.h"
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    24
#include "Master.h"
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    25
#include "TestMasterSlaveLSS.h"
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    26
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    27
/*****************************************************************************/
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    28
void TestSlaveA_heartbeatError(CO_Data* d, UNS8 heartbeatID)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    29
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    30
	eprintf("TestSlaveA_heartbeatError %d\n", heartbeatID);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    31
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    32
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    33
void TestSlaveA_initialisation(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    34
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    35
	eprintf("TestSlaveA_initialisation\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    36
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    37
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    38
void TestSlaveA_preOperational(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    39
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    40
	eprintf("TestSlaveA_preOperational\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    41
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    42
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    43
void TestSlaveA_operational(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    44
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    45
	eprintf("TestSlaveA_operational\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    46
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    47
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    48
void TestSlaveA_stopped(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    49
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    50
	eprintf("TestSlaveA_stopped\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    51
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    52
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    53
void TestSlaveA_post_sync(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    54
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    55
      eprintf("TestSlaveA_post_sync\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    56
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    57
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    58
void TestSlaveA_post_TPDO(CO_Data* d)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    59
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    60
	eprintf("TestSlaveA_post_TPDO\n");
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    61
	SlaveAMap1++;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    62
	SlaveAMap2+=2;
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    63
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    64
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    65
void TestSlaveA_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    66
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    67
	/*TODO : 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    68
	 * - call getODEntry for index and subindex, 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    69
	 * - save content to file, database, flash, nvram, ...
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    70
	 * 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    71
	 * To ease flash organisation, index of variable to store
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    72
	 * can be established by scanning d->objdict[d->ObjdictSize]
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    73
	 * for variables to store.
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    74
	 * 
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    75
	 * */
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    76
	eprintf("TestSlaveA_storeODSubIndex : %4.4x %2.2x\n", wIndex,  bSubindex);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    77
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    78
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    79
void TestSlaveA_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    80
{
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    81
	eprintf("SlaveA received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    82
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    83
517
003679edc437 FastScan review
groke6
parents: 384
diff changeset
    84
void TestSlaveA_NMT_Slave_Communications_Reset_Callback(CO_Data* d)
003679edc437 FastScan review
groke6
parents: 384
diff changeset
    85
{
003679edc437 FastScan review
groke6
parents: 384
diff changeset
    86
	eprintf("TestSlaveA_NMT_Slave_Communications_Reset_Callback\n");
003679edc437 FastScan review
groke6
parents: 384
diff changeset
    87
}
003679edc437 FastScan review
groke6
parents: 384
diff changeset
    88
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    89
void TestSlaveA_StoreConfiguration(CO_Data* d, UNS8 *error, UNS8 *spec_error)
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    90
{
517
003679edc437 FastScan review
groke6
parents: 384
diff changeset
    91
	eprintf("TestSlaveA_StoreConfiguration\n");
381
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    92
}
854c43cdc24a added TestMasterSlaveLSS. LSS protocol revised.
groke6
parents:
diff changeset
    93