Changeset 1135 for trunk/MagicSoft
- Timestamp:
- 12/21/01 11:10:51 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r1109 r1135 9 9 ClassImp(NodeDrv); 10 10 11 // -------------------------------------------------------------------------- 12 // 13 // Constructor for one node. Sets the Node Id (<32) the logging stream 14 // and the node name. The name is a name for debug output. 15 // 11 16 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0) 12 17 { … … 20 25 21 26 if (name) 22 { 23 fName = new char[strlen(name)+1]; 24 strcpy(fName, name); 25 } 27 fName = name; 26 28 else 27 29 { 28 fName = new char[9];29 sprintf(fName, "Node#%d", nodeid);30 fName = "Node#"; 31 fName += nodeid; 30 32 } 31 33 } 32 34 35 // -------------------------------------------------------------------------- 36 // 37 // Empty destructor 38 // 33 39 NodeDrv::~NodeDrv() 34 40 { 35 delete fName; 36 } 37 41 } 42 43 // -------------------------------------------------------------------------- 44 // 45 // Init device, sets the pointer to the whole network and enables 46 // the Can messages to be passed through the interface: 47 // PDO1 tx 48 // PDO2 tx 49 // PDO3 tx 50 // PDO4 tx 51 // SDO rx 52 // SDO tx 53 // 38 54 void NodeDrv::InitDevice(Network *net) 39 55 { … … 48 64 } 49 65 66 // -------------------------------------------------------------------------- 67 // 68 // Print an "SDO idx/subidx set." from this device message. 69 // This output is never redirected to the GUI 70 // 50 71 void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx) 51 72 { … … 63 84 } 64 85 86 // -------------------------------------------------------------------------- 87 // 88 // Print an error message with the corresponding data from this device. 89 // 65 90 void NodeDrv::HandleSDOError(LWORD_t data) 66 91 { 67 lout << "Nodedrv: SDO Error: Entry not found in d eictionary (data=0x";92 lout << "Nodedrv: SDO Error: Entry not found in dictionary (data=0x"; 68 93 lout << hex << setfill('0') << setw(4) << data << ")"; 69 94 lout << endl; 70 95 } 71 96 97 // -------------------------------------------------------------------------- 98 // 99 // Prints the received SDo from this device 100 // 72 101 void NodeDrv::HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv) 73 102 { … … 76 105 } 77 106 107 // -------------------------------------------------------------------------- 108 // 109 // Sends the given PDO1 through the network to this device 110 // A PDO is carrying up to eight bytes of information. 111 // PDO messages are broadcasts. 112 // 78 113 void NodeDrv::SendPDO1(BYTE_t data[8]) 79 114 { … … 81 116 } 82 117 118 // -------------------------------------------------------------------------- 119 // 120 // Sends the given PDO2 through the network to this device 121 // A PDO is carrying up to eight bytes of information. 122 // PDO messages are broadcasts. 123 // 83 124 void NodeDrv::SendPDO2(BYTE_t data[8]) 84 125 { … … 86 127 } 87 128 129 // -------------------------------------------------------------------------- 130 // 131 // Sends the given PDO1 through the network to this device 132 // A PDO is carrying up to eight bytes of information. 133 // PDO messages are broadcasts. 134 // 88 135 void NodeDrv::SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, 89 136 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0) … … 92 139 } 93 140 141 // -------------------------------------------------------------------------- 142 // 143 // Sends the given PDO2 through the network to this device 144 // A PDO is carrying up to eight bytes of information. 145 // PDO messages are broadcasts. 146 // 94 147 void NodeDrv::SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, 95 148 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0) … … 98 151 } 99 152 153 // -------------------------------------------------------------------------- 154 // 155 // Sends the given SDO through the network to this device 156 // An SDO message contains 157 // an address (this device) 158 // an index of the dictionary entry to address 159 // a subindex of this dictionary entry to access 160 // and a value to set for this dictionary entry 161 // 100 162 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store) 101 163 { … … 103 165 } 104 166 167 // -------------------------------------------------------------------------- 168 // 169 // Sends the given SDO through the network to this device 170 // An SDO message contains 171 // an address (this device) 172 // an index of the dictionary entry to address 173 // a subindex of this dictionary entry to access 174 // and a value to set for this dictionary entry 175 // 105 176 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store) 106 177 { … … 108 179 } 109 180 181 // -------------------------------------------------------------------------- 182 // 183 // Sends the given SDO through the network to this device 184 // An SDO message contains 185 // an address (this device) 186 // an index of the dictionary entry to address 187 // a subindex of this dictionary entry to access 188 // and a value to set for this dictionary entry 189 // 110 190 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store) 111 191 { … … 113 193 } 114 194 195 // -------------------------------------------------------------------------- 196 // 197 // Sends the given SDO through the network to this device 198 // An SDO message contains 199 // an address (this device) 200 // an index of the dictionary entry to address 201 // a subindex of this dictionary entry to access 202 // and a value to set for this dictionary entry 203 // 115 204 void NodeDrv::SendSDO(WORD_t idx, BYTE_t val) 116 205 { … … 118 207 } 119 208 209 // -------------------------------------------------------------------------- 210 // 211 // Sends the given SDO through the network to this device 212 // An SDO message contains 213 // an address (this device) 214 // an index of the dictionary entry to address 215 // a subindex of this dictionary entry to access 216 // and a value to set for this dictionary entry 217 // 120 218 void NodeDrv::SendSDO(WORD_t idx, WORD_t val) 121 219 { … … 123 221 } 124 222 223 // -------------------------------------------------------------------------- 224 // 225 // Sends the given SDO through the network to this device 226 // An SDO message contains 227 // an address (this device) 228 // an index of the dictionary entry to address 229 // a subindex of this dictionary entry to access 230 // and a value to set for this dictionary entry 231 // 125 232 void NodeDrv::SendSDO(WORD_t idx, LWORD_t val) 126 233 { … … 128 235 } 129 236 237 // -------------------------------------------------------------------------- 238 // 239 // Request a SDO for a given idx/subidx 240 // An SDO message contains 241 // an address (this device) 242 // an index of the dictionary entry to read 243 // a subindex of this dictionary entry to access 244 // 130 245 void NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx) 131 246 { … … 133 248 } 134 249 250 // -------------------------------------------------------------------------- 251 // 252 // Send an NMT message (command) to this device 253 // 135 254 void NodeDrv::SendNMT(BYTE_t cmd) 136 255 { … … 138 257 } 139 258 259 // -------------------------------------------------------------------------- 260 // 261 // Enable passthrough for the given functioncode of this device 262 // 140 263 void NodeDrv::EnableCanMsg(BYTE_t fcode) 141 264 { … … 143 266 } 144 267 268 // -------------------------------------------------------------------------- 269 // 270 // Wait a given timeout until the SDO with the given idx/subidx from 271 // this device has been received. 272 // You can stop waiting by StopWaitingForSDO. 273 // 145 274 void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORDS_t timeout) 146 275 { … … 156 285 */ 157 286 287 // -------------------------------------------------------------------------- 288 // 289 // Waits until the next Pdo1 from this device has been received 290 // 158 291 void NodeDrv::WaitForNextPdo1() 159 292 { … … 161 294 } 162 295 296 // -------------------------------------------------------------------------- 297 // 298 // Waits until the next Pdo2 from this device has been received 299 // 163 300 void NodeDrv::WaitForNextPdo2() 164 301 { 165 cout << "WAIT: " << (int)fId << " " << fNetwork << endl;166 302 fNetwork->WaitForNextPdo2(fId); 167 303 } 168 304 305 // -------------------------------------------------------------------------- 306 // 307 // Waits until the next Pdo3 from this device has been received 308 // 169 309 void NodeDrv::WaitForNextPdo3() 170 310 { … … 172 312 } 173 313 314 // -------------------------------------------------------------------------- 315 // 316 // Waits until the next Pdo4 from this device has been received 317 // 174 318 void NodeDrv::WaitForNextPdo4() 175 319 {
Note:
See TracChangeset
for help on using the changeset viewer.