Changeset 147
- Timestamp:
- 09/20/2008 09:34:08 PM (5 years ago)
- Location:
- trunk/src/com/romraider/io/j2534
- Files:
-
- 2 edited
-
api/J2534.java (modified) (1 diff)
-
op20/J2534OpenPort20.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/romraider/io/j2534/api/J2534.java
r144 r147 18 18 void writeMsg(int channelId, byte[] data); 19 19 20 byte[] readMsg(int channelId );20 byte[] readMsg(int channelId, long timeout); 21 21 22 22 void stopMsgFilter(int channelId, int msgId); -
trunk/src/com/romraider/io/j2534/op20/J2534OpenPort20.java
r144 r147 20 20 import static com.romraider.io.j2534.op20.OpenPort20.PassThruWriteMsgs; 21 21 import static com.romraider.io.j2534.op20.OpenPort20.STATUS_NOERROR; 22 import static com.romraider.util.HexUtil.asHex; 23 import static java.lang.System.currentTimeMillis; 22 24 23 25 public final class J2534OpenPort20 implements J2534 { … … 90 92 91 93 // FIX - Needs to check msg type and retry until msg received 92 public byte[] readMsg(int channelId) { 94 public byte[] readMsg(int channelId, long timeout) { 95 long end = currentTimeMillis() + timeout; 96 do { 97 PassThruMessage msg = doReadMsg(channelId); 98 System.out.println("Response: [ProtocolID=" + msg.ProtocolID + "|RxStatus=" + msg.RxStatus + "|TxFlags=" + msg.TxFlags + "|Timestamp=" + msg.Timestamp + "|DataSize=" + msg.DataSize + "|Data=" + asHex(msg.Data) + "]"); 99 if (isResponse(msg)) return data(msg); 100 } while (currentTimeMillis() <= end); 101 throw new J2534Exception("Read timeout."); 102 } 103 104 private boolean isResponse(PassThruMessage msg) { 105 // FIX - Complete! 106 return false; 107 } 108 109 private PassThruMessage doReadMsg(int channelId) { 93 110 PassThruMessage msg = passThruMessage(); 94 111 int[] pNumMsgs = {1}; 95 112 int status = PassThruReadMsgs(channelId, msg, pNumMsgs, 0); 96 113 if (status != STATUS_NOERROR) handleError(status); 97 return data(msg);114 return msg; 98 115 } 99 116
Note: See TracChangeset
for help on using the changeset viewer.