Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sfp-plus-i2c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
sfp-plus-i2c
Commits
69df5429
Commit
69df5429
authored
Jan 03, 2018
by
Vincent van Beveren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added retries when reading in datasource, and more delays
parent
19e2a50f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
+30
-7
DataSource.java
sw/jsfp/src/nl/nikhef/sfp/ddmi/DataSource.java
+30
-7
No files found.
sw/jsfp/src/nl/nikhef/sfp/ddmi/DataSource.java
View file @
69df5429
...
...
@@ -28,6 +28,8 @@ import org.luaj.vm2.LuaValue;
public
abstract
class
DataSource
{
private
final
static
int
MAX_RETRIES
=
3
;
private
String
_condition
;
private
static
final
Logger
LOG
=
Logger
.
getLogger
(
DataSource
.
class
.
getSimpleName
());
public
final
int
start
;
...
...
@@ -88,11 +90,23 @@ public abstract class DataSource {
public
synchronized
byte
[]
read
(
DDMIContext
ctx
,
int
off
,
int
len
)
{
byte
[]
b
;
byte
[]
b
=
null
;
if
(!
ctx
.
scratch
.
containsKey
(
key
))
{
for
(
int
retry
=
0
;
retry
<
MAX_RETRIES
;
retry
++)
{
try
{
b
=
readMedia
(
ctx
,
start
,
end
-
start
+
1
);
//if (b == null) return new byte[len];
break
;
}
catch
(
RuntimeException
re
)
{
if
(
retry
==
MAX_RETRIES
-
1
)
throw
re
;
try
{
Thread
.
sleep
(
5
);
}
catch
(
InterruptedException
ie
)
{
// ignore
}
}
}
if
(
b
==
null
)
return
null
;
ctx
.
scratch
.
put
(
key
,
b
);
}
else
{
...
...
@@ -130,10 +144,19 @@ public abstract class DataSource {
// With EEPROM, write in increments
for
(
int
i
=
0
;
i
<
data
.
length
;
i
+=
8
)
{
for
(
int
retry
=
0
;
retry
<
MAX_RETRIES
;
retry
++)
{
try
{
writeMedia
(
ctx
,
off
+
i
,
Arrays
.
copyOfRange
(
data
,
i
,
i
+
8
));
break
;
}
catch
(
RuntimeException
re
)
{
if
(
retry
==
MAX_RETRIES
-
1
)
throw
re
;
try
{
Thread
.
sleep
(
30
);
}
catch
(
InterruptedException
e
)
{
Thread
.
sleep
(
10
);
}
catch
(
InterruptedException
ie
)
{
// ignore
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment