nico@207: nico@207: nico@215: CanFestival: src/nmtMaster.c Source File nico@207: nico@207: nico@207: nico@207: nico@207:
nico@207:
nico@207:
nico@207:
nico@215: nico@215:

nmtMaster.c

Go to the documentation of this file.
00001 /*
nico@210: 00002   This file is part of CanFestival, a library implementing CanOpen
nico@210: 00003   Stack.
nico@210: 00004 
nico@210: 00005   Copyright (C): Edouard TISSERANT and Francis DUPIN
nico@210: 00006 
nico@210: 00007   See COPYING file for copyrights details.
nico@210: 00008 
nico@210: 00009   This library is free software; you can redistribute it and/or
nico@210: 00010   modify it under the terms of the GNU Lesser General Public
nico@210: 00011   License as published by the Free Software Foundation; either
nico@210: 00012   version 2.1 of the License, or (at your option) any later version.
nico@210: 00013 
nico@210: 00014   This library is distributed in the hope that it will be useful,
nico@210: 00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
nico@210: 00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
nico@210: 00017   Lesser General Public License for more details.
nico@210: 00018 
nico@210: 00019   You should have received a copy of the GNU Lesser General Public
nico@210: 00020   License along with this library; if not, write to the Free Software
nico@210: 00021   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
nico@210: 00022   USA
nico@210: 00023 */
nico@215: 00033 #include "nmtMaster.h"
nico@215: 00034 #include "canfestival.h"
nico@210: 00035 
etisserant@240: 00045 UNS8 masterSendNMTstateChange(CO_Data* d, UNS8 Node_ID, UNS8 cs)
nico@207: 00046 {
nico@215: 00047   Message m;
nico@210: 00048 
etisserant@240: 00049   MSG_WAR(0x3501, "Send_NMT cs : ", cs);
etisserant@240: 00050   MSG_WAR(0x3502, "    to node : ", Node_ID);
nico@215: 00051   /* message configuration */
etisserant@240: 00052   m.cob_id.w = 0x0000; /*(NMT) << 7*/
etisserant@240: 00053   m.rtr = NOT_A_REQUEST;
etisserant@240: 00054   m.len = 2;
etisserant@240: 00055   m.data[0] = cs;
etisserant@240: 00056   m.data[1] = Node_ID;
nico@210: 00057 
etisserant@240: 00058   return canSend(d->canHandle,&m);
nico@210: 00059 }
nico@210: 00060 
nico@210: 00061 
etisserant@240: 00070 UNS8 masterSendNMTnodeguard(CO_Data* d, UNS8 nodeId)
nico@210: 00071 {
nico@215: 00072   Message m;
nico@210: 00073 
etisserant@240: 00074   MSG_WAR(0x3503, "Send_NODE_GUARD to node : ", nodeId);
nico@210: 00075 
nico@210: 00076   /* message configuration */
etisserant@240: 00077   m.cob_id.w = nodeId | (NODE_GUARD << 7);
etisserant@240: 00078   m.rtr = REQUEST;
etisserant@240: 00079   m.len = 1;
nico@207: 00080 
etisserant@240: 00081   return canSend(d->canHandle,&m);
nico@210: 00082 }
nico@207: 00083 
etisserant@240: 00090 void masterRequestNodeState(CO_Data* d, UNS8 nodeId)
nico@210: 00091 {
nico@215: 00092   /* FIXME: should warn for bad toggle bit. */
nico@215: 00093 
nico@215: 00094   /* NMTable configuration to indicate that the master is waiting
nico@215: 00095     for a Node_Guard frame from the slave whose node_id is ID
nico@215: 00096   */
etisserant@240: 00097   d->NMTable[nodeId] = Unknown_state; /* A state that does not exist
nico@215: 00098                                        */
nico@215: 00099 
nico@215: 00100   if (nodeId == 0) { /* NMT broadcast */
etisserant@240: 00101     UNS8 i = 0;
etisserant@240: 00102     for (i = 0 ; i < NMT_MAX_NODE_ID ; i++) {
etisserant@240: 00103       d->NMTable[i] = Unknown_state;
nico@210: 00104     }
nico@210: 00105   }
etisserant@240: 00106   masterSendNMTnodeguard(d,nodeId);
nico@210: 00107 }
nico@210: 00108 
etisserant@240: 

Generated on Mon Jul 2 19:10:16 2007 for CanFestival by  nico@207: nico@207: doxygen 1.5.1
nico@207: nico@207: