update j2534 readmsgs

git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@176 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
kascade 2008-11-08 03:31:38 +00:00
parent b7633fc588
commit dc972ef62f
1 changed files with 12 additions and 9 deletions

View File

@ -108,17 +108,20 @@ public final class J2534OpenPort20 implements J2534 {
return data;
}
// FIX - Optimise & cleanup!!!
private byte[] doReadMsg(int channelId, int timeout) {
PassThruMessage msg = passThruMessage();
int[] pNumMsgs = {1};
PassThruMessage msg1 = passThruMessage();
PassThruMessage msg2 = passThruMessage();
PassThruMessage msg3 = passThruMessage();
PassThruMessage msg4 = passThruMessage();
PassThruMessage[] msgs = {msg1, msg2, msg3, msg4};
int[] pNumMsgs = {4};
int status = PassThruReadMsgs(channelId, msgs, pNumMsgs, timeout);
if (status != STATUS_NOERROR && status != STATUS_ERR_TIMEOUT) handleError(status);
LOGGER.trace("Read Msg: " + toString(msg2) + toString(msg4));
List<byte[]> responses = new ArrayList<byte[]>();
for (int i = 0; i < 4; i++) {
int status = PassThruReadMsgs(channelId, msg, pNumMsgs, timeout);
if (status != STATUS_NOERROR && status != STATUS_ERR_TIMEOUT) handleError(status);
LOGGER.trace("Read Msg: " + toString(msg));
if (!isResponse(msg)) continue;
responses.add(data(msg));
}
responses.add(data(msg2));
responses.add(data(msg4));
return concat(responses);
}