Ignore:
Timestamp:
01/14/03 12:08:46 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/candrv
Files:
6 edited

Legend:

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

    r1702 r1703  
    237237            lout << "- Setting up Node #" << dec << i << " (";
    238238            lout << fNodes[i]->GetNodeName() << ")" << endl;
    239             fNodes[i]->InitDevice(this);
    240             if (!fNodes[i]->IsZombieNode())
     239            if (fNodes[i]->InitDevice(this))
    241240                fNodeInitialized[i] = TRUE;
    242             /*else
    243                 fNodes[i]=NULL;*/
     241            else
     242                lout << "- " << fNodes[i]->GetNodeName() << ": InitDevice failed." << endl;
    244243        }
    245244    lout << "- All Nodes setup." << endl;
     
    310309bool Network::RebootZombies()
    311310{
     311    bool rc = true;
     312
    312313    lout << "- Trying to reboot all Zombies..." << endl;
    313314    for (int i=0; i<32; i++)
     
    317318                {
    318319                    lout << "- Failed to reboot " << fNodes[i]->GetNodeName() << "." << endl;
    319                     return false;
     320                    rc = false;
    320321                }
    321322
    322     lout << "- All Zombies rebooted." << endl;
    323 
    324     return true;
    325 }
     323    if (rc)
     324        lout << "- All Zombies rebooted." << endl;
     325
     326    return rc;
     327}
     328
     329// --------------------------------------------------------------------------
     330//
     331// Check the connections to all nodes. (This can also mean: Validate
     332// the correct setup, etc)
     333//
     334void Network::CheckConnections()
     335{
     336    for (int i=0; i<32; i++)
     337        if (fNodes[i])
     338            fNodes[i]->CheckConnection();
     339}
     340
  • trunk/MagicSoft/Cosy/candrv/network.h

    r1702 r1703  
    3535
    3636    bool RebootZombies();
     37    void CheckConnections();
    3738
    3839    ClassDef(Network, 0) // collection of nodes (nodedrv)
  • trunk/MagicSoft/Cosy/candrv/nodedrv.cc

    r1702 r1703  
    3030//
    3131// to be overloaded:
    32 //  virtual void InitDevice(Network *net)
     32//  virtual void Init()
    3333//  virtual void StopDevice()
    3434//  virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv)
     
    3939//  virtual void HandlePDO3(BYTE_t *data, timeval_t *tv)
    4040//  virtual void HandlePDO4(BYTE_t *data, timeval_t *tv)
     41//  virtual bool Reboot();
     42//  virtual void CheckConnection();
    4143//
    4244///////////////////////////////////////////////////////////////////////
     
    5658// and the node name. The name is a name for debug output.
    5759//
    58 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0), fIsZombie(kFALSE)
     60NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0), fIsZombie(kTRUE)
    5961{
    6062    if (nodeid>0x1f)
     
    9395{
    9496    fIsZombie = false;
    95     return true;
     97
     98    Init();
     99
     100    return !fIsZombie;
    96101}
    97102
     
    107112//   SDO tx
    108113//
    109 void NodeDrv::InitDevice(Network *net)
     114bool NodeDrv::InitDevice(Network *net)
    110115{
    111116    fNetwork = net;
     
    117122    EnableCanMsg(kSDO_RX);
    118123    EnableCanMsg(kSDO_TX);
     124
     125    fIsZombie = kFALSE;
     126
     127    Init();
     128
     129    return !fIsZombie;
    119130}
    120131
     
    165176// A PDO is carrying up to eight bytes of information.
    166177//
    167 void NodeDrv::SendPDO1(BYTE_t data[8])
    168 {
    169     fNetwork->SendPDO1(fId, data);
     178// The message is not send if the node has the status Zombie.
     179// In this case false is returned, otherwise true
     180//
     181bool NodeDrv::SendPDO1(BYTE_t data[8])
     182{
     183    if (!fIsZombie)
     184        fNetwork->SendPDO1(fId, data);
     185    return !fIsZombie;
    170186}
    171187
     
    175191// A PDO is carrying up to eight bytes of information.
    176192//
    177 void NodeDrv::SendPDO2(BYTE_t data[8])
    178 {
    179     fNetwork->SendPDO2(fId, data);
     193// The message is not send if the node has the status Zombie.
     194// In this case false is returned, otherwise true
     195//
     196bool NodeDrv::SendPDO2(BYTE_t data[8])
     197{
     198    if (!fIsZombie)
     199        fNetwork->SendPDO2(fId, data);
     200    return !fIsZombie;
    180201}
    181202
     
    185206// A PDO is carrying up to eight bytes of information.
    186207//
    187 void NodeDrv::SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
     208// The message is not send if the node has the status Zombie.
     209// In this case false is returned, otherwise true
     210//
     211bool NodeDrv::SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
    188212                       BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0)
    189213{
    190     fNetwork->SendPDO1(fId, m0, m1, m2, m3, m4, m5, m6, m7);
     214    if (!fIsZombie)
     215        fNetwork->SendPDO1(fId, m0, m1, m2, m3, m4, m5, m6, m7);
     216    return !fIsZombie;
    191217}
    192218
     
    196222// A PDO is carrying up to eight bytes of information.
    197223//
    198 void NodeDrv::SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
     224// The message is not send if the node has the status Zombie.
     225// In this case false is returned, otherwise true
     226//
     227bool NodeDrv::SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
    199228                       BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0)
    200229{
    201     fNetwork->SendPDO2(fId, m0, m1, m2, m3, m4, m5, m6, m7);
    202 }
    203 
    204 // --------------------------------------------------------------------------
    205 //
    206 // Sends the given SDO through the network to this device
    207 // An SDO message contains
    208 //  an address (this device)
    209 //  an index of the dictionary entry to address
    210 //  a subindex of this dictionary entry to access
    211 //  and a value to set for this dictionary entry
    212 //
    213 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store)
    214 {
    215     fNetwork->SendSDO(fId, idx, subidx, val, store);
    216 }
    217 
    218 // --------------------------------------------------------------------------
    219 //
    220 // Sends the given SDO through the network to this device
    221 // An SDO message contains
    222 //  an address (this device)
    223 //  an index of the dictionary entry to address
    224 //  a subindex of this dictionary entry to access
    225 //  and a value to set for this dictionary entry
    226 //
    227 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store)
    228 {
    229     fNetwork->SendSDO(fId, idx, subidx, val, store);
    230 }
    231 
    232 // --------------------------------------------------------------------------
    233 //
    234 // Sends the given SDO through the network to this device
    235 // An SDO message contains
    236 //  an address (this device)
    237 //  an index of the dictionary entry to address
    238 //  a subindex of this dictionary entry to access
    239 //  and a value to set for this dictionary entry
    240 //
    241 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store)
    242 {
    243     fNetwork->SendSDO(fId, idx, subidx, val, store);
    244 }
    245 
    246 // --------------------------------------------------------------------------
    247 //
    248 // Sends the given SDO through the network to this device
    249 // An SDO message contains
    250 //  an address (this device)
    251 //  an index of the dictionary entry to address
    252 //  a subindex of this dictionary entry to access
    253 //  and a value to set for this dictionary entry
    254 //
    255 void NodeDrv::SendSDO(WORD_t idx, BYTE_t val)
    256 {
    257     fNetwork->SendSDO(fId, idx, val, true);
    258 }
    259 
    260 // --------------------------------------------------------------------------
    261 //
    262 // Sends the given SDO through the network to this device
    263 // An SDO message contains
    264 //  an address (this device)
    265 //  an index of the dictionary entry to address
    266 //  a subindex of this dictionary entry to access
    267 //  and a value to set for this dictionary entry
    268 //
    269 void NodeDrv::SendSDO(WORD_t idx, WORD_t val)
    270 {
    271     fNetwork->SendSDO(fId, idx, val, true);
    272 }
    273 
    274 // --------------------------------------------------------------------------
    275 //
    276 // Sends the given SDO through the network to this device
    277 // An SDO message contains
    278 //  an address (this device)
    279 //  an index of the dictionary entry to address
    280 //  a subindex of this dictionary entry to access
    281 //  and a value to set for this dictionary entry
    282 //
    283 void NodeDrv::SendSDO(WORD_t idx, LWORD_t val)
    284 {
    285     fNetwork->SendSDO(fId, idx, val, true);
     230    if (!fIsZombie)
     231        fNetwork->SendPDO2(fId, m0, m1, m2, m3, m4, m5, m6, m7);
     232    return !fIsZombie;
     233}
     234
     235// --------------------------------------------------------------------------
     236//
     237// Sends the given SDO through the network to this device
     238// An SDO message contains
     239//  an address (this device)
     240//  an index of the dictionary entry to address
     241//  a subindex of this dictionary entry to access
     242//  and a value to set for this dictionary entry
     243//
     244// The message is not send if the node has the status Zombie.
     245// In this case false is returned, otherwise true
     246//
     247bool NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store)
     248{
     249    if (!fIsZombie)
     250        fNetwork->SendSDO(fId, idx, subidx, val, store);
     251    return !fIsZombie;
     252}
     253
     254// --------------------------------------------------------------------------
     255//
     256// Sends the given SDO through the network to this device
     257// An SDO message contains
     258//  an address (this device)
     259//  an index of the dictionary entry to address
     260//  a subindex of this dictionary entry to access
     261//  and a value to set for this dictionary entry
     262//
     263// The message is not send if the node has the status Zombie.
     264// In this case false is returned, otherwise true
     265//
     266bool NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store)
     267{
     268    if (!fIsZombie)
     269        fNetwork->SendSDO(fId, idx, subidx, val, store);
     270    return !fIsZombie;
     271}
     272
     273// --------------------------------------------------------------------------
     274//
     275// Sends the given SDO through the network to this device
     276// An SDO message contains
     277//  an address (this device)
     278//  an index of the dictionary entry to address
     279//  a subindex of this dictionary entry to access
     280//  and a value to set for this dictionary entry
     281//
     282// The message is not send if the node has the status Zombie.
     283// In this case false is returned, otherwise true
     284//
     285bool NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store)
     286{
     287    if (!fIsZombie)
     288        fNetwork->SendSDO(fId, idx, subidx, val, store);
     289    return !fIsZombie;
     290}
     291
     292// --------------------------------------------------------------------------
     293//
     294// Sends the given SDO through the network to this device
     295// An SDO message contains
     296//  an address (this device)
     297//  an index of the dictionary entry to address
     298//  a subindex of this dictionary entry to access
     299//  and a value to set for this dictionary entry
     300//
     301// The message is not send if the node has the status Zombie.
     302// In this case false is returned, otherwise true
     303//
     304bool NodeDrv::SendSDO(WORD_t idx, BYTE_t val)
     305{
     306    if (!fIsZombie)
     307        fNetwork->SendSDO(fId, idx, val, true);
     308    return !fIsZombie;
     309}
     310
     311// --------------------------------------------------------------------------
     312//
     313// Sends the given SDO through the network to this device
     314// An SDO message contains
     315//  an address (this device)
     316//  an index of the dictionary entry to address
     317//  a subindex of this dictionary entry to access
     318//  and a value to set for this dictionary entry
     319//
     320// The message is not send if the node has the status Zombie.
     321// In this case false is returned, otherwise true
     322//
     323bool NodeDrv::SendSDO(WORD_t idx, WORD_t val)
     324{
     325    if (!fIsZombie)
     326        fNetwork->SendSDO(fId, idx, val, true);
     327    return !fIsZombie;
     328}
     329
     330// --------------------------------------------------------------------------
     331//
     332// Sends the given SDO through the network to this device
     333// An SDO message contains
     334//  an address (this device)
     335//  an index of the dictionary entry to address
     336//  a subindex of this dictionary entry to access
     337//  and a value to set for this dictionary entry
     338//
     339// The message is not send if the node has the status Zombie.
     340// In this case false is returned, otherwise true
     341//
     342bool NodeDrv::SendSDO(WORD_t idx, LWORD_t val)
     343{
     344    if (!fIsZombie)
     345        fNetwork->SendSDO(fId, idx, val, true);
     346    return !fIsZombie;
    286347}
    287348
     
    294355//  a subindex of this dictionary entry to access
    295356//
    296 void NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx)
    297 {
    298     fNetwork->RequestSDO(fId, idx, subidx);
     357// The message is not send if the node has the status Zombie.
     358// In this case false is returned, otherwise true
     359//
     360bool NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx)
     361{
     362    if (!fIsZombie)
     363        fNetwork->RequestSDO(fId, idx, subidx);
     364    return !fIsZombie;
    299365}
    300366
     
    303369// Send an NMT message (command) to this device
    304370//
    305 void NodeDrv::SendNMT(BYTE_t cmd)
    306 {
    307     fNetwork->SendNMT(fId, cmd);
     371// The message is not send if the node has the status Zombie.
     372// In this case false is returned, otherwise true
     373//
     374bool NodeDrv::SendNMT(BYTE_t cmd)
     375{
     376    if (!fIsZombie)
     377        fNetwork->SendNMT(fId, cmd);
     378    return !fIsZombie;
    308379}
    309380
     
    323394// You can stop waiting by StopWaitingForSDO.
    324395// Return false if waiting timed out.
     396// If waiting timed out the node is set to status Zombie.
     397//
     398// If the node is already a zombie node, the message is deleted from the
     399// queue and no waiting is done, false is returned..
    325400//
    326401bool NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORDS_t timeout)
    327402{
    328     bool rc = fNetwork->WaitForSdo(fId, idx, subidx, timeout);
     403    bool rc = fNetwork->WaitForSdo(fId, idx, subidx, fIsZombie?-1:timeout);
    329404
    330405    if (!rc)
    331406        fIsZombie = kTRUE;
    332407
    333     return rc;
     408    return fIsZombie ? false : rc;
    334409}
    335410
  • trunk/MagicSoft/Cosy/candrv/nodedrv.h

    r1702 r1703  
    4444    Network    *GetNetwork()        { return fNetwork; }
    4545
    46     virtual void InitDevice(Network *net);
     46    virtual void Init() = 0;
     47    virtual bool InitDevice(Network *net);
    4748    virtual void StopDevice() = 0;
     49    virtual bool Reboot();
     50    virtual void CheckConnection() = 0;
    4851
    4952    int  GetError() const { return fError; }
     
    6164    virtual void HandlePDO4(BYTE_t *data, timeval_t *tv) {};
    6265
    63     virtual bool Reboot();
    64 
    65     void SendPDO1(BYTE_t data[8]);
    66     void SendPDO2(BYTE_t data[8]);
    67     void SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
     66    bool SendPDO1(BYTE_t data[8]);
     67    bool SendPDO2(BYTE_t data[8]);
     68    bool SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
    6869                  BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
    69     void SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
     70    bool SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
    7071                  BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
    7172
    72     void SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store=true);
    73     void SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store=true);
    74     void SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store=true);
     73    bool SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store=true);
     74    bool SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store=true);
     75    bool SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store=true);
    7576
    76     void SendSDO(WORD_t idx, BYTE_t val);
    77     void SendSDO(WORD_t idx, WORD_t val);
    78     void SendSDO(WORD_t idx, LWORD_t val=0);
     77    bool SendSDO(WORD_t idx, BYTE_t val);
     78    bool SendSDO(WORD_t idx, WORD_t val);
     79    bool SendSDO(WORD_t idx, LWORD_t val=0);
    7980
    80     void SendNMT(BYTE_t cmd);
     81    bool SendNMT(BYTE_t cmd);
    8182
    82     void RequestSDO(WORD_t idx, BYTE_t subidx=0);
     83    bool RequestSDO(WORD_t idx, BYTE_t subidx=0);
    8384
    8485    void WaitForNextPdo1();
  • trunk/MagicSoft/Cosy/candrv/vmodican.cc

    r1702 r1703  
    232232                cout << "TxErrCnt=" << (int)msg->data[5] << endl;
    233233            }
    234             TerminateApp();
     234            //FIXME? TerminateApp();
    235235            return;
    236236        case 0x02:
Note: See TracChangeset for help on using the changeset viewer.