当前位置: 首页>>代码示例>>Java>>正文


Java SerialPort.STOPBITS_2属性代码示例

本文整理汇总了Java中gnu.io.SerialPort.STOPBITS_2属性的典型用法代码示例。如果您正苦于以下问题:Java SerialPort.STOPBITS_2属性的具体用法?Java SerialPort.STOPBITS_2怎么用?Java SerialPort.STOPBITS_2使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gnu.io.SerialPort的用法示例。


在下文中一共展示了SerialPort.STOPBITS_2属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setStopbits

/**
 * Sets the number of stop bits.
 *
 * @param stopbits the new number of stop bits setting.
 */
public void setStopbits(double stopbits) throws IllegalArgumentException {
  if (!SerialParameterValidator.isStopbitsValid(stopbits)) {
    throw new IllegalArgumentException("stopbit value '" +
        stopbits + "' not valid");
  }

  if (stopbits == 1) {
    m_Stopbits = SerialPort.STOPBITS_1;
  } else if (stopbits == 1.5) {
    m_Stopbits = SerialPort.STOPBITS_1_5;
  } else if (stopbits == 2) {
    m_Stopbits = SerialPort.STOPBITS_2;
  } else {
    m_Stopbits = SerialPort.STOPBITS_1;
  }
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:21,代码来源:SerialParameters.java

示例2: setStopbits

/**
 * Sets the number of stop bits.
 *
 * @param stopbits the new number of stop bits setting.
 */
public void setStopbits(double stopbits) throws IllegalArgumentException {
    if (!SerialParameterValidator.isStopbitsValid(stopbits)) {
        throw new IllegalArgumentException("stopbit value '" + stopbits + "' not valid");
    }

    if (stopbits == 1) {
        m_Stopbits = SerialPort.STOPBITS_1;
    } else if (stopbits == 1.5) {
        m_Stopbits = SerialPort.STOPBITS_1_5;
    } else if (stopbits == 2) {
        m_Stopbits = SerialPort.STOPBITS_2;
    } else {
        m_Stopbits = SerialPort.STOPBITS_1;
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:20,代码来源:SerialParameters.java

示例3: getStopbitsString

/**
 * Returns the number of stop bits as <tt>String</tt>.
 *
 * @return the number of stop bits as <tt>String</tt>.
 */
public String getStopbitsString() {
  switch (m_Stopbits) {
    case SerialPort.STOPBITS_1:
      return "1";
    case SerialPort.STOPBITS_1_5:
      return "1.5";
    case SerialPort.STOPBITS_2:
      return "2";
    default:
      return "1";
  }
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:17,代码来源:SerialParameters.java

示例4: getStopbitsString

/**
 * Gets stop bits setting as a <code>String</code>.
 * 
 * @return Current stop bits setting.
 */
public String getStopbitsString() {
	switch (_stopbits) {
	case SerialPort.STOPBITS_1:
		return "1"; //$NON-NLS-1$
	case SerialPort.STOPBITS_1_5:
		return "1.5"; //$NON-NLS-1$
	case SerialPort.STOPBITS_2:
		return "2"; //$NON-NLS-1$
	default:
		return "1"; //$NON-NLS-1$
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:17,代码来源:SerialParameters.java

示例5: setStopbits

/**
 * Sets stop bits.
 * 
 * @param stopbits
 *            New stop bits setting.
 */
public void setStopbits(final String stopbits) {
	if (stopbits.equals("1")) { //$NON-NLS-1$
		this._stopbits = SerialPort.STOPBITS_1;
	}
	if (stopbits.equals("1.5")) { //$NON-NLS-1$
		this._stopbits = SerialPort.STOPBITS_1_5;
	}
	if (stopbits.equals("2")) { //$NON-NLS-1$
		this._stopbits = SerialPort.STOPBITS_2;
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:17,代码来源:SerialParameters.java

示例6: setStopbits

/**
 * Sets the number of stop bits from the given <tt>String</tt>.
 *
 * @param stopbits the number of stop bits as <tt>String</tt>.
 */
public void setStopbits(String stopbits) {
  if (stopbits.equals("1")) {
    m_Stopbits = SerialPort.STOPBITS_1;
  }
  if (stopbits.equals("1.5")) {
    m_Stopbits = SerialPort.STOPBITS_1_5;
  }
  if (stopbits.equals("2")) {
    m_Stopbits = SerialPort.STOPBITS_2;
  }
}
 
开发者ID:dog-gateway,项目名称:jamod-rtu-over-tcp,代码行数:16,代码来源:SerialParameters.java

示例7: getStopBits

public static int getStopBits(String sStopBitsParam) {
    switch (sStopBitsParam) {
        case "1":
            return SerialPort.STOPBITS_1;
        case "2":
            return SerialPort.STOPBITS_2;
        default:
            return SerialPort.STOPBITS_1;
    }
}
 
开发者ID:nordpos,项目名称:nordpos,代码行数:10,代码来源:SerialPortParameters.java

示例8: getStopbitsString

/**
 * Returns the number of stop bits as <tt>String</tt>.
 *
 * @return the number of stop bits as <tt>String</tt>.
 */
public String getStopbitsString() {
    switch (m_Stopbits) {
        case SerialPort.STOPBITS_1:
            return "1";
        case SerialPort.STOPBITS_1_5:
            return "1.5";
        case SerialPort.STOPBITS_2:
            return "2";
        default:
            return "1";
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:17,代码来源:SerialParameters.java

示例9: setStopbits

/**
 * Sets stop bits.
 * 
 * @param stopbits
 *            New stop bits setting.
 */
public void setStopbits(final String stopbits){
	if (stopbits.equals("1")) { //$NON-NLS-1$
		this.stopbits = SerialPort.STOPBITS_1;
	}
	if (stopbits.equals("1.5")) { //$NON-NLS-1$
		this.stopbits = SerialPort.STOPBITS_1_5;
	}
	if (stopbits.equals("2")) { //$NON-NLS-1$
		this.stopbits = SerialPort.STOPBITS_2;
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:17,代码来源:SerialParameters.java

示例10: getStopbitsString

/**
 * Gets stop bits setting as a <code>String</code>.
 * 
 * @return Current stop bits setting.
 */
public String getStopbitsString(){
	switch (stopbits) {
	case SerialPort.STOPBITS_1:
		return "1"; //$NON-NLS-1$
	case SerialPort.STOPBITS_1_5:
		return "1.5"; //$NON-NLS-1$
	case SerialPort.STOPBITS_2:
		return "2"; //$NON-NLS-1$
	default:
		return "1"; //$NON-NLS-1$
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:17,代码来源:SerialParameters.java

示例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);
}
 
开发者ID:xafero,项目名称:travelingsales,代码行数:70,代码来源:RXTXConnection.java

示例12: getPortSettingsFromString

/**
 *
 * @param portSettings
 * @return
 */
public static DSMRPortSettings getPortSettingsFromString(String portSettings) {
    Matcher m = Pattern.compile(PORT_SETTING_REGEX).matcher(portSettings);

    if (m.find()) {
        int baudrate = Integer.parseInt(m.group(1));
        int databits = Integer.parseInt(m.group(2));
        int parity;
        int stopbits;

        char parityChar = m.group(3).toUpperCase().charAt(0);
        switch (parityChar) {
            case 'E':
                parity = SerialPort.PARITY_EVEN;
                break;
            case 'O':
                parity = SerialPort.PARITY_ODD;
                break;
            case 'N':
                parity = SerialPort.PARITY_NONE;
                break;
            default:
                logger.error("Invalid parity ({}), ignoring fixed port settings.", parityChar);

                return null;
        }
        String stopbitsString = m.group(4);

        if (stopbitsString.equals("1")) {
            stopbits = SerialPort.STOPBITS_1;
        } else if (stopbitsString.equals("1.5")) {
            stopbits = SerialPort.STOPBITS_1_5;
        } else if (stopbitsString.equals("2")) {
            stopbits = SerialPort.STOPBITS_2;
        } else {
            logger.error("Invalid stop bits({}), ignoring fixed port settings.", stopbitsString);

            return null;
        }
        return new DSMRPortSettings(baudrate, databits, parity, stopbits);
    } else {
        return null;
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:48,代码来源:DSMRPortSettings.java


注:本文中的gnu.io.SerialPort.STOPBITS_2属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。