<!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++: serial.h Source File</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><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><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="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>serial.h</h1><a href="serial_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 1999-2005 Open Source Telecom Corporation.</span> <a name="l00002"></a>00002 <span class="comment">// Copyright (C) 2006-2008 David Sugar, Tycho Softworks.</span> <a name="l00003"></a>00003 <span class="comment">//</span> <a name="l00004"></a>00004 <span class="comment">// This program is free software; you can redistribute it and/or modify</span> <a name="l00005"></a>00005 <span class="comment">// it under the terms of the GNU General Public License as published by</span> <a name="l00006"></a>00006 <span class="comment">// the Free Software Foundation; either version 2 of the License, or</span> <a name="l00007"></a>00007 <span class="comment">// (at your option) any later version.</span> <a name="l00008"></a>00008 <span class="comment">//</span> <a name="l00009"></a>00009 <span class="comment">// This program is distributed in the hope that it will be useful,</span> <a name="l00010"></a>00010 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00011"></a>00011 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00012"></a>00012 <span class="comment">// GNU General Public License for more details.</span> <a name="l00013"></a>00013 <span class="comment">//</span> <a name="l00014"></a>00014 <span class="comment">// You should have received a copy of the GNU General Public License</span> <a name="l00015"></a>00015 <span class="comment">// along with this program; if not, write to the Free Software</span> <a name="l00016"></a>00016 <span class="comment">// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span> <a name="l00017"></a>00017 <span class="comment">//</span> <a name="l00018"></a>00018 <span class="comment">// As a special exception, you may use this file as part of a free software</span> <a name="l00019"></a>00019 <span class="comment">// library without restriction. Specifically, if other files instantiate</span> <a name="l00020"></a>00020 <span class="comment">// templates or use macros or inline functions from this file, or you compile</span> <a name="l00021"></a>00021 <span class="comment">// this file and link it with other files to produce an executable, this</span> <a name="l00022"></a>00022 <span class="comment">// file does not by itself cause the resulting executable to be covered by</span> <a name="l00023"></a>00023 <span class="comment">// the GNU General Public License. This exception does not however</span> <a name="l00024"></a>00024 <span class="comment">// invalidate any other reasons why the executable file might be covered by</span> <a name="l00025"></a>00025 <span class="comment">// the GNU General Public License.</span> <a name="l00026"></a>00026 <span class="comment">//</span> <a name="l00027"></a>00027 <span class="comment">// This exception applies only to the code released under the name GNU</span> <a name="l00028"></a>00028 <span class="comment">// Common C++. If you copy code from other releases into a copy of GNU</span> <a name="l00029"></a>00029 <span class="comment">// Common C++, as the General Public License permits, the exception does</span> <a name="l00030"></a>00030 <span class="comment">// not apply to the code that you add in this way. To avoid misleading</span> <a name="l00031"></a>00031 <span class="comment">// anyone as to the status of such modified files, you must delete</span> <a name="l00032"></a>00032 <span class="comment">// this exception notice from them.</span> <a name="l00033"></a>00033 <span class="comment">//</span> <a name="l00034"></a>00034 <span class="comment">// If you write modifications of your own for GNU Common C++, it is your choice</span> <a name="l00035"></a>00035 <span class="comment">// whether to permit this exception to apply to your modifications.</span> <a name="l00036"></a>00036 <span class="comment">// If you do not wish that, delete this exception notice.</span> <a name="l00037"></a>00037 <span class="comment">//</span> <a name="l00038"></a>00038 <a name="l00044"></a>00044 <span class="preprocessor">#ifndef CCXX_SERIAL_H_</span> <a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#define CCXX_SERIAL_H_</span> <a name="l00046"></a>00046 <span class="preprocessor"></span> <a name="l00047"></a>00047 <span class="preprocessor">#ifndef CCXX_MISSING_H_</span> <a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="missing_8h.html" title="substitute functions which may be missing in target platform libc.">cc++/missing.h</a>></span> <a name="l00049"></a>00049 <span class="preprocessor">#endif</span> <a name="l00050"></a>00050 <span class="preprocessor"></span> <a name="l00051"></a>00051 <span class="preprocessor">#ifndef CCXX_THREAD_H_</span> <a name="l00052"></a>00052 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="thread_8h.html" title="Synchronization and threading services.">cc++/thread.h</a>></span> <a name="l00053"></a>00053 <span class="preprocessor">#endif</span> <a name="l00054"></a>00054 <span class="preprocessor"></span> <a name="l00055"></a>00055 <span class="preprocessor">#ifndef CCXX_EXCEPTION_H_</span> <a name="l00056"></a>00056 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="exception_8h.html" title="GNU Common C++ exception model base classes.">cc++/exception.h</a>></span> <a name="l00057"></a>00057 <span class="preprocessor">#endif</span> <a name="l00058"></a>00058 <span class="preprocessor"></span> <a name="l00059"></a>00059 <span class="preprocessor">#ifndef WIN32</span> <a name="l00060"></a><a class="code" href="serial_8h.html#a069bb8cb95b0528d5ce0304bb5561a40">00060</a> <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">int</span> <a class="code" href="serial_8h.html#a069bb8cb95b0528d5ce0304bb5561a40">HANDLE</a>; <a name="l00061"></a><a class="code" href="serial_8h.html#a5fdc7facea201bfce4ad308105f88d0c">00061</a> <span class="preprocessor">#define INVALID_HANDLE_VALUE (-1)</span> <a name="l00062"></a>00062 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00063"></a>00063 <span class="preprocessor"></span> <a name="l00064"></a>00064 <span class="preprocessor">#ifdef CCXX_NAMESPACES</span> <a name="l00065"></a>00065 <span class="preprocessor"></span><span class="keyword">namespace </span>ost { <a name="l00066"></a>00066 <span class="preprocessor">#endif</span> <a name="l00067"></a>00067 <span class="preprocessor"></span> <a name="l00098"></a><a class="code" href="classost_1_1_serial.html">00098</a> <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" 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> <a name="l00099"></a>00099 { <a name="l00100"></a>00100 <span class="keyword">public</span>: <a name="l00101"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497">00101</a> <span class="keyword">enum</span> <a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497">Error</a> { <a name="l00102"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a40d28eb35e78818af6d54350c3fd597d">00102</a> errSuccess = 0, <a name="l00103"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497adea5750f4c5d011d5c543b373a2cf230">00103</a> errOpenNoTty, <a name="l00104"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497aef0ca060f94b5db0608bf3ceeaaedbee">00104</a> errOpenFailed, <a name="l00105"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a5fa6a9e68cb29ec15f600c22fb424c9a">00105</a> errSpeedInvalid, <a name="l00106"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a936c7e7aedb62d8c3654192f96b0c1b5">00106</a> errFlowInvalid, <a name="l00107"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497adc409d6ffee22d17e7646bfce2d50b8e">00107</a> errParityInvalid, <a name="l00108"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a280b96416b3ad39f1142f6918267bf5f">00108</a> errCharsizeInvalid, <a name="l00109"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a5b6b13043d4c239acbdbcfb0b53ece92">00109</a> errStopbitsInvalid, <a name="l00110"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a56ec86c7748b88f2e61e7cb2aa6313d0">00110</a> errOptionInvalid, <a name="l00111"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497aac71caec475b2c8e77061d486f000b04">00111</a> errResourceFailure, <a name="l00112"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a461e080df6f82ec6017226cba19a92b2">00112</a> errOutput, <a name="l00113"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a3f81ba432a4ff8864033a355bd1ffccd">00113</a> errInput, <a name="l00114"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497ac64e00c5dee4d6ac546856dc8135ccd9">00114</a> errTimeout, <a name="l00115"></a><a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497a71b4964c5c550da322e19ae8fdb0b190">00115</a> errExtended <a name="l00116"></a>00116 }; <a name="l00117"></a><a class="code" href="classost_1_1_serial.html#a1955d3954338199da7165a4beb7c9703">00117</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> <a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497">Error</a> <a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497">Error</a>; <a name="l00118"></a>00118 <a name="l00119"></a><a class="code" href="classost_1_1_serial.html#a269fc64928cd10bae2fe8a2eefab6303">00119</a> <span class="keyword">enum</span> <a class="code" href="classost_1_1_serial.html#a269fc64928cd10bae2fe8a2eefab6303">Flow</a> { <a name="l00120"></a><a class="code" href="classost_1_1_serial.html#a269fc64928cd10bae2fe8a2eefab6303a200f49e5ec47a4060706a210148af629">00120</a> flowNone, <a name="l00121"></a><a class="code" href="classost_1_1_serial.html#a269fc64928cd10bae2fe8a2eefab6303a40e097623df09f0aa335e2316eba1893">00121</a> flowSoft, <a name="l00122"></a><a class="code" href="classost_1_1_serial.html#a269fc64928cd10bae2fe8a2eefab6303a7b1222095085ca00a08988a849c0d78f">00122</a> flowHard, <a name="l00123"></a><a class="code" href="classost_1_1_serial.html#a269fc64928cd10bae2fe8a2eefab6303a74c00e3f9dd79bb8493f5fc87bd73b81">00123</a> flowBoth <a name="l00124"></a>00124 }; <a name="l00125"></a><a class="code" href="classost_1_1_serial.html#a032e8d67ca5a8f64a5cd348e1cba423d">00125</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> <a class="code" href="classost_1_1_serial.html#a269fc64928cd10bae2fe8a2eefab6303">Flow</a> <a class="code" href="classost_1_1_serial.html#a269fc64928cd10bae2fe8a2eefab6303">Flow</a>; <a name="l00126"></a>00126 <a name="l00127"></a><a class="code" href="classost_1_1_serial.html#a54bdc2b3ce16dbf3542785ef69188f7c">00127</a> <span class="keyword">enum</span> <a class="code" href="classost_1_1_serial.html#a54bdc2b3ce16dbf3542785ef69188f7c">Parity</a> { <a name="l00128"></a><a class="code" href="classost_1_1_serial.html#a54bdc2b3ce16dbf3542785ef69188f7cac6e7991c8940f35aed8d547ac1455e0c">00128</a> parityNone, <a name="l00129"></a><a class="code" href="classost_1_1_serial.html#a54bdc2b3ce16dbf3542785ef69188f7cab31e527b4644ba0f4b08f14a016e54c2">00129</a> parityOdd, <a name="l00130"></a><a class="code" href="classost_1_1_serial.html#a54bdc2b3ce16dbf3542785ef69188f7cac99c7fdd2af17159f785e878edd1f221">00130</a> parityEven <a name="l00131"></a>00131 }; <a name="l00132"></a><a class="code" href="classost_1_1_serial.html#af7aab47de333eecc51d76a551dcd81db">00132</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> <a class="code" href="classost_1_1_serial.html#a54bdc2b3ce16dbf3542785ef69188f7c">Parity</a> <a class="code" href="classost_1_1_serial.html#a54bdc2b3ce16dbf3542785ef69188f7c">Parity</a>; <a name="l00133"></a>00133 <a name="l00134"></a><a class="code" href="classost_1_1_serial.html#a74fbabfe1dcbaebf6e484af11dd6d8b7">00134</a> <span class="keyword">enum</span> <a class="code" href="classost_1_1_serial.html#a74fbabfe1dcbaebf6e484af11dd6d8b7">Pending</a> { <a name="l00135"></a><a class="code" href="classost_1_1_serial.html#a74fbabfe1dcbaebf6e484af11dd6d8b7a252411555c5a7db1682c762f3acc5ad5">00135</a> pendingInput, <a name="l00136"></a><a class="code" href="classost_1_1_serial.html#a74fbabfe1dcbaebf6e484af11dd6d8b7aa13e15f4121356d33e5b9c7485b6a6b5">00136</a> pendingOutput, <a name="l00137"></a><a class="code" href="classost_1_1_serial.html#a74fbabfe1dcbaebf6e484af11dd6d8b7ad738f8c83dd497aeff2d639ba86bb84c">00137</a> pendingError <a name="l00138"></a>00138 }; <a name="l00139"></a><a class="code" href="classost_1_1_serial.html#a7acdd43b4d1766daa58bbb49352dd942">00139</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> <a class="code" href="classost_1_1_serial.html#a74fbabfe1dcbaebf6e484af11dd6d8b7">Pending</a> <a class="code" href="classost_1_1_serial.html#a74fbabfe1dcbaebf6e484af11dd6d8b7">Pending</a>; <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="keyword">private</span>: <a name="l00142"></a>00142 <a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497">Error</a> errid; <a name="l00143"></a>00143 <span class="keywordtype">char</span> *errstr; <a name="l00144"></a>00144 <a name="l00145"></a>00145 <span class="keyword">struct </span>{ <a name="l00146"></a><a class="code" href="classost_1_1_serial.html#a08089082dbf6e6095257b7835624ea20">00146</a> <span class="keywordtype">bool</span> thrown: 1; <a name="l00147"></a><a class="code" href="classost_1_1_serial.html#afb17fb6c08d2405281f473a037891aaf">00147</a> <span class="keywordtype">bool</span> linebuf: 1; <a name="l00148"></a>00148 } flags; <a name="l00149"></a>00149 <a name="l00150"></a>00150 <span class="keywordtype">void</span> * original; <a name="l00151"></a>00151 <span class="keywordtype">void</span> * current; <a name="l00152"></a>00152 <a name="l00156"></a>00156 <span class="keywordtype">void</span> initSerial(<span class="keywordtype">void</span>); <a name="l00157"></a>00157 <a name="l00158"></a>00158 <span class="keyword">protected</span>: <a name="l00159"></a>00159 <a name="l00160"></a><a class="code" href="classost_1_1_serial.html#a0f2dc5d07e275ab632df9630d4d7ad45">00160</a> <a class="code" href="serial_8h.html#a069bb8cb95b0528d5ce0304bb5561a40">HANDLE</a> dev; <a name="l00161"></a>00161 <a name="l00162"></a><a class="code" href="classost_1_1_serial.html#a6b974da21c9bdaf38d745c7cb533bd4c">00162</a> <span class="keywordtype">int</span> bufsize; <a name="l00163"></a>00163 <a name="l00169"></a>00169 <span class="keywordtype">void</span> open(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname); <a name="l00170"></a>00170 <a name="l00175"></a>00175 <span class="keywordtype">void</span> close(<span class="keywordtype">void</span>); <a name="l00176"></a>00176 <a name="l00184"></a>00184 <span class="keyword">virtual</span> <span class="keywordtype">int</span> aRead(<span class="keywordtype">char</span> * Data, <span class="keyword">const</span> <span class="keywordtype">int</span> Length); <a name="l00185"></a>00185 <a name="l00192"></a>00192 <span class="keyword">virtual</span> <span class="keywordtype">int</span> aWrite(<span class="keyword">const</span> <span class="keywordtype">char</span> * Data, <span class="keyword">const</span> <span class="keywordtype">int</span> Length); <a name="l00193"></a>00193 <a name="l00201"></a>00201 <a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497">Error</a> <a class="code" href="namespaceost.html#a61faeec2dc6ec946dc3e98979bd93124" title="Manipulator for error level.">error</a>(<a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497">Error</a> <a class="code" href="namespaceost.html#a61faeec2dc6ec946dc3e98979bd93124" title="Manipulator for error level.">error</a>, <span class="keywordtype">char</span> *errstr = NULL); <a name="l00202"></a>00202 <a name="l00209"></a><a class="code" href="classost_1_1_serial.html#aa27ac2ed46bf90a4bab62ecbc19febb6">00209</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespaceost.html#a61faeec2dc6ec946dc3e98979bd93124" title="Manipulator for error level.">error</a>(<span class="keywordtype">char</span> *err) <a name="l00210"></a>00210 {<a class="code" href="classost_1_1_serial.html#aa27ac2ed46bf90a4bab62ecbc19febb6" title="This service is used to thow application defined serial errors where the application...">error</a>(errExtended, err);}; <a name="l00211"></a>00211 <a name="l00212"></a>00212 <a name="l00219"></a><a class="code" href="classost_1_1_serial.html#a1d6cbc8147a6f77c01f3b2b7cb5a39d1">00219</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setError(<span class="keywordtype">bool</span> enable) <a name="l00220"></a>00220 {flags.thrown = !enable;}; <a name="l00221"></a>00221 <a name="l00232"></a>00232 <span class="keywordtype">int</span> setPacketInput(<span class="keywordtype">int</span> size, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> btimer = 0); <a name="l00233"></a>00233 <a name="l00243"></a>00243 <span class="keywordtype">int</span> setLineInput(<span class="keywordtype">char</span> newline = 13, <span class="keywordtype">char</span> nl1 = 0); <a name="l00244"></a>00244 <a name="l00248"></a>00248 <span class="keywordtype">void</span> restore(<span class="keywordtype">void</span>); <a name="l00249"></a>00249 <a name="l00253"></a>00253 <span class="keywordtype">void</span> flushInput(<span class="keywordtype">void</span>); <a name="l00254"></a>00254 <a name="l00258"></a>00258 <span class="keywordtype">void</span> flushOutput(<span class="keywordtype">void</span>); <a name="l00259"></a>00259 <a name="l00263"></a>00263 <span class="keywordtype">void</span> waitOutput(<span class="keywordtype">void</span>); <a name="l00264"></a>00264 <a name="l00269"></a>00269 <span class="keywordtype">void</span> endSerial(<span class="keywordtype">void</span>); <a name="l00270"></a>00270 <a name="l00276"></a>00276 <span class="keywordtype">void</span> initConfig(<span class="keywordtype">void</span>); <a name="l00277"></a>00277 <a name="l00282"></a><a class="code" href="classost_1_1_serial.html#a2cc577c5c283fa23edf6efeaf5617829">00282</a> <a class="code" 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>() <a name="l00283"></a>00283 {initSerial();}; <a name="l00284"></a>00284 <a name="l00291"></a>00291 <a class="code" 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>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name); <a name="l00292"></a>00292 <a name="l00293"></a>00293 <a name="l00294"></a>00294 <span class="keyword">public</span>: <a name="l00295"></a>00295 <a name="l00302"></a>00302 <span class="keyword">virtual</span> ~<a class="code" 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>(); <a name="l00303"></a>00303 <a name="l00308"></a>00308 <a class="code" 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> &operator=(<span class="keyword">const</span> <a class="code" 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> &from); <a name="l00309"></a>00309 <a name="l00316"></a>00316 Error setSpeed(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> speed); <a name="l00317"></a>00317 <a name="l00324"></a>00324 Error setCharBits(<span class="keywordtype">int</span> bits); <a name="l00325"></a>00325 <a name="l00332"></a>00332 Error setParity(Parity parity); <a name="l00333"></a>00333 <a name="l00340"></a>00340 Error setStopBits(<span class="keywordtype">int</span> bits); <a name="l00341"></a>00341 <a name="l00348"></a>00348 Error setFlowControl(Flow flow); <a name="l00349"></a>00349 <a name="l00355"></a>00355 <span class="keywordtype">void</span> toggleDTR(<a class="code" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> millisec); <a name="l00356"></a>00356 <a name="l00360"></a>00360 <span class="keywordtype">void</span> sendBreak(<span class="keywordtype">void</span>); <a name="l00361"></a>00361 <a name="l00368"></a><a class="code" href="classost_1_1_serial.html#ac8d9a9eedecf7dc42f53e8c852e9e6d3">00368</a> <span class="keyword">inline</span> <a class="code" href="classost_1_1_serial.html#a2f1bcf165447d5ed96093b6c8a346497">Error</a> getErrorNumber(<span class="keywordtype">void</span>) <a name="l00369"></a>00369 {<span class="keywordflow">return</span> errid;}; <a name="l00370"></a>00370 <a name="l00377"></a><a class="code" href="classost_1_1_serial.html#a0d67fb60e34c7a725f4494adaa11c0c9">00377</a> <span class="keyword">inline</span> <span class="keywordtype">char</span> *getErrorString(<span class="keywordtype">void</span>) <a name="l00378"></a>00378 {<span class="keywordflow">return</span> errstr;}; <a name="l00379"></a>00379 <a name="l00387"></a><a class="code" href="classost_1_1_serial.html#ae6d478bbdac8593181fc64eb66106815">00387</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> getBufferSize(<span class="keywordtype">void</span>) <a name="l00388"></a>00388 {<span class="keywordflow">return</span> bufsize;}; <a name="l00389"></a>00389 <a name="l00399"></a>00399 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> isPending(Pending pend, <a class="code" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout = <a class="code" href="thread_8h.html#a74f2d4c747bce0b8f7f7c1f48e651876">TIMEOUT_INF</a>); <a name="l00400"></a>00400 }; <a name="l00401"></a>00401 <a name="l00423"></a><a class="code" href="classost_1_1_t_t_y_stream.html">00423</a> <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a> : <span class="keyword">protected</span> std::streambuf, <span class="keyword">public</span> <a class="code" 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>, <span class="keyword">public</span> std::iostream <a name="l00424"></a>00424 { <a name="l00425"></a>00425 <span class="keyword">private</span>: <a name="l00426"></a>00426 <span class="keywordtype">int</span> doallocate(); <a name="l00427"></a>00427 <a name="l00428"></a>00428 <span class="keyword">friend</span> <a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a>& crlf(<a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a>&); <a name="l00429"></a>00429 <span class="keyword">friend</span> <a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a>& lfcr(<a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a>&); <a name="l00430"></a>00430 <a name="l00431"></a>00431 <span class="keyword">protected</span>: <a name="l00432"></a><a class="code" href="classost_1_1_t_t_y_stream.html#a05574ac3124042f6fd7d7126b7d2dbde">00432</a> <span class="keywordtype">char</span> *gbuf, *pbuf; <a name="l00433"></a><a class="code" href="classost_1_1_t_t_y_stream.html#ada518ac8768e0e9336267f6f91846eb2">00433</a> <a class="code" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout; <a name="l00434"></a>00434 <a name="l00439"></a>00439 <a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a>(); <a name="l00440"></a>00440 <a name="l00445"></a>00445 <span class="keywordtype">void</span> allocate(<span class="keywordtype">void</span>); <a name="l00446"></a>00446 <a name="l00451"></a>00451 <span class="keywordtype">void</span> endStream(<span class="keywordtype">void</span>); <a name="l00452"></a>00452 <a name="l00459"></a>00459 <span class="keywordtype">int</span> underflow(<span class="keywordtype">void</span>); <a name="l00460"></a>00460 <a name="l00469"></a>00469 <span class="keywordtype">int</span> uflow(<span class="keywordtype">void</span>); <a name="l00470"></a>00470 <a name="l00478"></a>00478 <span class="keywordtype">int</span> overflow(<span class="keywordtype">int</span> ch); <a name="l00479"></a>00479 <a name="l00480"></a>00480 <span class="keyword">public</span>: <a name="l00487"></a>00487 <a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename, <a class="code" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> to = 0); <a name="l00488"></a>00488 <a name="l00492"></a>00492 <span class="keyword">virtual</span> ~<a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a>(); <a name="l00493"></a>00493 <a name="l00499"></a><a class="code" href="classost_1_1_t_t_y_stream.html#a10ec50ecf62fb6c5cda903389d96d127">00499</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setTimeout(<a class="code" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> to) <a name="l00500"></a>00500 {timeout = to;}; <a name="l00501"></a>00501 <a name="l00509"></a>00509 <span class="keywordtype">void</span> interactive(<span class="keywordtype">bool</span> flag); <a name="l00510"></a>00510 <a name="l00517"></a>00517 <span class="keywordtype">int</span> sync(<span class="keywordtype">void</span>); <a name="l00518"></a>00518 <a name="l00530"></a>00530 <span class="keywordtype">bool</span> isPending(Pending pend, <a class="code" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout = <a class="code" href="thread_8h.html#a74f2d4c747bce0b8f7f7c1f48e651876">TIMEOUT_INF</a>); <a name="l00531"></a>00531 }; <a name="l00532"></a>00532 <a name="l00542"></a><a class="code" href="classost_1_1ttystream.html">00542</a> <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1ttystream.html" title="A more natural C++ &quot;ttystream&quot; class for use by non-threaded applications...">ttystream</a> : <span class="keyword">public</span> <a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a> <a name="l00543"></a>00543 { <a name="l00544"></a>00544 <span class="keyword">public</span>: <a name="l00548"></a>00548 <a class="code" href="classost_1_1ttystream.html" title="A more natural C++ &quot;ttystream&quot; class for use by non-threaded applications...">ttystream</a>(); <a name="l00549"></a>00549 <a name="l00557"></a>00557 <a class="code" href="classost_1_1ttystream.html" title="A more natural C++ &quot;ttystream&quot; class for use by non-threaded applications...">ttystream</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name); <a name="l00558"></a>00558 <a name="l00564"></a>00564 <span class="keywordtype">void</span> open(<span class="keyword">const</span> <span class="keywordtype">char</span> *name); <a name="l00565"></a>00565 <a name="l00569"></a>00569 <span class="keywordtype">void</span> close(<span class="keywordtype">void</span>); <a name="l00570"></a>00570 <a name="l00574"></a><a class="code" href="classost_1_1ttystream.html#a8e77838120b5128c2dfa48d0f9ccaebc">00574</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!() <a name="l00575"></a>00575 {<span class="keywordflow">return</span> (dev < 0);}; <a name="l00576"></a>00576 }; <a name="l00577"></a>00577 <a name="l00588"></a><a class="code" href="classost_1_1_t_t_y_session.html">00588</a> <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_t_t_y_session.html" title="The TTYSession aggragates a TTYStream and a Common C++ Thread which is assumed to...">TTYSession</a> : <span class="keyword">public</span> <a class="code" href="classost_1_1_thread.html" title="Every thread of execution in an application is created by instantiating an object...">Thread</a>, <span class="keyword">public</span> <a class="code" href="classost_1_1_t_t_y_stream.html" title="TTY streams are used to represent serial connections that are fully &quot;streamable&quot;...">TTYStream</a> <a name="l00589"></a>00589 { <a name="l00590"></a>00590 <span class="keyword">public</span>: <a name="l00598"></a>00598 <a class="code" href="classost_1_1_t_t_y_session.html" title="The TTYSession aggragates a TTYStream and a Common C++ Thread which is assumed to...">TTYSession</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> pri = 0, <span class="keywordtype">int</span> stack = 0); <a name="l00599"></a>00599 <a name="l00600"></a>00600 <span class="keyword">virtual</span> ~<a class="code" href="classost_1_1_t_t_y_session.html" title="The TTYSession aggragates a TTYStream and a Common C++ Thread which is assumed to...">TTYSession</a>(); <a name="l00601"></a>00601 }; <a name="l00602"></a>00602 <a name="l00603"></a>00603 <span class="preprocessor">#ifndef WIN32</span> <a name="l00604"></a>00604 <span class="preprocessor"></span> <a name="l00605"></a>00605 <span class="comment">// Not support this right now.......</span> <a name="l00606"></a>00606 <span class="comment">//</span> <a name="l00607"></a>00607 <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a>; <a name="l00608"></a>00608 <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a>; <a name="l00609"></a>00609 <a name="l00631"></a><a class="code" href="classost_1_1_serial_port.html">00631</a> <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a>: <span class="keyword">public</span> <a class="code" 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>, <span class="keyword">public</span> <a class="code" href="classost_1_1_timer_port.html" title="Timer ports are used to provide synchronized timing events when managed under a &quot;service...">TimerPort</a> <a name="l00632"></a>00632 { <a name="l00633"></a>00633 <span class="keyword">private</span>: <a name="l00634"></a>00634 <a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a> *next, *prev; <a name="l00635"></a>00635 <a class="code" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a> *service; <a name="l00636"></a>00636 <span class="preprocessor">#ifdef USE_POLL</span> <a name="l00637"></a>00637 <span class="preprocessor"></span> <span class="keyword">struct </span>pollfd *ufd; <a name="l00638"></a>00638 <span class="preprocessor">#endif</span> <a name="l00639"></a>00639 <span class="preprocessor"></span> <span class="keywordtype">bool</span> detect_pending; <a name="l00640"></a>00640 <span class="keywordtype">bool</span> detect_output; <a name="l00641"></a>00641 <span class="keywordtype">bool</span> detect_disconnect; <a name="l00642"></a>00642 <a name="l00643"></a><a class="code" href="classost_1_1_serial_port.html#aa8c4721865365c59db66755ea23bc4fb">00643</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a>; <a name="l00644"></a>00644 <a name="l00645"></a>00645 <span class="keyword">protected</span>: <a name="l00652"></a>00652 <a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a>(<a class="code" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a> *svc, <span class="keyword">const</span> <span class="keywordtype">char</span> *name); <a name="l00653"></a>00653 <a name="l00658"></a>00658 <span class="keyword">virtual</span> ~<a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a>(); <a name="l00659"></a>00659 <a name="l00664"></a>00664 <span class="keywordtype">void</span> setDetectPending( <span class="keywordtype">bool</span> ); <a name="l00665"></a>00665 <a name="l00669"></a><a class="code" href="classost_1_1_serial_port.html#a85cd2f84d0117820545694ff4e122912">00669</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> getDetectPending( <span class="keywordtype">void</span> )<span class="keyword"> const</span> <a name="l00670"></a>00670 <span class="keyword"> </span>{ <span class="keywordflow">return</span> detect_pending; } <a name="l00671"></a>00671 <a name="l00676"></a>00676 <span class="keywordtype">void</span> setDetectOutput( <span class="keywordtype">bool</span> ); <a name="l00677"></a>00677 <a name="l00681"></a><a class="code" href="classost_1_1_serial_port.html#aeeb3b9dbdaaa73b0c2960d332f80207c">00681</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> getDetectOutput( <span class="keywordtype">void</span> )<span class="keyword"> const</span> <a name="l00682"></a>00682 <span class="keyword"> </span>{ <span class="keywordflow">return</span> detect_output; } <a name="l00683"></a>00683 <a name="l00688"></a>00688 <span class="keyword">virtual</span> <span class="keywordtype">void</span> expired(<span class="keywordtype">void</span>); <a name="l00689"></a>00689 <a name="l00695"></a>00695 <span class="keyword">virtual</span> <span class="keywordtype">void</span> pending(<span class="keywordtype">void</span>); <a name="l00696"></a>00696 <a name="l00701"></a>00701 <span class="keyword">virtual</span> <span class="keywordtype">void</span> disconnect(<span class="keywordtype">void</span>); <a name="l00702"></a>00702 <a name="l00712"></a><a class="code" href="classost_1_1_serial_port.html#a2ace6514780e229ea0ac7dff9778583e">00712</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> output(<span class="keywordtype">void</span> *buf, <span class="keywordtype">int</span> len) <a name="l00713"></a>00713 {<span class="keywordflow">return</span> aWrite((<span class="keywordtype">char</span> *)buf, len);}; <a name="l00714"></a>00714 <a name="l00718"></a>00718 <span class="keyword">virtual</span> <span class="keywordtype">void</span> output(<span class="keywordtype">void</span>); <a name="l00719"></a>00719 <a name="l00729"></a><a class="code" href="classost_1_1_serial_port.html#aeb0db8bb689d4610e91ce81f68dfd590">00729</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> input(<span class="keywordtype">void</span> *buf, <span class="keywordtype">int</span> len) <a name="l00730"></a>00730 {<span class="keywordflow">return</span> aRead((<span class="keywordtype">char</span> *)buf, len);}; <a name="l00731"></a>00731 <span class="keyword">public</span>: <a name="l00739"></a>00739 <span class="keywordtype">void</span> setTimer(<a class="code" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout = 0); <a name="l00740"></a>00740 <a name="l00746"></a>00746 <span class="keywordtype">void</span> incTimer(<a class="code" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout); <a name="l00747"></a>00747 }; <a name="l00748"></a>00748 <a name="l00771"></a><a class="code" href="classost_1_1_serial_service.html">00771</a> <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a> : <span class="keyword">public</span> <a class="code" href="classost_1_1_thread.html" title="Every thread of execution in an application is created by instantiating an object...">Thread</a>, <span class="keyword">private</span> <a class="code" href="classost_1_1_mutex.html" title="The Mutex class is used to protect a section of code so that at any given time only...">Mutex</a> <a name="l00772"></a>00772 { <a name="l00773"></a>00773 <span class="keyword">private</span>: <a name="l00774"></a>00774 fd_set connect; <a name="l00775"></a>00775 <span class="keywordtype">int</span> iosync[2]; <a name="l00776"></a>00776 <span class="keywordtype">int</span> hiwater; <a name="l00777"></a>00777 <span class="keywordtype">int</span> count; <a name="l00778"></a>00778 <a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a> *first, *last; <a name="l00779"></a>00779 <a name="l00785"></a>00785 <span class="keywordtype">void</span> attach(<a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a> *port); <a name="l00786"></a>00786 <a name="l00792"></a>00792 <span class="keywordtype">void</span> detach(<a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a> *port); <a name="l00793"></a>00793 <a name="l00797"></a>00797 <span class="keywordtype">void</span> run(<span class="keywordtype">void</span>); <a name="l00798"></a>00798 <a name="l00799"></a><a class="code" href="classost_1_1_serial_service.html#a84d7b24f575569e86cb63b1f8c62e84a">00799</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a>; <a name="l00800"></a>00800 <a name="l00801"></a>00801 <span class="keyword">protected</span>: <a name="l00808"></a>00808 <span class="keyword">virtual</span> <span class="keywordtype">void</span> onUpdate(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> flag); <a name="l00809"></a>00809 <a name="l00814"></a>00814 <span class="keyword">virtual</span> <span class="keywordtype">void</span> onEvent(<span class="keywordtype">void</span>); <a name="l00815"></a>00815 <a name="l00822"></a>00822 <span class="keyword">virtual</span> <span class="keywordtype">void</span> onCallback(<a class="code" href="classost_1_1_serial_port.html" title="The serial port is an internal class which is attached to and then serviced by a...">SerialPort</a> *port); <a name="l00823"></a>00823 <a name="l00824"></a>00824 <span class="keyword">public</span>: <a name="l00834"></a>00834 <span class="keywordtype">void</span> update(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> flag = 0xff); <a name="l00835"></a>00835 <a name="l00844"></a>00844 <a class="code" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a>(<span class="keywordtype">int</span> pri = 0, <span class="keywordtype">size_t</span> stack = 0, <span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keywordtype">id</span> = NULL); <a name="l00845"></a>00845 <a name="l00849"></a>00849 <span class="keyword">virtual</span> ~<a class="code" href="classost_1_1_serial_service.html" title="The SerialService is a thead service object that is meant to service attached serial...">SerialService</a>(); <a name="l00850"></a>00850 <a name="l00857"></a><a class="code" href="classost_1_1_serial_service.html#a9b613f73f7222745076f9f78aff7c78c">00857</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> getCount(<span class="keywordtype">void</span>) <a name="l00858"></a>00858 {<span class="keywordflow">return</span> count;}; <a name="l00859"></a>00859 }; <a name="l00860"></a>00860 <a name="l00861"></a>00861 <span class="preprocessor">#endif</span> <a name="l00862"></a>00862 <span class="preprocessor"></span> <a name="l00863"></a>00863 <a name="l00864"></a>00864 <a name="l00865"></a>00865 <span class="preprocessor">#ifdef COMMON_STD_EXCEPTION</span> <a name="l00866"></a><a class="code" href="classost_1_1_ser_exception.html">00866</a> <span class="preprocessor"></span><span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_ser_exception.html">SerException</a> : <span class="keyword">public</span> <a class="code" href="classost_1_1_i_o_exception.html" title="A sub-hierarchy for all Common C++ I/O related classes.">IOException</a> <a name="l00867"></a>00867 { <a name="l00868"></a>00868 <span class="keyword">public</span>: <a name="l00869"></a><a class="code" href="classost_1_1_ser_exception.html#ad76db341b143e77c5bfaf2615608bc18">00869</a> <a class="code" href="classost_1_1_ser_exception.html#ad76db341b143e77c5bfaf2615608bc18">SerException</a>(<span class="keyword">const</span> <a class="code" href="classost_1_1_string.html" title="This is a generic and portable string class.">String</a> &str) : <a class="code" href="classost_1_1_i_o_exception.html" title="A sub-hierarchy for all Common C++ I/O related classes.">IOException</a>(str) {}; <a name="l00870"></a>00870 }; <a name="l00871"></a>00871 <span class="preprocessor">#endif</span> <a name="l00872"></a>00872 <span class="preprocessor"></span> <a name="l00873"></a>00873 <span class="preprocessor">#ifdef CCXX_NAMESPACES</span> <a name="l00874"></a>00874 <span class="preprocessor"></span>} <a name="l00875"></a>00875 <span class="preprocessor">#endif</span> <a name="l00876"></a>00876 <span class="preprocessor"></span> <a name="l00877"></a>00877 <span class="preprocessor">#endif</span> <a name="l00878"></a>00878 <span class="preprocessor"></span> </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Fri Mar 12 10:07:39 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>