Skip to content

Commit 0949fc0

Browse files
committed
Fix: add max retry limit and error handling to MATLAB read loop - Fixes #239
1 parent 3975bbd commit 0949fc0

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

concore_read.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@
88
catch exc
99
ins = inistr;
1010
end
11-
while length(ins) == 0
11+
maxretries = 5;
12+
attempts = 0;
13+
while length(ins) == 0 && attempts < maxretries
1214
pause(concore.delay);
13-
input1 = fopen(strcat(concore.inpath,num2str(port),'/',name));
14-
ins = fscanf(input1,'%c');
15-
fclose(input1);
15+
try
16+
input1 = fopen(strcat(concore.inpath,num2str(port),'/',name));
17+
ins = fscanf(input1,'%c');
18+
fclose(input1);
19+
catch exc
20+
end
1621
concore.retrycount = concore.retrycount + 1;
22+
attempts = attempts + 1;
23+
end
24+
if length(ins) == 0
25+
ins = inistr;
1726
end
1827
concore.s = strcat(concore.s, ins);
1928
result = eval(ins);

0 commit comments

Comments
 (0)