Changeset 11921 for trunk/FACT++


Ignore:
Timestamp:
08/31/11 15:13:49 (13 years ago)
Author:
tbretz
Message:
Added a second argument to AsyncRead to be able to propagate a counter; for the moment switched DEBUG_TX on; only try to close the connection if it is not open
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/ConnectionUSB.cc

    r11851 r11921  
    1818using ba::serial_port_base;
    1919
    20 //#define DEBUG_TX
     20#define DEBUG_TX
    2121
    2222    // -------- Abbreviations for starting async tasks ---------
     
    3030}
    3131
    32 void ConnectionUSB::AsyncRead(const ba::mutable_buffers_1 buffers, int type)
     32void ConnectionUSB::AsyncRead(const ba::mutable_buffers_1 buffers, int type, int counter)
    3333{
    3434    ba::async_read(*this, buffers,
    3535                   boost::bind(&ConnectionUSB::HandleReceivedData, this,
    36                                dummy::error, dummy::bytes_transferred, type));
     36                               dummy::error, dummy::bytes_transferred, type, counter));
    3737}
    3838
     
    7777        Error("Cancel async requests on "+URL()+": "+ec.message());
    7878
    79     close(ec);
    80     if (!ec)
    81         Error("Closing "+URL()+": "+ec.message());
     79    if (IsConnected())
     80    {
     81        close(ec);
     82        if (!ec)
     83            Error("Closing "+URL()+": "+ec.message());
     84    }
    8285
    8386    // Reset the connection status
  • trunk/FACT++/src/ConnectionUSB.h

    r11471 r11921  
    4646    // -------- Abbreviations for starting async tasks ---------
    4747
    48     void AsyncRead(const boost::asio::mutable_buffers_1 buffers, int type=0);
     48    void AsyncRead(const boost::asio::mutable_buffers_1 buffers, int type=0, int counter=0);
    4949    void AsyncWrite(const boost::asio::const_buffers_1 &buffers);
    5050    void AsyncWait(boost::asio::deadline_timer &timer, int millisec,
     
    9595    // ------------------------ others --------------------------
    9696
    97     virtual void HandleReceivedData(const boost::system::error_code&, size_t, int = 0) { }
     97    virtual void HandleReceivedData(const boost::system::error_code&, size_t, int = 0, int = 0) { }
    9898    virtual void HandleTransmittedData(size_t) { }
    9999    virtual void HandleReadTimeout(const boost::system::error_code&) { }
Note: See TracChangeset for help on using the changeset viewer.