How can i connect raspberry pi (Ubuntu 22.04 OS) with Matlab?

6 次查看(过去 30 天)
when i try to connect raspberry pi with matlab i face those problems
or try to setup simulink raspberry pi package
It would help too much if problem solved
>> a = raspi
### Updating Raspberry Pi I/O server...
### Connecting to board...
### Connected to 172.20.10.14...
### Installing nanomsg Library (this might take a while)...
### Creating server folder...
Error executing command "sudo make -C /opt/MATLAB/mw_server_v22.2.0
SERVER_DIR=/opt/MATLAB/mw_server_v22.2.0 -f Makefile_raspiPeriphs". Details:
STDERR: MW_availableWebcam.c: In function getCameraList:
MW_availableWebcam.c:129:9: warning: ignoring return value of ‘fgets’ declared with attribute
warn_unused_result[-Wunused-result]
129 | fgets(webCamName, sizeof(webCamName)-1, fp);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MW_SocketCAN.c: In function MW_printError:
MW_SocketCAN.c:37:5: warning: format not a string literal and no format arguments [-Wformat-security]
37 | fprintf(stderr,errString);
| ^~~~~~~
MW_SocketCAN.c: In function MW_getTimeNow:
MW_SocketCAN.c:139:8: warning: implicit declaration of function ‘gettimeofday’
[-Wimplicit-function-declaration]
139 | if(gettimeofday(&timeNow,NULL)==-1)
| ^~~~~~~~~~~~
MW_SocketCAN.c: In function MW_executeCommand:
MW_SocketCAN.c:33:5: warning: ignoring return value of ‘system’ declared with attribute
warn_unused_result[-Wunused-result]
33 | system(cmd);
| ^~~~~~~~~~~
MW_gpio.c: In function MW_dumpGpioInfo:
MW_gpio.c:231:54: warning: format %d’ expects a matching ‘int’ argument [-Wformat=]
231 | printf("GPIO = %d, dir = %d, res = %d, fd = %d\n",
| ~^
| |
| int
MW_I2C.c: In function EXT_I2C_readRegisterH:
MW_I2C.c:145:23: warning: assignment to ‘struct i2c_msg *’ from incompatible pointer type ‘struct
i2c_msg (*)[2][-Wincompatible-pointer-types]
145 | i2c_data.msgs = &msg;
| ^
MW_Raspi_PulseIn.c: In function MW_getPulseDuration:
MW_Raspi_PulseIn.c:81:77: warning: format %lu’ expects argument of type ‘long unsigned int’, but
argument 2 has type ‘uint32_T’ {aka ‘unsigned int’} [-Wformat=]
81 | printf("MW_PULSE_IN: Pulse duration exceeded the limit of %lu micro sec
\n",PULSEIN_TIMEOUT);
| ~~^
~~~~~~~~~~~~~~~
| | |
| |
uint32_T {aka unsigned int}
| long unsigned int
| %u
/usr/bin/ld: MW_availableWebcam.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `wc' which
may bind externally can not be used when making a shared object; recompile with -fPIC
MW_availableWebcam.c.o: in function `getCameraAddrIndex':
MW_availableWebcam.c:(.text+0x14c): dangerous relocation: unsupported relocation
/usr/bin/ld: MW_availableWebcam.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `wc' which
may bind externally can not be used when making a shared object; recompile with -fPIC
MW_availableWebcam.c:(.text+0x238): dangerous relocation: unsupported relocation
/usr/bin/ld: MW_availableWebcam.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `wc' which
may bind externally can not be used when making a shared object; recompile with -fPIC
MW_availableWebcam.c.o: in function `validateResolution':
MW_availableWebcam.c:(.text+0x2d4): dangerous relocation: unsupported relocation
/usr/bin/ld: MW_availableWebcam.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `wc' which
may bind externally can not be used when making a shared object; recompile with -fPIC
MW_availableWebcam.c:(.text+0x378): dangerous relocation: unsupported relocation
/usr/bin/ld: MW_availableWebcam.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `wc' which
may bind externally can not be used when making a shared object; recompile with -fPIC
MW_availableWebcam.c.o: in function `getCameraResolution':
MW_availableWebcam.c:(.text+0x560): dangerous relocation: unsupported relocation
/usr/bin/ld: MW_availableWebcam.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `wc' which
may bind externally can not be used when making a shared object; recompile with -fPIC
MW_availableWebcam.c.o: in function `getCameraList':
MW_availableWebcam.c:(.text+0x8d0): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
make: *** [Makefile_raspiPeriphs:213: libmwraspiperipheral.so] Error 1
STDOUT: make: Entering directory '/opt/MATLAB/mw_server_v22.2.0'
gcc -c -MMD -MP -MF"MW_availableWebcam.c.dep" -MT"MW_availableWebcam.c.o" -O2 -D_MATLABIO_
-I/opt/MATLAB/mw_server_v22.2.0 -o "MW_availableWebcam.c.o" "MW_availableWebcam.c"
gcc -c -MMD -MP -MF"MW_SocketCAN.c.dep" -MT"MW_SocketCAN.c.o" -O2 -D_MATLABIO_
-I/opt/MATLAB/mw_server_v22.2.0 -o "MW_SocketCAN.c.o" "MW_SocketCAN.c"
gcc -c -MMD -MP -MF"MW_v4l2_cam.c.dep" -MT"MW_v4l2_cam.c.o" -O2 -D_MATLABIO_
-I/opt/MATLAB/mw_server_v22.2.0 -o "MW_v4l2_cam.c.o" "MW_v4l2_cam.c"
gcc -c -MMD -MP -MF"MW_gpio.c.dep" -MT"MW_gpio.c.o" -O2 -D_MATLABIO_ -I/opt/MATLAB/mw_server_v22.2.0
-o "MW_gpio.c.o" "MW_gpio.c"
gcc -c -MMD -MP -MF"MW_I2C.c.dep" -MT"MW_I2C.c.o" -O2 -D_MATLABIO_ -I/opt/MATLAB/mw_server_v22.2.0 -o
"MW_I2C.c.o" "MW_I2C.c"
gcc -c -MMD -MP -MF"MW_SPI.c.dep" -MT"MW_SPI.c.o" -O2 -D_MATLABIO_ -I/opt/MATLAB/mw_server_v22.2.0 -o
"MW_SPI.c.o" "MW_SPI.c"
gcc -c -MMD -MP -MF"MW_SCI.c.dep" -MT"MW_SCI.c.o" -O2 -D_MATLABIO_ -I/opt/MATLAB/mw_server_v22.2.0 -o
"MW_SCI.c.o" "MW_SCI.c"
gcc -c -MMD -MP -MF"MW_Raspi_PulseIn.c.dep" -MT"MW_Raspi_PulseIn.c.o" -O2 -D_MATLABIO_
-I/opt/MATLAB/mw_server_v22.2.0 -o "MW_Raspi_PulseIn.c.o" "MW_Raspi_PulseIn.c"
gcc -c -MMD -MP -MF"devices.c.dep" -MT"devices.c.o" -O2 -D_MATLABIO_ -I/opt/MATLAB/mw_server_v22.2.0
-o "devices.c.o" "devices.c"
gcc -c -MMD -MP -MF"linuxTimeLogger.c.dep" -MT"linuxTimeLogger.c.o" -O2 -D_MATLABIO_
-I/opt/MATLAB/mw_server_v22.2.0 -o "linuxTimeLogger.c.o" "linuxTimeLogger.c"
echo "### Creating dynamic library "libmwraspiperipheral.so" ..."
### Creating dynamic library libmwraspiperipheral.so ...
gcc -shared -lrt -lpthread -ldl -o libmwraspiperipheral.so MW_availableWebcam.c.o MW_SocketCAN.c.o
MW_v4l2_cam.c.o MW_gpio.c.o MW_I2C.c.o MW_SPI.c.o MW_SCI.c.o MW_Raspi_PulseIn.c.o devices.c.o
linuxTimeLogger.c.o -lm -lm -lstdc++
make: Leaving directory '/opt/MATLAB/mw_server_v22.2.0'

回答(1 个)

Vijay
Vijay 2022-12-28
编辑:Vijay 2022-12-28
The issue is with libmmal library. libmmal library deals with camera interfacing on raspberry Pi.
With the limited information that you have provided I would suggest you to please check the following things and retry interfacing
  1. Please check if your UBUNTU on your raspberry Pi is 32bit, as libmmal only supports 32bit architecture.
  2. As you are using UBUNTU please check if all required dependencies are installed for MATLAB interfacing.
Please follow the links below for more information on interfacing raspberry Pi to MATLAB
  1. Raspberry Pi Support from MATLAB, Part 1: Getting Started with MATLAB Support Package for Raspberry Pi Hardware - Video - MATLAB (mathworks.com)
  2. Connection to Raspberry Pi board - MATLAB - MathWorks India
  3. Install Support for Raspberry Pi Hardware - MATLAB & Simulink - MathWorks India
Hope this helps!

类别

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