Ignore:
Timestamp:
01/23/03 13:32:58 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/candrv/canopen.cc

    r1275 r1727  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz <mailto:tbretz@uni-sw.gwdg.de>, 2001
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2001
     18!   Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>, 2003
     19!
     20!   Copyright: MAGIC Software Development, 2000-2003
    2121!
    2222!
     
    8484{
    8585    const WORD_t fcode = cobid >> 7;
     86    const BYTE_t  node = cobid & 0x1f;
    8687
    8788    switch (fcode)
     
    9495        return;
    9596
    96     case kSYNC:
    97         cout << "Sync" << endl;
     97    case kEMERGENCY: // also case kSYNC:
     98        if (cobid==0)
     99            cout << "Sync" << endl;
     100        else
     101        {
     102            cout << "EMERGENCY Node #" << dec << (int)data[1] << endl;
     103            HandleEmergency(node, tv);
     104        }
     105        return;
     106
     107    case kNodeguard:
     108        //cout << "Nodeguard Node #" << dec << (int)node << endl;
     109        HandleNodeguard(node, tv);
    98110        return;
    99111
    100112    case kSDO_RX:
    101113        {
    102             const BYTE_t  node   = cobid & 0x1f;
    103114            const BYTE_t  cmd    = data[0];
    104115            const LWORD_t dat    = data[4] | (data[5]<<8) | (data[6]<<16) | (data[7]<<24);
     
    114125    case kPDO1_TX:
    115126        {
    116             const BYTE_t node = cobid & 0x1f;
    117127            HandlePDO1(node, data, tv);
    118128            pthread_cond_broadcast(&fPdoCond[node-1][0]);
     
    122132    case kPDO2_TX:
    123133        {
    124             const BYTE_t node = cobid & 0x1f;
    125134            HandlePDO2(node, data, tv);
    126135            pthread_cond_broadcast(&fPdoCond[node-1][1]);
     
    130139    case kPDO3_TX:
    131140        {
    132             const BYTE_t node = cobid & 0x1f;
    133141            HandlePDO3(node, data, tv);
    134142            pthread_cond_broadcast(&fPdoCond[node-1][2]);
     
    138146    case kPDO4_TX:
    139147        {
    140             const BYTE_t node = cobid & 0x1f;
    141148            HandlePDO4(node, data, tv);
    142149            pthread_cond_broadcast(&fPdoCond[node-1][3]);
     
    145152    }
    146153
    147     const BYTE_t node = cobid & 0x1f;
    148     cout << "Function Code: 0x" << hex << fcode << "  Node: " << dec << (int)node << endl;
     154    cout << "CanOpen::HandleCanMessage - Unhandled Message: Function Code=0x" << hex << fcode << "  Node #" << dec << (int)node << endl;
    149155}
    150156
     
    168174{
    169175    EnableCanMsg(node, kEMERGENCY);
     176}
     177
     178// --------------------------------------------------------------------------
     179//
     180// Enables Nodeguard messages for a given node
     181//
     182void CanOpen::EnableNodeguard(BYTE_t node)
     183{
     184    EnableCanMsg(node, kNodeguard);
    170185}
    171186
     
    372387// --------------------------------------------------------------------------
    373388//
    374 // Send an NMT Message to the given node with command cmd
     389// Send a NMT Message to the given node with command cmd
    375390//
    376391void CanOpen::SendNMT(BYTE_t node, BYTE_t cmd)
     
    381396// --------------------------------------------------------------------------
    382397//
     398// Send a Nodeguard Message to the given node with command cmd
     399//
     400void CanOpen::SendNodeguard(BYTE_t node)
     401{
     402    BYTE_t msg[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
     403    SendCanFrame(CobId(node, kNodeguard), msg, 1);
     404}
     405
     406// --------------------------------------------------------------------------
     407//
    383408// Decodes node and function code into a CobId
    384409//
Note: See TracChangeset for help on using the changeset viewer.