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

📄 excep.htm

📁 串口调试工具 用于串口调 试的很方便
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title>CModbusException Class</title>
</head>

<body bgcolor="#FFFFFF">

<p><font size="5"><strong>CModbusException Class</strong></font></p>

<p><font size="3"><strong>class CModbusException : public </strong></font><a
href="mk:@ivt:vcmfc/D3/S455C.HTM"><strong>CException</strong></a></p>

<p>A CModbusException object represents an exception condition
related to a communication operation whith modbus slave device.
These exceptions include communications exceptions and modbus
functions exceptions, for instance , if you try to preset a
register and the address is invalid, the modbus slave return a
message indicating this invalid operation.</p>

<p>You do not need to create objects of this class, this creation
is intended to be made inside <a href="modbuimp.htm">CModbus
Class</a>.</p>

<p><strong>Constructor</strong> </p>

<p><strong>CModbusException(CString&amp; sMessage,int nError);</strong></p>

<p>parameters </p>

<p>sMessage - String with error Description.</p>

<p>nError - Error number.</p>

<p><strong>example</strong></p>

<p>&nbsp;</p>

<p><font size="2">extern CModbus* pModbus; // this pointer is
created by a derived class. </font></p>

<p><font size="2">pModbus-&gt;ThrowException(TRUE);</font></p>

<p><font size="2">try {</font></p>

<blockquote>
    <p><font size="2">//It's not needed to verify each call for
    errors</font></p>
    <p><font size="2">pModbus-&gt;ForceSingleCoil(17,172,TRUE) ;
    //force coil 173 ON in slave device 17<br>
    pModbus-&gt;PresetSingleRegister(17,1,3) ; //preset register
    40002 to 03 in slave device 17 </font></p>
</blockquote>

<p><font size="2">}</font></p>

<p><font size="2">catch(CModbusException* pException) {</font></p>

<blockquote>
    <p><font size="2">TCHAR szCause[255]; </font></p>
    <p><font size="2">CString strFormatted; </font></p>
    <p><font size="2">pException-&gt;GetErrorMessage(szCause,
    255); <br>
    strFormatted = _T(&quot;Modbus Function Error-&quot;);</font></p>
    <p><font size="2">strFormatted += szCause;
    AfxMessageBox(strFormatted);</font></p>
    <p><font size="2">AfxMessageBox(strFormatted);</font></p>
    <p><font size="2">pException-&gt;Delete();</font></p>
</blockquote>

<p><font size="2">}</font></p>

<p>&nbsp;</p>

<p><strong>See also:</strong> <a
href="mk:@ivt:vcmfc/D3/S455C.HTM">CException</a> in MCF library
help files.</p>

<p>&nbsp;</p>

<p>&nbsp;</p>
</body>
</html>

⌨️ 快捷键说明

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