Error using icinterface/fopen (line 83) Unsuccessful open: OBJ has already been opened.
9 views (last 30 days)
Show older comments
Hello i designed an APP how conect with a Industrial Camera.
it worked all fine until the last Days.
I got a Few errors ( shown Below)
I don't know why i get this Errors now, because i changend nothing. The software worked well before.
I think it is a connection problemwith the Camera. Maybe someone can help me.
If you need some more Codes tell me wich part you wanna see.
Thanks for your help.
The Errors
Warning: The specified amount of data was not returned within the Timeout period.
'tcpip' unable to read any data. For more information on possible reasons, see TCPIP Read Warnings.
Error using icinterface/fopen (line 83)
Unsuccessful open: OBJ has already been opened.
Error in ConStop (line 11)
fopen(t);
Error in GetMeasurements (line 25)
ConStop(t);
The code where i Connect the Camera:
% Button pushed function: scanButton
function scanButtonPushed(app, event)
if app.min_grau == 0 && app.max_grau == 0
message = 'Please create or load a grayscale profile first!';
uialert(app.GocatorInterfaceUIFigure , message , 'Fehler');
return
else
try
scanning = uiprogressdlg(app.GocatorInterfaceUIFigure,"Title",...
'scanning ...',"Indeterminate","on");
[app.xyz,app.graustufe] = GetSurface(GetMeasurements(app.r,app.tc),...
app.min_grau,...
app.max_grau,...
app.boden_max);
if app.scanmultipleobjectsCheckBox.Value == 1
app.graustufe_rs = multiZuschnitt(app.graustufe);
else
app.graustufe_rs = zuschneiden(app.graustufe);
end
app.bildpfad = DatenSpeichern(app.xyz,app.graustufe,app.graustufe_rs,...
app.createCSVfileCheckBox.Value,...
app.pfad);
close(scanning);
uialert(app.GocatorInterfaceUIFigure, 'Scan successfull!', '',"Icon","success");
catch
message = sprintf(['Error while transmitting data! \n Check Gocator' ...
' connections and scan settings.']);
uialert(app.GocatorInterfaceUIFigure , message , 'Error');
end
end
end
The Code where i start working with the Camera:
% Button pushed function:
% createandsavegrayscaleprofileButton
function createandsavegrayscaleprofileButtonPushed(app, event)
h = inputdlg('Object height?(mm)');
figure(app.GocatorInterfaceUIFigure)
h = str2double(h{1});
if isempty(h)
message = sprintf('No object height specified!');
uialert(app.GocatorInterfaceUIFigure , message , 'Error');
return
end
message = 'Please remove the Object from the scanned area and confirm with "OK"!';
bereit = uiconfirm(app.GocatorInterfaceUIFigure,message,'');
figure(app.GocatorInterfaceUIFigure)
bereit = strcmp(bereit,'OK');
if bereit
scanning = uiprogressdlg(app.GocatorInterfaceUIFigure,"Title",...
'scanning ...',"Indeterminate","on");
[app.xyz,app.graustufe] = GetSurface(GetMeasurements(app.r,app.tc),...
0,...
100000,...
0);
close(scanning);
app.boden_min = min(app.xyz(:,3));
app.boden_max = max(app.xyz(:,3));
if app.boden_max - app.boden_min > 2000
message = sprintf('Scanned surface uneven! Please adjust!');
uialert(app.GocatorInterfaceUIFigure , message , 'Error');
return
end
app.boden_max = app.boden_max + 1000;
app.min_grau = mean(app.xyz(:,3));
app.max_grau = app.min_grau + (h*1200);
[tmpfile,tmppfad] = uiputfile('*.mat');
tmpfullfile = strcat(tmppfad,tmpfile);
if tmpfile == 0
figure(app.GocatorInterfaceUIFigure)
uialert(app.GocatorInterfaceUIFigure, 'canceled', '');
return
end
val1 = app.min_grau;
val2 = app.max_grau;
val3 = app.boden_max;
save(tmpfullfile,'val1','val2','val3');
figure(app.GocatorInterfaceUIFigure)
uialert(app.GocatorInterfaceUIFigure, 'saved successfully!', '',"Icon","success");
else
figure(app.GocatorInterfaceUIFigure)
uialert(app.GocatorInterfaceUIFigure, 'canceled', '');
end
0 Comments
Accepted Answer
Harald
on 7 Jul 2023
Hi,
it might be too late for the OP but in case others read this:
The error message indicates a connection that has not been closed properly. If you cannot figure out how to close it, the easiest is probably to restart MATLAB and in the worst case, your computer.
In general, when your code opens an interface, be sure to properly close it when you are done. For example inside functions, onCleanup can be helpful. For apps, this may be something to do in the CloseRequestFcn. Another approach could be try / catch.
Best wishes,
Harald
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!