function.dio-tcsetattr.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 132 行
HTML
132 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Sets terminal attributes and baud rate for a serial port</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.dio-stat.html">dio_stat</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.dio-truncate.html">dio_truncate</a></div> <div class="up"><a href="ref.dio.html">Direct IO Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.dio-tcsetattr" class="refentry"> <div class="refnamediv"> <h1 class="refname">dio_tcsetattr</h1> <p class="verinfo">(PHP 4 >= 4.3.0, PHP 5 <= 5.0.5)</p><p class="refpurpose"><span class="refname">dio_tcsetattr</span> — <span class="dc-title"> Sets terminal attributes and baud rate for a serial port </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>dio_tcsetattr</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$fd</tt></span> , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$options</tt></span> )</div> <p class="para rdfs-comment"> <b>dio_tcsetattr()</b> sets the terminal attributes and baud rate of the open <i><tt class="parameter">fd</tt></i>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">fd</tt></i></span> <dd> <p class="para"> The file descriptor returned by <a href="function.dio-open.html" class="function">dio_open()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">options</tt></i></span> <dd> <p class="para"> The currently available options are: <ul class="itemizedlist"> <li class="listitem"> <p class="para"> 'baud' - baud rate of the port - can be 38400,19200,9600,4800,2400,1800, 1200,600,300,200,150,134,110,75 or 50, default value is 9600. </p> </li> <li class="listitem"> <p class="para"> 'bits' - data bits - can be 8,7,6 or 5. Default value is 8. </p> </li> <li class="listitem"> <p class="para"> 'stop' - stop bits - can be 1 or 2. Default value is 1. </p> </li> <li class="listitem"> <p class="para"> 'parity' - can be 0,1 or 2. Default value is 0. </p> </li> </ul> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> No value is returned. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Setting the baud rate on a serial port</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br />$fd </span><span style="color: #007700">= </span><span style="color: #0000BB">dio_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/dev/ttyS0'</span><span style="color: #007700">, </span><span style="color: #0000BB">O_RDWR </span><span style="color: #007700">| </span><span style="color: #0000BB">O_NOCTTY </span><span style="color: #007700">| </span><span style="color: #0000BB">O_NONBLOCK</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">dio_fcntl</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">, </span><span style="color: #0000BB">F_SETFL</span><span style="color: #007700">, </span><span style="color: #0000BB">O_SYNC</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">dio_tcsetattr</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">, array(<br /> </span><span style="color: #DD0000">'baud' </span><span style="color: #007700">=> </span><span style="color: #0000BB">9600</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'bits' </span><span style="color: #007700">=> </span><span style="color: #0000BB">8</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'stop' </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'parity' </span><span style="color: #007700">=> </span><span style="color: #0000BB">0<br /></span><span style="color: #007700">)); <br /><br />while (</span><span style="color: #0000BB">1</span><span style="color: #007700">) {<br /><br /> </span><span style="color: #0000BB">$data </span><span style="color: #007700">= </span><span style="color: #0000BB">dio_read</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">, </span><span style="color: #0000BB">256</span><span style="color: #007700">);<br /><br /> if (</span><span style="color: #0000BB">$data</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">$data</span><span style="color: #007700">;<br /> }<br />} <br /><br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: <span class="simpara">This function is notimplemented on Windows platforms.</span></p></blockquote> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.dio-stat.html">dio_stat</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.dio-truncate.html">dio_truncate</a></div> <div class="up"><a href="ref.dio.html">Direct IO Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?