本文整理汇总了Java中gnu.io.SerialPort.DATABITS_6属性的典型用法代码示例。如果您正苦于以下问题:Java SerialPort.DATABITS_6属性的具体用法?Java SerialPort.DATABITS_6怎么用?Java SerialPort.DATABITS_6使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gnu.io.SerialPort
的用法示例。
在下文中一共展示了SerialPort.DATABITS_6属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDatabits
/**
* Sets the number of data bits.
*
* @param databits the new number of data bits.
*/
public void setDatabits(int databits) throws IllegalArgumentException {
if (!SerialParameterValidator.isDataBitsValid(databits)) {
throw new IllegalArgumentException("Databit '" + databits + "' invalid");
}
switch (databits) {
case 5:
m_Databits = SerialPort.DATABITS_5;
break;
case 6:
m_Databits = SerialPort.DATABITS_6;
break;
case 7:
m_Databits = SerialPort.DATABITS_7;
break;
case 8:
m_Databits = SerialPort.DATABITS_8;
break;
default:
m_Databits = SerialPort.DATABITS_8;
break;
}
}
示例2: setDatabits
/**
* Sets the number of data bits.
*
* @param databits the new number of data bits.
*/
public void setDatabits(int databits) throws IllegalArgumentException {
if (!SerialParameterValidator.isDataBitsValid(databits)) {
throw new IllegalArgumentException("Databit '" + databits + "' invalid");
}
switch (databits) {
case 5:
m_Databits = SerialPort.DATABITS_5;
break;
case 6:
m_Databits = SerialPort.DATABITS_6;
break;
case 7:
m_Databits = SerialPort.DATABITS_7;
break;
case 8:
m_Databits = SerialPort.DATABITS_8;
break;
default:
m_Databits = SerialPort.DATABITS_8;
break;
}
}
示例3: getDatabitsString
/**
* Returns the number of data bits as <tt>String</tt>.
*
* @return the number of data bits as <tt>String</tt>.
*/
public String getDatabitsString() {
switch (m_Databits) {
case SerialPort.DATABITS_5:
return "5";
case SerialPort.DATABITS_6:
return "6";
case SerialPort.DATABITS_7:
return "7";
case SerialPort.DATABITS_8:
return "8";
default:
return "8";
}
}
示例4: getDatabitsString
/**
* Gets data bits as a <code>String</code>.
*
* @return Current data bits setting.
*/
public String getDatabitsString() {
switch (_databits) {
case SerialPort.DATABITS_5:
return "5"; //$NON-NLS-1$
case SerialPort.DATABITS_6:
return "6"; //$NON-NLS-1$
case SerialPort.DATABITS_7:
return "7"; //$NON-NLS-1$
case SerialPort.DATABITS_8:
return "8"; //$NON-NLS-1$
default:
return "8"; //$NON-NLS-1$
}
}
示例5: setDatabits
/**
* Sets data bits.
*
* @param databits
* New data bits setting.
*/
public void setDatabits(final String databits) {
if (databits.equals("5")) { //$NON-NLS-1$
this._databits = SerialPort.DATABITS_5;
}
if (databits.equals("6")) { //$NON-NLS-1$
this._databits = SerialPort.DATABITS_6;
}
if (databits.equals("7")) { //$NON-NLS-1$
this._databits = SerialPort.DATABITS_7;
}
if (databits.equals("8")) { //$NON-NLS-1$
this._databits = SerialPort.DATABITS_8;
}
}
示例6: setDatabits
/**
* Sets the number of data bits from the given <tt>String</tt>.
*
* @param databits the new number of data bits as <tt>String</tt>.
*/
public void setDatabits(String databits) {
if (databits.equals("5")) {
m_Databits = SerialPort.DATABITS_5;
}
if (databits.equals("6")) {
m_Databits = SerialPort.DATABITS_6;
}
if (databits.equals("7")) {
m_Databits = SerialPort.DATABITS_7;
}
if (databits.equals("8")) {
m_Databits = SerialPort.DATABITS_8;
}
}
示例7: getDataBits
public static int getDataBits(String sBitsParam) {
switch (sBitsParam) {
case "5":
return SerialPort.DATABITS_5;
case "6":
return SerialPort.DATABITS_6;
case "7":
return SerialPort.DATABITS_7;
case "8":
return SerialPort.DATABITS_8;
default:
return SerialPort.DATABITS_8;
}
}
示例8: getDatabitsString
/**
* Returns the number of data bits as <tt>String</tt>.
*
* @return the number of data bits as <tt>String</tt>.
*/
public String getDatabitsString() {
switch (m_Databits) {
case SerialPort.DATABITS_5:
return "5";
case SerialPort.DATABITS_6:
return "6";
case SerialPort.DATABITS_7:
return "7";
case SerialPort.DATABITS_8:
return "8";
default:
return "8";
}
}
示例9: setDatabits
/**
* Sets data bits.
*
* @param databits
* New data bits setting.
*/
public void setDatabits(final String databits){
if (databits.equals("5")) { //$NON-NLS-1$
this.databits = SerialPort.DATABITS_5;
}
if (databits.equals("6")) { //$NON-NLS-1$
this.databits = SerialPort.DATABITS_6;
}
if (databits.equals("7")) { //$NON-NLS-1$
this.databits = SerialPort.DATABITS_7;
}
if (databits.equals(Messages.SerialParameters_4)) {
this.databits = SerialPort.DATABITS_8;
}
}
示例10: getDatabitsString
/**
* Gets data bits as a <code>String</code>.
*
* @return Current data bits setting.
*/
public String getDatabitsString(){
switch (databits) {
case SerialPort.DATABITS_5:
return "5"; //$NON-NLS-1$
case SerialPort.DATABITS_6:
return "6"; //$NON-NLS-1$
case SerialPort.DATABITS_7:
return "7"; //$NON-NLS-1$
case SerialPort.DATABITS_8:
return "8"; //$NON-NLS-1$
default:
return "8"; //$NON-NLS-1$
}
}
示例11: open
/**
* @param def has 2 formats: e.g. "COM5,57600,8,1,N" or "ttyS3,9600"
* @return the connection, never null
* @throws IOException if we cannot parse the definition
*/
public static RXTXConnection open(final String def) throws IOException {
StringTokenizer st = new StringTokenizer(def, ",");
int count = st.countTokens();
final int minParam = 2;
final int maxParam = 5;
if ((count < minParam) || (count > maxParam)) {
throw new IOException("Open comm string must contain " + minParam + " to " + maxParam + " parameters");
}
String portName = st.nextToken();
String baudRateStr = st.nextToken();
int baudRate;
try {
baudRate = Integer.parseInt(baudRateStr);
} catch (NumberFormatException e) {
throw new IOException("Baud rate must be number: \"" + baudRateStr + "\"");
}
String dataBitsStr = "8";
if (count > minParam) {
dataBitsStr = st.nextToken().trim();
}
int dataBits;
if ("5".equals(dataBitsStr)) {
dataBits = SerialPort.DATABITS_5;
} else if ("6".equals(dataBitsStr)) {
dataBits = SerialPort.DATABITS_6;
} else if ("7".equals(dataBitsStr)) {
dataBits = SerialPort.DATABITS_7;
} else if ("8".equals(dataBitsStr)) {
dataBits = SerialPort.DATABITS_8;
} else {
throw new IOException("Data bits value may only be one of 5, 6, 7 or 8");
}
String stopBitsStr = "1";
if (count > minParam + 1) {
stopBitsStr = st.nextToken().trim();
}
int stopBits;
if ("1".equals(stopBitsStr)) {
stopBits = SerialPort.STOPBITS_1;
} else if ("1.5".equals(stopBitsStr)) {
stopBits = SerialPort.STOPBITS_1_5;
} else if ("2".equals(stopBitsStr)) {
stopBits = SerialPort.STOPBITS_2;
} else {
throw new IOException("Stop bits value may one be one of 1, 1.5 or 2");
}
String parityStr = "N";
if (count > minParam + 2) {
parityStr = st.nextToken().trim().toUpperCase();
}
int parity;
if ("E".equals(parityStr)) {
parity = SerialPort.PARITY_EVEN;
} else if ("O".equals(parityStr)) {
parity = SerialPort.PARITY_ODD;
} else if ("N".equals(parityStr)) {
parity = SerialPort.PARITY_NONE;
} else if ("M".equals(parityStr)) {
parity = SerialPort.PARITY_MARK;
} else {
throw new IOException("Parity value may only be one of E, O, N, M");
}
return new RXTXConnection(portName, baudRate, dataBits, stopBits, parity);
}