Changeset 10031 for trunk/Cosy/candrv


Ignore:
Timestamp:
10/21/10 16:16:52 (14 years ago)
Author:
tbretz
Message:
Changed connection from SPS to a client-only connection.
Location:
trunk/Cosy/candrv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosy/candrv/ethernet.cc

    r9439 r10031  
    5555//  and switch the can bus communication on
    5656//
    57 Ethernet::Ethernet(const char *addr, const int tx, const int rx, CanOpen *receiver)
    58     : MTcpIpI(rx), /*MTcpIpO(addr, tx),*/ Interface(receiver), fTxAddress(addr), fTxPort(tx)
     57Ethernet::Ethernet(const char *addr, const int tx, CanOpen *receiver)
     58    : MTcpIpOI(addr, tx), Interface(receiver)
    5959{
    6060    gLog << inf2 << "- Ethernet initialized." << endl;
     
    6868Ethernet::~Ethernet()
    6969{
    70     MTcpIpI::CancelThread();
     70    CancelThread();
    7171    gLog << inf2 << "- Ethernet stopped." << endl;
    7272}
     
    7979
    8080    Message msg;
     81    msg.len = 0;
    8182    msg.cmd = M_BCAN_RX_ind;
    8283    msg.data[0] = 0;
    8384    msg.data[1] = 0;
    8485
    85     const TString address = MTcpIpO::GetSocketAddress(rx);
    86 
    87     while (!MTcpIpI::IsThreadCanceled())
     86    const TString address = GetSocketAddress(rx);
     87
     88    while (!IsThreadCanceled())
    8889    {
    8990        unsigned char c;
     
    280281    st.Start();
    281282#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
    284286#ifdef DEBUG
    285287    st.Print();
    286288#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  
    1010#endif
    1111
    12 class Ethernet : public MTcpIpI, /*public MTcpIpO,*/ public Interface
     12class Ethernet : public MTcpIpOI, public Interface
    1313{
    1414private:
    15     TString fTxAddress;
    16     Int_t   fTxPort;
    17 
    1815    // Send interface based on MTcpIpI
    1916    Bool_t ReadSocket(TSocket &rx);
    2017
    2118    // 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(); }
    2621
    2722public:
    28     Ethernet(const char *addr, const int tx, const int rx, CanOpen *receiver);
     23    Ethernet(const char *addr, const int tx, CanOpen *receiver);
    2924    virtual ~Ethernet();
    3025
Note: See TracChangeset for help on using the changeset viewer.