1.串口、Telnet、SSH登录工具
1.1 MobaXterm
1.2 SecureCrt
记录打印日志
日志文件名:
D:\log%H-%Y-%M-%D_%h_%m_%s.log
在每一行
[%Y-%M-%D %h:%m:%s]
测试脚本
#$language = "VBScript"
#$interface = "1.0"
crt.Screen.Synchronous = True
Sub Main
do
crt.Sleep(1000)
crt.Screen.Send "ls"
crt.Screen.Send chr(13)
crt.Sleep(1000)
crt.Screen.Send "ls"
crt.Screen.Send chr(13)
crt.Screen.WaitForString "#"
loop
End Sub
2.代码编辑工具
2.1 VSCode
settings.json
settings.json汇总如下
包含这些功能配置:编码、astyle、Doxygen
{
//"files.encoding": "gb2312",
"files.encoding": "utf8",
"astyle.executable": "D:/software/astyle/astyle.exe",
"editor.mouseWheelZoom": true,
"astyle.additional_languages": [
"h",
"hpp",
"c",
"cpp",
],
"astyle.cmd_options": [
"--style=allman",
"--indent=spaces=4",
"--convert-tabs",
"--align-pointer=name",
"--align-reference=name",
"--keep-one-line-statements",
"--pad-header",
"--pad-oper",
"--break-closing-braces",
],
"[h]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"[hpp]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"[c]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"[cpp]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"editor.detectIndentation": false,
"doxdocgen.file.fileTemplate": "@file {name}",
"doxdocgen.file.versionTag": "@version 1.0",
"doxdocgen.generic.linesToGet": 3,
"doxdocgen.generic.authorName": "XXXX",
"doxdocgen.generic.authorEmail": "XXXX@XXXX.com",
"doxdocgen.generic.authorTag": "@author {author} ({email})",
"doxdocgen.file.copyrightTag": ["@copyright{indent:12} Copyright (c) XXXX"],
"doxdocgen.file.customTag": ["*****************************************************************************"],
"doxdocgen.generic.briefTemplate": "@brief{indent:12} {text}",
"doxdocgen.generic.dateTemplate": "@date{indent:12} {date}",
"doxdocgen.c.firstLine": "/*",
"doxdocgen.c.commentPrefix": "*",
"doxdocgen.c.lastLine": "*/",
"doxdocgen.file.fileOrder":
[
"custom",
"file",
"brief",
"author",
"date",
"copyright",
"custom"
],
"[c]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"doxdocgen.generic.paramTemplate": "@param [in/out] {indent:12} {param} ",
"doxdocgen.generic.returnTemplate": "@return{indent:12} {type} ",
"doxdocgen.generic.order":
[
"brief",
"param",
"return"
]
}
快捷键
快捷添加文件头和函数注释
可通过koroFileheader插件或Doxygen插件实现
koroFileheader使用时发现不稳定,推荐Doxygen
通过Doxygen插件实现
安装 Doxygen Documentation Generator
安装这是好了后在文件头和函数头输入/**即可自动填写
settings.json设置
{
//"files.encoding": "gb2312",
"files.encoding": "utf8",
"doxdocgen.file.fileTemplate": "@file {name}",
"doxdocgen.file.versionTag": "@version 1.0",
"doxdocgen.generic.linesToGet": 2,
"doxdocgen.generic.authorName": "myname",
"doxdocgen.generic.authorEmail": "myname@xxx.com",
"doxdocgen.generic.authorTag": "@author {author} ({email})",
"doxdocgen.file.copyrightTag": ["@copyright{indent:12} Copyright (c) XXX公司"],
"doxdocgen.file.customTag": ["*****************************************************************************"],
"doxdocgen.generic.briefTemplate": "@brief{indent:12} {text}",
"doxdocgen.generic.dateTemplate": "@date{indent:12} {date}",
"doxdocgen.c.firstLine": "/*",
"doxdocgen.c.commentPrefix": "*",
"doxdocgen.c.lastLine": "*/",
"doxdocgen.file.fileOrder":
[
"custom",
"file",
"brief",
"author",
"date",
"copyright",
"custom"
],
"doxdocgen.generic.paramTemplate": "@param{indent:12} {param} ",
"doxdocgen.generic.returnTemplate": "@return{indent:12} {type} ",
"doxdocgen.generic.order":
[
"brief",
"param",
"return"
]
}
通过koroFileheader插件
安装
这是默认配置
{
"window.commandCenter": true,
"fileheader.configObj": {
"createFileTime": true,
"language": {
"c/cpp/h/hpp/java": {
"head": "/$$",
"middle": " $ @",
"end": " $/",
"functionSymbol": {
"head": "/** ",
"middle": " * @",
"end": " */"
},
"functionParams": "js"
}
},
"autoAdd": true,
"autoAddLine": 100,
"autoAlready": true,
"annotationStr": {
"head": "/*",
"middle": " * @",
"end": " */",
"use": false
},
"headInsertLine": {
"php": 2,
"sh": 2
},
"beforeAnnotation": {
"文件后缀": "该文件后缀的头部注释之前添加某些内容"
},
"afterAnnotation": {
"文件后缀": "该文件后缀的头部注释之后添加某些内容"
},
"specialOptions": {
"特殊字段": "自定义比如LastEditTime/LastEditors"
},
"switch": {
"newlineAddAnnotation": true
},
"supportAutoLanguage": [],
"prohibitAutoAdd": [
"json"
],
"folderBlacklist": [
"node_modules",
"文件夹禁止自动添加头部注释"
],
"prohibitItemAutoAdd": [
"项目的全称, 整个项目禁止自动添加头部注释, 可以使用快捷键添加"
],
"moveCursor": true,
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"atSymbol": [
"@",
"@"
],
"atSymbolObj": {
"文件后缀": [
"头部注释@符号",
"函数注释@符号"
]
},
"colon": [
": ",
": "
],
"colonObj": {
"文件后缀": [
"头部注释冒号",
"函数注释冒号"
]
},
"filePathColon": "路径分隔符替换",
"showErrorMessage": false,
"writeLog": false,
"wideSame": false,
"wideNum": 13,
"functionWideNum": 0,
"CheckFileChange": false,
"createHeader": false,
"useWorker": false,
"designAddHead": false,
"headDesignName": "random",
"headDesign": false,
"cursorModeInternalAll": {},
"openFunctionParamsCheck": true,
"functionParamsShape": [
"{",
"}"
],
"functionBlankSpaceAll": {},
"functionTypeSymbol": "*",
"typeParamOrder": "type param",
"customHasHeadEnd": {},
"throttleTime": 60000,
"functionParamAddStr": "",
"NoMatchParams": "no show param"
}
}
改成
{
"window.commandCenter": true,
"fileheader.configObj": {
"createFileTime": true,
"language": {
"c/cpp/h/hpp/java": {
"head": "/**\r\n****************************************************************************************",
"middle": " * @",
"end": "****************************************************************************************\r\n*/"
"functionSymbol": {
"head": "/********************************** ",
"middle": " * @",
"end": " *********************************/"
},
"functionParams": "js"
},
},
"autoAdd": true,
"autoAddLine": 100,
"autoAlready": true,
"annotationStr": {
"head": "/*",
"middle": " * @",
"end": " */",
"use": false
},
"headInsertLine": {
"php": 2,
"sh": 2
},
"beforeAnnotation": {
"文件后缀": "该文件后缀的头部注释之前添加某些内容"
},
"afterAnnotation": {
"文件后缀": "该文件后缀的头部注释之后添加某些内容"
},
"specialOptions": {
"param":"param[in]"
},
"switch": {
"newlineAddAnnotation": true
},
"supportAutoLanguage": [],
"prohibitAutoAdd": [
"json"
],
"folderBlacklist": [
"node_modules",
"文件夹禁止自动添加头部注释"
],
"prohibitItemAutoAdd": [
"项目的全称, 整个项目禁止自动添加头部注释, 可以使用快捷键添加"
],
"moveCursor": true,
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"atSymbol": [
"@",
"@"
],
"atSymbolObj": {
"文件后缀": [
"头部注释@符号",
"函数注释@符号"
]
},
"colon": [
": ",
": "
],
"colonObj": {
"文件后缀": [
"头部注释冒号",
"函数注释冒号"
]
},
"filePathColon": "路径分隔符替换",
"showErrorMessage": false,
"writeLog": false,
"wideSame": false,
"wideNum": 13,
"functionWideNum": 0,
"CheckFileChange": false,
"createHeader": true,
"useWorker": false,
"designAddHead": false,
"headDesignName": "random",
"headDesign": false,
"cursorModeInternalAll": {},
"openFunctionParamsCheck": true,
"functionParamsShape": "no type",
"typeParamOrder": "param",
"customHasHeadEnd": {},
"throttleTime": 60000
},
"fileheader.customMade": {
"FilePath":"only file name",
"Author":"xxx",
"Date":"Do not edit",
//"LastEditors":"",
//"LastEditTime":"Do not Edit",
// "custom_string_obkoro1~custom_string_obkoro100都可以输出自定义信息"
"custom_string_obkoro1_copyright":"Copyright: ${now_year} xxx CO.,LTD. All Rights Reserved.", // 版权声明 保留所有权利 自动替换年份
"Descripttion":"",
},
"fileheader.cursorMode": {
"brief":"",
"param" : " ",
"return":""
}
}
ctrl+win+i添加文件头
ctrl+win+t添加函数头
添加TODO
安装Todo Tree
输入//TODO,TODO会高亮显示
2.2 SourceInsight
添加文件和函数注释
参考:https://blog.csdn.net/weixin_36209467/article/details/120487408
打开base工程
编辑utils.em,全部替换成后面的文本。有4种功能:文件头注释、函数头注释、#if 0注释、取消#if 0注释
增加快捷键分别为Ctrl+1、Ctrl+2、Ctrl+3、Ctrl+4
以后在文件后按Ctrl+1
在函数头按Ctrl+2就可以了
/*获取文件名称*/
macro GetFileName(pathName)
{
nlength = strlen(pathName)
i = nlength - 1
name = ""
while (i + 1)
{
ch = pathName[i]
if ("\\" == "@ch@")
break
i = i - 1
}
i = i + 1
while (i < nlength)
{
name = cat(name, pathName[i])
i = i + 1
}
return name
}
macro InsertFileHeader()
{
//get crrunt time
szTime = GetSysTime(1)
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year
hbuf = GetCurrentBuf()//申请变量空间,Get a handle to the current file buffer and the name
PathName = GetBufName(hBuf)
FileName = GetFileName(PathName)
hbuf = GetCurrentBuf()
InsBufLine(hbuf, 0, "/*******************************************************************************")
InsBufLine(hbuf, 1, " * \@file @FileName@")
InsBufLine(hbuf, 2, " * \@version v1.0.0")
InsBufLine(hbuf, 3, " * \@copyright COPYRIGHT @Year@ 公司")
InsBufLine(hbuf, 4, " * \@author 姓名")
InsBufLine(hbuf, 5, " * \@date @Year@-@Month@-@Day@")
InsBufLine(hbuf, 6, " * \@brief")
InsBufLine(hbuf, 7, " * Modification History")
InsBufLine(hbuf, 8, " * ------------------------")
InsBufLine(hbuf, 9,"*******************************************************************************/")
}
macro InsertFunHeader()
{
/* 获取光标所在行 */
handle = GetCurrentWnd()
process_line = GetWndSelLnFirst(handle)
/* 获取函数所在行文本 */
file_txt = GetCurrentBuf()
process_txt = GetBufLine(file_txt,process_line + 1)
process_txt_len = strlen(process_txt)
if(process_txt == "")
{
stop
}
/* 获取函数名 */
symbol_rec = GetSymbolLocationFromLn (handle, process_line + 1)
if(symbol_rec == "")
{
stop
}
fuction_name = symbol_rec.Symbol
/* 获取参数个数及参数名 */
param_num = 0
param_list = SymListNew()
i=0,j=0
while(i < process_txt_len)
{
if(process_txt[i] == "," || process_txt[i] == ")")
{
j = i
while(j > 0)
{
if(process_txt[j] == " " || process_txt[j] == "*" || process_txt[j] == "&" ||
process_txt[j] == "(")
{
symbol_rec.Symbol = strmid(process_txt,j+1,i)
SymListInsert(param_list,param_num,symbol_rec)
param_num = param_num + 1
break;
}
j = j - 1
}
}
i = i + 1
}
/* 输出注释 */
PutBufLine(handle,process_line + 0,"/*******************************************************************************")
var temp_buffer
temp_buffer = cat("* \@FunctionName: ",fuction_name)
InsBufLine(handle,process_line + 1,temp_buffer)
InsBufLine(handle,process_line + 2,"* \@Author: YeWu")
sys_time = GetSysTime(1)
temp_buffer = "* \@DateTime: "
temp_buffer = cat(temp_buffer,sys_time.date)
temp_buffer = cat(temp_buffer,"T")
temp_buffer = cat(temp_buffer,sys_time.time)
temp_buffer = cat(temp_buffer,"+0800")
InsBufLine(handle,process_line + 3,temp_buffer)
InsBufLine(handle,process_line + 4,"* \@Brief: ")
param_line = process_line + 5
InsBufLine(handle,param_line,"*******************************************************************************/")
if(strmid(process_txt,0,4) != "void")
{
InsBufLine(handle,param_line,"* \@return:")
}
while(param_num > 0)
{
param_num = param_num - 1
symbol_rec = SymListItem(param_list,param_num)
temp_buffer = "* \@param: "
temp_buffer = cat(temp_buffer,symbol_rec.Symbol)
temp_buffer_len = strlen(temp_buffer)
temp_buffer_len = 38 - temp_buffer_len
while(temp_buffer_len > 0)
{
temp_buffer_len = temp_buffer_len - 1
temp_buffer = cat(temp_buffer," ")
}
//temp_buffer = cat(temp_buffer,"[description]")
InsBufLine(handle,param_line,temp_buffer)
}
SymListFree(param_list)
}
/*使用"if 0"宏定义注释选中的行*/
macro CommentLineWithIf0()
{
var Obj_Window;
var ilnFirst;
var ilnLast;
var Obj_Buffer;
Obj_Window = GetCurrentWnd()
ilnFirst = GetWndSelLnFirst(Obj_Window)
ilnLast = GetWndSelLnLast(Obj_Window)
Obj_Buffer = GetCurrentBuf()
InsBufLine(Obj_Buffer, ilnFirst, "#if 0")
InsBufLine(Obj_Buffer, ilnLast+2, "#endif")
}
/*取消使用"if 0"注释的行*/
macro UnCommentLineWithIf0()
{
var Obj_Window;
var ilnFirst;
var ilnLast;
var Obj_Buffer;
Obj_Window = GetCurrentWnd()
ilnFirst = GetWndSelLnFirst(Obj_Window)
ilnLast = GetWndSelLnLast(Obj_Window)
Obj_Buffer = GetCurrentBuf()
DelBufLine(Obj_Buffer, ilnFirst)
DelBufLine(Obj_Buffer, ilnLast - 1)
}
2.3 Notepad++
2.4 格式化工具astyle
我采用的格式化命令为
astyle.exe --style=allman -s4 --indent=spaces=4 -k3 -w -n -f -U %f
1.下载安装astyle程序 https://sourceforge.net/projects/astyle,如安装在D:/software/astyle/astyle.exe
2.vscode安装astyle插件
3.在settings.json中添加以下设置
使用方式,选中需要格式化的代码,shift+alt+f,或者右键操作
"astyle.executable": "D:/software/astyle/astyle.exe",
"editor.mouseWheelZoom": true,
"astyle.additional_languages": [
"h",
"hpp",
"c",
"cpp",
],
"astyle.cmd_options": [
"--style=allman",
"--indent=spaces=4",
"--convert-tabs",
"--align-pointer=name",
"--align-reference=name",
"--keep-one-line-statements",
"--pad-header",
"--pad-oper",
"--break-closing-braces",
],
"[h]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"[hpp]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"[c]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"[cpp]": {
"editor.defaultFormatter": "chiehyu.vscode-astyle"
},
"editor.detectIndentation": false,
3. 代码版本配置管理工具
3.1SVN
SVN-Windows版
安装SVN服务器
下载VisualSVN Server:
https://www.visualsvn.com/downloads/
安装SVN客户端
下载Tortoisesvn:
SVN-Linux版
sudo apt install subversion
3.2 Git
Git-Windows版
下载后安装:
https://github.com/git-for-windows/git/releases/download/v2.43.0.windows.1/Git-2.43.0-64-bit.exe
Git-Linux版
4、单元测试工具
Gtest
5、代码静态审查工具
splint
cppcheck
6、 其他软件
python3安装
windows版本
下载
https://repo.huaweicloud.com/python/3.11.5/python-3.11.5-amd64.exe
也可以到官网下载
安装时要加入要环境变量,以便在cmd中直接调用。如果忘记了,再重新运行安装包,选择repair,也可以添加。
安装pip3
下载安装
https://files.pythonhosted.org/packages/1f/7f/4da15e07ccd11c84c1ccc8f6e24288d5e76c99441bf80e315b33542db951/pip-23.3.1.tar.gz
解压后进入cmd,执行命令python setup.py install
脚本安装
下载get-pip.py
https://bootstrap.pypa.io/get-pip.py
到下载的目录中运行
python get-pip.py
升级到最新
python -m pip install --upgrade pip
Windows make
下载TDM-GCC
https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm64-2/tdm64-gcc-10.3.0-2.exe
安装完后mingw32-make.exe即为make命令