Problems with PIGPIO library and S-Function Builder - Raspberry Pi

조회 수: 16 (최근 30일)
Giacomo Melloni
Giacomo Melloni 2021년 7월 15일
Hi, I'm trying to use SPI protocoll with PIGPIO library with a Raspberry Pi 4 (http://abyz.me.uk/rpi/pigpio/), and the S-Function Builder Block's code is:
Includes_BEGIN:
# ifndef MATLAB_MEX_FILE
#define SPI_SPEED 15000000
#define SPI_CH 1
#define BUFFER_DIM 2
#include </home/pi/pigpio-master/pigpio.h>
#include </home/pi/pigpio-master/pigpio.c>
#include </usr/include/pthread.h>
#include </usr/include/fcntl.h>
char buffer[BUFFER_DIM], msb, lsb;
uint16_T msb_uint16;
int w;
#endif
Update_BEGIN:
if(xD[0] != 1){
# ifndef MATLAB_MEX_FILE
w = spiOpen(SPI_CH, SPI_SPEED, 0);
#endif
//done with initialization
xD[0] = 1;
}
Output_BEGIN:
if(xD[0] == 1)
{
#ifndef MATLAB_MEX_FILE
buffer[0] = in[0] >> 8;
buffer[1] = in[0];
spiWrite(w,buffer,BUFFER_DIM);
#endif
}
but I keep getting the following error:
<command-line>: note: this is the location of the previous definition
In file included from /home/pi/MATLAB_ws/R2021a/C/Users/jacqu/Desktop/Universita/Triennio/3_ANNO/TESI/raspberry/ADCDACPi/test_with_simulink/ex_with_lookup_table_and_pigpio/PIGPIO_SPI_wrapper.c:23:
/home/pi/pigpio-master/pigpio.c: In function gpioNotifyOpenWithSize:
/home/pi/pigpio-master/pigpio.c:12044:21: error: F_SETPIPE_SZundeclared (first use in this function); did you mean ‘FD_SETSIZE’?
i = fcntl(fd, F_SETPIPE_SZ, bufSize);
^~~~~~~~~~~~
FD_SETSIZE
Therefore, I tried commenting out the fcntl function inside the pigpio.c file, as below:
if (bufSize != 0)
{
//i = fcntl(fd, F_SETPIPE_SZ, bufSize);
i = bufSize;
if (i != bufSize)
{
gpioNotify[slot].state = PI_NOTIFY_CLOSED;
SOFT_ERROR(PI_BAD_PATHNAME,
"fcntl %s size %d failed (%m)", name, bufSize);
}
}
In this case, when I click "Build, Deploy and Start", I don't get any errors, but I don't read anything in output to the SPI, even though the process is running.
Any idea? I use the release R2021a .

답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by