ACE VERSION: 5.6.3
HOST MACHINE and OPERATING SYSTEM:
- Linux - Ubuntu 9.04 - Kernel 2.6.28
TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
-
COMPILER NAME AND VERSION (AND PATCHLEVEL):
- g++ Version 4.3.3
BUILD METHOD USED:
[Experimental ./configure or traditional makefile/project file?]
- makefile/project file
AREA/CLASS/EXAMPLE AFFECTED:
[What example failed? What module failed to compile?]
Example for using the Reactor with a serial device and not with TCP/IP as a data source. Compiling didn�t fail.
DOES THE PROBLEM AFFECT:
COMPILATION? -
LINKING? -
On Unix systems, did you run make realclean first?
- yes
EXECUTION?
- fails (no signal, caused by data input from the serial device, occurs)
DESCRIPTION:
The application uses the reactor. There is a serial device on which constantly data arrives. The applic just opens the serial connection and registers a handler to it. Then it starts the run_reactor_event_loop - in this case without an exit conditions.
The application uses the standard reactor methods:
The "open()" method registers a handler, makes a connect to the serial device and sets the serial parameters.
The "handle_input()" method doesn�t have to do anythng special. In this example it shall only dislay the received data.
"Handle_close()" just removes the handler, closes the serial connection and deletes the object.
Normally I would expect, that the reactor would get signals - cause of the incoming data on the serial interface - from the OS, which causes calls of the "handle_input()" method.
But nothing happens - the "handle_input()" routine's never been called, despite there�s always data arriving on the serial interface.
I tried also other examples, which were available online. They are similar structured and also never reach the "handle_input()".
here�s the code example:
#include "ace/DEV_Connector.h"
#include "ace/TTY_IO.h"
#include "ace/Time_Value.h"
#include "ace/Reactor.h"
#include <iostream>
class Service : public ACE_Event_Handler{
public:
Service();
virtual ~Service();
int open(const char *, ACE_TTY_IO::Serial_Params& sSerialParams);
virtual ACE_HANDLE get_handle(void) const
{
return this->peer_.get_handle();
}
virtual int handle_input(ACE_HANDLE fd = ACE_INVALID_HANDLE);
virtual int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask);
protected:
ACE_DEV_Connector connector_;
//ACE_Message_Queue<ACE_NULL_SYNC> output_queue;
private:
ACE_TTY_IO peer_;
};
int open(const char* name, ACE_TTY_IO::Serial_Params& sSerialParams) {
int nResult = 0;
ACE_Reactor::instance()->register_handler(this,
ACE_Event_Handler::READ_MASK);
// Set our I/O handle to that of the peer_ object handling our connection
if (this->connector_.connect(peer_, ACE_DEV_Addr(name), 0,
ACE_Addr::sap_any, 0, //reuse
O_RDWR | FILE_FLAG_OVERLAPPED) != 0) {
ACE_ERROR((LM_ERROR, ACE_TEXT("%p\n"),
ACE_TEXT("--- SerialIOHandler connect\n")));
nResult = -1;
}
if (peer_.control(ACE_TTY_IO::SETPARAMS, &sSerialParams) != 0) {
ACE_ERROR((LM_ERROR, ACE_TEXT("%p control\n"), name));
nResult = -1;
}
return nResult;
}
int handle_input(ACE_HANDLE) {
char *readBack;
peer_.recv((void *) &readBack, 1);
cout << readBack << endl;
return 0;
}
int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask) {
if (this->peer_.get_handle() != ACE_INVALID_HANDLE) {
ACE_Reactor_Mask m = ACE_Event_Handler::ACCEPT_MASK
| ACE_Event_Handler::DONT_CALL;
this->reactor()->remove_handler(this, m);
this->peer_.close();
delete this;
return 0;
}
return 0;
}
int ACE_TMAIN(int, ACE_TCHAR *[]) {
Service SerialIO0;
Service SerialIO1;
ACE_TTY_IO::Serial_Params sSerialParams;
sSerialPortParams.baudrate = 115200;
sSerialPortParams.xonlim = 0;
sSerialPortParams.xofflim = 0;
sSerialPortParams.readmincharacters = 0;
sSerialPortParams.readtimeoutmsec = 1000; // 1 second
sSerialPortParams.paritymode = "none";
sSerialPortParams.ctsenb = false;
sSerialPortParams.rtsenb = 0;
sSerialPortParams.xinenb = false;
sSerialPortParams.xoutenb = false;
sSerialPortParams.modem = false;
sSerialPortParams.rcvenb = true;
sSerialPortParams.dsrenb = false;
sSerialPortParams.dtrdisable = false;
sSerialPortParams.databits = 8;
sSerialPortParams.stopbits = 1;
const char * serName0 = "/dev/ttyUSB0";
const char * serName1 = "/dev/ttyUSB1";
if (SerialIO0.open(serName0, sSerialParams) == -1)
{
cout << "could not connect to: " << serName0 << endl;
return 1;
}
if (SerialIO1.open(serName1, sSerialParams) == -1)
{
cout << "could not connect to: " << serName1 << endl;
return 1;
}
cout << "connected to: " << serName0 << " " << serName1 << endl;
ACE_Reactor::instance()->run_reactor_event_loop();
return 0;
}
Would be great if somebody could give me a little help. Thanks a lot in advance.
Best regards,
Daniel
SAMPLE FIX/WORKAROUND:
[If available ]
--
GRATIS f�r alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
|
"Daniel Kempcke" <Daniel....@gmx.net> Sent by: ace-user...@list.isis.vanderbilt.edu 11/05/2009 10:21 AM |
|
I tried it with -1 (and also with some other values). But the behaviour didn't change.
But anyway - thx for your response...
Daniel
-------- Original-Nachricht --------
> Datum: Thu, 5 Nov 2009 10:41:30 -0500
> Von: robert...@us.transport.bombardier.com
> An: "Daniel Kempcke" <Daniel....@gmx.net>
> CC: ace-...@list.isis.vanderbilt.edu, ace-user...@list.isis.vanderbilt.edu
> Betreff: Re: [ace-users] Problem reactor used with serial interface
> GRATIS f�r alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> _______________________________________________
> ace-users mailing list
> ace-...@list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/ace-users
>
>
>
>
>
>
>
> _______________________________________________________________________________________________________________
>
> This e-mail communication (and any attachment/s) may contain confidential
> or privileged information and is intended only for the individual(s) or
> entity named above and to others who have been specifically authorized to
> receive it. If you are not the intended recipient, please do not read,
> copy, use or disclose the contents of this communication to others. Please
> notify the sender that you have received this e-mail in error by reply
> e-mail, and delete the e-mail subsequently. Please note that in order to
> protect the security of our information systems an AntiSPAM solution is in
> use and will browse through incoming emails.
> Thank you.
> _________________________________________________________________________________________________________________
>
>
> Ce message (ainsi que le(s) fichier(s)), transmis par courriel, peut
> contenir des renseignements confidentiels ou prot�g�s et est destin� �
> l?usage exclusif du destinataire ci-dessus. Toute autre personne est, par
> les pr�sentes, avis�e qu?il est strictement interdit de le diffuser, le
> distribuer ou le reproduire. Si vous l?avez re�u par inadvertance,
> veuillez nous en aviser et d�truire ce message. Veuillez prendre note
> qu'une solution antipollupostage (AntiSPAM) est utilis�e afin d'assurer
> la
> s�curit� de nos syst�mes d'information et qu'elle fur�tera les
> courriels
> entrants.
> Merci.
> _________________________________________________________________________________________________________________
>
>
--
GRATIS f�r alle GMX-Mitglieder: Die maxdome Movie-FLAT!
|
"Daniel Kempcke" <Daniel....@gmx.net> Sent by: ace-user...@list.isis.vanderbilt.edu |
| 11/06/2009 04:06 AM |
|
class SerialInputHandler: public ACE_Event_Handler {
public:
SerialInputHandler(ACE_Reactor* r) {
ACE_HANDLE fd = ACE_OS::open("/dev/ttyS0, O_RDWR);
//configure tty
set_handle(fd);
r->register_handler(this, ACE_Event_Handler::READ_MASK);
}
virtual ~SerialInputHandler() {
//do proper cleanup
}
int handle_input(ACE_HANDLE fd = ACE_INVALID_HANDLE) {
//process data
}
void set_handle(ACE_HANDLE fd) {
fd_serial = fd;
}
ACE_HANDLE get_handle(void) const {
return fd_serial;
}
private:
ACE_HANDLE fd_serial;
}
Best Wishes
Andreas
Daniel Kempcke schrieb:
that�s the error. When I'd started I had in the right order, but cause it wasn�t running (due to some further errors) I tried some things and totally forgot to change it back. Thank you so much^^.
Greetings,
Daniel
@Andreas: I didn�t need to try your version.^^ But thx anyway...
-------- Original-Nachricht --------
> Datum: Fri, 6 Nov 2009 08:19:09 -0500
> Von: robert...@us.transport.bombardier.com
> An: "Daniel Kempcke" <Daniel....@gmx.net>
> CC: ace-...@list.isis.vanderbilt.edu, ace-user...@list.isis.vanderbilt.edu
> Betreff: Re: [ace-users] Problem reactor used with serial interface
> Daniel,
>
> Another quick one: You're calling "reactor()->register_handler(...)"
> before calling "connector->connect(...)". The register_handler() will use
> your get_handle() to determine which handle to register. Since you
> haven't connected the port yet, your get_handle() (which calls
> peer_.get_handle()) is returning ACE_INVALID_HANDLE. It's in the
> connect() call where the peer's handle gets set to something valid.
>
> Try calling register_handler() *after* calling connect().
>
> - Bob
>
>
>
> Please consider the environment before you print / Antes de imprimir,
> piense en el medio ambiente
>
>
>
>
>
>
> "Daniel Kempcke" <Daniel....@gmx.net>
> Sent by: ace-user...@list.isis.vanderbilt.edu
> 11/06/2009 04:06 AM
>
> To
> ace-...@list.isis.vanderbilt.edu
> cc
>
> Subject
> Re: [ace-users] Problem reactor used with serial interface
>
>
>
>
>
>
>
>
> Hi Bob,
>
> I tried it with -1 (and also with some other values). But the behaviour
> didn't change.
> But anyway - thx for your response...
>
> Daniel
>
> -------- Original-Nachricht --------
> > Datum: Thu, 5 Nov 2009 10:41:30 -0500
> > Von: robert...@us.transport.bombardier.com
> > An: "Daniel Kempcke" <Daniel....@gmx.net>
> > CC: ace-...@list.isis.vanderbilt.edu,
> ace-user...@list.isis.vanderbilt.edu
> > Betreff: Re: [ace-users] Problem reactor used with serial interface
>
> > Daniel,
> >
> > As a quick guess: try setting your serial parameters' "readtimeoutmsec"
> > field to -1. This *should* cause the reactor (select() call) to
> correctly
> > block on the handle.
> >
> > - Bob
> >
> >
> > Please consider the environment before you print / Antes de imprimir,
> > piense en el medio ambiente
> >
> >
> >
> >
> >
> >
> > "Daniel Kempcke" <Daniel....@gmx.net>
> > Sent by: ace-user...@list.isis.vanderbilt.edu
> > 11/05/2009 10:21 AM
> >
> > To
> > ace-...@list.isis.vanderbilt.edu
> > cc
> >
> > Subject
> > [ace-users] Problem reactor used with serial interface
> >
> >
> >
> >
> >
> >
> >
> > GRATIS f�r alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> > _______________________________________________
> > ace-users mailing list
> > ace-...@list.isis.vanderbilt.edu
> > http://list.isis.vanderbilt.edu/mailman/listinfo/ace-users
> >
> >
> >
> >
> >
> >
> >
> >
> _______________________________________________________________________________________________________________
> >
> > This e-mail communication (and any attachment/s) may contain
> confidential
> > or privileged information and is intended only for the individual(s) or
> > entity named above and to others who have been specifically authorized
> to
> > receive it. If you are not the intended recipient, please do not read,
> > copy, use or disclose the contents of this communication to others.
> Please
> > notify the sender that you have received this e-mail in error by reply
> > e-mail, and delete the e-mail subsequently. Please note that in order to
>
> > protect the security of our information systems an AntiSPAM solution is
> in
> > use and will browse through incoming emails.
> > Thank you.
> >
> _________________________________________________________________________________________________________________
> >
> >
> > Ce message (ainsi que le(s) fichier(s)), transmis par courriel, peut
> > contenir des renseignements confidentiels ou prot�g�s et est destin�
> �
> > l?usage exclusif du destinataire ci-dessus. Toute autre personne est,
> par
> > les pr�sentes, avis�e qu?il est strictement interdit de le diffuser,
> le
> > distribuer ou le reproduire. Si vous l?avez re�u par inadvertance,
> > veuillez nous en aviser et d�truire ce message. Veuillez prendre note
> > qu'une solution antipollupostage (AntiSPAM) est utilis�e afin d'assurer
> > la
> > s�curit� de nos syst�mes d'information et qu'elle fur�tera les
> > courriels
> > entrants.
> > Merci.
> >
> _________________________________________________________________________________________________________________
> >
> >
>
> --
> GRATIS f�r alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> _______________________________________________
> ace-users mailing list
> ace-...@list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/ace-users
>
>
>
>
>
>
>
> _______________________________________________________________________________________________________________
>
> This e-mail communication (and any attachment/s) may contain confidential
> or privileged information and is intended only for the individual(s) or
> entity named above and to others who have been specifically authorized to
> receive it. If you are not the intended recipient, please do not read,
> copy, use or disclose the contents of this communication to others. Please
> notify the sender that you have received this e-mail in error by reply
> e-mail, and delete the e-mail subsequently. Please note that in order to
> protect the security of our information systems an AntiSPAM solution is in
> use and will browse through incoming emails.
> Thank you.
> _________________________________________________________________________________________________________________
>
>
> Ce message (ainsi que le(s) fichier(s)), transmis par courriel, peut
> contenir des renseignements confidentiels ou prot�g�s et est destin� �
> l?usage exclusif du destinataire ci-dessus. Toute autre personne est, par
> les pr�sentes, avis�e qu?il est strictement interdit de le diffuser, le
> distribuer ou le reproduire. Si vous l?avez re�u par inadvertance,
> veuillez nous en aviser et d�truire ce message. Veuillez prendre note
> qu'une solution antipollupostage (AntiSPAM) est utilis�e afin d'assurer
> la
> s�curit� de nos syst�mes d'information et qu'elle fur�tera les
> courriels
> entrants.
> Merci.
> _________________________________________________________________________________________________________________
>
>
--
GRATIS f�r alle GMX-Mitglieder: Die maxdome Movie-FLAT!
|
"Daniel Kempcke" <Daniel....@gmx.net> Sent by: ace-user...@list.isis.vanderbilt.edu |
| 11/09/2009 02:02 AM |