<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>GNU CommonC++: ost::SerialPort Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespaceost.html">ost</a>::<a class="el" href="classost_1_1_serial_port.html">SerialPort</a> </div> </div> <div class="contents"> <h1>ost::SerialPort Class Reference</h1><!-- doxytag: class="ost::SerialPort" --><!-- doxytag: inherits="ost::Serial,ost::TimerPort" --> <p>The serial port is an internal class which is attached to and then serviced by a specified <a class="el" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a> thread. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="serial_8h_source.html">serial.h</a>></code></p> <div class="dynheader"> Inheritance diagram for ost::SerialPort:</div> <div class="dynsection"> <div class="center"> <img src="classost_1_1_serial_port.png" usemap="#ost::SerialPort_map" alt=""/> <map id="ost::SerialPort_map" name="ost::SerialPort_map"> <area href="classost_1_1_serial.html" alt="ost::Serial" shape="rect" coords="0,0,90,24"/> <area href="classost_1_1_timer_port.html" alt="ost::TimerPort" shape="rect" coords="100,0,190,24"/> </map> </div> </div> <p><a href="classost_1_1_serial_port-members.html">List of all members.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#aeb008981e1a1d2eff230b231c3ce5d9c">setTimer</a> (<a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout=0)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Derived setTimer to notify the service thread pool of changes in expected timeout. <a href="#aeb008981e1a1d2eff230b231c3ce5d9c"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#a4fa45b7494efbcd0c1b28a724f93b6b3">incTimer</a> (<a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Derived incTimer to notify the service thread pool of a change in expected timeout. <a href="#a4fa45b7494efbcd0c1b28a724f93b6b3"></a><br/></td></tr> <tr><td colspan="2"><h2>Protected Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#a8e281b17e996c4f5eb18bdbb9a0b3e4b">SerialPort</a> (<a class="el" href="classost_1_1_serial_service.html">SerialService</a> *svc, const char *name)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Construct a tty serial port for a named serial device. <a href="#a8e281b17e996c4f5eb18bdbb9a0b3e4b"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#a1c4a6f8cd51e17f153a0575c1036a8a5">~SerialPort</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Disconnect the <a class="el" href="classost_1_1_serial.html" title="The Serial class is used as the base for all serial I/O services under APE.">Serial</a> Port from the service pool thread and shutdown the port. <a href="#a1c4a6f8cd51e17f153a0575c1036a8a5"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#ab12b5f15481bf49b32e76a740c61ae6c">setDetectPending</a> (bool)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Used to indicate if the service thread should monitor pending data for us. <a href="#ab12b5f15481bf49b32e76a740c61ae6c"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#a85cd2f84d0117820545694ff4e122912">getDetectPending</a> (void) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the current state of the DetectPending flag. <a href="#a85cd2f84d0117820545694ff4e122912"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#a247a1b23aa9b819dadd3f671f5cbbdb9">setDetectOutput</a> (bool)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Used to indicate if output ready monitoring should be performed by the service thread. <a href="#a247a1b23aa9b819dadd3f671f5cbbdb9"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#aeeb3b9dbdaaa73b0c2960d332f80207c">getDetectOutput</a> (void) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the current state of the DetectOutput flag. <a href="#aeeb3b9dbdaaa73b0c2960d332f80207c"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#a5a0f7222d19dc7f97ebbd7fd471f39ac">expired</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Called by the service thread when the objects timer has expired. <a href="#a5a0f7222d19dc7f97ebbd7fd471f39ac"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#a47facdf73be726e440d39872130bf5b2">pending</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Called by the service thread when input data is pending for this tty port. <a href="#a47facdf73be726e440d39872130bf5b2"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#ac56f59989b9b11b094064e70eef6a681">disconnect</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Called by the service thread when an exception has occured such as a hangup. <a href="#ac56f59989b9b11b094064e70eef6a681"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#a2ace6514780e229ea0ac7dff9778583e">output</a> (void *buf, int len)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Transmit "send" data to the serial port. <a href="#a2ace6514780e229ea0ac7dff9778583e"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#afc68b51175f68493f644af5f3a5d8985">output</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Perform when output is available for sending data. <a href="#afc68b51175f68493f644af5f3a5d8985"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#aeb0db8bb689d4610e91ce81f68dfd590">input</a> (void *buf, int len)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Receive "input" for pending data from the serial port. <a href="#aeb0db8bb689d4610e91ce81f68dfd590"></a><br/></td></tr> <tr><td colspan="2"><h2>Friends</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_serial_port.html#aa8c4721865365c59db66755ea23bc4fb">SerialService</a></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>The serial port is an internal class which is attached to and then serviced by a specified <a class="el" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a> thread. </p> <p>Derived versions of this class offer specific functionality such as serial integration protocols.</p> <p>The TTYPort and TTYService classes are used to form thread-pool serviced serial I/O protocol sets. These can be used when one has a large number of serial devices to manage, and a single (or limited number of) thread(s) can then be used to service the tty port objects present. Each tty port supports a timer control and several virtual methods that the service thread can call when events occur. This model provides for "callback" event management, whereby the service thread performs a "callback" into the port object when events occur. Specific events supported include the expiration of a TTYPort timer, pending input data waiting to be read, and "sighup" connection breaks.</p> <dl class="author"><dt><b>Author:</b></dt><dd>David Sugar <<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>> base class for thread pool serviced serial I/O. </dd></dl> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="a8e281b17e996c4f5eb18bdbb9a0b3e4b"></a><!-- doxytag: member="ost::SerialPort::SerialPort" ref="a8e281b17e996c4f5eb18bdbb9a0b3e4b" args="(SerialService *svc, const char *name)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">ost::SerialPort::SerialPort </td> <td>(</td> <td class="paramtype"><a class="el" href="classost_1_1_serial_service.html">SerialService</a> * </td> <td class="paramname"> <em>svc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"> <em>name</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Construct a tty serial port for a named serial device. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>svc</em> </td><td>pool thread object. </td></tr> <tr><td valign="top"></td><td valign="top"><em>name</em> </td><td>of tty port. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a1c4a6f8cd51e17f153a0575c1036a8a5"></a><!-- doxytag: member="ost::SerialPort::~SerialPort" ref="a1c4a6f8cd51e17f153a0575c1036a8a5" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual ost::SerialPort::~SerialPort </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td><code> [protected, virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Disconnect the <a class="el" href="classost_1_1_serial.html" title="The Serial class is used as the base for all serial I/O services under APE.">Serial</a> Port from the service pool thread and shutdown the port. </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="ac56f59989b9b11b094064e70eef6a681"></a><!-- doxytag: member="ost::SerialPort::disconnect" ref="ac56f59989b9b11b094064e70eef6a681" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual void ost::SerialPort::disconnect </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td><code> [protected, virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Called by the service thread when an exception has occured such as a hangup. </p> </div> </div> <a class="anchor" id="a5a0f7222d19dc7f97ebbd7fd471f39ac"></a><!-- doxytag: member="ost::SerialPort::expired" ref="a5a0f7222d19dc7f97ebbd7fd471f39ac" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual void ost::SerialPort::expired </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td><code> [protected, virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Called by the service thread when the objects timer has expired. </p> </div> </div> <a class="anchor" id="aeeb3b9dbdaaa73b0c2960d332f80207c"></a><!-- doxytag: member="ost::SerialPort::getDetectOutput" ref="aeeb3b9dbdaaa73b0c2960d332f80207c" args="(void) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool ost::SerialPort::getDetectOutput </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td> const<code> [inline, protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Get the current state of the DetectOutput flag. </p> </div> </div> <a class="anchor" id="a85cd2f84d0117820545694ff4e122912"></a><!-- doxytag: member="ost::SerialPort::getDetectPending" ref="a85cd2f84d0117820545694ff4e122912" args="(void) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool ost::SerialPort::getDetectPending </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td> const<code> [inline, protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Get the current state of the DetectPending flag. </p> </div> </div> <a class="anchor" id="a4fa45b7494efbcd0c1b28a724f93b6b3"></a><!-- doxytag: member="ost::SerialPort::incTimer" ref="a4fa45b7494efbcd0c1b28a724f93b6b3" args="(timeout_t timeout)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::SerialPort::incTimer </td> <td>(</td> <td class="paramtype"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> </td> <td class="paramname"> <em>timeout</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Derived incTimer to notify the service thread pool of a change in expected timeout. </p> <p>This allows <a class="el" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a> to reschedule all timers. </p> <p>Reimplemented from <a class="el" href="classost_1_1_timer_port.html#ab2c732120c3bb09e8d38a87b7443906d">ost::TimerPort</a>.</p> </div> </div> <a class="anchor" id="aeb0db8bb689d4610e91ce81f68dfd590"></a><!-- doxytag: member="ost::SerialPort::input" ref="aeb0db8bb689d4610e91ce81f68dfd590" args="(void *buf, int len)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int ost::SerialPort::input </td> <td>(</td> <td class="paramtype">void * </td> <td class="paramname"> <em>buf</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"> <em>len</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [inline, protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Receive "input" for pending data from the serial port. </p> <p>This is not a public member since it's meant to support internal protocols rather than direct external access to the device.</p> <dl class="return"><dt><b>Returns:</b></dt><dd>number of bytes received. </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>buf</em> </td><td>address of buffer to input. </td></tr> <tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>of input buffer used. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="afc68b51175f68493f644af5f3a5d8985"></a><!-- doxytag: member="ost::SerialPort::output" ref="afc68b51175f68493f644af5f3a5d8985" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual void ost::SerialPort::output </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td><code> [protected, virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Perform when output is available for sending data. </p> </div> </div> <a class="anchor" id="a2ace6514780e229ea0ac7dff9778583e"></a><!-- doxytag: member="ost::SerialPort::output" ref="a2ace6514780e229ea0ac7dff9778583e" args="(void *buf, int len)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int ost::SerialPort::output </td> <td>(</td> <td class="paramtype">void * </td> <td class="paramname"> <em>buf</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"> <em>len</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [inline, protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Transmit "send" data to the serial port. </p> <p>This is not public since it's meant to support internal protocols rather than direct public access to the device.</p> <dl class="return"><dt><b>Returns:</b></dt><dd>number of bytes send. </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>buf</em> </td><td>address of buffer to send. </td></tr> <tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>of bytes to send. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a47facdf73be726e440d39872130bf5b2"></a><!-- doxytag: member="ost::SerialPort::pending" ref="a47facdf73be726e440d39872130bf5b2" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual void ost::SerialPort::pending </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td><code> [protected, virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Called by the service thread when input data is pending for this tty port. </p> <p>Effected by setPacketInput and by setLineInput. </p> </div> </div> <a class="anchor" id="a247a1b23aa9b819dadd3f671f5cbbdb9"></a><!-- doxytag: member="ost::SerialPort::setDetectOutput" ref="a247a1b23aa9b819dadd3f671f5cbbdb9" args="(bool)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::SerialPort::setDetectOutput </td> <td>(</td> <td class="paramtype">bool </td> <td class="paramname"></td> <td> ) </td> <td><code> [protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Used to indicate if output ready monitoring should be performed by the service thread. </p> </div> </div> <a class="anchor" id="ab12b5f15481bf49b32e76a740c61ae6c"></a><!-- doxytag: member="ost::SerialPort::setDetectPending" ref="ab12b5f15481bf49b32e76a740c61ae6c" args="(bool)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::SerialPort::setDetectPending </td> <td>(</td> <td class="paramtype">bool </td> <td class="paramname"></td> <td> ) </td> <td><code> [protected]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Used to indicate if the service thread should monitor pending data for us. </p> </div> </div> <a class="anchor" id="aeb008981e1a1d2eff230b231c3ce5d9c"></a><!-- doxytag: member="ost::SerialPort::setTimer" ref="aeb008981e1a1d2eff230b231c3ce5d9c" args="(timeout_t timeout=0)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::SerialPort::setTimer </td> <td>(</td> <td class="paramtype"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> </td> <td class="paramname"> <em>timeout</em> = <code>0</code></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Derived setTimer to notify the service thread pool of changes in expected timeout. </p> <p>This allows <a class="el" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a> to reschedule all timers.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>in milliseconds. </td></tr> </table> </dd> </dl> <p>Reimplemented from <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f">ost::TimerPort</a>.</p> </div> </div> <hr/><h2>Friends And Related Function Documentation</h2> <a class="anchor" id="aa8c4721865365c59db66755ea23bc4fb"></a><!-- doxytag: member="ost::SerialPort::SerialService" ref="aa8c4721865365c59db66755ea23bc4fb" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">friend class <a class="el" href="classost_1_1_serial_service.html">SerialService</a><code> [friend]</code></td> </tr> </table> </div> <div class="memdoc"> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="serial_8h_source.html">serial.h</a></li> </ul> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Fri Mar 12 10:07:41 2010 for GNU CommonC++ by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>