List of usage examples for io.netty.channel.rxtx RxtxDeviceAddress RxtxDeviceAddress
public RxtxDeviceAddress(String value)
From source file:com.cmz.rxtx.RxtxClient.java
License:Apache License
public static void main(String[] args) throws Exception { EventLoopGroup group = new OioEventLoopGroup(); try {//w w w .ja v a 2 s .co m Bootstrap b = new Bootstrap(); b.group(group).channel(RxtxChannel.class).handler(new ChannelInitializer<RxtxChannel>() { @Override public void initChannel(RxtxChannel ch) throws Exception { ch.pipeline().addLast(new LineBasedFrameDecoder(32768), new StringEncoder(), new StringDecoder(), new RxtxClientHandler()); } }); ChannelFuture f = b.connect(new RxtxDeviceAddress(PORT)).sync(); f.channel().closeFuture().sync(); } finally { group.shutdownGracefully(); } }
From source file:com.hxr.javatone.concurrency.netty.official.rxtx.RxtxClient.java
License:Apache License
public static void main(String[] args) throws Exception { EventLoopGroup group = new OioEventLoopGroup(); try {//from w ww. ja v a 2s .c o m Bootstrap b = new Bootstrap(); b.group(group).channel(RxtxChannel.class).handler(new ChannelInitializer<RxtxChannel>() { @Override public void initChannel(RxtxChannel ch) throws Exception { ch.pipeline().addLast(new LineBasedFrameDecoder(32768), new StringEncoder(), new StringDecoder(), new RxtxClientHandler()); } }); ChannelFuture f = b.connect(new RxtxDeviceAddress("/dev/ttyUSB0")).sync(); f.channel().closeFuture().sync(); } finally { group.shutdownGracefully(); } }
From source file:com.whizzosoftware.hobson.api.plugin.channel.AbstractChannelObjectPlugin.java
License:Open Source License
private boolean processConfig(Configuration config) { boolean didConfigChange = false; if (config != null) { String s = (String) config.getPropertyValue("serial.port"); if (s != null && s.trim().length() > 0 && !s.equals(serialDevice)) { serialDevice = s;//from w w w . j a v a 2s . c o m setRemoteAddress(new RxtxDeviceAddress(serialDevice)); didConfigChange = true; } else { s = (String) config.getPropertyValue("serial.hostname"); if (s != null && s.trim().length() > 0 && !s.equals(serialDevice)) { serialDevice = s; setRemoteAddress(new InetSocketAddress(serialDevice, 4999)); didConfigChange = true; } } } if (serialDevice == null) { setStatus(PluginStatus.notConfigured("Neither serial port nor serial hostname are configured")); } return didConfigChange; }
From source file:com.whizzosoftware.wzwave.controller.netty.NettyZWaveController.java
License:Open Source License
public void start() { if (channel == null) { // set up Netty bootstrap bootstrap = new Bootstrap(); bootstrap.group(new OioEventLoopGroup()); bootstrap.channel(RxtxChannel.class); bootstrap.handler(new ChannelInitializer<RxtxChannel>() { @Override//ww w . j a v a2s . co m protected void initChannel(RxtxChannel channel) throws Exception { NettyZWaveController.this.channel = channel; channel.config().setBaudrate(115200); channel.config().setDatabits(RxtxChannelConfig.Databits.DATABITS_8); channel.config().setParitybit(RxtxChannelConfig.Paritybit.NONE); channel.config().setStopbits(RxtxChannelConfig.Stopbits.STOPBITS_1); channel.pipeline().addLast("decoder", new ZWaveFrameDecoder()); channel.pipeline().addLast("ack", new ACKInboundHandler()); channel.pipeline().addLast("encoder", new ZWaveFrameEncoder()); channel.pipeline().addLast("writeQueue", new FrameQueueHandler()); channel.pipeline().addLast("transaction", new TransactionInboundHandler()); channel.pipeline().addLast("handler", inboundHandler); } }); bootstrap.connect(new RxtxDeviceAddress(serialPort)).addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { sendDataFrame(new Version()); sendDataFrame(new MemoryGetId()); sendDataFrame(new InitData()); } else { onZWaveConnectionFailure(future.cause()); } } }); } }