signal_io() and callback confusion



Hi there,

I would like to open a serial port connection (ttyS*) and to display the recieved chars in a TextView widget. Therefore, I use the callback function so the mouse/keyboard user input will be processed.

But now I can't manage to set up a slot (port config is not done yet). G++ puts this message:

serialport.cpp: In member function `gint serialport::start()':
serialport.cpp:35: error: invalid use of `template<class T_return, class
   T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class
   T_arg6, class T_arg7> class sigc::slot'


// serialport.h ----------------------------------------------
#ifndef serialportH
#define serialportH

#include "config.h"

#include <gtkmm.h>
#include <sigc++/signal.h>
#include <sigc++/object.h>


class serialport: public SigC::Object
{
public:
  serialport();
  virtual ~serialport();

  gint start();

private:
  bool callback_funcion(Glib::IOCondition);

private:
  gchar* portname;
  gint fd;

  SigC::Connection connection;

};
#endif


// serialport.cpp --------------------------------------------
#include "serialport.h"

#include <stdio.h>   /* Standard input/output definitions */
#include <string.h>  /* String function definitions */
#include <unistd.h>  /* UNIX standard function definitions */
#include <fcntl.h>   /* File control definitions */
#include <errno.h>   /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <sys/types.h>
#include <iostream>
#include <sigc++/slot.h>

using namespace std;

serialport::serialport()
{
  portname = "/dev/ttyS0";
}

serialport::~serialport()
{
}

gint serialport::start()
{
  this->fd = ::open(this->portname, O_RDWR);

  if(this->fd<0)
  {
    cout << "Error opening serial port" << endl;
  }


  this->connection = Glib::signal_io().connect(
                     sigc::slot(*this, &serialport::callback_funcion),
                     this->fd,
                     Glib::IO_IN);
  return 0;

}


bool serialport::callback_funcion(Glib::IOCondition)
{
  cout << "Callback" << endl;
}
// ---------------------------------------------------------

Thanks in advance!
Claudio



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]