分析分布式工作流中作为独立代码生成的代码
生成并打包Polyspace®选项文件从Simulink金宝app®通过使用函数进行建模polyspacepackNGo
.使用这些选项文件对生成的代码运行Polyspace分析,这些代码使用特定于模型的信息,例如设计范围规范,而不需要Simulink。金宝app
开放模式
该模型demo_math_operations
对模型输入执行各种数学操作。该模型有一个执行自定义C代码的C函数块。该模型还有一个C Caller块,用于调用C函数GMean
,在源文件GMean.c中实现。要打开用于代码生成和打包Polyspace选项的模型文件,请在MATLAB帮助浏览器中搜索当前主题并单击开放模式按钮。或者,在MATLAB命令窗口中,粘贴并运行以下代码。
openExample (“金宝appsimulink_general / PPNGStandAloneExample”);open_system (“demo_math_operations”);
配置模型
要配置用于生成代码和打包Polyspace选项文件的模型,请指定以下配置参数:
若要创建包含生成代码的存档,请设置
“PackageGeneratedCodeAndArtifacts”
来真正的
.为代码归档文件指定一个名称。例如,将名称设置为
genCodeArchive.zip
.中指定的自定义代码设置模拟目标在代码生成过程中,设置
“RTWUseSimCustomCode”
来“上”
.要使模型和生成的代码与Polyspace兼容,请设置
ert.tlc
作为系统目标文件。看到多空间分析的推荐模型配置参数(Polyspace Bug Finder).
在“命令窗口”或“编辑器”中输入以下参数配置:
configSet = getActiveConfigSet(“demo_math_operations”);set_param (configSet“PackageGeneratedCodeAndArtifacts”,真正的);set_param (configSet“PackageName”,“genCodeArchive.zip”);set_param (configSet“SystemTargetFile”,“ert.tlc”);set_param (configSet“RTWUseSimCustomCode”,“上”)
生成代码存档
指定一个文件夹来存储生成的代码。要开始代码生成,在命令窗口或编辑器中输入:
codegenFolder =“demo_math_operations_ert_rtw”;如果codegenFolder存在(fullfile (pwd),“dir”) == 0 slbuild(“demo_math_operations”)结束
因为PackageGeneratedCodeAndArtifacts
设置为真正的
,生成的代码被打包到存档中genCodeArchive.zip
.
生成和打包Polyspace选择文件
要为生成的代码生成Polyspace选项文件,在命令窗口或编辑器中输入:
zipFile = polyspacePackNGo(“demo_math_operations”);
在档案中genCodeArchive.zip
,在文件夹中找到选项文件
.<当前文件夹>
/ polyspace
运行Polyspace使用打包的选项文件进行分析
解压缩代码存档
genCodeArchive.zip
并定位
文件夹中。<当前文件夹>
/ polyspace打开命令行终端,并将工作文件夹更改为
polyspace
子文件夹中的cd
命令。开始Polyspace分析。
要运行桌面Polyspace分析,请使用其中任何一种
polyspace-code-prover
或polyspace-bug-finder
.要在服务器中运行Polyspace分析,请使用其中之一polyspace-bug-finder-server
或polyspace-code-prover-server
.Polyspace Bug Finder和Code Prover以不同的方式分析代码。看到Polyspace Bug Finder和Polyspace Code Prover的区别(Polyspace Bug Finder).指定文件
optionsFile.txt
作为论证选项文件
.
要运行Code验证程序分析,运行以下命令:
polyspace-code-prover -options-file optionsFile.txt -results-dir执行结果
.中生成的日志文件中跟踪分析的进度
结果
文件夹中。若要在桌面用户界面查看结果,请在命令行中输入:
polyspace结果\ ps_results.pscp
.扩展ps_results
文件更改取决于您是运行代码验证器分析还是Bug查找器分析。结果包含几个橙色的检查。或者,将结果上传到Polyspace Access。看到将结果上传到Polyspace Access(Polyspace Bug Finder).
处理结果。有关更多信息,请参见通过错误修复或注释处理结果(Polyspace Bug Finder).
另请参阅
polyspacePackNGo
|slbuild
|packNGo
(嵌入式编码)