src/nmtMaster.c
author lbessard
Fri, 29 Jun 2007 17:24:27 +0200
changeset 233 6f2936f7fb3f
parent 215 f49e5a6b7804
child 365 9b76e0881beb
permissions -rw-r--r--
Permitting user to type decimal or hexadecimal for integer values
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
     2
  This file is part of CanFestival, a library implementing CanOpen
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
     3
  Stack.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
     5
  Copyright (C): Edouard TISSERANT and Francis DUPIN
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
     7
  See COPYING file for copyrights details.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
     9
  This library is free software; you can redistribute it and/or
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    10
  modify it under the terms of the GNU Lesser General Public
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    11
  License as published by the Free Software Foundation; either
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    12
  version 2.1 of the License, or (at your option) any later version.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    14
  This library is distributed in the hope that it will be useful,
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    15
  but WITHOUT ANY WARRANTY; without even the implied warranty of
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    17
  Lesser General Public License for more details.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    19
  You should have received a copy of the GNU Lesser General Public
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    20
  License along with this library; if not, write to the Free Software
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    21
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    22
  USA
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
*/
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    24
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    25
** @file   nmtMaster.c
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    26
** @author Edouard TISSERANT and Francis DUPIN
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    27
** @date   Tue Jun  5 08:47:18 2007
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    28
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    29
** @brief
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    30
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    31
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    32
*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
#include "nmtMaster.h"
149
fe50ada8020b Changes in the API:
etisserant
parents: 71
diff changeset
    34
#include "canfestival.h"
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    36
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    37
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    38
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    39
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    40
** @param Node_ID
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    41
** @param cs
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    42
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    43
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    44
**/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    45
UNS8 masterSendNMTstateChange(CO_Data* d, UNS8 Node_ID, UNS8 cs)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
  Message m;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
  MSG_WAR(0x3501, "Send_NMT cs : ", cs);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
  MSG_WAR(0x3502, "    to node : ", Node_ID);
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    51
  /* message configuration */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
  m.cob_id.w = 0x0000; /*(NMT) << 7*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
  m.rtr = NOT_A_REQUEST;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
  m.len = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
  m.data[0] = cs;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
  m.data[1] = Node_ID;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    57
149
fe50ada8020b Changes in the API:
etisserant
parents: 71
diff changeset
    58
  return canSend(d->canHandle,&m);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    62
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    63
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    64
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    65
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    66
** @param nodeId
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    67
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    68
** @return
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    69
**/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
UNS8 masterSendNMTnodeguard(CO_Data* d, UNS8 nodeId)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
  Message m;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    73
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
  MSG_WAR(0x3503, "Send_NODE_GUARD to node : ", nodeId);
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    75
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
  /* message configuration */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
  m.cob_id.w = nodeId | (NODE_GUARD << 7);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
  m.rtr = REQUEST;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
  m.len = 1;
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    80
149
fe50ada8020b Changes in the API:
etisserant
parents: 71
diff changeset
    81
  return canSend(d->canHandle,&m);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    84
/*!
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    85
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    86
**
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    87
** @param d
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    88
** @param nodeId
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    89
**/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
void masterRequestNodeState(CO_Data* d, UNS8 nodeId)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
{
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    92
  /* FIXME: should warn for bad toggle bit. */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    94
  /* NMTable configuration to indicate that the master is waiting
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    95
    for a Node_Guard frame from the slave whose node_id is ID
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    96
  */
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
    97
  d->NMTable[nodeId] = Unknown_state; /* A state that does not exist
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 149
diff changeset
    98
                                       */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   100
  if (nodeId == 0) { /* NMT broadcast */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
    UNS8 i = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
    for (i = 0 ; i < NMT_MAX_NODE_ID ; i++) {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
      d->NMTable[i] = Unknown_state;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
  }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
  masterSendNMTnodeguard(d,nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108