1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
<HTML>
<HEAD>
<TITLE>class Serial</TITLE>
<META NAME="Generator" CONTENT="KDOC ">
</HEAD>
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
<TABLE WIDTH="100%" BORDER="0">
<TR>
<TD>
<TABLE BORDER="0">
<TR><TD valign="top" align="left" cellspacing="10">
<h1>class Serial</h1>
</TD>
<TD valign="top" align="right" colspan="1">Generic serial device access.
<small><A HREF="#longdesc">More...</A></small></TD></TR>
</TABLE>
<HR>
<TABLE BORDER="0">
<TR><TH>Definition</TH><TD><code>#include <<A HREF="serial_h.html">serial.h</A>></code></TD></TR>
<TR><TH><A HREF="full-list-Serial.html">List of all Methods</A></TH></TR>
</TABLE>
</TD>
<TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</small></TD></TR>
<TR><TD><small><A HREF="header-list.html">Files</small></TD></TR>
<TR><TD><small><A HREF="all-globals.html">Globals</small></TD></TR>
<TR><TD><small><A HREF="hier.html">Hierarchy</small></TD></TR>
<TR><TD><small><A HREF="index.html">Index</small></TD></TR>
</TABLE></TD></TR></TABLE>
<H2>Public Members</H2>
<UL>
<LI> <b><A HREF="#ref5">Serial</A></b> (const char *fname, long speed, int format, int flow)
</LI>
<LI>virtual <b><A HREF="#ref6">~Serial</A></b> ()
</LI>
<LI>void <b><A HREF="#ref7">setFlowControl</A></b> (int flow)
</LI>
<LI>void <b><A HREF="#ref8">setSpeed</A></b> (long speed)
</LI>
<LI>void <b><A HREF="#ref9">setFormat</A></b> (int format)
</LI>
<LI>int <b><A HREF="#ref10">Inkey</A></b> (timeout_t timer = 0)
</LI>
<LI>int <b><A HREF="#ref11">Read</A></b> (void *buf, size_t len, timeout_t timer = 0)
</LI>
<LI>int <b><A HREF="#ref12">Readline</A></b> (char *buf, size_t max, timeout_t timer = 0)
</LI>
<LI>inline void <b><A HREF="#ref13">setNewline</A></b> (char nl)
</LI>
<LI>virtual inline int <b><A HREF="#ref14">Write</A></b> (void *buf, size_t len)
</LI>
<LI>friend inline int <b>write</b> (Serial &s, void *buf, size_t len)
</LI>
<LI>virtual inline int <b><A HREF="#ref16">Write</A></b> (char *buf)
</LI>
<LI>friend inline int <b>write</b> (Serial &s, char *buf)
</LI>
</UL>
<HR><A NAME="longdesc"><H2>Detailed Description</H2><p>
A portable APE class for access to generic serial devices. The win32
version has not yet been written, but the Posix version uses termios
services.
</p><p></p><A NAME=Serial></A><A NAME=ref5></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong> <b>Serial</b> (const char *fname, long speed, int format, int flow)
</strong></td></tr></table></p><p>
Open a named serial device under a specified set of attributes.
Attributes include the serial device speed (baud rate), the
data format (SERIAL_FORMAT_7E1, SERIAL_FORMAT_7O1, SERIAL_FORMAT_7N1,
SERIAL_FORMAT_7S2, SERIAL_FORMAT_8E1, SERIAL_FORMAT_8O1,
SERIAL_FORMAT_8N1, and SERIAL_FORMAT_8S2), as well as the kind of
flow control (SERIAL_FLOW_NONE, SERIAL_FLOW_HARD, SERIAL_FLOW_SOFT and
SERIAL_FLOW_BOTH) to use. Additional data formats would be easy
enough to add if so desired.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>fname</i></TD><TD align="left" valign="top">path name of logical serial device.
@speed absolute speed in bits per second.
@format serial data format to use.
@flow serial device flow control method to use.
</TD></TR>
</TABLE></P>
<A NAME=~Serial></A><A NAME=ref6></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong> <b>~Serial</b> ()
</strong></td></tr></table> <small>[virtual]</small></p><p>
Release the serial device and restore it to it's previous
attributes.
</p><A NAME=setFlowControl></A><A NAME=ref7></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>void <b>setFlowControl</b> (int flow)
</strong></td></tr></table></p><p>
Change the flow control mode in effect for the serial device.
This allows post constructor changes.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>flow</i></TD><TD align="left" valign="top">serial device flow control method to use.
</TD></TR>
</TABLE></P>
<A NAME=setSpeed></A><A NAME=ref8></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>void <b>setSpeed</b> (long speed)
</strong></td></tr></table></p><p>
Change the serial port baud rate (speed in bps) for the serial
device.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>speed</i></TD><TD align="left" valign="top">absolute speed in bits per second.
</TD></TR>
</TABLE></P>
<A NAME=setFormat></A><A NAME=ref9></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>void <b>setFormat</b> (int format)
</strong></td></tr></table></p><p>
Change the serial port data format in use for the serial device.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>format</i></TD><TD align="left" valign="top">serial data format to use.
</TD></TR>
</TABLE></P>
<A NAME=Inkey></A><A NAME=ref10></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>int <b>Inkey</b> (<A HREF="#timeout_t">timeout_t</A> timer = 0)
</strong></td></tr></table></p><p>
Wait up to a specified timeout for a single character to appear
at the serial device, and return that character.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>timer</i></TD><TD align="left" valign="top">timeout specified in milliseconds.
</TD></TR>
</TABLE></P>
<p><b>Returns</b>: character read or -1 if timed out.
</p>
<A NAME=Read></A><A NAME=ref11></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>int <b>Read</b> (void *buf, size_t len, <A HREF="#timeout_t">timeout_t</A> timer = 0)
</strong></td></tr></table></p><p>
Read a specified number of bytes from the serial device but
wait no longer than a specified timeout for data to become
available. The Posix termios only supports timeout resolution
within 1/10th of a second, hence, specifying a timeout with
an accuracy less than 100 milliseconds is useless.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>buf</i></TD><TD align="left" valign="top">pointer to store data from the device.
</TD></TR>
<TR><TD align="left" valign="top"><i>len</i></TD><TD align="left" valign="top">number of bytes to read.
</TD></TR>
<TR><TD align="left" valign="top"><i>timer</i></TD><TD align="left" valign="top">timeout specified in milliseconds.
</TD></TR>
</TABLE></P>
<p><b>Returns</b>: number of bytes actually read.
</p>
<A NAME=Readline></A><A NAME=ref12></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>int <b>Readline</b> (char *buf, size_t max, <A HREF="#timeout_t">timeout_t</A> timer = 0)
</strong></td></tr></table></p><p>
Read a specified number of bytes from the serial device
but wait no longer than a specified timeout, and also stop
if the newline character has been read.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>buf</i></TD><TD align="left" valign="top">pointer to store data from the device.
</TD></TR>
<TR><TD align="left" valign="top"><i>len</i></TD><TD align="left" valign="top">number of bytes to read.
</TD></TR>
<TR><TD align="left" valign="top"><i>timer</i></TD><TD align="left" valign="top">timeout specified in milliseconds.
</TD></TR>
</TABLE></P>
<p><b>Returns</b>: number of bytes actually read.
</p>
<A NAME=setNewline></A><A NAME=ref13></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>inline void <b>setNewline</b> (char nl)
</strong></td></tr></table></p><p>
Specify the newline character code to use with ReadLine.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>nl</i></TD><TD align="left" valign="top">newline character code (default 13).
</TD></TR>
</TABLE></P>
<A NAME=Write></A><A NAME=ref14></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>inline int <b>Write</b> (void *buf, size_t len)
</strong></td></tr></table> <small>[virtual]</small></p><p>
Write a block of data to the serial device.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>buf</i></TD><TD align="left" valign="top">pointer to data to write.
</TD></TR>
<TR><TD align="left" valign="top"><i>len</i></TD><TD align="left" valign="top">number of bytes to write.
</TD></TR>
</TABLE></P>
<p><b>Returns</b>: number of bytes written on success, -1 on error.
</p>
<A NAME=Write></A><A NAME=ref16></A><table width="100%"><tr bgcolor="#eeeeee"><td><strong>inline int <b>Write</b> (char *buf)
</strong></td></tr></table> <small>[virtual]</small></p><p>
Write a null terminated C string directly to the serial
device.
</p><p></p><p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5">
<TR><TD align="left" valign="top"><i>buf</i></TD><TD align="left" valign="top">pointer to null terminated string to write.
</TD></TR>
</TABLE></P>
<p><b>Returns</b>: number of bytes written on success, -1 on error.
</p>
<HR><UL><LI><i>Author</i>: David Sugar <dyfet@ostel.com>
</LI><LI><i>Generated</i>: dyfet@home.sys on Wed Dec 1 16:09:46 199.</LI></UL></BODY></HTML>
|