How to add libraries stored on the remote target (Raspberry Pi)

3 visualizzazioni (ultimi 30 giorni)
Good day !
I have developed a piece of code to read i2c buffer (32 bits) on a Raspberry Pi. It works well on the Pi, and I am trying to implement the code as a Matlab system object.
I need to add the following libraries to make it work:
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
How should this be added to the Matlab system object ?
My first guess is that it should not require any link flags.
My second guess this is: use the addLinkerFlags function, but I have no idea what argument should be added.
function updateBuildInfo(buildInfo, context)
if context.isCodeGenTarget('rtw')
% Update buildInfo
srcDir = fullfile(fileparts(mfilename('fullpath')),'src'); %#ok<NASGU>
includeDir = fullfile(fileparts(mfilename('fullpath')),'include');
addIncludePaths(buildInfo,includeDir);
% Use the following API's to add include files, sources and
% linker flags
addIncludeFiles(buildInfo,'I2C_read.h',includeDir);
addSourceFiles(buildInfo,'I2C_read.c',srcDir);
% addLinkFlags(buildInfo,{'-lwiringPi'});
%addLinkObjects(buildInfo,'sourcelib.a',srcDir);
%addCompileFlags(buildInfo,{'-D_DEBUG=1'});
%addDefines(buildInfo,'MY_DEFINE_1')
end
any help ?
  2 Commenti
Prasanth Sunkara
Prasanth Sunkara il 10 Mar 2023
Hi Sylvain,
I dont think you need any explicit linker flags for this header. In which case, you dont have to use addLinkFlags API. By the way, is there any specific reason as to why you are rewriting i2c block/function? There is already a MATLAB function and Simulink blocks for i2c from the Raspberry Pi Support Package
Sylvain
Sylvain il 10 Mar 2023
Hi Prasanth,
thanks for your comments. I guess we have discuss this during our call last week with one of your colleague from the UK Office.
I am developping some drivers for the raspberry Pi, (fan controller) using the standard i2c blocks. The main issue are:
  • translation of some existing code into simulink: eg. read register > compare it to a value > update register
  • Addition of delay blocks
  • long compilation time (so that I need to use reference models)
I am happy to discuss this further if you wish.
The issue I am facing now is that some of the linux libraries are not found by the compiler. Especially: asm/rwonce.h

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Raspberry Pi Hardware in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by