<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Yate: yatemodem.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.7.1 --> <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> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <h1>yatemodem.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * yatemodem.h</span> <a name="l00003"></a>00003 <span class="comment"> * This file is part of the YATE Project http://YATE.null.ro</span> <a name="l00004"></a>00004 <span class="comment"> *</span> <a name="l00005"></a>00005 <span class="comment"> * Yet Another Modem</span> <a name="l00006"></a>00006 <span class="comment"> *</span> <a name="l00007"></a>00007 <span class="comment"> * Yet Another Telephony Engine - a fully featured software PBX and IVR</span> <a name="l00008"></a>00008 <span class="comment"> * Copyright (C) 2004-2006 Null Team</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span> <a name="l00011"></a>00011 <span class="comment"> * it under the terms of the GNU General Public License as published by</span> <a name="l00012"></a>00012 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span> <a name="l00013"></a>00013 <span class="comment"> * (at your option) any later version.</span> <a name="l00014"></a>00014 <span class="comment"> *</span> <a name="l00015"></a>00015 <span class="comment"> * This program is distributed in the hope that it will be useful,</span> <a name="l00016"></a>00016 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00017"></a>00017 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00018"></a>00018 <span class="comment"> * GNU General Public License for more details.</span> <a name="l00019"></a>00019 <span class="comment"> *</span> <a name="l00020"></a>00020 <span class="comment"> * You should have received a copy of the GNU General Public License</span> <a name="l00021"></a>00021 <span class="comment"> * along with this program; if not, write to the Free Software</span> <a name="l00022"></a>00022 <span class="comment"> * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.</span> <a name="l00023"></a>00023 <span class="comment"> */</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#ifndef __YATEMODEM_H</span> <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define __YATEMODEM_H</span> <a name="l00027"></a>00027 <span class="preprocessor"></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <yateclass.h></span> <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="preprocessor">#ifdef _WINDOWS</span> <a name="l00031"></a>00031 <span class="preprocessor"></span> <a name="l00032"></a>00032 <span class="preprocessor">#ifdef LIBYMODEM_EXPORTS</span> <a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define YMODEM_API __declspec(dllexport)</span> <a name="l00034"></a>00034 <span class="preprocessor"></span><span class="preprocessor">#else</span> <a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#ifndef LIBYMODEM_STATIC</span> <a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#define YMODEM_API __declspec(dllimport)</span> <a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00038"></a>00038 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00039"></a>00039 <span class="preprocessor"></span> <a name="l00040"></a>00040 <span class="preprocessor">#endif </span><span class="comment">/* _WINDOWS */</span> <a name="l00041"></a>00041 <a name="l00042"></a>00042 <span class="preprocessor">#ifndef YMODEM_API</span> <a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#define YMODEM_API</span> <a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00045"></a>00045 <span class="preprocessor"></span> <a name="l00046"></a>00046 <a name="l00050"></a>00050 <span class="keyword">namespace </span>TelEngine { <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keyword">class </span>BitAccumulator; <span class="comment">// 1-byte length bit accumulator</span> <a name="l00053"></a>00053 <span class="keyword">class </span>FSKModem; <span class="comment">// Frequency Shift Keying modulator/demodulator</span> <a name="l00054"></a>00054 <span class="keyword">class </span>UART; <span class="comment">// UART receiver/transmitter</span> <a name="l00055"></a>00055 <span class="keyword">class </span>UARTBuffer; <span class="comment">// A byte accumulator used by an UART</span> <a name="l00056"></a>00056 <span class="keyword">class </span>ETSIModem; <span class="comment">// An analog signal processor as defined by ETSI</span> <a name="l00057"></a>00057 <span class="comment">// Internal forward declarations</span> <a name="l00058"></a>00058 <span class="keyword">class </span>BitBuffer; <span class="comment">// Used to accumulate all bits to be printed to output</span> <a name="l00059"></a>00059 <span class="keyword">class </span>FSKFilter; <span class="comment">// The internal signal filter</span> <a name="l00060"></a>00060 <a name="l00061"></a>00061 <a name="l00066"></a><a class="code" href="classTelEngine_1_1BitAccumulator.html">00066</a> <span class="keyword">class </span>YMODEM_API <a class="code" href="classTelEngine_1_1BitAccumulator.html" title="A 1-byte length bit accumulator.">BitAccumulator</a> <a name="l00067"></a>00067 { <a name="l00068"></a>00068 <span class="keyword">public</span>: <a name="l00073"></a><a class="code" href="classTelEngine_1_1BitAccumulator.html#6e2ee4a2a6fb08d3a8ccaf7a6943fc8e">00073</a> <span class="keyword">inline</span> <a class="code" href="classTelEngine_1_1BitAccumulator.html" title="A 1-byte length bit accumulator.">BitAccumulator</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> dataBits) <a name="l00074"></a>00074 : m_crtByte(0), m_crtPos(0), m_dataBits(dataBits), m_oddParity(false) <a name="l00075"></a>00075 {} <a name="l00076"></a>00076 <a name="l00081"></a><a class="code" href="classTelEngine_1_1BitAccumulator.html#2cc481ac2eccc6686074744f53ac4117">00081</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> dataBits()<span class="keyword"> const</span> <a name="l00082"></a>00082 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_dataBits; } <a name="l00083"></a>00083 <a name="l00088"></a><a class="code" href="classTelEngine_1_1BitAccumulator.html#5eb11cbe39aa6512283a6b734fe8ff46">00088</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classTelEngine_1_1BitAccumulator.html#5eb11cbe39aa6512283a6b734fe8ff46">dataBits</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> value) { <a name="l00089"></a>00089 m_dataBits = value; <a name="l00090"></a>00090 reset(); <a name="l00091"></a>00091 } <a name="l00092"></a>00092 <a name="l00098"></a><a class="code" href="classTelEngine_1_1BitAccumulator.html#e24e0fabf62f00402c04363b3b2ad0bd">00098</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="classTelEngine_1_1BitAccumulator.html#e24e0fabf62f00402c04363b3b2ad0bd">reset</a>(<span class="keywordtype">bool</span>* oddParity = 0) { <a name="l00099"></a>00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> tmp = m_crtByte; <a name="l00100"></a>00100 m_crtByte = m_crtPos = 0; <a name="l00101"></a>00101 <span class="keywordflow">if</span> (oddParity) <a name="l00102"></a>00102 *oddParity = m_oddParity; <a name="l00103"></a>00103 m_oddParity = <span class="keyword">false</span>; <a name="l00104"></a>00104 <span class="keywordflow">return</span> tmp; <a name="l00105"></a>00105 } <a name="l00106"></a>00106 <a name="l00113"></a><a class="code" href="classTelEngine_1_1BitAccumulator.html#3cc0c994f54f7792535d7bf206e51bde">00113</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classTelEngine_1_1BitAccumulator.html#3cc0c994f54f7792535d7bf206e51bde">accumulate</a>(<span class="keywordtype">bool</span> bit, <span class="keywordtype">bool</span>* oddParity = 0) { <a name="l00114"></a>00114 <span class="keywordflow">if</span> (bit) { <a name="l00115"></a>00115 m_crtByte |= (1 << m_crtPos); <a name="l00116"></a>00116 m_oddParity = !m_oddParity; <a name="l00117"></a>00117 } <a name="l00118"></a>00118 m_crtPos++; <a name="l00119"></a>00119 <span class="keywordflow">if</span> (m_crtPos != m_dataBits) <a name="l00120"></a>00120 <span class="keywordflow">return</span> 0xffff; <a name="l00121"></a>00121 <span class="keywordflow">return</span> reset(oddParity); <a name="l00122"></a>00122 } <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="keyword">private</span>: <a name="l00125"></a>00125 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_crtByte; <span class="comment">// Current partial byte</span> <a name="l00126"></a>00126 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_crtPos; <span class="comment">// Current free bit position</span> <a name="l00127"></a>00127 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_dataBits; <span class="comment">// The length of a data byte (interval: 1..8)</span> <a name="l00128"></a>00128 <span class="keywordtype">bool</span> m_oddParity; <span class="comment">// The parity of the current byte value (true: odd)</span> <a name="l00129"></a>00129 }; <a name="l00130"></a>00130 <a name="l00131"></a>00131 <a name="l00137"></a><a class="code" href="classTelEngine_1_1FSKModem.html">00137</a> <span class="keyword">class </span>YMODEM_API <a class="code" href="classTelEngine_1_1FSKModem.html" title="A Frequency Shift Keying modem.">FSKModem</a> <a name="l00138"></a>00138 { <a name="l00139"></a>00139 <span class="keyword">public</span>: <a name="l00143"></a><a class="code" href="classTelEngine_1_1FSKModem.html#1d1cfd8ffb84e947f82999c682b666a7">00143</a> <span class="keyword">enum</span> <a class="code" href="classTelEngine_1_1FSKModem.html#1d1cfd8ffb84e947f82999c682b666a7">Type</a> { <a name="l00144"></a>00144 ETSI = 0, <span class="comment">// ETSI caller id signal: MARK:1200 SPACE:2200 BAUDRATE:1200</span> <a name="l00145"></a>00145 <span class="comment">// SAMPLERATE:8000 SAMPLES/BIT:7 STOPBITS:1 PARITY:NONE</span> <a name="l00146"></a>00146 TypeCount = 1 <a name="l00147"></a>00147 <span class="comment">// NOTE: Don't change these values: they are used as array indexes</span> <a name="l00148"></a>00148 }; <a name="l00149"></a>00149 <a name="l00155"></a>00155 <a class="code" href="classTelEngine_1_1FSKModem.html" title="A Frequency Shift Keying modem.">FSKModem</a>(<span class="keyword">const</span> <a class="code" href="classTelEngine_1_1NamedList.html" title="A named string container class.">NamedList</a>& params, <a class="code" href="classTelEngine_1_1UART.html" title="An UART receiver/transmitter.">UART</a>* uart); <a name="l00156"></a>00156 <a name="l00160"></a>00160 ~<a class="code" href="classTelEngine_1_1FSKModem.html" title="A Frequency Shift Keying modem.">FSKModem</a>(); <a name="l00161"></a>00161 <a name="l00167"></a><a class="code" href="classTelEngine_1_1FSKModem.html#6670bec75731f6f769bed2f86d402393">00167</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> terminated()<span class="keyword"> const</span> <a name="l00168"></a>00168 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_terminated; } <a name="l00169"></a>00169 <a name="l00174"></a><a class="code" href="classTelEngine_1_1FSKModem.html#4609e33962a63a3b71f17de25e8745aa">00174</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> type()<span class="keyword"> const</span> <a name="l00175"></a>00175 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_type; } <a name="l00176"></a>00176 <a name="l00180"></a>00180 <span class="keywordtype">void</span> reset(); <a name="l00181"></a>00181 <a name="l00187"></a>00187 <span class="keywordtype">bool</span> demodulate(<span class="keyword">const</span> <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& data); <a name="l00188"></a>00188 <a name="l00197"></a>00197 <span class="keywordtype">void</span> modulate(<a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& dest, <span class="keyword">const</span> <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& data); <a name="l00198"></a>00198 <a name="l00205"></a><a class="code" href="classTelEngine_1_1FSKModem.html#54a857dbce89ce43c1d93d2bdceb97d4">00205</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classTelEngine_1_1FSKModem.html#54a857dbce89ce43c1d93d2bdceb97d4">addRaw</a>(<a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& dest, <span class="keywordtype">void</span>* buf, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len) { <a name="l00206"></a>00206 <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a> tmp(buf,len,<span class="keyword">false</span>); <a name="l00207"></a>00207 dest += tmp; <a name="l00208"></a>00208 tmp.<a class="code" href="classTelEngine_1_1DataBlock.html#7927d7a1ef8f8c13a1ba9d90ad352c49">clear</a>(<span class="keyword">false</span>); <a name="l00209"></a>00209 } <a name="l00210"></a>00210 <a name="l00214"></a><a class="code" href="classTelEngine_1_1FSKModem.html#ffadd530d1e93767ef3bfbad2f4b754d">00214</a> <span class="keyword">static</span> <a class="code" href="structTelEngine_1_1TokenDict.html">TokenDict</a> s_typeName[]; <a name="l00215"></a>00215 <a name="l00216"></a>00216 <span class="keyword">private</span>: <a name="l00217"></a>00217 <span class="keywordtype">int</span> m_type; <span class="comment">// Modem type</span> <a name="l00218"></a>00218 <span class="keywordtype">bool</span> m_terminated; <span class="comment">// Terminated flag (need reset if true)</span> <a name="l00219"></a>00219 FSKFilter* m_filter; <span class="comment">// Internal filter used to demodulate received data</span> <a name="l00220"></a>00220 <a class="code" href="classTelEngine_1_1UART.html" title="An UART receiver/transmitter.">UART</a>* m_uart; <span class="comment">// The UART using this modem's services</span> <a name="l00221"></a>00221 <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a> m_buffer; <span class="comment">// Partial input buffer when used to demodulate or modulate data</span> <a name="l00222"></a>00222 BitBuffer* m_bits; <span class="comment">// Bit buffer used when debugging</span> <a name="l00223"></a>00223 }; <a name="l00224"></a>00224 <a name="l00225"></a>00225 <a name="l00230"></a><a class="code" href="classTelEngine_1_1UART.html">00230</a> <span class="keyword">class </span>YMODEM_API <a class="code" href="classTelEngine_1_1UART.html" title="An UART receiver/transmitter.">UART</a> : <span class="keyword">public</span> <a class="code" href="classTelEngine_1_1DebugEnabler.html" title="A holder for a debug level.">DebugEnabler</a> <a name="l00231"></a>00231 { <a name="l00232"></a>00232 <span class="keyword">public</span>: <a name="l00236"></a><a class="code" href="classTelEngine_1_1UART.html#5d74787dedbc4e11c1ab15bf487e61f8">00236</a> <span class="keyword">enum</span> <a class="code" href="classTelEngine_1_1UART.html#5d74787dedbc4e11c1ab15bf487e61f8">State</a> { <a name="l00237"></a>00237 Idle, <span class="comment">// Not started</span> <a name="l00238"></a>00238 BitStart, <span class="comment">// Waiting for start bit (SPACE)</span> <a name="l00239"></a>00239 BitData, <span class="comment">// Accumulate data bits</span> <a name="l00240"></a>00240 BitParity, <span class="comment">// Waiting for parity bit(s)</span> <a name="l00241"></a>00241 BitStop, <span class="comment">// Waiting for stop bit (MARK)</span> <a name="l00242"></a>00242 UARTError, <span class="comment">// Error</span> <a name="l00243"></a>00243 }; <a name="l00244"></a>00244 <a name="l00248"></a><a class="code" href="classTelEngine_1_1UART.html#2c3e4bb40f36b262a5214e2da2bca9c5">00248</a> <span class="keyword">enum</span> <a class="code" href="classTelEngine_1_1UART.html#2c3e4bb40f36b262a5214e2da2bca9c5">Error</a> { <a name="l00249"></a>00249 EFraming, <span class="comment">// Frame error: invalid stop bit(s)</span> <a name="l00250"></a>00250 EParity, <span class="comment">// Parity error</span> <a name="l00251"></a>00251 EChksum, <span class="comment">// Message checksum error</span> <a name="l00252"></a>00252 EInvalidData, <span class="comment">// Invalid (inconsistent) data</span> <a name="l00253"></a>00253 EUnknown, <span class="comment">// Unknown error</span> <a name="l00254"></a>00254 EStopped, <span class="comment">// Aborted by descendants</span> <a name="l00255"></a>00255 ENone <a name="l00256"></a>00256 }; <a name="l00257"></a>00257 <a name="l00264"></a>00264 <a class="code" href="classTelEngine_1_1UART.html" title="An UART receiver/transmitter.">UART</a>(State state, <span class="keyword">const</span> <a class="code" href="classTelEngine_1_1NamedList.html" title="A named string container class.">NamedList</a>& params, <span class="keyword">const</span> <span class="keywordtype">char</span>* name = 0); <a name="l00265"></a>00265 <a name="l00269"></a><a class="code" href="classTelEngine_1_1UART.html#a17b513b37b54eb08699870d19b29501">00269</a> <span class="keyword">virtual</span> ~<a class="code" href="classTelEngine_1_1UART.html" title="An UART receiver/transmitter.">UART</a>() <a name="l00270"></a>00270 {} <a name="l00271"></a>00271 <a name="l00276"></a><a class="code" href="classTelEngine_1_1UART.html#3804c9648e6d1325751536cca350f2bf">00276</a> <span class="keyword">inline</span> <a class="code" href="classTelEngine_1_1UART.html#5d74787dedbc4e11c1ab15bf487e61f8">State</a> state()<span class="keyword"> const</span> <a name="l00277"></a>00277 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_state; } <a name="l00278"></a>00278 <a name="l00283"></a><a class="code" href="classTelEngine_1_1UART.html#6c0803d83827f0d9aa8be11472c6c542">00283</a> <span class="keyword">inline</span> <a class="code" href="classTelEngine_1_1UART.html#2c3e4bb40f36b262a5214e2da2bca9c5">Error</a> error()<span class="keyword"> const</span> <a name="l00284"></a>00284 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_error; } <a name="l00285"></a>00285 <a name="l00290"></a><a class="code" href="classTelEngine_1_1UART.html#58042723326c2296bec27ecf08fcbc27">00290</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> modemType()<span class="keyword"> const</span> <a name="l00291"></a>00291 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_modem.type(); } <a name="l00292"></a>00292 <a name="l00297"></a><a class="code" href="classTelEngine_1_1UART.html#3828c3e3be53039a07e077ab82a7d0b2">00297</a> <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code" href="classTelEngine_1_1BitAccumulator.html" title="A 1-byte length bit accumulator.">BitAccumulator</a>& accumulator()<span class="keyword"> const</span> <a name="l00298"></a>00298 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_accumulator; } <a name="l00299"></a>00299 <a name="l00304"></a>00304 <span class="keyword">virtual</span> <span class="keywordtype">void</span> reset(State newState = Idle); <a name="l00305"></a>00305 <a name="l00311"></a><a class="code" href="classTelEngine_1_1UART.html#5b447c39dc5e071deb6e4d33f6c9af3c">00311</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> demodulate(<span class="keyword">const</span> <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& data) <a name="l00312"></a>00312 { <span class="keywordflow">return</span> m_modem.demodulate(data); } <a name="l00313"></a>00313 <a name="l00320"></a><a class="code" href="classTelEngine_1_1UART.html#c75c7402a4fc83bf4987c13ca8aacfa3">00320</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classTelEngine_1_1UART.html#c75c7402a4fc83bf4987c13ca8aacfa3">modulate</a>(<a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& dest, <a class="code" href="classTelEngine_1_1NamedList.html" title="A named string container class.">NamedList</a>& params) { <a name="l00321"></a>00321 <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a> data; <a name="l00322"></a>00322 <span class="keywordflow">if</span> (!createMsg(params,data)) <a name="l00323"></a>00323 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00324"></a>00324 m_modem.modulate(dest,data); <a name="l00325"></a>00325 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00326"></a>00326 } <a name="l00327"></a>00327 <a name="l00333"></a><a class="code" href="classTelEngine_1_1UART.html#d914cd566b8351615165d3b3054f4eab">00333</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> modulate(<a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& dest, <span class="keyword">const</span> <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& src) <a name="l00334"></a>00334 { m_modem.modulate(dest,src); } <a name="l00335"></a>00335 <a name="l00341"></a>00341 <span class="keywordtype">bool</span> recvBit(<span class="keywordtype">bool</span> value); <a name="l00342"></a>00342 <a name="l00348"></a><a class="code" href="classTelEngine_1_1UART.html#2b2c72d82aa0d491bd8b474058bb7386">00348</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> recvByte(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data) <a name="l00349"></a>00349 { <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00350"></a>00350 <a name="l00355"></a><a class="code" href="classTelEngine_1_1UART.html#69ebd093d2dd1d0a5a5dd738ac576c38">00355</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> fskStarted() <a name="l00356"></a>00356 { <span class="keywordflow">return</span> <span class="keyword">true</span>; } <a name="l00357"></a>00357 <a name="l00361"></a><a class="code" href="classTelEngine_1_1UART.html#6ddd6252fb312fddd0709b0c0411a3e5">00361</a> <span class="keyword">static</span> <a class="code" href="structTelEngine_1_1TokenDict.html">TokenDict</a> s_errors[]; <a name="l00362"></a>00362 <a name="l00363"></a>00363 <span class="keyword">protected</span>: <a name="l00369"></a><a class="code" href="classTelEngine_1_1UART.html#9176044928486fb38fca7adc5804cd29">00369</a> <span class="keyword">virtual</span> <span class="keywordtype">int</span> idleRecvByte(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data) <a name="l00370"></a>00370 { <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00371"></a>00371 <a name="l00378"></a><a class="code" href="classTelEngine_1_1UART.html#75cfe67ac70886275dbb6b997b1674ae">00378</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> createMsg(<a class="code" href="classTelEngine_1_1NamedList.html" title="A named string container class.">NamedList</a>& params, <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& data) <a name="l00379"></a>00379 { <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00380"></a>00380 <a name="l00386"></a>00386 <span class="keywordtype">bool</span> error(Error e); <a name="l00387"></a>00387 <a name="l00388"></a>00388 <span class="keyword">private</span>: <a name="l00389"></a>00389 <span class="comment">// Change this UART's state</span> <a name="l00390"></a>00390 <span class="keywordtype">void</span> changeState(State newState); <a name="l00391"></a>00391 <a name="l00392"></a>00392 <a class="code" href="classTelEngine_1_1FSKModem.html" title="A Frequency Shift Keying modem.">FSKModem</a> m_modem; <span class="comment">// The modem used by this UART</span> <a name="l00393"></a>00393 State m_state; <span class="comment">// The state of this UART</span> <a name="l00394"></a>00394 Error m_error; <span class="comment">// The error type if state is error</span> <a name="l00395"></a>00395 <span class="keywordtype">int</span> m_parity; <span class="comment">// Used parity: 0=none, -1=odd, 1=even</span> <a name="l00396"></a>00396 <span class="keywordtype">bool</span> m_expectedParity; <span class="comment">// The expected value of the parity bit if used</span> <a name="l00397"></a>00397 <a class="code" href="classTelEngine_1_1BitAccumulator.html" title="A 1-byte length bit accumulator.">BitAccumulator</a> m_accumulator; <span class="comment">// The data bits accumulator</span> <a name="l00398"></a>00398 }; <a name="l00399"></a>00399 <a name="l00400"></a>00400 <a name="l00405"></a><a class="code" href="classTelEngine_1_1UARTBuffer.html">00405</a> <span class="keyword">class </span>YMODEM_API <a class="code" href="classTelEngine_1_1UARTBuffer.html" title="A fixed length byte accumulator used by an UART.">UARTBuffer</a> <a name="l00406"></a>00406 { <a name="l00407"></a>00407 <span class="keyword">public</span>: <a name="l00412"></a><a class="code" href="classTelEngine_1_1UARTBuffer.html#a088061fe2beee4c0311bf838cf6176e">00412</a> <span class="keyword">inline</span> <a class="code" href="classTelEngine_1_1UARTBuffer.html" title="A fixed length byte accumulator used by an UART.">UARTBuffer</a>(<a class="code" href="classTelEngine_1_1UART.html" title="An UART receiver/transmitter.">UART</a>* client) <a name="l00413"></a>00413 : m_client(client) <a name="l00414"></a>00414 { reset(); } <a name="l00415"></a>00415 <a name="l00420"></a><a class="code" href="classTelEngine_1_1UARTBuffer.html#ef4b4ca09dc9fa6950b8a7293f5e0383">00420</a> <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& buffer()<span class="keyword"> const</span> <a name="l00421"></a>00421 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_buffer; } <a name="l00422"></a>00422 <a name="l00427"></a><a class="code" href="classTelEngine_1_1UARTBuffer.html#5db13496564758e8576dfa3d057b9023">00427</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> free()<span class="keyword"> const</span> <a name="l00428"></a>00428 <span class="keyword"> </span>{ <span class="keywordflow">return</span> m_free; } <a name="l00429"></a>00429 <a name="l00434"></a><a class="code" href="classTelEngine_1_1UARTBuffer.html#ef603afa6525c4959916d86d22e05639">00434</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classTelEngine_1_1UARTBuffer.html#ef603afa6525c4959916d86d22e05639">reset</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len = 0) { <a name="l00435"></a>00435 m_buffer.clear(); <a name="l00436"></a>00436 m_crtIdx = m_free = 0; <a name="l00437"></a>00437 <span class="keywordflow">if</span> (len) { <a name="l00438"></a>00438 m_buffer.assign(0,len); <a name="l00439"></a>00439 m_free = len; <a name="l00440"></a>00440 } <a name="l00441"></a>00441 } <a name="l00442"></a>00442 <a name="l00448"></a><a class="code" href="classTelEngine_1_1UARTBuffer.html#bd22dc3e293742fc5306f4cf66616212">00448</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classTelEngine_1_1UARTBuffer.html#bd22dc3e293742fc5306f4cf66616212">accumulate</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> value) { <a name="l00449"></a>00449 <span class="keywordflow">if</span> (m_free) { <a name="l00450"></a>00450 ((<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)m_buffer.data())[m_crtIdx++] = value; <a name="l00451"></a>00451 m_free--; <a name="l00452"></a>00452 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00453"></a>00453 } <a name="l00454"></a>00454 <a class="code" href="namespaceTelEngine.html#3340bc2f81fe3a2eb7b8ed6778d84a37">Debug</a>(m_client,DebugNote,<span class="stringliteral">"Buffer overflow"</span>); <a name="l00455"></a>00455 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00456"></a>00456 } <a name="l00457"></a>00457 <a name="l00458"></a>00458 <span class="keyword">private</span>: <a name="l00459"></a>00459 <a class="code" href="classTelEngine_1_1UART.html" title="An UART receiver/transmitter.">UART</a>* m_client; <span class="comment">// The client</span> <a name="l00460"></a>00460 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_crtIdx; <span class="comment">// Current index n buffer</span> <a name="l00461"></a>00461 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_free; <span class="comment">// Free buffer length</span> <a name="l00462"></a>00462 <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a> m_buffer; <span class="comment">// The buffer</span> <a name="l00463"></a>00463 }; <a name="l00464"></a>00464 <a name="l00465"></a>00465 <a name="l00471"></a><a class="code" href="classTelEngine_1_1ETSIModem.html">00471</a> <span class="keyword">class </span>YMODEM_API <a class="code" href="classTelEngine_1_1ETSIModem.html" title="An analog signal processor as defined by ETSI.">ETSIModem</a> : <span class="keyword">public</span> <a class="code" href="classTelEngine_1_1UART.html" title="An UART receiver/transmitter.">UART</a> <a name="l00472"></a>00472 { <a name="l00473"></a>00473 <span class="keyword">public</span>: <a name="l00477"></a><a class="code" href="classTelEngine_1_1ETSIModem.html#5d74787dedbc4e11c1ab15bf487e61f8">00477</a> <span class="keyword">enum</span> <a class="code" href="classTelEngine_1_1ETSIModem.html#5d74787dedbc4e11c1ab15bf487e61f8">State</a> { <a name="l00478"></a>00478 StateError, <span class="comment">// Error encountered: need reset</span> <a name="l00479"></a>00479 WaitFSKStart, <span class="comment">// Waiting for data start pattern</span> <a name="l00480"></a>00480 WaitMark, <span class="comment">// Waiting for mark pattern</span> <a name="l00481"></a>00481 WaitMsg, <span class="comment">// Wait a message</span> <a name="l00482"></a>00482 WaitMsgLen, <span class="comment">// Received message: wait length</span> <a name="l00483"></a>00483 WaitParam, <span class="comment">// Wait a parameter</span> <a name="l00484"></a>00484 WaitParamLen, <span class="comment">// Received parameter: wait length</span> <a name="l00485"></a>00485 WaitData, <span class="comment">// Received parameter length: wait data</span> <a name="l00486"></a>00486 WaitChksum, <span class="comment">// Wait checksum</span> <a name="l00487"></a>00487 }; <a name="l00488"></a>00488 <a name="l00492"></a><a class="code" href="classTelEngine_1_1ETSIModem.html#2ea0bb09adcce7f655e8f8ee8d30561b">00492</a> <span class="keyword">enum</span> <a class="code" href="classTelEngine_1_1ETSIModem.html#2ea0bb09adcce7f655e8f8ee8d30561b">MsgType</a> { <a name="l00493"></a>00493 MsgCallSetup = 0x80, <span class="comment">// Call setup</span> <a name="l00494"></a>00494 MsgMWI = 0x82, <span class="comment">// Message waiting indicator</span> <a name="l00495"></a>00495 MsgCharge = 0x86, <span class="comment">// Advise of charge</span> <a name="l00496"></a>00496 MsgSMS = 0x89, <span class="comment">// Short message service</span> <a name="l00497"></a>00497 }; <a name="l00498"></a>00498 <a name="l00502"></a><a class="code" href="classTelEngine_1_1ETSIModem.html#174aa3d1143579b2916738e4d5894fae">00502</a> <span class="keyword">enum</span> <a class="code" href="classTelEngine_1_1ETSIModem.html#174aa3d1143579b2916738e4d5894fae">MsgParam</a> { <a name="l00503"></a>00503 DateTime = 0x01, <span class="comment">// 8 Date and Time</span> <a name="l00504"></a>00504 CallerId = 0x02, <span class="comment">// max. 20 Calling Line Identity</span> <a name="l00505"></a>00505 CalledId = 0x03, <span class="comment">// max. 20 Called Line Identity</span> <a name="l00506"></a>00506 CallerIdReason = 0x04, <span class="comment">// 1 Reason for Absence of Calling Line Identity</span> <a name="l00507"></a>00507 CallerName = 0x07, <span class="comment">// max. 50 Calling Party Name</span> <a name="l00508"></a>00508 CallerNameReason = 0x08, <span class="comment">// 1 Reason for absence of Calling Party Name</span> <a name="l00509"></a>00509 VisualIndicator = 0x0B, <span class="comment">// 1 Visual Indicator</span> <a name="l00510"></a>00510 MessageId = 0x0D, <span class="comment">// 3 Message Identification</span> <a name="l00511"></a>00511 LastMsgCLI = 0x0E, <span class="comment">// max. 20 Last Message CLI</span> <a name="l00512"></a>00512 CompDateTime = 0x0F, <span class="comment">// 8 or 10 Complementary Date and Time</span> <a name="l00513"></a>00513 CompCallerId = 0x10, <span class="comment">// max. 20 Complementary Calling Line Identity</span> <a name="l00514"></a>00514 CallType = 0x11, <span class="comment">// 1 Call type</span> <a name="l00515"></a>00515 FirstCalledId = 0x12, <span class="comment">// max. 20 First Called Line Identity</span> <a name="l00516"></a>00516 MWICount = 0x13, <span class="comment">// 1 Number of Messages</span> <a name="l00517"></a>00517 FwdCallType = 0x15, <span class="comment">// 1 Type of Forwarded call</span> <a name="l00518"></a>00518 CallerType = 0x16, <span class="comment">// 1 Type of Calling user</span> <a name="l00519"></a>00519 RedirNumber = 0x1A, <span class="comment">// max. 20 Redirecting Number</span> <a name="l00520"></a>00520 Charge = 0x20, <span class="comment">// 14 Charge</span> <a name="l00521"></a>00521 AdditionalCharge = 0x21, <span class="comment">// 14 Additional Charge</span> <a name="l00522"></a>00522 Duration = 0x23, <span class="comment">// 6 Duration of the Call</span> <a name="l00523"></a>00523 NetworkID = 0x30, <span class="comment">// max. 20 Network Provider Identity</span> <a name="l00524"></a>00524 CarrierId = 0x31, <span class="comment">// max. 20 Carrier Identity</span> <a name="l00525"></a>00525 SelectFunction = 0x40, <span class="comment">// 2-21 Selection of Terminal Function</span> <a name="l00526"></a>00526 Display = 0x50, <span class="comment">// max. 253 Display Information</span> <a name="l00527"></a>00527 ServiceInfo = 0x55, <span class="comment">// 1 Service Information</span> <a name="l00528"></a>00528 Extension = 0xE0, <span class="comment">// 10 Extension for network operator use</span> <a name="l00529"></a>00529 Unknown <a name="l00530"></a>00530 }; <a name="l00531"></a>00531 <a name="l00537"></a>00537 <a class="code" href="classTelEngine_1_1ETSIModem.html" title="An analog signal processor as defined by ETSI.">ETSIModem</a>(<span class="keyword">const</span> <a class="code" href="classTelEngine_1_1NamedList.html" title="A named string container class.">NamedList</a>& params, <span class="keyword">const</span> <span class="keywordtype">char</span>* name = 0); <a name="l00538"></a>00538 <a name="l00542"></a>00542 <span class="keyword">virtual</span> ~<a class="code" href="classTelEngine_1_1ETSIModem.html" title="An analog signal processor as defined by ETSI.">ETSIModem</a>(); <a name="l00543"></a>00543 <a name="l00547"></a>00547 <span class="keyword">virtual</span> <span class="keywordtype">void</span> reset(); <a name="l00548"></a>00548 <a name="l00554"></a>00554 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> recvByte(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data); <a name="l00555"></a>00555 <a name="l00559"></a><a class="code" href="classTelEngine_1_1ETSIModem.html#5b48dd9cca4a273a60961848daf8377d">00559</a> <span class="keyword">static</span> <a class="code" href="structTelEngine_1_1TokenDict.html">TokenDict</a> s_msg[]; <a name="l00560"></a>00560 <a name="l00564"></a><a class="code" href="classTelEngine_1_1ETSIModem.html#dcdb818f7c4fcd88bcd96cf6c61e0e56">00564</a> <span class="keyword">static</span> <a class="code" href="structTelEngine_1_1TokenDict.html">TokenDict</a> s_msgParams[]; <a name="l00565"></a>00565 <a name="l00566"></a>00566 <span class="keyword">protected</span>: <a name="l00572"></a>00572 <span class="keyword">virtual</span> <span class="keywordtype">int</span> idleRecvByte(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data); <a name="l00573"></a>00573 <a name="l00580"></a><a class="code" href="classTelEngine_1_1ETSIModem.html#532bc5706aeed4cc8da10aba5d5d26fa">00580</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> recvParams(<a class="code" href="classTelEngine_1_1ETSIModem.html#2ea0bb09adcce7f655e8f8ee8d30561b">MsgType</a> msg, <span class="keyword">const</span> <a class="code" href="classTelEngine_1_1NamedList.html" title="A named string container class.">NamedList</a>& params) <a name="l00581"></a>00581 { <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00582"></a>00582 <a name="l00589"></a>00589 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> decode(MsgType msg, <span class="keyword">const</span> <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& buffer); <a name="l00590"></a>00590 <a name="l00598"></a>00598 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> createMsg(<a class="code" href="classTelEngine_1_1NamedList.html" title="A named string container class.">NamedList</a>& params, <a class="code" href="classTelEngine_1_1DataBlock.html" title="A class that holds just a block of raw data.">DataBlock</a>& data); <a name="l00599"></a>00599 <a name="l00600"></a>00600 <span class="keyword">private</span>: <a name="l00601"></a>00601 <span class="comment">// Change decoder's state</span> <a name="l00602"></a>00602 <span class="keywordtype">void</span> changeState(State newState); <a name="l00603"></a>00603 <a name="l00604"></a>00604 <a class="code" href="classTelEngine_1_1UARTBuffer.html" title="A fixed length byte accumulator used by an UART.">UARTBuffer</a> m_buffer; <span class="comment">// The buffer used to accumulate messages</span> <a name="l00605"></a>00605 State m_state; <span class="comment">// Decoder state</span> <a name="l00606"></a>00606 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_waitSeizureCount; <span class="comment">// Expected number of channel seizure bytes in a row</span> <a name="l00607"></a>00607 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_crtSeizureCount; <span class="comment">// Current number of channel seizure bytes in a row</span> <a name="l00608"></a>00608 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_crtMsg; <span class="comment">// Current message id</span> <a name="l00609"></a>00609 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_crtParamLen; <span class="comment">// Current receiving parameter length</span> <a name="l00610"></a>00610 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_chksum; <span class="comment">// Current calculated checksum</span> <a name="l00611"></a>00611 }; <a name="l00612"></a>00612 <a name="l00613"></a>00613 } <a name="l00614"></a>00614 <a name="l00615"></a>00615 <span class="preprocessor">#endif </span><span class="comment">/* __YATEMODEM_H */</span> <a name="l00616"></a>00616 <a name="l00617"></a>00617 <span class="comment">/* vi: set ts=8 sw=4 sts=4 noet: */</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Sun Dec 7 21:36:10 2008 for Yate by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.7.1 </small></address> </body> </html>