Using R2016a, I'd like to nicely deal with fopen(serial) errors rather than the command window barf at me.
Normal syntax for fopen() includes [fileID,errmsg] = fopen(___)
But the serial version of the command using an object doesn't appear to return anything unless it errors.
>> obj1 = instrfind('Type', 'serial', 'Port', port, 'Tag', '');
>> set(obj1, 'BaudRate', 115200, 'Timeout', 1, 'Terminator','LF');
Note that fopen just happened without saying it worked.
Now, I'll open a TeraTerm session to COM5 and try again...
Error using serial/fopen (line 72)
Open failed: Cannot connect to the COM5 port. Possible reasons are another
application is connected to the port or the port does not exist.
As expected. But... how do I deal with these messages programmatically?
>> [fileID,errmsg] = fopen(obj1)
Error using serial/fopen
Too many output arguments.