|
|
@ -29,15 +29,15 @@ public class HexDataSender {
|
|
|
|
b.handler(new ChannelInitializer<SocketChannel>() {
|
|
|
|
b.handler(new ChannelInitializer<SocketChannel>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void initChannel(SocketChannel ch) {
|
|
|
|
public void initChannel(SocketChannel ch) {
|
|
|
|
ChannelPipeline p = ch.pipeline();
|
|
|
|
//ChannelPipeline p = ch.pipeline();
|
|
|
|
p.addLast(new HexDataEncoder());
|
|
|
|
//p.addLast(new HexDataEncoder());
|
|
|
|
p.addLast(new HexDataSenderHandler(hexData));
|
|
|
|
//p.addLast(new HexDataSenderHandler(hexData));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Start the client.
|
|
|
|
// Start the client.
|
|
|
|
ChannelFuture f = b.connect(host, port).sync();
|
|
|
|
ChannelFuture f = b.connect(host, port).sync();
|
|
|
|
|
|
|
|
f.channel().writeAndFlush(Unpooled.copiedBuffer(hexData.getBytes())).sync();
|
|
|
|
// Wait until the connection is closed.
|
|
|
|
// Wait until the connection is closed.
|
|
|
|
f.channel().closeFuture().sync();
|
|
|
|
f.channel().closeFuture().sync();
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
@ -48,9 +48,9 @@ public class HexDataSender {
|
|
|
|
public static String IP = "10.10.21.18";
|
|
|
|
public static String IP = "10.10.21.18";
|
|
|
|
public static int PORT = 8001;
|
|
|
|
public static int PORT = 8001;
|
|
|
|
|
|
|
|
|
|
|
|
public static void Open(String sb_id) throws Exception {
|
|
|
|
public static void Open() throws Exception {
|
|
|
|
//开
|
|
|
|
//开
|
|
|
|
String hexData = "16 00 34 F5 41 11 FE 82 0D 02 ? 00 00 00 00 00 00 01 00 00 01".replace("?", sb_id).replace(" ", "");
|
|
|
|
String hexData = "16 00 34 F5 41 11 FE 82 0D 02 6D FF 00 00 00 00 00 00 01 00 00 01".replace(" ","");
|
|
|
|
HexDataSender sender = new HexDataSender(IP, PORT);
|
|
|
|
HexDataSender sender = new HexDataSender(IP, PORT);
|
|
|
|
sender.sendHexData(hexData);
|
|
|
|
sender.sendHexData(hexData);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -63,9 +63,9 @@ public class HexDataSender {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
Close("6D FF");
|
|
|
|
//Close("6D FF");
|
|
|
|
//Thread.sleep(3000);
|
|
|
|
|
|
|
|
//Open("6D FF");
|
|
|
|
Open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|