How can I read big-endian binary files with embedded coder?
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Texas Instruments C2000 Processors dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!