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

17 visualizzazioni (ultimi 30 giorni)
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 .

Risposte (0)

Categorie

Scopri di più su MATLAB Support Package for Raspberry Pi Hardware in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by