⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indexv2.html

📁 串口通讯驱动
💻 HTML
📖 第 1 页 / 共 2 页
字号:

<tr VALIGN=TOP>
<td>SERIAL_CD_OFF</td>

<td>This event is the opposite of CD_ON, it indicates when the communication
with the other modem dropped.</td>
</tr>
</table>
</ol>

<h3>

<hr ALIGN=LEFT SIZE=3 WIDTH="100%"></h3>

<h3>
Software API</h3>

<p><br>You may download the following files:
<table>
<tr VALIGN=TOP>
<td>
<ul>
<li>
<a href="tserial_event.h">tserial_event.h</a></li>
</ul>
</td>

<td>Header file for the serial_event communication object&nbsp;</td>
</tr>

<tr VALIGN=TOP>
<td>
<ul>
<li>
<a href="tserial_event.cpp">tserial_event.cpp</a></li>
</ul>
</td>

<td>C++ source file for the serial_event communication object</td>
</tr>

<tr VALIGN=TOP>
<td>
<ul>
<li>
<a href="serialtest.cpp">serialtest.cpp</a></li>
</ul>
</td>

<td>Simple application using the serial_event communication object</td>
</tr>
</table>

<br>&nbsp;
<br>&nbsp;
<h4>
Methods</h4>

<table BORDER >
<tr BGCOLOR="#000000">
<td><b><font color="#FFFFFF">Function</font></b></td>

<td><b><font color="#FFFFFF">Description</font></b></td>
</tr>

<tr VALIGN=TOP>
<td>Tserial_event()</td>

<td>Object creation</td>
</tr>

<tr VALIGN=TOP>
<td>~Tserial_event()</td>

<td>Object destruction</td>
</tr>

<tr VALIGN=TOP>
<td>int connect (char *port_arg, int rate_arg, serial_parity parity_arg,
int ByteSize, bool modem_events)</td>

<td>Serial port setup and start of connection&nbsp;
<ul>
<li>
port_arg : "COM1", "COM2", ...</li>

<li>
rate_arg : 19200, 9600, ...</li>

<li>
parity_arg : spNONE, spODD, spEVEN</li>

<li>
ByteSize : size of data transmitted (7 or 8 bits)</li>

<li>
modem_event : indicates if you want to receive CD and RING events</li>
</ul>
Returns 0 if no error occured</td>
</tr>

<tr>
<td>void setManager(type_myCallBack manager)</td>

<td>Specify the event manager of this communication object. This is the
address of the callback function.</td>
</tr>

<tr>
<td>void setRxSize(int size)</td>

<td>Specifiy the size of the data to read from the port. Note that this
might not always be the size of the data actually read. To know this value,
use the getDataInSize().</td>
</tr>

<tr>
<td>void sendData(char *buffer, int size)</td>

<td>Transmit the message array to the output driver. This buffer is copied
internally and should not be longer than SERIAL_MAX_TX, so the buffer may
be freed directly after the call. You should never call this function is
you have not received a SERIAL_DATA_SENT event (or if it's the first write).</td>
</tr>

<tr VALIGN=TOP>
<td>int getNbrOfBytes (void)</td>

<td>Returns the number of bytes waiting in the input buffer. Not very usefull.</td>
</tr>

<tr>
<td>int getDataInSize (void)</td>

<td>Returns the number of data that have been read.</td>
</tr>

<tr>
<td>char *getDataInBuffer (void)</td>

<td>Returns a pointer to the buffer where the data read are stored. Since
this memory location is used by the serial object, you MUST call dataHasBeenRead()
once you finished reading the data, and you should not access the buffer
after that.&nbsp;</td>
</tr>

<tr>
<td>void dataHasBeenRead (void)</td>

<td>Calling this function will tell the serial object that you have read
the incoming data and that it can continue to read further incoming data.
If you do not call this function, the port is not read anymore.</td>
</tr>

<tr VALIGN=TOP>
<td>void disconnect (void)</td>

<td>Disconnect the serial port.</td>
</tr>
</table>

<br>&nbsp;
<br>&nbsp;
<h4>
Events</h4>
When an event occurs, the serial object call the callback function (if
not null). This function must have the following prototype:
<blockquote><i>void SerialEventManager(uint32 object, uint32 event)</i></blockquote>
where <i>uint32&nbsp;</i> is an unsigned long.
<p>The <b>object</b> field is the address of the serial communication object
that has called the callback function.
<br><b>event</b> is the event kind that occured. It can be any of the seven
values described above. For six of them, the event is notified with no
additionnal data. The SERIAL_DATA_ARRIVAL is associated with data. These
one can be retrieved by calling <b>getDataInSize</b> and <b>getDataInBuffer</b>,
like described hereafter.
<br>&nbsp;

<pre>
void SerialEventManager(uint32 object, uint32 event)
{
    char *buffer;
    int   size;
    Tserial_event *com;

    com = (Tserial_event *) object;
    if (com!=0)
    {
        switch(event)
        {
            case  SERIAL_CONNECTED  :
                                        printf("Connected ! \n");
                                        break;
            case  SERIAL_DISCONNECTED  :
                                        printf("Disonnected ! \n");
                                        break;
            case  SERIAL_DATA_SENT  :
                                        printf("Data sent ! \n");
                                        break;
            case  SERIAL_RING       :
                                        printf("DRING ! \n");
                                        break;
            case  SERIAL_CD_ON      :
                                        printf("Carrier Detected ! \n");
                                        break;
            case  SERIAL_CD_OFF     :
                                        printf("No more carrier ! \n");
                                        break;
            case  SERIAL_DATA_ARRIVAL  :
                                        size   = com->getDataInSize();
                                        buffer = com->getDataInBuffer();
                                        OnDataArrival(size, buffer);
                                        com->dataHasBeenRead();
                                        break;
        }
    }
}

</pre>

</blockquote>

<br>&nbsp;
<br>&nbsp;
<p>
<hr>Copyright &copy; 2001-2002 - Tetraedre SARL, Thierry Schneider
<br>&nbsp;
<br>&nbsp;
<p>
<hr WIDTH="75%">
<center><a href="http://www.digits.com/">Mr. Web Counter</a> says you're
only visitor since April 11th 2001<img SRC="thierrydollar" HSPACE=4 VSPACE=2 BORDER=0 height=20 width=60 align=CENTER>...
Keep trying!</center>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -