本文整理汇总了Java中gnu.io.SerialPort.DATABITS_8属性的典型用法代码示例。如果您正苦于以下问题:Java SerialPort.DATABITS_8属性的具体用法?Java SerialPort.DATABITS_8怎么用?Java SerialPort.DATABITS_8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gnu.io.SerialPort
的用法示例。
在下文中一共展示了SerialPort.DATABITS_8属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: StreamCommand
/**
* Creates a new instance for serial communication.
*
* @param listener receiving all messages/answers/errors asynchronously;
* there can only be one registered listener
* @param baudRate for the serial line
*
* @see #setBaudRate
*/
public StreamCommand(StreamCommandListener listener,int baudRate)
{
this.listener= listener;
this.baudRate= baudRate;
log.info("serial communication settings : "
+baudRate+" baud, 8 data- 1 stop-bit, no flow control");
dataBits= SerialPort.DATABITS_8;
stopBits= SerialPort.STOPBITS_1;
paritiyFlags= SerialPort.PARITY_NONE;
port= null;
is= null;
os= null;
synced= true;
currentCommand= null;
cmdPipe= new ArrayList<String>();
cmdWatchdog= null;
rtsWatchdog= null;
message= new StreamCommandMessage();
messageTimes= new ArrayList<Long>();
cmdsSent= 0;
cmdsTimeouts= 0;
}
示例4: SerialParameters
/**
* Constructs a new <tt>SerialParameters</tt> instance with
* default values: 9600 boud - 8N1 - ASCII.
*/
public SerialParameters() {
m_PortName = "";
m_BaudRate = 9600;
m_FlowControlIn = SerialPort.FLOWCONTROL_NONE;
m_FlowControlOut = SerialPort.FLOWCONTROL_NONE;
m_Databits = SerialPort.DATABITS_8;
m_Stopbits = SerialPort.STOPBITS_1;
m_Parity = SerialPort.PARITY_NONE;
m_Encoding = Modbus.DEFAULT_SERIAL_ENCODING;
m_ReceiveTimeout = 500; //5 secs
m_Echo = false;
}
示例5: 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";
}
}
示例6: SerialParameters
/**
* Default constructer. Sets parameters to no port, 9600 baud, no flow control, 8 data bits, 1
* stop bit, no parity.
*/
public SerialParameters() {
this(
UI.EMPTY_STRING,
9600,
SerialPort.FLOWCONTROL_NONE,
SerialPort.FLOWCONTROL_NONE,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
}
示例7: 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$
}
}
示例8: 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;
}
}
示例9: getPortParameters
@Override
public SerialParameters getPortParameters(final String portName) {
return new SerialParameters(
portName,
9600,
SerialPort.FLOWCONTROL_NONE,
SerialPort.FLOWCONTROL_NONE,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
}
示例10: getPortParameters
@Override
public SerialParameters getPortParameters(final String portName) {
final SerialParameters hac5PortParameters = new SerialParameters(
portName,
4800,
SerialPort.FLOWCONTROL_NONE,
SerialPort.FLOWCONTROL_NONE,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
return hac5PortParameters;
}
示例11: getPortParameters
@Override
public SerialParameters getPortParameters(String portName) {
SerialParameters portParameters = new SerialParameters(portName,
4800,
SerialPort.FLOWCONTROL_NONE,
SerialPort.FLOWCONTROL_NONE,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
return portParameters;
}
示例12: SerialParameters
/**
* Constructs a new <tt>SerialParameters</tt> instance with
* default values.
*/
public SerialParameters() {
m_PortName = "";
m_BaudRate = 9600;
m_FlowControlIn = SerialPort.FLOWCONTROL_NONE;
m_FlowControlOut = SerialPort.FLOWCONTROL_NONE;
m_Databits = SerialPort.DATABITS_8;
m_Stopbits = SerialPort.STOPBITS_1;
m_Parity = SerialPort.PARITY_NONE;
m_Encoding = Modbus.DEFAULT_SERIAL_ENCODING;
m_ReceiveTimeout = 500; //5 secs
m_Echo = false;
}
示例13: 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;
}
}
示例14: 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;
}
}
示例15: 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";
}
}