Changeset 1138 for trunk/MagicSoft/Cosy/candrv
- Timestamp:
- 12/21/01 11:59:50 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy/candrv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/candrv/canopen.cc
r1109 r1138 1 /* ======================================================================== *\ 2 ! 3 ! * 4 ! * This file is part of Stesy, the MAGIC Steering System 5 ! * Software. It is distributed to you in the hope that it can be a useful 6 ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. 7 ! * It is distributed WITHOUT ANY WARRANTY. 8 ! * 9 ! * Permission to use, copy, modify and distribute this software and its 10 ! * documentation for any purpose is hereby granted without fee, 11 ! * provided that the above copyright notice appear in all copies and 12 ! * that both that copyright notice and this permission notice appear 13 ! * in supporting documentation. It is provided "as is" without express 14 ! * or implied warranty. 15 ! * 16 ! 17 ! 18 ! Author(s): Thomas Bretz, 2001 <mailto:tbretz@uni-sw.gwdg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2001 21 ! 22 ! 23 \* ======================================================================== */ 24 25 /////////////////////////////////////////////////////////////////////// 26 // 27 // CanOpen 28 // 29 // implements the canopen layer over the raw device driver 30 // 31 /////////////////////////////////////////////////////////////////////// 1 32 #include "canopen.h" 2 33 … … 6 37 ClassImp(CanOpen); 7 38 39 // -------------------------------------------------------------------------- 40 // 41 // Initializes a conditional and a mutex semaphore for all possible 42 // PDO combinations 43 // 8 44 CanOpen::CanOpen(const char *dev, const int baud, MLog &out) : VmodIcan(dev, baud, out) 9 45 { … … 17 53 } 18 54 55 // -------------------------------------------------------------------------- 56 // 57 // Destroys all conditional and mutex semaphores 58 // 19 59 CanOpen::~CanOpen() 20 60 { … … 27 67 } 28 68 69 // -------------------------------------------------------------------------- 70 // 71 // This overloads VmodIcan::HandleCanMessage. It is called if a can 72 // message was received with all message relevant data (COBId, data, time) 73 // It distributes the data depending on its function code to several 74 // functions (to be obverloaded) 75 // In case of a PDO the conditional semaphore corresponding to this PDO 76 // is raised (WaitForNextPDO) 77 // HandleSDO: handles a SDO message 78 // HandlePDO1/2/3/4:handles received PDOs 79 // 29 80 void CanOpen::HandleCanMessage(WORD_t cobid, BYTE_t *data, struct timeval *tv) 30 81 { … … 95 146 } 96 147 148 // -------------------------------------------------------------------------- 149 // 150 // Enables can messaged for a given node ID and function code. 151 // 97 152 void CanOpen::EnableCanMsg(BYTE_t node, BYTE_t fcode, int flag) 98 153 { … … 103 158 } 104 159 160 // -------------------------------------------------------------------------- 161 // 162 // Enables Emergency messages for a given node 163 // 105 164 void CanOpen::EnableEmcy(BYTE_t node) 106 165 { … … 109 168 110 169 170 // -------------------------------------------------------------------------- 171 // 172 // Enables SDO rx messages for a given node 173 // 111 174 void CanOpen::EnableSdoRx(BYTE_t node) 112 175 { … … 114 177 } 115 178 179 // -------------------------------------------------------------------------- 180 // 181 // Enables PDO1 tx messages for a given node 182 // 116 183 void CanOpen::EnablePdo1Rx(BYTE_t node) 117 184 { … … 119 186 } 120 187 188 // -------------------------------------------------------------------------- 189 // 190 // Enables PDO2 tx messages for a given node 191 // 121 192 void CanOpen::EnablePdo2Rx(BYTE_t node) 122 193 { … … 124 195 } 125 196 197 // -------------------------------------------------------------------------- 198 // 199 // Enables PDO3 rx messages for a given node 200 // 126 201 void CanOpen::EnablePdo3Rx(BYTE_t node) 127 202 { … … 129 204 } 130 205 206 // -------------------------------------------------------------------------- 207 // 208 // Enables PDO4 rx messages for a given node 209 // 131 210 void CanOpen::EnablePdo4Rx(BYTE_t node) 132 211 { … … 134 213 } 135 214 215 // -------------------------------------------------------------------------- 216 // 217 // Sends a PDO1 message with the given data to the given node 218 // 136 219 void CanOpen::SendPDO1(BYTE_t node, BYTE_t data[8]) 137 220 { … … 139 222 } 140 223 224 // -------------------------------------------------------------------------- 225 // 226 // Sends a PDO2 message with the given data to the given node 227 // 141 228 void CanOpen::SendPDO2(BYTE_t node, BYTE_t data[8]) 142 229 { … … 144 231 } 145 232 233 // -------------------------------------------------------------------------- 234 // 235 // Sends a PDO3 message with the given data to the given node 236 // 146 237 void CanOpen::SendPDO3(BYTE_t node, BYTE_t data[8]) 147 238 { … … 149 240 } 150 241 242 // -------------------------------------------------------------------------- 243 // 244 // Sends a PDO4 message with the given data to the given node 245 // 151 246 void CanOpen::SendPDO4(BYTE_t node, BYTE_t data[8]) 152 247 { … … 154 249 } 155 250 251 // -------------------------------------------------------------------------- 252 // 253 // Sends a PDO1 message with the given data to the given node 254 // 156 255 void CanOpen::SendPDO1(BYTE_t node, 157 256 BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, … … 162 261 } 163 262 263 // -------------------------------------------------------------------------- 264 // 265 // Sends a PDO2 message with the given data to the given node 266 // 164 267 void CanOpen::SendPDO2(BYTE_t node, 165 268 BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, … … 170 273 } 171 274 275 // -------------------------------------------------------------------------- 276 // 277 // Sends a PDO3 message with the given data to the given node 278 // 172 279 void CanOpen::SendPDO3(BYTE_t node, 173 280 BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, … … 178 285 } 179 286 287 // -------------------------------------------------------------------------- 288 // 289 // Sends a PDO4 message with the given data to the given node 290 // 180 291 void CanOpen::SendPDO4(BYTE_t node, 181 292 BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, … … 186 297 } 187 298 299 // -------------------------------------------------------------------------- 300 // 301 // Sends a SDO message with the given data to the given node: 302 // - index describing the dictionary index to set 303 // - subindex describing the dictionary subindex of theindex to set 304 // - val describing the value to set. 305 // - store describes whether the sdo should be stored in a list to 306 // be able to wait for an answer 307 // 188 308 void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, BYTE_t val, bool store) 189 309 { … … 195 315 } 196 316 317 // -------------------------------------------------------------------------- 318 // 319 // Sends a SDO message with the given data to the given node: 320 // - index describing the dictionary index to set 321 // - subindex describing the dictionary subindex of theindex to set 322 // - val describing the value to set. 323 // - store describes whether the sdo should be stored in a list to 324 // be able to wait for an answer 325 // 197 326 void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, WORD_t val, bool store) 198 327 { … … 205 334 } 206 335 336 // -------------------------------------------------------------------------- 337 // 338 // Sends a SDO message with the given data to the given node: 339 // - index describing the dictionary index to set 340 // - subindex describing the dictionary subindex of theindex to set 341 // - val describing the value to set. 342 // - store describes whether the sdo should be stored in a list to 343 // be able to wait for an answer 344 // 207 345 void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, LWORD_t val, bool store) 208 346 { … … 216 354 } 217 355 356 // -------------------------------------------------------------------------- 357 // 358 // Request a SDO message from the given node: 359 // - index describing the dictionary index to request 360 // - subindex describing the dictionary subindex of the index to request 361 // 218 362 void CanOpen::RequestSDO(BYTE_t node, WORD_t idx, BYTE_t subidx) 219 363 { … … 223 367 } 224 368 369 // -------------------------------------------------------------------------- 370 // 371 // Send an NMT Message to the given node with command cmd 372 // 225 373 void CanOpen::SendNMT(BYTE_t node, BYTE_t cmd) 226 374 { … … 228 376 } 229 377 378 // -------------------------------------------------------------------------- 379 // 380 // Decodes node and function code into a CobId 381 // 230 382 WORD_t CanOpen::CobId(BYTE_t node, BYTE_t fcode) const 231 383 { -
trunk/MagicSoft/Cosy/candrv/network.cc
r1109 r1138 1 /* ======================================================================== *\ 2 ! 3 ! * 4 ! * This file is part of Stesy, the MAGIC Steering System 5 ! * Software. It is distributed to you in the hope that it can be a useful 6 ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. 7 ! * It is distributed WITHOUT ANY WARRANTY. 8 ! * 9 ! * Permission to use, copy, modify and distribute this software and its 10 ! * documentation for any purpose is hereby granted without fee, 11 ! * provided that the above copyright notice appear in all copies and 12 ! * that both that copyright notice and this permission notice appear 13 ! * in supporting documentation. It is provided "as is" without express 14 ! * or implied warranty. 15 ! * 16 ! 17 ! 18 ! Author(s): Thomas Bretz, 2001 <mailto:tbretz@uni-sw.gwdg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2001 21 ! 22 ! 23 \* ======================================================================== */ 24 25 /////////////////////////////////////////////////////////////////////// 26 // 27 // Network 28 // 29 // is a collection of nodes which coordinates the network 30 // 31 /////////////////////////////////////////////////////////////////////// 1 32 #include "network.h" 2 33 … … 6 37 ClassImp(Network); 7 38 39 // -------------------------------------------------------------------------- 40 // 41 // Start the canopen module 42 // Initialize all nodes (calling NodeDrv::Init() 43 // 8 44 void Network::Start() 9 45 { … … 16 52 } 17 53 54 // -------------------------------------------------------------------------- 55 // 56 // Stop all nodes, stop the can module 57 // 18 58 void Network::Stop() 19 59 { … … 26 66 } 27 67 68 // -------------------------------------------------------------------------- 69 // 70 // Initialize the network, set all nodes to NULL (n/a) 71 // 28 72 Network::Network(const char *dev, const int baud, MLog &out) : CanOpen(dev, baud, out) 29 73 { … … 32 76 } 33 77 78 // -------------------------------------------------------------------------- 79 // 80 // Distributes the received SDO messages to the addressed nodes. 81 // Depending on the received command either HandleSDO, HandleSDOOK or 82 // HandleSDOError called. 83 // HandleSDO: Handles a received value 84 // HandleSDOOK: Handles the acknoledgment of a trasmitted SDO 85 // HandleSDOError: Handles error occursion (see CanOpen standard) 86 // 34 87 void Network::HandleSDO(BYTE_t node, BYTE_t cmd, WORD_t idx, BYTE_t subidx, LWORD_t data, struct timeval *tv) 35 88 { … … 82 135 } 83 136 137 // -------------------------------------------------------------------------- 138 // 139 // Distributes PDO1 messages to the correspoding node calling HandlePDO1 140 // 84 141 void Network::HandlePDO1(BYTE_t node, BYTE_t *data, struct timeval *tv) 85 142 { … … 96 153 } 97 154 155 // -------------------------------------------------------------------------- 156 // 157 // Distributes PDO2 messages to the correspoding node calling HandlePDO2 158 // 98 159 void Network::HandlePDO2(BYTE_t node, BYTE_t *data, struct timeval *tv) 99 160 { … … 110 171 } 111 172 173 // -------------------------------------------------------------------------- 174 // 175 // Distributes PDO3 messages to the correspoding node calling HandlePDO3 176 // 112 177 void Network::HandlePDO3(BYTE_t node, BYTE_t *data, struct timeval *tv) 113 178 { … … 124 189 } 125 190 191 // -------------------------------------------------------------------------- 192 // 193 // Distributes PDO4 messages to the correspoding node calling HandlePDO4 194 // 126 195 void Network::HandlePDO4(BYTE_t node, BYTE_t *data, struct timeval *tv) 127 196 { … … 138 207 } 139 208 209 // -------------------------------------------------------------------------- 210 // 211 // Sets a node to a given nodedrv. The id is requested from the drv object. 212 // 140 213 void Network::SetNode(NodeDrv *drv) 141 214 { … … 151 224 } 152 225 226 // -------------------------------------------------------------------------- 227 // 228 // Initializes all nodes calling InitDevice 229 // 153 230 void Network::InitNodes() 154 231 { … … 163 240 } 164 241 242 // -------------------------------------------------------------------------- 243 // 244 // Stop all nodes calling StopDevice 245 // 165 246 void Network::StopNodes() 166 247 { … … 174 255 } 175 256 257 // -------------------------------------------------------------------------- 258 // 259 // returns true if one of the nodes has the error-flag set (HasError). 260 // 176 261 bool Network::HasError() const 177 262 { -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r1136 r1138 140 140 // Sends the given PDO1 through the network to this device 141 141 // A PDO is carrying up to eight bytes of information. 142 // PDO messages are broadcasts.143 142 // 144 143 void NodeDrv::SendPDO1(BYTE_t data[8]) … … 151 150 // Sends the given PDO2 through the network to this device 152 151 // A PDO is carrying up to eight bytes of information. 153 // PDO messages are broadcasts.154 152 // 155 153 void NodeDrv::SendPDO2(BYTE_t data[8]) … … 162 160 // Sends the given PDO1 through the network to this device 163 161 // A PDO is carrying up to eight bytes of information. 164 // PDO messages are broadcasts.165 162 // 166 163 void NodeDrv::SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, … … 174 171 // Sends the given PDO2 through the network to this device 175 172 // A PDO is carrying up to eight bytes of information. 176 // PDO messages are broadcasts.177 173 // 178 174 void NodeDrv::SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0, -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r1109 r1138 23 23 BYTE_t fId; 24 24 25 char *fName;25 TString fName; 26 26 27 27 int fError;
Note:
See TracChangeset
for help on using the changeset viewer.