フィルターのクリア

How to use real time workshop to convert the matlab functions' fread" and "fwrite" into c code?

1 回表示 (過去 30 日間)
David
David 2013 年 6 月 27 日
Hi,
I was wondering if there was a way to convert the Matlab functions fread and fwrite to C code using Real time Workshop or Matlab Coder. I saw in the "Matlab Coder" user guide that fread and fwrite are not supported functions that can be converted to C code. I was wondering if there was a way around this. Is there another function that does the same thing as fread and fwrite that is supported by Real Time Workshop/Matlab Coder. My bigger goal is to run Matlab in real time. I realize I can only do this by first converting my Matlab code to C code. However,I cannot convert the Matlab functions fread and fwrite to C using Real Time Workshop. (FYI: My matlab code is reading and writing to the COM port.)
Thanks in advance, David

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 6 月 27 日
I have never used those, but my understanding is that you can change the call names (e.g, fread to FREAD), and coder.extrinsic('FREAD'), and then you supply minor interface code along the lines of
#include <stdio.h>
int FREAD(.... prototype here ....) {
return fread(....)
}
except that you would need to do whatever is necessary to deal with an array (e.g., passing in a buffer and buffer size, reading the data to the buffer, returning the fread() status.)
  3 件のコメント
David
David 2013 年 7 月 2 日
I tried using the code fread from the link you posted. But because I have matlab 2009 I do not have coder installed. Is there another way to do this using the functions in matlab 2009?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by