Know if Serialport is connected (in App Designer program); ishandle() always true
I open a serial port to my Arduino and it usually works. I’m trying to take care of various errors, for one of which I need to know if the port handle is there and connected or not. In Command window I can tell when ishandle(MyCom) returns a logical answer
ishandle(app.PicoCom)
ans =
0×0 empty logical array
But programatically determining if it’s there, say with
ishandle(app.PicoCom) == false
ans =
0×0 empty logical array
Doesn’t work, it’s always true. How do I ask a false logical array if it’s false and why does this have to be so hard? Does anybody really need an array response to ishandle(app.PicoCom)? if ~ishandle(app.PicoCom) should be enough.
I also tried if ~exist(…) and even isstr(app.PicoCom.Port) but they don’t work when it’s not a handle.
BTW, ishandle() is only described as for graphic objects and figures and the existing answer doesn’t answer my question
https://www.mathworks.com/matlabcentral/answers/13424-why-does-ishandle-0-return-1?s_tid=srchtitleI open a serial port to my Arduino and it usually works. I’m trying to take care of various errors, for one of which I need to know if the port handle is there and connected or not. In Command window I can tell when ishandle(MyCom) returns a logical answer
ishandle(app.PicoCom)
ans =
0×0 empty logical array
But programatically determining if it’s there, say with
ishandle(app.PicoCom) == false
ans =
0×0 empty logical array
Doesn’t work, it’s always true. How do I ask a false logical array if it’s false and why does this have to be so hard? Does anybody really need an array response to ishandle(app.PicoCom)? if ~ishandle(app.PicoCom) should be enough.
I also tried if ~exist(…) and even isstr(app.PicoCom.Port) but they don’t work when it’s not a handle.
BTW, ishandle() is only described as for graphic objects and figures and the existing answer doesn’t answer my question
https://www.mathworks.com/matlabcentral/answers/13424-why-does-ishandle-0-return-1?s_tid=srchtitle I open a serial port to my Arduino and it usually works. I’m trying to take care of various errors, for one of which I need to know if the port handle is there and connected or not. In Command window I can tell when ishandle(MyCom) returns a logical answer
ishandle(app.PicoCom)
ans =
0×0 empty logical array
But programatically determining if it’s there, say with
ishandle(app.PicoCom) == false
ans =
0×0 empty logical array
Doesn’t work, it’s always true. How do I ask a false logical array if it’s false and why does this have to be so hard? Does anybody really need an array response to ishandle(app.PicoCom)? if ~ishandle(app.PicoCom) should be enough.
I also tried if ~exist(…) and even isstr(app.PicoCom.Port) but they don’t work when it’s not a handle.
BTW, ishandle() is only described as for graphic objects and figures and the existing answer doesn’t answer my question
https://www.mathworks.com/matlabcentral/answers/13424-why-does-ishandle-0-return-1?s_tid=srchtitle ishandle is true when its false MATLAB Answers — New Questions