[ace-users] Trying to adding an ACE_TTY_IO handler to the reactor.
Douglas C. Schmidt
schmidt at dre.vanderbilt.edu
Fri Jun 15 06:01:34 CDT 2007
Hi,
Thanks for using the PRF.
> ACE VERSION: 5.5.7
>
>=20
>
> HOST MACHINE and OPERATING SYSTEM:
>
> I386 Win XP
>
>=20
>
> TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
>
> COMPILER NAME AND VERSION (AND PATCHLEVEL):
>
>=20
>
> THE $ACE_ROOT/ace/config.h FILE [if you use a link to a platform-
>
> specific file, simply state which one]: ace/config-win32.h"
>
>=20
>
> THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE [if you
>
> use a link to a platform-specific file, simply state which one
>
> (unless this isn't used in this case, e.g., with Microsoft Visual
>
> C++)]:=20
>
>=20
>
> CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
>
> (used by MPC when you generate your own makefiles):
>
>=20
>
> AREA/CLASS/EXAMPLE AFFECTED:
>
>I used "Logger_Simple_Server" as base.
>
>=20
>
> SYNOPSIS:
>
>Trying to add a handler for ACE_TTY_IO to add with the reactor, but it
>fail when I try to register the handler for the serial device.
You're using the wrong method to register the event handler. You'll
need to use this method:
/**
* Register handler for OS events.
*
* Register an <event_handler> that will be notified when
* <event_handle> is signaled. This will call back its
* <handle_signal> hook method.
*
* Reactor will call ACE_Event_Handler::add_reference() for a new
* handler/handle pair.
*
* This interface is only available Win32 platforms because
* ACE_HANDLE is an int on non-Win32 platforms and compilers are not
* able to tell the difference between
* register_handler(ACE_Event_Handler*,ACE_Reactor_Mask) and
* register_handler(ACE_Event_Handler*,ACE_HANDLE).
*/
virtual int register_handler (ACE_Event_Handler *event_handler,
ACE_HANDLE event_handle = ACE_INVALID_HANDLE);
Please see Chapter 4 of C++NPv2 <www.cs.wustl.edu/~schmidt/ACE/book2/>
for information.
Thanks,
Doug
>=20
>
>=20
>
> DESCRIPTION:
>
>This is my first trial using ACE.
>
>=20
>
>My RS232 handler class
>
>=20
>
>class Rs232Handler : public ACE_Event_Handler
>
>{
>
>public:
>
> Rs232Handler() ;
>
>=20
>
> int open( char * ) ;
>
>=20
>
>private:
>
> virtual int handle_input( ACE_HANDLE ) ;
>
> //virtual int handle_close( ACE_HANDLE, ACE_Reactor_Mask ) ;
>
> virtual ACE_HANDLE get_handle( void ) const ;
>
>=20
>
> ~Rs232Handler() ;
>
>=20
>
> ACE_TTY_IO *ser_dev_ ;
>
> ACE_DEV_Connector *con_ ;
>
>=20
>
> ACE_TTY_IO::Serial_Params dev_params ;
>
>} ;
>
>=20
>
>Rs232Handler::Rs232Handler()
>
>{
>
> ser_dev_ =3D 0 ;
>
> con_ =3D 0 ;
>
>}
>
>=20
>
>Rs232Handler::~Rs232Handler()
>
>{
>
> if( ser_dev_)
>
> delete ser_dev_ ;
>
>=20
>
> if( con_ )
>
> delete con_ ;
>
>=20
>
>}
>
>=20
>
>int Rs232Handler::open( char *dev )
>
>{
>
> ACE_NEW_RETURN( ser_dev_, ACE_TTY_IO, 1 ) ;
>
> ACE_NEW_RETURN( con_, ACE_DEV_Connector, 1 ) ;
>
>=20
>
> if( con_->connect( (*ser_dev_), ACE_DEV_Addr(dev) ) =3D=3D -1 )
>
> return -1 ;
>
>=20
>
> dev_params.baudrate =3D 19200 ;
>
> dev_params.xonlim =3D 0 ;
>
> dev_params.xofflim =3D 0 ;
>
> dev_params.readmincharacters =3D 0 ;
>
> dev_params.readtimeoutmsec =3D 0 ; // 0 sec
>
> dev_params.paritymode =3D "EVEN" ;
>
> dev_params.ctsenb =3D false ;
>
> dev_params.rtsenb =3D 0 ;
>
> dev_params.xinenb =3D false ;
>
> dev_params.xoutenb =3D false ;
>
> dev_params.modem =3D false ;
>
> dev_params.rcvenb =3D true ;
>
> dev_params.dsrenb =3D false ;
>
> dev_params.dtrdisable =3D false ;
>
> dev_params.databits =3D 8 ;
>
> dev_params.stopbits =3D 1 ;
>
>=20
>
> if( ser_dev_->control(ACE_TTY_IO::SETPARAMS, &dev_params) =3D=3D -1 =
>)
>
> return -1 ;
>
>}
>
>=20
>
>int Rs232Handler::handle_input( ACE_HANDLE )
>
>{
>
> char readback ;
>
> ssize_t bytes_read =3D ser_dev_->recv( (void*) &readback, 1 ) ;
>
> int read_count =3D 0 ;
>
> while( bytes_read =3D=3D 1 )=20
>
> {
>
> ACE_DEBUG( ( LM_DEBUG, ACE_TEXT( "read: %c\n" ),readback ) ) ;
>
> read_count++ ;
>
> bytes_read =3D ser_dev_->recv( (void*) &readback, 1 ) ;
>
> }
>
> =20
>
> if( read_count > 0 )
>
> return -1 ;
>
> else
>
> return 0 ;
>
>=20
>
>}
>
>=20
>
>ACE_HANDLE Rs232Handler::get_handle( void ) const=20
>
>{
>
> return this->ser_dev_->get_handle() ;
>
>}
>
>=20
>
>=20
>
>The code from ACE_TMAIN()
>
>:
>
>:
>
> // do the network preparation.
>
> if (peer_acceptor->open (addr) =3D=3D -1)
>
> ACE_ERROR_RETURN ((LM_ERROR,
>
> ACE_TEXT ("%p\n"),
>
> ACE_TEXT ("open net")),
>
> -1);
>
> else if (REACTOR::instance ()->register_handler
>
> (peer_acceptor,
>
> ACE_Event_Handler::ACCEPT_MASK) =3D=3D -1)
>
> ACE_ERROR_RETURN ((LM_ERROR,
>
> ACE_TEXT ("registering net service with
>ACE_Reactor\n")),
>
> -1);
>
>=20
>
> // do the PS232 preparation.
>
> Rs232Handler *ser_handler ;
>
> ACE_NEW_RETURN( ser_handler, Rs232Handler, 1 ) ;
>
> if( ser_handler->open( "\\\\.\\COM1" ) =3D=3D -1 )
>
> ACE_ERROR_RETURN ((LM_ERROR,
>
> ACE_TEXT ("%p\n"),
>
> ACE_TEXT ("open ser")),
>
> -1);
>
> else if (REACTOR::instance ()->register_handler
>
> (ser_handler,
>
> ACE_Event_Handler::READ_MASK) =3D=3D -1) //<<<<<<<<< ----- =
>Fails
>here
>
> ACE_ERROR_RETURN ((LM_ERROR,
>
> ACE_TEXT ("registering ser service with
>ACE_Reactor\n")),
>
> -1);
>
>=20
>
> // Run forever, performing the logging service.
>
>=20
>
> ACE_DEBUG ((LM_DEBUG,
>
> ACE_TEXT ("(%P|%t) starting up server logging daemon\n")));
>
>=20
>
> while (!finished)
>
> REACTOR::instance ()->handle_events ();
>
>=20
>
> ACE_DEBUG ((LM_DEBUG,
>
> ACE_TEXT ("(%P|%t) shutting down server logging
>daemon\n")));
>
> return 0;
>
>}
>
>=20
>
>=20
>
> REPEAT BY:
>
>=20
>
>=20
>
> SAMPLE FIX/WORKAROUND:
>
>?
>
>
>------_=_NextPart_001_01C7AF22.BC6644DA
>Content-Type: text/html;
> charset="us-ascii"
>Content-Transfer-Encoding: quoted-printable
>
><html xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
>xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
>xmlns=3D"http://www.w3.org/TR/REC-html40">
>
><head>
><meta http-equiv=3DContent-Type content=3D"text/html; =
>charset=3Dus-ascii">
><meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
><style>
><!--
> /* Style Definitions */
> p.MsoNormal, li.MsoNormal, div.MsoNormal
> {margin:0cm;
> margin-bottom:.0001pt;
> font-size:12.0pt;
> font-family:"Times New Roman";}
>a:link, span.MsoHyperlink
> {color:blue;
> text-decoration:underline;}
>a:visited, span.MsoHyperlinkFollowed
> {color:purple;
> text-decoration:underline;}
>span.EmailStyle17
> {mso-style-type:personal-compose;
> font-family:Arial;
> color:windowtext;}
>@page Section1
> {size:612.0pt 792.0pt;
> margin:72.0pt 90.0pt 72.0pt 90.0pt;}
>div.Section1
> {page:Section1;}
>-->
></style>
>
></head>
>
><body lang=3DEN-US link=3Dblue vlink=3Dpurple>
>
><div class=3DSection1>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> ACE VERSION: =
>5.5.7<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> HOST MACHINE and OPERATING =
>SYSTEM:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> I386 Win =
>XP<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> TARGET MACHINE and OPERATING =
>SYSTEM, if
>different from HOST:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> COMPILER NAME AND VERSION (AND
>PATCHLEVEL):<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> THE $ACE_ROOT/ace/config.h FILE =
>[if you
>use a link to a platform-<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> specific file, simply state which =
>one]: ace/config-win32.h"<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> THE
>$ACE_ROOT/include/makeinclude/platform_macros.GNU FILE [if =
>you<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> use a link to a platform-specific =
>file,
>simply state which one<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> (unless this isn't used in this =
>case,
>e.g., with Microsoft Visual<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> C++)]: =
><o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> CONTENTS OF
>$ACE_ROOT/bin/MakeProjectCreator/config/default.features<o:p></o:p></span=
>></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> (used by MPC when you generate =
>your own
>makefiles):<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> AREA/CLASS/EXAMPLE =
>AFFECTED:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'>I used “Logger_Simple_Server” as =
>base.<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> =
>SYNOPSIS:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'>Trying to add a handler for ACE_TTY_IO to add with =
>the
>reactor, but it fail when I try to register the handler for the serial =
>device.<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> =
>DESCRIPTION:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'>This is my first trial using =
>ACE.<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'>My RS232 handler class<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>color=3Dblue
>face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;font-family:"Courier New";
>color:blue'>class</span></font><font size=3D2 face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> Rs232Handler : =
><font
>color=3Dblue><span style=3D'color:blue'>public</span></font> =
>ACE_Event_Handler<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>{<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>color=3Dblue
>face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;font-family:"Courier New";
>color:blue'>public</span></font><font size=3D2 face=3D"Courier =
>New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>Rs232Handler() ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>int</span></font> open( <font =
>color=3Dblue><span
>style=3D'color:blue'>char</span></font> * ) =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>color=3Dblue
>face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;font-family:"Courier New";
>color:blue'>private</span></font><font size=3D2 face=3D"Courier =
>New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>virtual</span></font> <font =
>color=3Dblue><span
>style=3D'color:blue'>int</span></font> handle_input( ACE_HANDLE ) =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dgreen><span style=3D'color:green'>//virtual int handle_close( =
>ACE_HANDLE,
>ACE_Reactor_Mask ) ;<o:p></o:p></span></font></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>virtual</span></font> ACE_HANDLE
>get_handle( <font color=3Dblue><span =
>style=3D'color:blue'>void</span></font> ) <font
>color=3Dblue><span style=3D'color:blue'>const</span></font> =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>~Rs232Handler() ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_TTY_IO =
>*ser_dev_ ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_DEV_Connector *con_ ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_TTY_IO::Serial_Params dev_params ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span lang=3DDA
>style=3D'font-size:10.0pt;font-family:"Courier New"'>} =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span lang=3DDA
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>Rs232Handler::Rs232Handler()<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>{<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>ser_dev_ =3D 0 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>con_ =3D 0 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>}<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>Rs232Handler::~Rs232Handler()<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>{<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> <font
>color=3Dblue><span style=3D'color:blue'>if</span></font>( =
>ser_dev_)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
></span></font><font size=3D2 color=3Dblue face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New";color:blue'>delete</span></font><font
>size=3D2 face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ser_dev_ ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>if</span></font>( con_ =
>)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
><font color=3Dblue><span style=3D'color:blue'>delete</span></font> con_ =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>}<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>color=3Dblue
>face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;font-family:"Courier New";
>color:blue'>int</span></font><font size=3D2 face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
>Rs232Handler::open( <font
>color=3Dblue><span style=3D'color:blue'>char</span></font> *dev =
>)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>{<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_NEW_RETURN( ser_dev_, ACE_TTY_IO, 1 ) ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_NEW_RETURN( con_, ACE_DEV_Connector, 1 ) =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>if</span></font>( =
>con_->connect(
>(*ser_dev_), ACE_DEV_Addr(dev) ) =3D=3D -1 =
>)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
><font color=3Dblue><span style=3D'color:blue'>return</span></font> -1 =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.baudrate =
>
>=3D 19200 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.xonlim &n=
>bsp;
>=3D 0 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.xofflim &=
>nbsp;
>=3D 0 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.readmincharacters =3D 0 =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.readtimeoutmsec =3D 0 ; <font
>color=3Dgreen><span style=3D'color:green'>// 0 =
>sec<o:p></o:p></span></font></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.paritymode &nbs=
>p;
>=3D <font color=3Dmaroon><span =
>style=3D'color:maroon'>"EVEN"</span></font>
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.ctsenb &n=
>bsp;
>=3D <font color=3Dblue><span style=3D'color:blue'>false</span></font> =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.rtsenb &n=
>bsp;
>=3D 0 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.xinenb &n=
>bsp;
>=3D <font color=3Dblue><span style=3D'color:blue'>false</span></font> =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.xoutenb =
> &=
>nbsp;=3D
><font color=3Dblue><span style=3D'color:blue'>false</span></font> =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.modem &nb=
>sp;
>=3D <font color=3Dblue><span style=3D'color:blue'>false</span></font> =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.rcvenb &n=
>bsp;
>=3D <font color=3Dblue><span style=3D'color:blue'>true</span></font> =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.dsrenb &n=
>bsp;
>=3D <font color=3Dblue><span style=3D'color:blue'>false</span></font> =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.dtrdisable &nbs=
>p;
>=3D <font color=3Dblue><span style=3D'color:blue'>false</span></font> =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.databits =
>
>=3D 8 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>dev_params.stopbits =
>
>=3D 1 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>if</span></font>(
>ser_dev_->control(ACE_TTY_IO::SETPARAMS, &dev_params) =3D=3D -1 =
>)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
><font color=3Dblue><span style=3D'color:blue'>return</span></font> -1 =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>}<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>color=3Dblue
>face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;font-family:"Courier New";
>color:blue'>int</span></font><font size=3D2 face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
>Rs232Handler::handle_input(
>ACE_HANDLE )<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>{<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>char</span></font> readback =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
>ssize_t
>bytes_read =3D ser_dev_->recv( (<font color=3Dblue><span =
>style=3D'color:blue'>void</span></font>*)
>&readback, 1 ) ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>int</span></font> read_count =3D =
>0 ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>while</span></font>( bytes_read =
>=3D=3D 1 ) <o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
>{<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>ACE_DEBUG( ( LM_DEBUG, ACE_TEXT( <font color=3Dmaroon><span =
>style=3D'color:maroon'>"read:
>%c\n"</span></font> ),readback ) ) ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>read_count++ ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>bytes_read =3D ser_dev_->recv( (<font color=3Dblue><span =
>style=3D'color:blue'>void</span></font>*)
>&readback, 1 ) ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
>}<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>if</span></font>( read_count =
>> 0 )<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
><font color=3Dblue><span style=3D'color:blue'>return</span></font> -1 =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span =
>style=3D'color:blue'>else<o:p></o:p></span></font></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
><font color=3Dblue><span style=3D'color:blue'>return</span></font> 0 =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>}<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>ACE_HANDLE
>Rs232Handler::get_handle( <font color=3Dblue><span =
>style=3D'color:blue'>void</span></font>
>) <font color=3Dblue><span style=3D'color:blue'>const</span></font> =
><o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>{<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>return</span></font> <font =
>color=3Dblue><span
>style=3D'color:blue'>this</span></font>->ser_dev_->get_handle() =
>;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>}<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'>The code from =
>ACE_TMAIN()<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'>:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'>:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> <font =
>color=3Dgreen><span
>style=3D'color:green'>// do the network =
>preparation.<o:p></o:p></span></font></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> <font =
>color=3Dblue><span
>style=3D'color:blue'>if</span></font> (peer_acceptor->open (addr) =
>=3D=3D -1)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_ERROR_RETURN ((LM_ERROR,<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> &=
>nbsp;
>ACE_TEXT (<font color=3Dmaroon><span =
>style=3D'color:maroon'>"%p\n"</span></font>),<o:p></o:p></span>=
></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> &=
>nbsp;
>ACE_TEXT (<font color=3Dmaroon><span style=3D'color:maroon'>"open =
>net"</span></font>)),<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> &=
>nbsp;
>-1);<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> <font =
>color=3Dblue><span
>style=3D'color:blue'>else</span></font> <font color=3Dblue><span =
>style=3D'color:blue'>if</span></font>
>(REACTOR::instance ()->register_handler<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>(peer_acceptor,<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>ACE_Event_Handler::ACCEPT_MASK) =3D=3D -1)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_ERROR_RETURN ((LM_ERROR,<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> =
>
>ACE_TEXT (<font color=3Dmaroon><span =
>style=3D'color:maroon'>"registering net
>service with =
>ACE_Reactor\n"</span></font>)),<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> =
>
>-1);<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> <font =
>color=3Dgreen><span
>style=3D'color:green'>// do the PS232 =
>preparation.<o:p></o:p></span></font></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> Rs232Handler
>*ser_handler ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> =
>ACE_NEW_RETURN(
>ser_handler, Rs232Handler, 1 ) ;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> <font =
>color=3Dblue><span
>style=3D'color:blue'>if</span></font>( ser_handler->open( <font =
>color=3Dmaroon><span
>style=3D'color:maroon'>"\\\\.\\COM1"</span></font> ) =3D=3D -1 =
>)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_ERROR_RETURN ((LM_ERROR,<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> &=
>nbsp;
>ACE_TEXT (<font color=3Dmaroon><span =
>style=3D'color:maroon'>"%p\n"</span></font>),<o:p></o:p></span>=
></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> &=
>nbsp;
>ACE_TEXT (<font color=3Dmaroon><span style=3D'color:maroon'>"open =
>ser"</span></font>)),<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> &=
>nbsp;
></span></font><font size=3D2 face=3D"Courier New"><span lang=3DDA =
>style=3D'font-size:
>10.0pt;font-family:"Courier New"'>-1);<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier New"'> =
><font
>color=3Dblue><span style=3D'color:blue'>else</span></font> <font =
>color=3Dblue><span
>style=3D'color:blue'>if</span></font> (REACTOR::instance =
>()->register_handler<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>(ser_handler,<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>lang=3DDA style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
></span></font><font size=3D2 face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;
>font-family:"Courier New"'>ACE_Event_Handler::READ_MASK) =3D=3D =
>-1)
>//<<<<<<<<< ----- Fails =
>here<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'>
>ACE_ERROR_RETURN ((LM_ERROR,<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> =
>
>ACE_TEXT (<font color=3Dmaroon><span =
>style=3D'color:maroon'>"registering ser
>service with =
>ACE_Reactor\n"</span></font>)),<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'> =
>
>-1);<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> <font =
>color=3Dgreen><span
>style=3D'color:green'>// Run forever, performing the logging =
>service.<o:p></o:p></span></font></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>color=3Dgreen
>face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;font-family:"Courier New";
>color:green'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> ACE_DEBUG =
>((LM_DEBUG,<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>ACE_TEXT (<font color=3Dmaroon><span =
>style=3D'color:maroon'>"(%P|%t) starting
>up server logging =
>daemon\n"</span></font>)));<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> <font =
>color=3Dblue><span
>style=3D'color:blue'>while</span></font> =
>(!finished)<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>REACTOR::instance ()->handle_events ();<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> ACE_DEBUG =
>((LM_DEBUG,<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier =
>New"'>
>ACE_TEXT (<font color=3Dmaroon><span =
>style=3D'color:maroon'>"(%P|%t) shutting
>down server logging =
>daemon\n"</span></font>)));<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
>face=3D"Courier New"><span
>style=3D'font-size:10.0pt;font-family:"Courier New"'> <font =
>color=3Dblue><span
>style=3D'color:blue'>return</span></font> =
>0;<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
>style=3D'font-size:10.0pt;
>font-family:"Courier New"'>}</span></font><font size=3D2 =
>face=3DArial><span
>style=3D'font-size:10.0pt;font-family:Arial'><o:p></o:p></span></font></p=
>>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> REPEAT =
>BY:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'><o:p> </o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'> SAMPLE =
>FIX/WORKAROUND:<o:p></o:p></span></font></p>
>
><p class=3DMsoNormal><font size=3D2 face=3DArial><span =
>style=3D'font-size:10.0pt;
>font-family:Arial'>?<o:p></o:p></span></font></p>
>
></div>
>
></body>
>
></html>
>
>------_=_NextPart_001_01C7AF22.BC6644DA--
>
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Vanderbilt University WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203 NET: d.schmidt at vanderbilt.edu
More information about the Ace-users
mailing list