Skip to content

Commit 2d937fa

Browse files
committed
setting the txtime to zero on both fixes the delay
1 parent 1f93cee commit 2d937fa

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

epoll-test/src/test/java/tel/schich/javacan/test/util/IsotpListenerTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import tel.schich.javacan.IsotpSocketAddress;
3434
import tel.schich.javacan.platform.linux.epoll.EPollSelector;
3535
import tel.schich.javacan.test.CanTestHelper;
36+
import tel.schich.javacan.util.CanUtils;
3637
import tel.schich.javacan.util.IsotpListener;
3738
import tel.schich.javacan.util.MessageHandler;
3839

@@ -60,11 +61,15 @@ void testBroker() throws Exception {
6061

6162
IsotpSocketAddress addrA = IsotpSocketAddress.isotpAddress(SFF_ECU_REQUEST_BASE + DESTINATION_ECU_1);
6263
IsotpSocketAddress addrB = IsotpSocketAddress.isotpAddress(SFF_ECU_RESPONSE_BASE + DESTINATION_ECU_1);
64+
final IsotpOptions isotpOptions = IsotpOptions.DEFAULT
65+
.withFrameTransmissionTime(IsotpOptions.FRAME_TXTIME_ZERO);
6366

6467
try (IsotpListener broker = new IsotpListener(threadFactory, EPollSelector.open(), Duration.ofSeconds(5))) {
6568
try (IsotpCanChannel a = CanChannels.newIsotpChannel()) {
6669
try (IsotpCanChannel b = CanChannels.newIsotpChannel()) {
67-
a.setOption(IsotpCanSocketOptions.OPTS, IsotpOptions.DEFAULT.withFrameTransmissionTime(IsotpOptions.FRAME_TXTIME_ZERO));
70+
a.setOption(IsotpCanSocketOptions.OPTS, isotpOptions);
71+
b.setOption(IsotpCanSocketOptions.OPTS, isotpOptions);
72+
6873
final ByteBuffer buf = IsotpCanChannel.allocateSufficientMemory();
6974
final Lock lock = new ReentrantLock();
7075
final Condition condition = lock.newCondition();
@@ -81,7 +86,7 @@ void testBroker() throws Exception {
8186

8287
try {
8388
lock.lock();
84-
assertTrue(condition.await(120, TimeUnit.SECONDS), "The backing CAN socket should be fast enough to reach 4096 bytes within 120 seconds of ping-pong");
89+
assertTrue(condition.await(20, TimeUnit.SECONDS), "The backing CAN socket should be fast enough to reach 4096 bytes within 20 seconds of ping-pong");
8590
} finally {
8691
lock.unlock();
8792
}
@@ -109,10 +114,10 @@ public PingPong(Lock lock, Condition condition, ByteBuffer buf) {
109114

110115
@Override
111116
public void handle(IsotpCanChannel ch, ByteBuffer buffer) {
112-
// int length = buffer.remaining();
113-
// if (length % 200 == 0) {
114-
// LOGGER.info(String.format("(%04d) -> %08X#%s%n", length, ch.getTxAddress().getId(), CanUtils.hexDump(buffer)));
115-
// }
117+
int length = buffer.remaining();
118+
if (LOGGER.isInfoEnabled() && length % 200 == 0) {
119+
LOGGER.info(String.format("(%04d) -> %08X#%s%n", length, ch.getTxAddress().getId(), CanUtils.hexDump(buffer)));
120+
}
116121
buf.clear();
117122
buf.put(buffer);
118123
buf.put(randomByte());

0 commit comments

Comments
 (0)