Index: trunk/MagicSoft/Cosy/candrv/nodedrv.cc
===================================================================
--- trunk/MagicSoft/Cosy/candrv/nodedrv.cc	(revision 1111)
+++ trunk/MagicSoft/Cosy/candrv/nodedrv.cc	(revision 1135)
@@ -9,4 +9,9 @@
 ClassImp(NodeDrv);
 
+// --------------------------------------------------------------------------
+//
+// Constructor for one node. Sets the Node Id (<32) the logging stream
+// and the node name. The name is a name for debug output.
+//
 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0)
 {
@@ -20,20 +25,31 @@
 
     if (name)
-    {
-        fName = new char[strlen(name)+1];
-        strcpy(fName, name);
-    }
+        fName = name;
     else
     {
-        fName = new char[9];
-        sprintf(fName, "Node#%d", nodeid);
+        fName = "Node#";
+        fName += nodeid;
     }
 }
 
+// --------------------------------------------------------------------------
+//
+// Empty destructor
+//
 NodeDrv::~NodeDrv()
 {
-    delete fName;
-}
-
+}
+
+// --------------------------------------------------------------------------
+//
+// Init device, sets the pointer to the whole network and enables
+// the Can messages to be passed through the interface:
+//   PDO1 tx
+//   PDO2 tx
+//   PDO3 tx
+//   PDO4 tx
+//   SDO rx
+//   SDO tx
+//
 void NodeDrv::InitDevice(Network *net)
 {
@@ -48,4 +64,9 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Print an "SDO idx/subidx set." from this device message.
+// This output is never redirected to the GUI
+//
 void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx)
 {
@@ -63,11 +84,19 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Print an error message with the corresponding data from this device.
+//
 void NodeDrv::HandleSDOError(LWORD_t data)
 {
-    lout << "Nodedrv: SDO Error: Entry not found in deictionary (data=0x";
+    lout << "Nodedrv: SDO Error: Entry not found in dictionary (data=0x";
     lout << hex << setfill('0') << setw(4) << data << ")";
     lout << endl;
 }
 
+// --------------------------------------------------------------------------
+//
+// Prints the received SDo from this device
+//
 void NodeDrv::HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv)
 {
@@ -76,4 +105,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given PDO1 through the network to this device
+// A PDO is carrying up to eight bytes of information.
+// PDO messages are broadcasts.
+//
 void NodeDrv::SendPDO1(BYTE_t data[8])
 {
@@ -81,4 +116,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given PDO2 through the network to this device
+// A PDO is carrying up to eight bytes of information.
+// PDO messages are broadcasts.
+//
 void NodeDrv::SendPDO2(BYTE_t data[8])
 {
@@ -86,4 +127,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given PDO1 through the network to this device
+// A PDO is carrying up to eight bytes of information.
+// PDO messages are broadcasts.
+//
 void NodeDrv::SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
                        BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0)
@@ -92,4 +139,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given PDO2 through the network to this device
+// A PDO is carrying up to eight bytes of information.
+// PDO messages are broadcasts.
+//
 void NodeDrv::SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
                        BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0)
@@ -98,4 +151,13 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given SDO through the network to this device
+// An SDO message contains
+//  an address (this device)
+//  an index of the dictionary entry to address
+//  a subindex of this dictionary entry to access
+//  and a value to set for this dictionary entry
+//
 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store)
 {
@@ -103,4 +165,13 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given SDO through the network to this device
+// An SDO message contains
+//  an address (this device)
+//  an index of the dictionary entry to address
+//  a subindex of this dictionary entry to access
+//  and a value to set for this dictionary entry
+//
 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store)
 {
@@ -108,4 +179,13 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given SDO through the network to this device
+// An SDO message contains
+//  an address (this device)
+//  an index of the dictionary entry to address
+//  a subindex of this dictionary entry to access
+//  and a value to set for this dictionary entry
+//
 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store)
 {
@@ -113,4 +193,13 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given SDO through the network to this device
+// An SDO message contains
+//  an address (this device)
+//  an index of the dictionary entry to address
+//  a subindex of this dictionary entry to access
+//  and a value to set for this dictionary entry
+//
 void NodeDrv::SendSDO(WORD_t idx, BYTE_t val)
 {
@@ -118,4 +207,13 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given SDO through the network to this device
+// An SDO message contains
+//  an address (this device)
+//  an index of the dictionary entry to address
+//  a subindex of this dictionary entry to access
+//  and a value to set for this dictionary entry
+//
 void NodeDrv::SendSDO(WORD_t idx, WORD_t val)
 {
@@ -123,4 +221,13 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Sends the given SDO through the network to this device
+// An SDO message contains
+//  an address (this device)
+//  an index of the dictionary entry to address
+//  a subindex of this dictionary entry to access
+//  and a value to set for this dictionary entry
+//
 void NodeDrv::SendSDO(WORD_t idx, LWORD_t val)
 {
@@ -128,4 +235,12 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Request a SDO for a given idx/subidx
+// An SDO message contains
+//  an address (this device)
+//  an index of the dictionary entry to read
+//  a subindex of this dictionary entry to access
+//
 void NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx)
 {
@@ -133,4 +248,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Send an NMT message (command) to this device
+//
 void NodeDrv::SendNMT(BYTE_t cmd)
 {
@@ -138,4 +257,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Enable passthrough for the given functioncode of this device
+//
 void NodeDrv::EnableCanMsg(BYTE_t fcode)
 {
@@ -143,4 +266,10 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Wait a given timeout until the SDO with the given idx/subidx from
+// this device has been received.
+// You can stop waiting by StopWaitingForSDO.
+//
 void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORDS_t timeout)
 {
@@ -156,4 +285,8 @@
 */
 
+// --------------------------------------------------------------------------
+//
+// Waits until the next Pdo1 from this device has been received
+//
 void NodeDrv::WaitForNextPdo1()
 {
@@ -161,10 +294,17 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Waits until the next Pdo2 from this device has been received
+//
 void NodeDrv::WaitForNextPdo2()
 {
-    cout << "WAIT: " << (int)fId << " " << fNetwork << endl;
     fNetwork->WaitForNextPdo2(fId);
 }
 
+// --------------------------------------------------------------------------
+//
+// Waits until the next Pdo3 from this device has been received
+//
 void NodeDrv::WaitForNextPdo3()
 {
@@ -172,4 +312,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Waits until the next Pdo4 from this device has been received
+//
 void NodeDrv::WaitForNextPdo4()
 {
