平头哥RVB2601测评:控制台与关于CDK
本帖最后由 xiyue521 于 2021-7-19 01:36 编辑<h5 style="margin-top:18px; margin-bottom:19px; text-align:justify"> </h5>
<p><span style="font-size:26px;"><strong>一、控制台与自定义命令:</strong></span></p>
<p> </p>
<h5 style="margin-top:18px; margin-bottom:19px; text-align:justify"><strong><span style="font-size:24px;"><span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体"> 在</font>HelloWorld历程<font face="黑体">中我发现可以通过在串口助手输入</font><font face="Times New Roman">help</font><font face="黑体">可以获取可以键入的命令:</font></span></span></span></span></span></strong></h5>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p class="imagemiddle" style="text-align: center;"><strong><span style="font-size:24px;"></span></strong></p>
<p style="text-align:justify"><strong><span style="font-size:24px;"> </span></strong></p>
<p> </p>
<p> </p>
<p style="text-align: center;"><strong><span style="font-size:24px;"><span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体">包括了系统命令和用户命令</font></span></span></span></span></span></strong></p>
<p style="text-align: center;"> </p>
<p><strong><span style="font-size:24px;"><span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体"> 但是在做</font>LED<font face="黑体">实验时输入</font><font face="Times New Roman">help</font><font face="黑体">却没有反应,但是这个控制台确实是比较方便调试,还有系统的状态查看,所以我对比了两个工程的异同。</font></span></span></span></span></span></strong></p>
<p><strong><span style="font-size:24px;"><span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体"> 在进入</font>main<font face="黑体">函数后先进行</font><font face="Times New Roman">yoc</font><font face="黑体">初始化,这里面初始化了</font><font face="Times New Roman">RX,TX</font><font face="黑体">引脚和功能,然后进行波特率的设置,设置</font><font face="Times New Roman">LOG</font><font face="黑体">打印等级,最后就是关键的</font><font face="Times New Roman">cli</font><font face="黑体">初始化,这个就是控制台的初始化,在</font><font face="Times New Roman">cli</font><font face="黑体">初始化里面,</font><font face="Times New Roman">aos_cli_init</font><font face="黑体">就是前面看到的系统</font><font face="Times New Roman">Commands</font><font face="黑体">,</font><font face="Times New Roman">cli_reg_cmd_ps</font><font face="黑体">、</font><font face="Times New Roman">cli_reg_cmd_free()</font><font face="黑体">就是</font><font face="Times New Roman">User Commands</font><font face="黑体">。</font></span></span></span></span></span></strong></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p class="imagemiddle" style="text-align: center;"><br />
<strong><span style="font-size:24px;"></span></strong><br />
<strong><span style="font-size:24px;"></span></strong></p>
<p style="text-align:justify"><strong><span style="font-size:24px;"> </span></strong></p>
<p> </p>
<p> </p>
<p> </p>
<p><strong><span style="font-size:24px;"><span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体">添加完这些代码之后再编译烧录就可以使用控制台命令了!!</font></span></span></span></span></span></strong></p>
<p><strong><span style="font-size:24px;"><span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体">那我们可不可以自己定义自己的命令呢?</font></span></span></span></span></span></strong></p>
<p><strong><span style="font-size:24px;"><span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体">照着</font>ps<font face="黑体">和</font><font face="Times New Roman">free</font><font face="黑体">的命令,</font><font face="Times New Roman">ps</font><font face="黑体">命令初始化函数如下:</font></span></span></span></span></span></strong></p>
<p class="imagemiddle" style="text-align: center;"><strong><span style="font-size:24px;"></span></strong></p>
<h5 style="text-align:left; margin-top:18px; margin-bottom:19px"><strong><span style="font-size:24px;"> <span style="font-family:Arial"><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"> cli_command<font face="黑体">是命令的结构体,有三个成员变量,分别为名字还有命令的具体描述信息还有回调函数。</font></span></span></span></span></span></strong></h5>
<p class="imagemiddle" style="text-align: center;"></p>
<p style="text-align:justify"><strong><span style="font-size:24px;"> </span></strong></p>
<p> </p>
<p><strong><span style="font-size:24px;"><span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体"> 我们可以自定义一个命令,取名</font>test<font face="黑体">:然后编写回调函数:(这里</font><font face="Times New Roman">argc</font><font face="黑体">是输入参数的个数,我们将输入的参数全部打印出来作为测试用),最后调用注册命令函数传入自定义命令结构体:</font></span></span></span></span></span></strong></p>
<p class="imagemiddle" style="text-align: center;"><strong><span style="font-size:24px;"></span></strong></p>
<p><strong><span style="font-size:24px;"> <span style="font-family:"Times New Roman""><span style="font-weight:bold"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体"> 编译烧录控制台键入</font>help<font face="黑体">可以看到</font><font face="Times New Roman">test</font><font face="黑体">出现在了用户命令中了:</font></span></span></span></span></span></strong></p>
<p class="imagemiddle" style="text-align: center;"><strong><span style="font-size:24px;"></span></strong></p>
<h5 style="margin-top:18px; margin-bottom:19px; text-align:justify"><strong><span style="font-size:24px;"> <span style="font-weight: bold;"><span style="font-weight: bold;"><font face="黑体" style="font-family: 黑体;"> 然后输入带参数的</font><font face="黑体" style="font-family: 黑体;">test命令,可以看到与预期的结果一致(注意这里是得到字符串,我们可以用</font><font face="Times New Roman" style="font-family: 黑体;">strcmp或</font><font face="黑体" style="">用</font><font face="Times New Roman" style="font-family: 黑体;">atoi</font><font face="黑体" style="font-family: 黑体;">将数字字符串转为</font><font face="Times New Roman" style="font-family: 黑体;">int</font><font face="黑体" style="font-family: 黑体;">形进一步去判断然后实现自己想要的业务逻辑功能):</font></span></span></span></strong></h5>
<p class="imagemiddle" style="text-align: center;"></p>
<h5 style="text-align:left; margin-top:18px; margin-bottom:19px"><span style="font-size:26px;"><strong>二、关于CDK:</strong></span></h5>
<p><strong><span style="font-size:24px;">CDK的主题支持4种,还可以格式化代码:</span></strong></p>
<p style="margin-left: 40px;"> </p>
<p class="imagemiddle" style="text-align: center;"><strong><span style="font-size:24px;"></span></strong></p>
<p class="imagemiddle" style="text-align: center;"><strong><span style="font-size:24px;"> </span></strong></p>
<p class="imagemiddle" style="text-align: center;"><strong><span style="font-size:24px;"> </span></strong></p>
<p class="imagemiddle"><strong><span style="font-size:24px;">我们可以右键工程来配置一些参数 :包括一些输出的文件,还有优化等级,flash下载设置和KEIL的设置很相似:</span></strong></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p class="imagemiddle"><strong><span style="font-size:24px;"> </span></strong></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p class="imagemiddle"><strong><span style="font-size:24px;">我们还可以用CDK自带的串口助手:就是交互的时候不是很方便。</span></strong></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p class="imagemiddle"><strong><span style="font-size:24px;">还可以点击ctrl然后鼠标点击想要查看的函数跳转过去,滚轮缩放等等很方便。</span></strong></p>
<p> </p>
<p style="margin-left: 40px;"><strong><span style="font-size:24px;"> </span></strong> </p>
<p style="margin-left: 40px;"> </p>
<h5 style="text-align:left; margin-top:18px; margin-bottom:19px"><strong><span style="font-size:24px;"> </span></strong></h5>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>开发工具看起来还挺方便的</p> 本帖最后由 xiyue521 于 2021-7-21 01:35 编辑
<p>.</p>
本帖最后由 xiyue521 于 2021-7-21 01:36 编辑
<p>.</p>
本帖最后由 xiyue521 于 2021-7-21 01:35 编辑
<p>.</p>
littleshrimp 发表于 2021-7-20 08:14
开发工具看起来还挺方便的
<table cellpadding="0" cellspacing="0" id="pid3079143" summary="pid3079143">
<tbody>
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<p>平头哥CDK还是可以的,就是主题换了黑色系有些字体图标看不清,还不能自己定义颜色,所以又换回来了</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</tbody>
</table>
<p>2-5楼的点是怎么回事儿?</p>
nmg 发表于 2021-7-26 17:44
2-5楼的点是怎么回事儿?
<p>那时候点了好几下好像没发出</p>
页:
[1]