Changeset 10031 for trunk/Cosy/candrv
- Timestamp:
- 10/21/10 16:16:52 (14 years ago)
- Location:
- trunk/Cosy/candrv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosy/candrv/ethernet.cc
r9439 r10031 55 55 // and switch the can bus communication on 56 56 // 57 Ethernet::Ethernet(const char *addr, const int tx, const int rx,CanOpen *receiver)58 : MTcpIp I(rx), /*MTcpIpO(addr, tx),*/ Interface(receiver), fTxAddress(addr), fTxPort(tx)57 Ethernet::Ethernet(const char *addr, const int tx, CanOpen *receiver) 58 : MTcpIpOI(addr, tx), Interface(receiver) 59 59 { 60 60 gLog << inf2 << "- Ethernet initialized." << endl; … … 68 68 Ethernet::~Ethernet() 69 69 { 70 MTcpIpI::CancelThread();70 CancelThread(); 71 71 gLog << inf2 << "- Ethernet stopped." << endl; 72 72 } … … 79 79 80 80 Message msg; 81 msg.len = 0; 81 82 msg.cmd = M_BCAN_RX_ind; 82 83 msg.data[0] = 0; 83 84 msg.data[1] = 0; 84 85 85 const TString address = MTcpIpO::GetSocketAddress(rx);86 87 while (! MTcpIpI::IsThreadCanceled())86 const TString address = GetSocketAddress(rx); 87 88 while (!IsThreadCanceled()) 88 89 { 89 90 unsigned char c; … … 280 281 st.Start(); 281 282 #endif 282 MTcpIpO::SendFrame(fTxAddress, fTxPort, (char*)(msg.data+1), msg.len-1); 283 // Send((char*)(msg.data+1), msg.len-1); 283 284 Send((char*)(msg.data+1), msg.len-1); 285 284 286 #ifdef DEBUG 285 287 st.Print(); 286 288 #endif 287 //Send((char*)(msg.data+1), msg.len-1); 288 289 /* 290 const WORD_t desc = MsgDescr(cobid, 8, rtr); 291 292 Message msg; 293 294 msg.cmd = M_BCAN_TX_req; 295 296 msg.len = 12; 297 msg.data[0] = 0; 298 msg.data[1] = 0; 299 msg.data[2] = word_to_msb(desc); 300 msg.data[3] = word_to_lsb(desc); 301 302 memcpy(&msg.data[4], m, 8); 303 304 while (!Send(&msg));*/ 305 } 289 } -
trunk/Cosy/candrv/ethernet.h
r9439 r10031 10 10 #endif 11 11 12 class Ethernet : public MTcpIp I, /*public MTcpIpO,*/public Interface12 class Ethernet : public MTcpIpOI, public Interface 13 13 { 14 14 private: 15 TString fTxAddress;16 Int_t fTxPort;17 18 15 // Send interface based on MTcpIpI 19 16 Bool_t ReadSocket(TSocket &rx); 20 17 21 18 // Start/stop communication inherited from Interface 22 void Start() { MTcpIpI::RunThread(); } 23 void Stop() { MTcpIpI::CancelThread(); } 24 25 Bool_t HasConnection() const { return MTcpIpI::IsConnectionEstablished(); } 19 void Start() { if (!IsThreadRunning()) RunThread(); } 20 void Stop() { CancelThread(); } 26 21 27 22 public: 28 Ethernet(const char *addr, const int tx, const int rx,CanOpen *receiver);23 Ethernet(const char *addr, const int tx, CanOpen *receiver); 29 24 virtual ~Ethernet(); 30 25
Note:
See TracChangeset
for help on using the changeset viewer.