Error while running simulink model connecting to raspberry pi with a webcam for real time image processing

79 views (last 30 days)
I'm trying to connect raspberry pi to simulink for capturing images from a webcam on raspberry pi. When I run the simulink model, some errors occur. Is there anyone to help me to solve this problem? Thanks for answers...
1) Error occurred while executing External Mode MEX-file 'ext_comm': ExtTargetPktPending() call failed while checking for target pkt
2) Error occurred while executing External Mode MEX-file 'ext_comm': ExtSetTargetPkt() call failed on CLOSE. Ensure target is still running
On matlab command window, it is written::"### Generated code for 'raspberrypi_inversion' is up to date because no structural, parameter or code replacement library changes were found."

Answers (4)

Pavel Roslovets
Pavel Roslovets on 13 Jan 2016
Seems like you are trying to send a too big amount of data from Raspberry to MATLAB in External Mode, so you get lost connection to target.
You can check this proposition. When the error occures go to Code->External Mode Control Panel in your Simulink model window and press the Connect button (see the picture 1 below).
If after this action simulation will continue press the Arm Trigger button to continue recieve signals from target.
To solve your problem and get rid of error press Disarm Trigger to stop recieve signals and then press Signal & triggering... button and in window that appears turn off redundant signals (picture 2).
Also a good practice is to slightly change your model. Use Rate Transition blocks before Scopes that you use to collect data from target with a view to enlarge signal sample time and decrease the load on your data channel.
And the last advice is to close all your Scopes when starting simulation in External Mode because an open Scope window can slow down your simulation that cause a loss of connection to the target. Also you can change Solver settings in Model Configuration Parameters to speed up a simulation.
Picture 1
Picture 2

Myles Joseph
Myles Joseph on 24 Jan 2018
I am having this issue, and it is largely due to the amount of data being send over in external mode. The time step of the system is not so important, so I can wait. is it possible to increase the timeout for this?

Murat Belge
Murat Belge on 23 Apr 2014
Is the webcam you are using in the supported USB webcams list? Check your webcam against the table in the following link:
From the description, it looks like the Simulink application is not starting at all or exited because of an error. Are you executing one of the demo models?

Ajay Joseph
Ajay Joseph on 29 Nov 2018
Try disabling the firewall. I wasn't getting the exact error but it was similar.

Community Treasure Hunt

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

Start Hunting!