Changeset 8864 for trunk/MagicSoft/Cosy/candrv
- Timestamp:
- 02/17/08 22:39:04 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy/candrv
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/candrv/canopen.cc
r8862 r8864 78 78 if (fInterface) 79 79 fInterface->Stop(); 80 } 81 82 bool CanOpen::HasError() const 83 { 84 return fInterface ? !fInterface->HasConnection() : kFALSE; 80 85 } 81 86 -
trunk/MagicSoft/Cosy/candrv/canopen.h
r8813 r8864 78 78 virtual void Start(); // Start CanOpen communication 79 79 virtual void Stop(); // Stop CanOpen communcation 80 81 virtual bool HasError() const; 80 82 81 83 private: -
trunk/MagicSoft/Cosy/candrv/ethernet.cc
r8862 r8864 74 74 // -------------------------------------------------------------------------- 75 75 // 76 voidEthernet::ReadSocket(TSocket &rx)76 Bool_t Ethernet::ReadSocket(TSocket &rx) 77 77 { 78 78 Int_t pos = -1; … … 87 87 while (!IsThreadCanceled()) 88 88 { 89 //TThread::CancelPoint();90 91 89 unsigned char c; 92 90 const Int_t len = rx.RecvRaw(&c, 1); 93 91 94 //TThread::CancelPoint();95 96 92 // No data received (non-blocking mode) 97 93 if (len<0) … … 101 97 } 102 98 103 // Data received with zero length! 99 // Data received with zero length! (Connection lost) 104 100 if (len==0) 105 { 106 gLog << warn << "WARNING - Connection lost (received 0bytes) to " << address << endl; 107 //break; // This break is for TEST PURPOSE FIXME!!! 108 continue; 109 } 101 return kFALSE; 110 102 111 103 // Data received … … 113 105 { 114 106 gLog << err << "Data received from " << address << " is more than one byte!" << endl; 115 break;107 continue; 116 108 } 117 109 … … 121 113 { 122 114 cout << "Data received from " << address << " too long (> " << MSGLEN << ")" << endl; 123 break;115 continue; 124 116 } 125 117 … … 147 139 // String completed 148 140 HandleMessage(msg); 141 142 return kTRUE; 149 143 } 150 } 151 144 145 return kTRUE; 146 } 147 148 /* 149 void Ethernet::ReadSocket(TSocket &rx) 150 { 151 Int_t pos = -1; 152 153 Message msg; 154 msg.cmd = M_BCAN_RX_ind; 155 msg.data[0] = 0; 156 msg.data[1] = 0; 157 158 const TString address = MTcpIpO::GetSocketAddress(rx); 159 160 while (!IsThreadCanceled()) 161 { 162 //TThread::CancelPoint(); 163 164 unsigned char c; 165 const Int_t len = rx.RecvRaw(&c, 1); 166 167 //TThread::CancelPoint(); 168 169 // No data received (non-blocking mode) 170 if (len<0) 171 { 172 usleep(1); 173 continue; 174 } 175 176 // Data received with zero length! 177 if (len==0) 178 { 179 gLog << warn << "WARNING - Connection lost (received 0bytes) to " << address << endl; 180 //break; // This break is for TEST PURPOSE FIXME!!! 181 return; 182 } 183 184 // Data received 185 if (len>1) 186 { 187 gLog << err << "Data received from " << address << " is more than one byte!" << endl; 188 continue; 189 } 190 191 if (pos<0) 192 { 193 if (c>=MSGLEN) 194 { 195 cout << "Data received from " << address << " too long (> " << MSGLEN << ")" << endl; 196 continue; 197 } 198 199 msg.len = c; 200 pos = 2; 201 continue; 202 } 203 204 // if (pos==2 && c==0x0a) 205 // continue; 206 207 msg.data[pos++] = c; 208 if (pos-2<msg.len) 209 continue; 210 211 #ifdef DEBUG 212 cout << "*** RcvdCanFrame len=" << dec << msg.len << ": "; 213 for (int i=0; i<msg.len; i++) 214 cout << "0x" << setfill('0') << setw(2) << hex << (int)((msg.data+2)[i]) << " "; 215 cout << dec << endl; 216 #endif 217 218 pos = -1; 219 220 // String completed 221 HandleMessage(msg); 222 } 223 } 224 */ 152 225 153 226 // -------------------------------------------------------------------------- … … 174 247 // */ 175 248 // 249 #ifdef DEBUG 250 #include <TStopwatch.h> 251 #endif 176 252 void Ethernet::SendCanFrame(WORD_t cobid, BYTE_t m[8], BYTE_t rtr) 177 253 { … … 203 279 #endif 204 280 281 #ifdef DEBUG 282 TStopwatch st; 283 st.Start(); 284 #endif 205 285 MTcpIpO::SendFrame(fTxAddress, fTxPort, (char*)(msg.data+1), msg.len-1); 286 #ifdef DEBUG 287 st.Print(); 288 #endif 206 289 //Send((char*)(msg.data+1), msg.len-1); 207 290 -
trunk/MagicSoft/Cosy/candrv/ethernet.h
r8862 r8864 17 17 18 18 // Send interface based on MTcpIpI 19 voidReadSocket(TSocket &rx);19 Bool_t ReadSocket(TSocket &rx); 20 20 21 21 // Start/stop communication inherited from Interface 22 22 void Start() { RunThread(); } 23 23 void Stop() { CancelThread(); } 24 25 Bool_t HasConnection() const { return IsConnectionEstablished(); } 24 26 25 27 public: -
trunk/MagicSoft/Cosy/candrv/interface.h
r8854 r8864 45 45 virtual void EnableCobId(WORD_t cobid, int flag=TRUE) { } 46 46 47 virtual bool HasConnection() const { return true; } 48 47 49 // Public interface 48 50 void PrintMsg(const Message &m); -
trunk/MagicSoft/Cosy/candrv/network.cc
r8863 r8864 314 314 continue; 315 315 316 if (CanOpen::HasError()) 317 fNodes[i]->SetZombie(); 318 316 319 if (!fNodes[i]->HasError()) 317 320 continue; … … 325 328 //gLog << "' has error #" << fNodes[i]->GetError() << endl; 326 329 } 330 331 if (CanOpen::HasError()) 332 return true; 327 333 328 334 return rc; -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r8863 r8864 60 60 61 61 int GetError() const { return fError; } 62 bool HasError() const { return fError ; }62 bool HasError() const { return fError!=0; } 63 63 64 64 bool IsZombieNode() const { return fIsZombie; }
Note:
See TracChangeset
for help on using the changeset viewer.