Commit e641be2b authored by Vincent van Beveren's avatar Vincent van Beveren

Missed a location where timeout could occur

parent 69df5429
......@@ -28,7 +28,7 @@ import org.luaj.vm2.LuaValue;
public abstract class DataSource {
private final static int MAX_RETRIES = 3;
private final static int MAX_RETRIES = 20;
private String _condition;
private static final Logger LOG = Logger.getLogger(DataSource.class.getSimpleName());
......@@ -58,8 +58,18 @@ public abstract class DataSource {
public void update(DDMIContext ctx)
{
byte[] area = readMedia(ctx, start, ( end - start ) + 1);
byte[] area = null;
for (int retry = 0; retry < MAX_RETRIES; retry++)
{
try {
area = readMedia(ctx, start, ( end - start ) + 1);
} catch (RuntimeException re) {
if (retry == MAX_RETRIES - 1) throw re;
}
}
if (area == null) return;
write(ctx, offset, new byte[] { SFPUtils.checkSum(area, 0, ( end - start ) + 1) } );
}
......@@ -129,7 +139,20 @@ public abstract class DataSource {
}
// System.out.printf("Rescaling write, old-off=%d new-off=%d old-len=%d new-len=%d\n", off, nOff, data.length, nLen);
byte[] newData = read(ctx, nOff, nLen);
byte[] newData = null;
for (int retry = 0; retry < MAX_RETRIES; retry++)
{
newData = read(ctx, nOff, nLen);
if (newData != null) break;
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
}
if (newData == null) {
throw new RuntimeException("Failed to cache EEPROM data");
}
System.arraycopy(data, 0, newData, err, data.length);
off = nOff;
......@@ -263,8 +286,15 @@ public abstract class DataSource {
return c.read(ctx, off, len);
}
}
return readMedia(ctx, off, len);
for (int retry = 0; retry < MAX_RETRIES; retry++)
{
try {
return readMedia(ctx, off, len);
} catch (RuntimeException re) {
if (retry == MAX_RETRIES - 1) throw re;
}
}
throw new AssertionError("Unreachable code");
}
public void write(DDMIContext ctx, int off, byte[] data)
......@@ -283,7 +313,14 @@ public abstract class DataSource {
}
writeMedia(ctx, off, data);
for (int retry = 0; retry < MAX_RETRIES; retry++)
{
try {
writeMedia(ctx, off, data);
} catch (RuntimeException re) {
if (retry == MAX_RETRIES - 1) throw re;
}
}
}
......
......@@ -254,7 +254,7 @@ public class DollyModel implements SFPDeviceListener, SFPProviderListener {
DDMIValue v = _selectedValues.get(_counter);
LOG.info("Copying value " + v.getLabel());
LOG.info("Copying value " + v.getName());
byte[] value;
try {
value = _vg.getValue(v);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment