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

조회 수: 5 (최근 30일)
Sylvain
Sylvain 2023년 2월 27일
댓글: Sylvain 2023년 3월 10일
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
Prasanth Sunkara
Prasanth Sunkara 2023년 3월 10일
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 2023년 3월 10일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Raspberry Pi Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by