Error writing IOServerBlock when trying to write to an Arduino

68 views (last 30 days)
I was running a long script to read from a sensor connected to an Arduino, and after a while I saw that the script had stopped and had reported the following error:
Error writing IOServerBlock.
Invalid operation. Object must be connected to the serial port.
I did not change anything in the script, and I verified everything was still properly wired to the Arduino, so what may have caused this error, and how can I resolve it?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 30 Dec 2021
Possible Explanation:
Most likely, this error was caused by the Arduino losing connection to your computer while a script is running. This can happen from simply bumping the USB Cable and accidentally disconnecting the Arduino temporarily, or if the computer goes to sleep in the middle of a script. Even if the Arduino is reconnected, the error may still be generated.
Resolution:
To resolve this issue, ensure the Arduino is connected, then delete the Arduino variable, and re-instantiate it.
For example, if your Arduino variable is "a", then execute the following:
%% Assumes an Arduino variable 'a' is already instantiated
% Delete existing Arduino variable
clear a
% Re-instantiate Arduino variable
a = arduino(); % include all parameters from your original call

More Answers (0)

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!