Simulink error when using ginput on separate script

1 view (last 30 days)
Hello,
I am using Simulink in external mode to control a Lego NXT robot. While simulink is running I am using Matlab scripts to complete various tasks. One of those task is to select Waypoints using ginput to select points on a figure.
My problem:
Ginput seems to hang up simulink. While ginput is waiting for me to select a point, simulink appears to be stopped (the clock in the bottom right of the simulink window stops).
If I wait too long before I select a point using ginput an error occurs and Simulink stops running.
The error appears as follows:
Error occurred while executing External Mode MEX-file 'ext_serial_win32_comm_no_acks_rtt': ExtGetTargetPkt() call failed while retrieving pkt data
A few observations:
1) Running ginput from a script, the command line and from a GUI all cause the same error
2) If I click on the figure fast enough (under 2s) the timer in simulink resumes and has not lost any time i.e. pauses at 15.2 s and resumes as 16.9s
3) running ginput in a second instance of matlab does not cause an error or freeze simulink (but I don't wan to have to import and export variable from one matlab instance to the other if I don't have to....)
I am wondering if there is any setting I can change to disable what appears to be a whatchdog time or is I can run a script in a separate thread.
Any help would be appreciated. Let me know if you need more information to help.
Thanks,
Tyler

Accepted Answer

Anton Rubisov
Anton Rubisov on 1 Apr 2014
Tyler,
The problem isn't specific to ginput. Any operation outside of Simulink (such as running a long script, prompting for input with ginput, even a messagebox) will cause Simulink to stop receiving packets via the Bluetooth connection. After the critical duration (around 2s as you noted) it'll error out that the connection was lost.
In the absence of the Parallel Computing Toolbox, one solution is to have two instances of MATLAB open - one will run the Simulink model, the other will do all the prompting and calculation. To send parameters to and from the model, you can have a simple GUI running on the Simulink instance that saves and reads from file. Likewise, the computational instance will also need to read and write to the same files.
Anton

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!