<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>注意事项 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Sun, 03 May 2020 13:26:53 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] something about Google Test(Google C++ Testing Framework)</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9bsomething-about-google-testgoogle-c-testing-framework/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9bsomething-about-google-testgoogle-c-testing-framework/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 14 Sep 2010 03:57:05 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[cxxtest]]></category>
		<category><![CDATA[Framework)]]></category>
		<category><![CDATA[Google Mock]]></category>
		<category><![CDATA[Google Test]]></category>
		<category><![CDATA[libgtest]]></category>
		<category><![CDATA[No such file or directory]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[介绍]]></category>
		<category><![CDATA[使用]]></category>
		<category><![CDATA[注意事项]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=239</guid>

					<description><![CDATA[<p>
	&#160;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">先说说cxxtest这个测试框架：用cxxtest来编写测试用例时，我们需要写的只是一个.h文件，在这个文件里include你要测试的类或函数所在的头文件，然后写各种测试函数。与该.h文件对应的.cpp文件是用cxxtest自带的一个脚本cxxtestgen.pl来生成的（脚本调用方法请看cxxtest手册），然后我们就得到了一个.h文件和一个.cpp文件，用gcc/g++编译，得到一个可执行文件，运行此文件，就执行了你所编写的测试用例。</span></span></span><br />
	<span id="more-239"></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">使用Google Test作为你的测试框架时，有点不一样：</span></span></span><br />
	<span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">你需要编写一个测试用例文件（例如，unittest.cpp），在这个文件里include你要测试的类或函数所在的头文件（当然也少不了 #include &#60;gtest/gtest.h&#62; ，这是Google Test必需的），然后在里面写各种测试，写完之后，你还再需要写一个含有main()函数的文件，例如main.cpp，内容简单，如下：</span></span></span></p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
#include &#60;gtest/gtest.h&#62;

int main(int argc, char** argv)
{
  testing::InitGoogleTest(&#38;argc, argv);
  return RUN_ALL_TESTS();
}
</pre>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">有点乱了，理一下：现在共有4个文件：main.cpp，unittest.cpp，以及你需要测试的类的.h文件及.cpp文件。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">然后，用gcc/g++编译链接这些文件，得到一个可执行文件，运行此文件，就执行了你所编写的测试用例。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">注意：</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">（1）安装好Google Test 之后，用它编写了测试用例，可能会发现运行不了测试用例，提示&#8220;error while loading shared libraries: libgtest.so.0: cannot open shared object file: No such file or directory&#8221;，那么你就要检查一下Google Test动态库的安装路径了，例如我的RHEL5默认就是安装在 /usr/local/lib/ 下的，这个时候，你需要copy一份同样的文件在 /usr/lib/ 下，当然更简单的方法是做一个符号链接（即&#8220;快捷方式&#8221;）：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
cd /usr/lib/
ln -s /usr/local/lib/libgtest.so.0.0.0</pre>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9bsomething-about-google-testgoogle-c-testing-framework/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
	&nbsp;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">先说说cxxtest这个测试框架：用cxxtest来编写测试用例时，我们需要写的只是一个.h文件，在这个文件里include你要测试的类或函数所在的头文件，然后写各种测试函数。与该.h文件对应的.cpp文件是用cxxtest自带的一个脚本cxxtestgen.pl来生成的（脚本调用方法请看cxxtest手册），然后我们就得到了一个.h文件和一个.cpp文件，用gcc/g++编译，得到一个可执行文件，运行此文件，就执行了你所编写的测试用例。</span></span></span><br />
	<span id="more-239"></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">使用Google Test作为你的测试框架时，有点不一样：</span></span></span><br />
	<span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">你需要编写一个测试用例文件（例如，unittest.cpp），在这个文件里include你要测试的类或函数所在的头文件（当然也少不了 #include &lt;gtest/gtest.h&gt; ，这是Google Test必需的），然后在里面写各种测试，写完之后，你还再需要写一个含有main()函数的文件，例如main.cpp，内容简单，如下：</span></span></span></p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
#include &lt;gtest/gtest.h&gt;

int main(int argc, char** argv)
{
  testing::InitGoogleTest(&amp;argc, argv);
  return RUN_ALL_TESTS();
}
</pre>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">有点乱了，理一下：现在共有4个文件：main.cpp，unittest.cpp，以及你需要测试的类的.h文件及.cpp文件。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">然后，用gcc/g++编译链接这些文件，得到一个可执行文件，运行此文件，就执行了你所编写的测试用例。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">注意：</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">（1）安装好Google Test 之后，用它编写了测试用例，可能会发现运行不了测试用例，提示&ldquo;error while loading shared libraries: libgtest.so.0: cannot open shared object file: No such file or directory&rdquo;，那么你就要检查一下Google Test动态库的安装路径了，例如我的RHEL5默认就是安装在 /usr/local/lib/ 下的，这个时候，你需要copy一份同样的文件在 /usr/lib/ 下，当然更简单的方法是做一个符号链接（即&ldquo;快捷方式&rdquo;）：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
cd /usr/lib/
ln -s /usr/local/lib/libgtest.so.0.0.0 libgtest.so.0
</pre>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">（2）编译Google Test 自带的sample的时候，有几个注意事项：你除了要带上 -lgtest 选项，还要带上 -lpthread 选项（似乎不搭边的，不过如果不带的话，会提示几个错误），例如，我编译sample1的命令为：</span></span></span><br />
	<span style="color:#0000ff;">gcc -o sample1_exec sample1.cc sample1_unittest.cc main.cpp -lgtest -lpthread</span></p>
<p>	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">其中，sample1_exec 是生成的可执行文件名，sample1.cc 相当于我上面所说的你需要测试的类的.cpp文件，sample1_unittest.cc 相当于我上面所说的&nbsp;unittest.cpp 文件，main.cpp 就是上面所说的 main.cpp 文件。</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">编译完成后，执行 sample1_exec，输出如下结果，测试通过：</span></span></span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
[==========] Running 6 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN      ] FactorialTest.Negative
[       OK ] FactorialTest.Negative (0 ms)
[ RUN      ] FactorialTest.Zero
[       OK ] FactorialTest.Zero (0 ms)
[ RUN      ] FactorialTest.Positive
[       OK ] FactorialTest.Positive (0 ms)
[----------] 3 tests from FactorialTest (1 ms total)
[----------] 3 tests from IsPrimeTest
[ RUN      ] IsPrimeTest.Negative
[       OK ] IsPrimeTest.Negative (0 ms)
[ RUN      ] IsPrimeTest.Trivial
[       OK ] IsPrimeTest.Trivial (0 ms)
[ RUN      ] IsPrimeTest.Positive
[       OK ] IsPrimeTest.Positive (0 ms)
[----------] 3 tests from IsPrimeTest (0 ms total)
[----------] Global test environment tear-down
[==========] 6 tests from 2 test cases ran. (3 ms total)
[  PASSED  ] 6 tests.
</pre>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
	<span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
	<span style="color: rgb(0, 0, 0); "><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">总结：</span></span></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">cxxtest是用脚本帮你生成测试含main()的.cpp文件，Google Test是你自己写含main()的.cpp文件（其实也是固定的内容），相比之下，哪个都不算麻烦。关键是，Google Test是与</span></span></span><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;"><a href="http://code.google.com/p/googlemock/" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-decoration: none; color: rgb(0, 77, 153); "><span style="color:#000000;">Google Mock</span></a><span style="color:#000000;">&ldquo;无缝结合&rdquo;的，如果你要用</span><a href="http://code.google.com/p/googlemock/" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-decoration: none; color: rgb(0, 77, 153); "><span style="color:#000000;">Google Mock</span></a></span></span><span style="color:#000000;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">，那么就最好选择Google Test了（Google Mock也可以与cxxtest联合使用，请看Google Mock的文档）。</span></span></span></p>
<p>	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	<span style="color:#ffffff;"><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:14px;">文章来源：http://www.codelast.com/</span></span></span></p>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushShell.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']	= true;
			SyntaxHighlighter.defaults['tab-size']		= 2;
			SyntaxHighlighter.defaults['gutter']		= true;
			SyntaxHighlighter.defaults['quick-code']	= true;
			SyntaxHighlighter.defaults['collapse'] 		= false;
			SyntaxHighlighter.defaults['auto-links']	= true;
			SyntaxHighlighter.defaults['toolbar']		= true;
			SyntaxHighlighter.all();
			</script>
			<!--[/syntaxhighlighter]-->]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9bsomething-about-google-testgoogle-c-testing-framework/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>利用串口调试工具来调试GSM/GPRS模块时，几个注意事项</title>
		<link>https://www.codelast.com/%e5%88%a9%e7%94%a8%e4%b8%b2%e5%8f%a3%e8%b0%83%e8%af%95%e5%b7%a5%e5%85%b7%e6%9d%a5%e8%b0%83%e8%af%95gsmgprs%e6%a8%a1%e5%9d%97%e6%97%b6%ef%bc%8c%e5%87%a0%e4%b8%aa%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9/</link>
					<comments>https://www.codelast.com/%e5%88%a9%e7%94%a8%e4%b8%b2%e5%8f%a3%e8%b0%83%e8%af%95%e5%b7%a5%e5%85%b7%e6%9d%a5%e8%b0%83%e8%af%95gsmgprs%e6%a8%a1%e5%9d%97%e6%97%b6%ef%bc%8c%e5%87%a0%e4%b8%aa%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 14 Sep 2010 02:36:42 +0000</pubDate>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[GPRS]]></category>
		<category><![CDATA[GSM]]></category>
		<category><![CDATA[串口]]></category>
		<category><![CDATA[模块]]></category>
		<category><![CDATA[注意事项]]></category>
		<category><![CDATA[调试]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=65</guid>

					<description><![CDATA[<p>
	&#160;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	推荐&#8220;串口调试助手&#8221;&#160;，调试起来非常方便。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（1）关于波特率：对有些模块，用超级终端进行配置的时候，波特率是要设置为57600的，而用串口调试工具进行调试的时候，波特率应设置为你的系统中用到的实际通信速率（例如我用的是9600），这两个波特率的概念是不一样的，前者只是用超级终端配置时的波特率。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
<span id="more-65"></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（2）关于回显：对GSM模块发&#160;ATE1&#60;回车&#62;&#160;命令可以打开回显功能，如果在超级终端中进行AT指令交互，则不会有这个麻烦，因为你所输入的全都会打在屏幕上，但是如果在串口调试工具中，你输完一个命令，它并不会显示在数据接收区中。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（3）关于重复显示：有些模块，你一开始输入AT命令，输入一个字符出来两个，例如你想输入AT，但是实际上它出来AATT，此时用ATE0&#60;回车&#62;命令可以解决这个问题，变为正常显示。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（4）在串口调试工具中输入发送短信的结尾符&#160;Ctrl+Z&#160;时，需要选上&#8220;以16进制发送&#8221;，并且在发送框中填上1A&#160;（Ctrl+Z&#160;的ASCII码的16进制就是 0x1A），这样之后再点&#8220;发送&#8221;，就OK了。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&#160;</p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;版权声明&#160;<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&#160;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" />&#8230; <a href="https://www.codelast.com/%e5%88%a9%e7%94%a8%e4%b8%b2%e5%8f%a3%e8%b0%83%e8%af%95%e5%b7%a5%e5%85%b7%e6%9d%a5%e8%b0%83%e8%af%95gsmgprs%e6%a8%a1%e5%9d%97%e6%97%b6%ef%bc%8c%e5%87%a0%e4%b8%aa%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
	&nbsp;</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	推荐&ldquo;串口调试助手&rdquo;&nbsp;，调试起来非常方便。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（1）关于波特率：对有些模块，用超级终端进行配置的时候，波特率是要设置为57600的，而用串口调试工具进行调试的时候，波特率应设置为你的系统中用到的实际通信速率（例如我用的是9600），这两个波特率的概念是不一样的，前者只是用超级终端配置时的波特率。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
<span id="more-65"></span></p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（2）关于回显：对GSM模块发&nbsp;ATE1&lt;回车&gt;&nbsp;命令可以打开回显功能，如果在超级终端中进行AT指令交互，则不会有这个麻烦，因为你所输入的全都会打在屏幕上，但是如果在串口调试工具中，你输完一个命令，它并不会显示在数据接收区中。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（3）关于重复显示：有些模块，你一开始输入AT命令，输入一个字符出来两个，例如你想输入AT，但是实际上它出来AATT，此时用ATE0&lt;回车&gt;命令可以解决这个问题，变为正常显示。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	（4）在串口调试工具中输入发送短信的结尾符&nbsp;Ctrl+Z&nbsp;时，需要选上&ldquo;以16进制发送&rdquo;，并且在发送框中填上1A&nbsp;（Ctrl+Z&nbsp;的ASCII码的16进制就是 0x1A），这样之后再点&ldquo;发送&rdquo;，就OK了。</p>
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; margin-top: 0px; margin-right: 0px; margin-bottom: 9px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(77, 77, 77); ">
	&nbsp;</p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%88%a9%e7%94%a8%e4%b8%b2%e5%8f%a3%e8%b0%83%e8%af%95%e5%b7%a5%e5%85%b7%e6%9d%a5%e8%b0%83%e8%af%95gsmgprs%e6%a8%a1%e5%9d%97%e6%97%b6%ef%bc%8c%e5%87%a0%e4%b8%aa%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
