Changeset 1703 for trunk/MagicSoft/Cosy/candrv
- Timestamp:
- 01/14/03 12:08:46 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/candrv
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/candrv/network.cc
r1702 r1703 237 237 lout << "- Setting up Node #" << dec << i << " ("; 238 238 lout << fNodes[i]->GetNodeName() << ")" << endl; 239 fNodes[i]->InitDevice(this); 240 if (!fNodes[i]->IsZombieNode()) 239 if (fNodes[i]->InitDevice(this)) 241 240 fNodeInitialized[i] = TRUE; 242 /*else243 fNodes[i]=NULL;*/241 else 242 lout << "- " << fNodes[i]->GetNodeName() << ": InitDevice failed." << endl; 244 243 } 245 244 lout << "- All Nodes setup." << endl; … … 310 309 bool Network::RebootZombies() 311 310 { 311 bool rc = true; 312 312 313 lout << "- Trying to reboot all Zombies..." << endl; 313 314 for (int i=0; i<32; i++) … … 317 318 { 318 319 lout << "- Failed to reboot " << fNodes[i]->GetNodeName() << "." << endl; 319 r eturnfalse;320 rc = false; 320 321 } 321 322 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 // 334 void 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 35 35 36 36 bool RebootZombies(); 37 void CheckConnections(); 37 38 38 39 ClassDef(Network, 0) // collection of nodes (nodedrv) -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r1702 r1703 30 30 // 31 31 // to be overloaded: 32 // virtual void Init Device(Network *net)32 // virtual void Init() 33 33 // virtual void StopDevice() 34 34 // virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv) … … 39 39 // virtual void HandlePDO3(BYTE_t *data, timeval_t *tv) 40 40 // virtual void HandlePDO4(BYTE_t *data, timeval_t *tv) 41 // virtual bool Reboot(); 42 // virtual void CheckConnection(); 41 43 // 42 44 /////////////////////////////////////////////////////////////////////// … … 56 58 // and the node name. The name is a name for debug output. 57 59 // 58 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0), fIsZombie(k FALSE)60 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0), fIsZombie(kTRUE) 59 61 { 60 62 if (nodeid>0x1f) … … 93 95 { 94 96 fIsZombie = false; 95 return true; 97 98 Init(); 99 100 return !fIsZombie; 96 101 } 97 102 … … 107 112 // SDO tx 108 113 // 109 voidNodeDrv::InitDevice(Network *net)114 bool NodeDrv::InitDevice(Network *net) 110 115 { 111 116 fNetwork = net; … … 117 122 EnableCanMsg(kSDO_RX); 118 123 EnableCanMsg(kSDO_TX); 124 125 fIsZombie = kFALSE; 126 127 Init(); 128 129 return !fIsZombie; 119 130 } 120 131 … … 165 176 // A PDO is carrying up to eight bytes of information. 166 177 // 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 // 181 bool NodeDrv::SendPDO1(BYTE_t data[8]) 182 { 183 if (!fIsZombie) 184 fNetwork->SendPDO1(fId, data); 185 return !fIsZombie; 170 186 } 171 187 … … 175 191 // A PDO is carrying up to eight bytes of information. 176 192 // 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 // 196 bool NodeDrv::SendPDO2(BYTE_t data[8]) 197 { 198 if (!fIsZombie) 199 fNetwork->SendPDO2(fId, data); 200 return !fIsZombie; 180 201 } 181 202 … … 185 206 // A PDO is carrying up to eight bytes of information. 186 207 // 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 // 211 bool NodeDrv::SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, 188 212 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0) 189 213 { 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; 191 217 } 192 218 … … 196 222 // A PDO is carrying up to eight bytes of information. 197 223 // 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 // 227 bool NodeDrv::SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, 199 228 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0) 200 229 { 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 // 247 bool 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 // 266 bool 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 // 285 bool 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 // 304 bool 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 // 323 bool 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 // 342 bool NodeDrv::SendSDO(WORD_t idx, LWORD_t val) 343 { 344 if (!fIsZombie) 345 fNetwork->SendSDO(fId, idx, val, true); 346 return !fIsZombie; 286 347 } 287 348 … … 294 355 // a subindex of this dictionary entry to access 295 356 // 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 // 360 bool NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx) 361 { 362 if (!fIsZombie) 363 fNetwork->RequestSDO(fId, idx, subidx); 364 return !fIsZombie; 299 365 } 300 366 … … 303 369 // Send an NMT message (command) to this device 304 370 // 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 // 374 bool NodeDrv::SendNMT(BYTE_t cmd) 375 { 376 if (!fIsZombie) 377 fNetwork->SendNMT(fId, cmd); 378 return !fIsZombie; 308 379 } 309 380 … … 323 394 // You can stop waiting by StopWaitingForSDO. 324 395 // 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.. 325 400 // 326 401 bool NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORDS_t timeout) 327 402 { 328 bool rc = fNetwork->WaitForSdo(fId, idx, subidx, timeout);403 bool rc = fNetwork->WaitForSdo(fId, idx, subidx, fIsZombie?-1:timeout); 329 404 330 405 if (!rc) 331 406 fIsZombie = kTRUE; 332 407 333 return rc;408 return fIsZombie ? false : rc; 334 409 } 335 410 -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r1702 r1703 44 44 Network *GetNetwork() { return fNetwork; } 45 45 46 virtual void InitDevice(Network *net); 46 virtual void Init() = 0; 47 virtual bool InitDevice(Network *net); 47 48 virtual void StopDevice() = 0; 49 virtual bool Reboot(); 50 virtual void CheckConnection() = 0; 48 51 49 52 int GetError() const { return fError; } … … 61 64 virtual void HandlePDO4(BYTE_t *data, timeval_t *tv) {}; 62 65 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, 68 69 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0); 69 voidSendPDO2(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, 70 71 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0); 71 72 72 voidSendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store=true);73 voidSendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store=true);74 voidSendSDO(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); 75 76 76 voidSendSDO(WORD_t idx, BYTE_t val);77 voidSendSDO(WORD_t idx, WORD_t val);78 voidSendSDO(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); 79 80 80 voidSendNMT(BYTE_t cmd);81 bool SendNMT(BYTE_t cmd); 81 82 82 voidRequestSDO(WORD_t idx, BYTE_t subidx=0);83 bool RequestSDO(WORD_t idx, BYTE_t subidx=0); 83 84 84 85 void WaitForNextPdo1(); -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r1702 r1703 232 232 cout << "TxErrCnt=" << (int)msg->data[5] << endl; 233 233 } 234 TerminateApp();234 //FIXME? TerminateApp(); 235 235 return; 236 236 case 0x02:
Note:
See TracChangeset
for help on using the changeset viewer.