You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ld...@apache.org on 2020/09/01 16:49:30 UTC
[plc4x] 08/12: Fix socketcan transport.
This is an automated email from the ASF dual-hosted git repository.
ldywicki pushed a commit to branch feature/socketcan
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 831e3e1177b0c395b3fc68b9c64c4879ab3b9cc1
Author: Ćukasz Dywicki <lu...@code-house.org>
AuthorDate: Sat Aug 29 10:08:17 2020 +0200
Fix socketcan transport.
---
.../plc4x/java/transport/socketcan/netty/SocketCANChannel.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/netty/SocketCANChannel.java b/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/netty/SocketCANChannel.java
index 305d452..b302a7d 100644
--- a/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/netty/SocketCANChannel.java
+++ b/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/netty/SocketCANChannel.java
@@ -114,10 +114,10 @@ public class SocketCANChannel extends OioByteStreamChannel {
try {
while (!isInputShutdown()) {
CanFrame frame = handle.read();
- ByteBuf frameBytes = ByteBufAllocator.DEFAULT.buffer();
- frameBytes.writeBytes(frame.getBuffer());
- String dump = ByteBufUtil.prettyHexDump(frameBytes);
- System.out.println(frame + "\n" + dump);
+// ByteBuf frameBytes = ByteBufAllocator.DEFAULT.buffer();
+// frameBytes.writeBytes(frame.getBuffer());
+// String dump = ByteBufUtil.prettyHexDump(frameBytes);
+// System.out.println(frame + "\n" + dump);
buffer.writeBytes(frame.getBuffer());
}
} catch (IOException e) {
@@ -245,6 +245,7 @@ public class SocketCANChannel extends OioByteStreamChannel {
public void write(byte[] b, int off, int len) throws IOException {
ByteBuffer buffer = ByteBuffer.allocateDirect(len - off);
buffer.put(b, off, len);
+ buffer.flip();
CanFrame frame = CanFrame.create(buffer);
rawCanChannel.write(frame);
}