コード例 #1
0
ファイル: model.cpp プロジェクト: jwildeboer/repsnapper
bool Model::handle_dev_fd (Glib::IOCondition cond)
{
  int result;
  if (cond & Glib::IO_IN) {
    result = rr_dev_handle_readable (m_device);
    if (result < 0)
      error ("Error reading from device!", strerror (errno));
  }
  if (cond & Glib::IO_OUT) {
    result = rr_dev_handle_writable (m_device);
    if (result < 0)
      error ("Error writing to device!", strerror (errno));
  }
  if (cond & (Glib::IO_ERR | Glib::IO_HUP))
    serial_try_connect (false);

  return true;
}
コード例 #2
0
bool Printer::handle_dev_fd (Glib::IOCondition cond)
{
  if (device==NULL) return false;
  int result;
  if (cond & Glib::IO_IN) {
    result = rr_dev_handle_readable (device);
    if (result < 0)
      error (_("Error reading from device!"), std::strerror (errno));
  }
  // try to avoid reading and writing at exactly the same time
  else if (cond & Glib::IO_OUT) {
    result = rr_dev_handle_writable (device);
    if (result < 0)
      error (_("Error writing to device!"), std::strerror (errno));
  }
  if (cond & (Glib::IO_ERR | Glib::IO_HUP))
    serial_try_connect (false);

  return true;
}