Fix naming issues in RxtxChannelConfig / Format cleanup
This commit is contained in:
parent
0c3732cad5
commit
4528c793ba
@ -15,8 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.transport.rxtx;
|
package io.netty.transport.rxtx;
|
||||||
|
|
||||||
import static io.netty.transport.rxtx.RxtxChannelOptions.*;
|
import gnu.io.CommPort;
|
||||||
|
import gnu.io.CommPortIdentifier;
|
||||||
|
import gnu.io.SerialPort;
|
||||||
import io.netty.buffer.BufType;
|
import io.netty.buffer.BufType;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelConfig;
|
import io.netty.channel.ChannelConfig;
|
||||||
@ -30,9 +31,7 @@ import java.net.SocketAddress;
|
|||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.nio.channels.NotYetConnectedException;
|
import java.nio.channels.NotYetConnectedException;
|
||||||
|
|
||||||
import gnu.io.CommPort;
|
import static io.netty.transport.rxtx.RxtxChannelOptions.*;
|
||||||
import gnu.io.CommPortIdentifier;
|
|
||||||
import gnu.io.SerialPort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A channel to a serial device using the RXTX library.
|
* A channel to a serial device using the RXTX library.
|
||||||
@ -111,9 +110,9 @@ public class RxtxChannel extends AbstractOioByteChannel {
|
|||||||
serialPort = (SerialPort) commPort;
|
serialPort = (SerialPort) commPort;
|
||||||
serialPort.setSerialPortParams(
|
serialPort.setSerialPortParams(
|
||||||
config().getOption(BAUD_RATE),
|
config().getOption(BAUD_RATE),
|
||||||
config().getOption(DATA_BITS).getValue(),
|
config().getOption(DATA_BITS).value(),
|
||||||
config().getOption(STOP_BITS).getValue(),
|
config().getOption(STOP_BITS).value(),
|
||||||
config().getOption(PARITY_BIT).getValue()
|
config().getOption(PARITY_BIT).value()
|
||||||
);
|
);
|
||||||
serialPort.setDTR(config().getOption(DTR));
|
serialPort.setDTR(config().getOption(DTR));
|
||||||
serialPort.setRTS(config().getOption(RTS));
|
serialPort.setRTS(config().getOption(RTS));
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.transport.rxtx;
|
package io.netty.transport.rxtx;
|
||||||
|
|
||||||
import static io.netty.transport.rxtx.RxtxChannelOptions.*;
|
import gnu.io.SerialPort;
|
||||||
|
|
||||||
import io.netty.channel.ChannelOption;
|
import io.netty.channel.ChannelOption;
|
||||||
import io.netty.channel.DefaultChannelConfig;
|
import io.netty.channel.DefaultChannelConfig;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import gnu.io.SerialPort;
|
import static io.netty.transport.rxtx.RxtxChannelOptions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A configuration class for RXTX device connections.
|
* A configuration class for RXTX device connections.
|
||||||
@ -49,17 +48,17 @@ public class RxtxChannelConfig extends DefaultChannelConfig {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getValue() {
|
public int value() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stopbits ofValue(int value) {
|
public static Stopbits valueOf(int value) {
|
||||||
for (Stopbits stopbit : Stopbits.values()) {
|
for (Stopbits stopbit : Stopbits.values()) {
|
||||||
if (stopbit.value == value) {
|
if (stopbit.value == value) {
|
||||||
return stopbit;
|
return stopbit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unknown value for Stopbits: " + value + '.');
|
throw new IllegalArgumentException("unknown " + Stopbits.class.getSimpleName() + " value: " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,17 +86,17 @@ public class RxtxChannelConfig extends DefaultChannelConfig {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getValue() {
|
public int value() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Databits ofValue(int value) {
|
public static Databits valueOf(int value) {
|
||||||
for (Databits databit : Databits.values()) {
|
for (Databits databit : Databits.values()) {
|
||||||
if (databit.value == value) {
|
if (databit.value == value) {
|
||||||
return databit;
|
return databit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unknown value for Databits: " + value + '.');
|
throw new IllegalArgumentException("unknown " + Databits.class.getSimpleName() + " value: " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,30 +130,25 @@ public class RxtxChannelConfig extends DefaultChannelConfig {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getValue() {
|
public int value() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Paritybit ofValue(int value) {
|
public static Paritybit valueOf(int value) {
|
||||||
for (Paritybit paritybit : Paritybit.values()) {
|
for (Paritybit paritybit : Paritybit.values()) {
|
||||||
if (paritybit.value == value) {
|
if (paritybit.value == value) {
|
||||||
return paritybit;
|
return paritybit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unknown value for paritybit: " + value + '.');
|
throw new IllegalArgumentException("unknown " + Paritybit.class.getSimpleName() + " value: " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private volatile int baudrate = 115200;
|
private volatile int baudrate = 115200;
|
||||||
|
|
||||||
private volatile boolean dtr;
|
private volatile boolean dtr;
|
||||||
|
|
||||||
private volatile boolean rts;
|
private volatile boolean rts;
|
||||||
|
|
||||||
private volatile Stopbits stopbits = Stopbits.STOPBITS_1;
|
private volatile Stopbits stopbits = Stopbits.STOPBITS_1;
|
||||||
|
|
||||||
private volatile Databits databits = Databits.DATABITS_8;
|
private volatile Databits databits = Databits.DATABITS_8;
|
||||||
|
|
||||||
private volatile Paritybit paritybit = Paritybit.NONE;
|
private volatile Paritybit paritybit = Paritybit.NONE;
|
||||||
|
|
||||||
public RxtxChannelConfig(RxtxChannel channel) {
|
public RxtxChannelConfig(RxtxChannel channel) {
|
||||||
@ -163,8 +157,7 @@ public class RxtxChannelConfig extends DefaultChannelConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<ChannelOption<?>, Object> getOptions() {
|
public Map<ChannelOption<?>, Object> getOptions() {
|
||||||
return getOptions(super.getOptions(),
|
return getOptions(super.getOptions(), BAUD_RATE, DTR, RTS, STOP_BITS, DATA_BITS, PARITY_BIT);
|
||||||
BAUD_RATE, DTR, RTS, STOP_BITS, DATA_BITS, PARITY_BIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
Loading…
Reference in New Issue
Block a user