How can I read big-endian binary files with embedded coder?
古いコメントを表示
I have a function in MATLAB that I am using to read some legacy binary files that use Big-endian format for bit ordering. It contains a few lines of code similar to:
% Open Binary File
fileID = fopen('myBinaryFile.xyz');
% Read from Binary file to structure
structure.fieldnameA = fread(fileID,[1 2],'*unit16','ieee-be');
structure.fieldnameB = fread(fileID,[1 1],'unit16=>char','ieee-be');
% Close file
fclose(fileID)
Where the sizes and types are picked here arbitarlity. I use the 'machineformat' argument in fread to order the bits correctly. This (appears) to work fine inside the MATLAB environment and I can generate a structure with the data I need.
However, I need to use this functionality inside a simulink model. Attempting to put this function into an embedded MATLAB block returns the error:
> For code generation, you cannot use the 'machineformat' input argument.
I also get a similar error when attempting to use MATLAB coder to generate C/C++ code that could be used in an S-Function.
My question:
Does there exist a code generation friendly version of the machineformat argument? If not, is it possible to write a function that has the same functionality, but is code generation friendly?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Texas Instruments C2000 Processors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!