Boost logo

Boost Users :

Subject: [Boost-users] [ASIO] serial_port read seems to lost packets
From: Daniele Barzotti (daniele.barzotti_at_[hidden])
Date: 2009-04-08 13:11:16


Hi,

I'm sure that is a my issue but I need your help..
In my project I have to talk with a modem.
In answer to my AT command it responds:

+CMGS: 0

OK

+CMGS: 0,4,26

+CTSDSR: 40,123,0,456,0,152
231270F2204AAADC1234663E8DE77708FC5F3E

where the +CTSDSR arrives some milliseconds after the last +CMGS.
The problem is that I catch the two +CMGS but i miss completely the
+CTSDSR and I don't know why!

the reading code is:

void SerialPort::read_start()
{
  // Start an asynchronous read
  _serialPort.async_read_some(boost::asio::buffer(_buf, m_buffer_size),
                              boost::bind(&SerialPort::read_complete,
                              this,
                              boost::asio::placeholders::error,
                     boost::asio::placeholders::bytes_transferred));
};

void SerialPort::read_complete(const boost::system::error_code& error,
size_t bytes_transferred)
{
  // the asynchronous read operation has now completed
  if (!error)
  {
    // saving data to vector
    _read_buffer.append(_buf, bytes_transferred);
   cout << _read_buffer << endl;
  }
  // start waiting for another asynchronous read again
  read_start();
};

Could someone give me some suggestions?

Thanks!
Daniele.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net