Is there a way to generate c code for system function which runs batch file?
古いコメントを表示
I am trying to run a batch file which eventually runs an exe file. I am trying to use system function to run this batch file.But system is not supported for code generation. Is there a way to generate c code for system function or is there a way with which I can run a batch file which will be supported by code generation?
回答 (1 件)
Walter Roberson
2018 年 1 月 9 日
0 投票
You can coder.ceval() to call CreateProcess() and see https://msdn.microsoft.com/en-us/library/windows/desktop/ms682015(v=vs.85).aspx or the ISO _execv() https://docs.microsoft.com/en-ca/cpp/c-runtime-library/reference/execv-wexecv
In Unix systems, execv() or execvp() would often be used.
7 件のコメント
sai kamal sreeja veepuri
2018 年 1 月 9 日
Walter Roberson
2018 年 1 月 9 日
You cannot do that when you generate C code. MATLAB only generates code that uses nothing more than the standard C library, and the standard C library does not have any routines corresponding to system() or unix() or dos() . As far as MATLAB Coder knows, the code is being sent to an FPGA or an embedded DSP that has no operating system, so you need to put in custom coder.ceval calls if you want something more.
sai kamal sreeja veepuri
2018 年 1 月 9 日
編集済み: Walter Roberson
2018 年 1 月 9 日
Walter Roberson
2018 年 1 月 9 日
Use the "call external C function" example (the first one). You would want one input argument that is const char *
sai kamal sreeja veepuri
2018 年 1 月 10 日
Walter Roberson
2018 年 1 月 10 日
The non-deploy branch,
y = 'C:\Users\Tester\Desktop\Release\meter_app.bat';
should also
system(y)
You should pay attention to the data type of the return value: system() at the C level returns an int, but in the non-deploy branch you have it returning a character vector. Perhaps you should change the deploy branch to
y = system('C:\Users\Tester\Desktop\Release\meter_app.bat');
I recommend changing your declaration from
int execute();
to
int execute(void);
sai kamal sreeja veepuri
2018 年 1 月 10 日
カテゴリ
ヘルプ センター および File Exchange で Deployment, Integration, and Supported Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!