This repository has been archived on 2020-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
arduino_universal_serial_ad.../Libraries/SerialPort/html/index.html

147 lines
10 KiB
HTML
Raw Permalink Normal View History

<!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>Serial Port: Arduino SerialPort Library</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Serial Port</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li class="current"><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<div class="title">Arduino SerialPort Library </div> </div>
</div>
<div class="contents">
<div class="textblock"><center>Copyright &copy; 2011 by William Greiman </center><h2><a class="anchor" id="Intro"></a>
Introduction</h2>
<p>This library provide more options for buffering, character size, parity and error checking than the standard Arduino HardwareSerial class for AVR Arduino boards.</p>
<p>The API was designed to be backward compatible with Arduino Serial. A number of functions have been added to the API.</p>
<p>To install the this library, copy the <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> folder to the your libraries folder.</p>
<p>Please explore the above tabs for detailed documentation.</p>
<h2><a class="anchor" id="howto"></a>
Quick How To</h2>
<p>This was posted in the Arduino forum by user sixeyes. It is a nice introduction to to the <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> library.</p>
<p>The core Arduino based serial code looks like this:</p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> setup()
{
Serial.begin(9600);
Serial.println(<span class="stringliteral">&quot;Using Arduino supplied HardwareSerial&quot;</span>);
}
<span class="keywordtype">void</span> loop()
{
}
</pre></div><p>So if you've copied the <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> folder from the zip file into your libraries folder (So you have <a class="el" href="a00005.html" title="Serial Port class.">Arduino/libraries/SerialPort/SerialPort.h</a> and <a class="el" href="a00004.html" title="Serial Port class.">Arduino/libraries/SerialPort/SerialPort.cpp</a>) you can write the following code instead</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="a00005.html" title="Serial Port class.">SerialPort.h</a>&gt;</span>
<a class="code" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort&lt;0, 32, 256&gt;</a> port;
<span class="keywordtype">void</span> setup()
{
port.<a class="code" href="a00001.html#a38b8cda8cb7c94a38de9f29ee48f4259">begin</a>(9600);
port.println(<span class="stringliteral">&quot;Using SerialPort class&quot;</span>);
}
<span class="keywordtype">void</span> loop()
{
}
</pre></div><p>Just remember to do the following and you should be alright:</p>
<ul>
<li>Include &lt;<a class="el" href="a00005.html" title="Serial Port class.">SerialPort.h</a>&gt;</li>
<li>Declare new Serial port including its parameters</li>
<li>Initialise (call begin()) and use the new serial port (NOT Serial)</li>
</ul>
<p>The configuration of the serial port looks odd to anyone not familiar with C++ templates, but it's easy to explain. The first parameter inside the angle brackets is the serial port number. Unless you've got a board with more than one serial port (e.g. Arduino Mega) this will always be 0. The second parameter is the size of the receive buffer in bytes and the third is the size of the transmit buffer in bytes.</p>
<p>You can ignore the stuff about editing <a class="el" href="a00005.html" title="Serial Port class.">SerialPort.h</a>. You'll only need this if you're short of flash memory at which point you can come back and ask more questions.</p>
<p>If you do by chance refer to both the new <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> and HardwareSerial in the same sketch you'll get some error messages about duplicate interrupt vectors.</p>
<p>Hope that helps.</p>
<p>Iain</p>
<h2><a class="anchor" id="logger"></a>
SerialPort Sd Logger</h2>
<p>The folder, SerialPortLogger, contains a demo data logging sketch that is capable of logging serial data to an SD card at up to 115200 baud.</p>
<p>The two programs, SerialPortLogger.ino and SerialDataSource.ino, demonstrate high speed logging of serial data.</p>
<p>For more information see the readme.txt file in the SerialPortLogger folder.</p>
<h2><a class="anchor" id="examples"></a>
Examples</h2>
<p>A number of examples are included in the SerialPort/examples folder.</p>
<p>ArduinoSize - Print the amount of free RAM using Arduino HardwareSerial.</p>
<p>ArduinoTest - Arduino HardwareSerial version of test sketch.</p>
<p>BufferedSize - Print the amount of free RAM using <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> with buffered RX and TX.</p>
<p>BufferedTest - Test <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> with buffered RX and TX.</p>
<p>HelloWorld - Simple first example.</p>
<p>MegaTest - Test all ports on a Mega using <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a>.</p>
<p>MegaTestArduino - Test all ports on a Mega using Arduino HardwareSerial.</p>
<p>ReadWriteTest - Test that ring buffer overrun can be detected.</p>
<p>UnbufferedSize - Print the amount of free RAM using <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> with no buffers.</p>
<p>UnbufferedTest - Test <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> with no buffering.</p>
<p>WriteFlash - Test write() for a flash string.</p>
<h2><a class="anchor" id="config"></a>
Configuration Options</h2>
<p>You can can save flash if your buffers are always smaller than 254 bytes by setting ALLOW_LARGE_BUFFERS zero in <a class="el" href="a00005.html" title="Serial Port class.">SerialPort.h</a>. This will also increase performance slightly.</p>
<p>You can save substantial flash by disabling the faster versions of write(const char*) and write(const uint8_t*, size_t) by setting USE_WRITE_OVERRIDES zero in <a class="el" href="a00005.html" title="Serial Port class.">SerialPort.h</a>.</p>
<p>If you only use unbuffered TX, edit <a class="el" href="a00005.html" title="Serial Port class.">SerialPort.h</a> and set BUFFERED_TX zero. This will save some flash and RAM by preventing the TX ISR from being loaded. TxBufSize must always be zero in <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> constructors if BUFFERED_TX is zero.</p>
<p>If you only do output or if input buffering is not required, edit <a class="el" href="a00005.html" title="Serial Port class.">SerialPort.h</a> and set BUFFERED_RX zero. This will save some flash and RAM by preventing the RX ISR from being loaded. RxBufSize must always be zero in <a class="el" href="a00001.html" title="Class for avr hardware USART ports.">SerialPort</a> constructors if BUFFERED_RX is zero.</p>
<p>You can disable RX error functions by setting ENABLE_RX_ERROR_CHECKING zero in <a class="el" href="a00005.html" title="Serial Port class.">SerialPort.h</a> This will save a tiny bit of flash, RAM, and speedup receive a little. </p>
</div></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Fri Feb 22 2013 11:38:19 for Serial Port by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>