34 lines
6.8 KiB
HTML
34 lines
6.8 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Device Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheDeviceKit_Overview.html" title="The Device Kit" /><link rel="prev" href="BJoystick_Overview.html" title="BJoystick" /><link rel="next" href="TheGameKit_Overview.html" title="The Game Kit" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BJoystick_Overview.html" title="BJoystick"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheDeviceKit_Overview.html" title="The Device Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="TheGameKit_Overview.html" title="The Game Kit"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Device Kit</div></div><div id="headerB">Prev: <a href="BJoystick_Overview.html">BJoystick</a> Up: <a href="TheDeviceKit_Overview.html">The Device Kit</a> Next: <a href="TheGameKit_Overview.html">The Game Kit</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BSerialPort_Overview"></a>BSerialPort</h2></div></div></div><a id="id482635" class="indexterm"></a><p>A <a class="link" href="BSerialPort.html" title="BSerialPort"><code class="classname">BSerialPort</code></a>
|
||
object represents an <acronym class="acronym">RS-232</acronym> serial connection to the
|
||
computer. Through <a class="link" href="BSerialPort.html" title="BSerialPort"><code class="classname">BSerialPort</code></a>
|
||
functions, you can read data received at a
|
||
serial ports and write data over the connection. You can also configure
|
||
the connection—for example, set the number of data and stop bits,
|
||
determine the rate at which data is sent and received, and select the
|
||
type of flow control (hardware or software) that should be used.</p><p>To read and write data, a
|
||
<a class="link" href="BSerialPort.html" title="BSerialPort"><code class="classname">BSerialPort</code></a>
|
||
object must first open one of the serial ports by name. To find the names of
|
||
all the serial ports on the computer, use the
|
||
<a class="link" href="BSerialPort.html#BSerialPort_CountDevices" title="CountDevices() , GetDeviceName()"><code class="methodname">CountDevices()</code></a>
|
||
and <a class="link" href="BSerialPort.html#BSerialPort_GetDeviceName"><code class="methodname">GetDeviceName()</code></a>
|
||
functions:</p><pre class="programlisting example cpp"><code class="classname">BSerialPort</code> <code class="varname">serial</code>;
|
||
<span class="type">char</span> <code class="varname">devName</code>[<code class="constant">B_OS_NAME_LENGTH</code>];
|
||
<span class="type">int32</span> <code class="varname">n</code> = 0;
|
||
|
||
for (<span class="type">int32</span> <code class="varname">n</code> = <code class="varname">serial</code>.<code class="methodname">CountDevices</code>() - 1; <code class="varname">n</code> >= 0; <code class="varname">n</code>--) {
|
||
<code class="varname">serial</code>.<code class="methodname">GetDeviceName</code>(<code class="varname">n</code>, <code class="varname">devName</code>);
|
||
|
||
if ( <code class="varname">serial</code>.<code class="methodname">Open</code>(<code class="varname">devName</code>) > 0 )
|
||
....
|
||
}</pre><p>The <a class="link" href="BSerialPort.html" title="BSerialPort"><code class="classname">BSerialPort</code></a> object communicates with the driver for the port it has
|
||
open. The driver maintains an input buffer to collect incoming data and a
|
||
smaller output buffer to hold outgoing data. When the object reads and
|
||
writes data, it reads from and writes to these buffers.</p><p>The serial port drivers, and therefore <a class="link" href="BSerialPort.html" title="BSerialPort"><code class="classname">BSerialPort</code></a> objects, send and
|
||
receive data asynchronously only.</p></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BJoystick_Overview.html">BJoystick</a> Up: <a href="TheDeviceKit_Overview.html">The Device Kit</a> Next: <a href="TheGameKit_Overview.html">The Game Kit</a> </div><div id="footerB"><div id="footerBL"><a href="BJoystick_Overview.html" title="BJoystick"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheDeviceKit_Overview.html" title="The Device Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="TheGameKit_Overview.html" title="The Game Kit"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|