etisserant@0: /* etisserant@0: This file is part of CanFestival, a library implementing CanOpen Stack. etisserant@0: etisserant@0: Copyright (C): Edouard TISSERANT and Francis DUPIN etisserant@0: etisserant@0: See COPYING file for copyrights details. etisserant@0: etisserant@0: This library is free software; you can redistribute it and/or etisserant@0: modify it under the terms of the GNU Lesser General Public etisserant@0: License as published by the Free Software Foundation; either etisserant@0: version 2.1 of the License, or (at your option) any later version. etisserant@0: etisserant@0: This library is distributed in the hope that it will be useful, etisserant@0: but WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU etisserant@0: Lesser General Public License for more details. etisserant@0: etisserant@0: You should have received a copy of the GNU Lesser General Public etisserant@0: License along with this library; if not, write to the Free Software etisserant@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA etisserant@0: */ etisserant@0: etisserant@0: #include "nmtMaster.h" etisserant@0: etisserant@0: /******************************************************************************/ etisserant@0: UNS8 masterSendNMTstateChange(CO_Data* d, UNS8 Node_ID, UNS8 cs) etisserant@0: { etisserant@0: Message m; etisserant@0: etisserant@0: MSG_WAR(0x3501, "Send_NMT cs : ", cs); etisserant@0: MSG_WAR(0x3502, " to node : ", Node_ID); etisserant@0: /* message configuration */ etisserant@0: m.cob_id.w = 0x0000; /*(NMT) << 7*/ etisserant@0: m.rtr = NOT_A_REQUEST; etisserant@0: m.len = 2; etisserant@0: m.data[0] = cs; etisserant@0: m.data[1] = Node_ID; etisserant@0: etisserant@0: return (*d->canSend)(&m); etisserant@0: } etisserant@0: etisserant@0: etisserant@0: /****************************************************************************/ etisserant@0: UNS8 masterSendNMTnodeguard(CO_Data* d, UNS8 nodeId) etisserant@0: { etisserant@0: Message m; etisserant@0: etisserant@0: MSG_WAR(0x3503, "Send_NODE_GUARD to node : ", nodeId); etisserant@0: etisserant@0: /* message configuration */ etisserant@0: m.cob_id.w = nodeId | (NODE_GUARD << 7); etisserant@0: m.rtr = REQUEST; etisserant@0: m.len = 1; etisserant@0: etisserant@0: return (*d->canSend)(&m); etisserant@0: } etisserant@0: etisserant@0: /******************************************************************************/ etisserant@0: void masterRequestNodeState(CO_Data* d, UNS8 nodeId) etisserant@0: { etisserant@0: // FIXME: should warn for bad toggle bit. etisserant@0: etisserant@0: /* NMTable configuration to indicate that the master is waiting etisserant@0: * for a Node_Guard frame from the slave whose node_id is ID */ etisserant@0: d->NMTable[nodeId] = Unknown_state; // A state that does not exist etisserant@0: etisserant@0: if (nodeId == 0) { // NMT broadcast etisserant@0: UNS8 i = 0; etisserant@0: for (i = 0 ; i < NMT_MAX_NODE_ID ; i++) { etisserant@0: d->NMTable[i] = Unknown_state; etisserant@0: } etisserant@0: } etisserant@0: masterSendNMTnodeguard(d,nodeId); etisserant@0: } etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: