Package gurux.serial
Class GXSerial
java.lang.Object
gurux.serial.GXSerial
- All Implemented Interfaces:
gurux.common.IGXMedia,gurux.common.IGXMedia2,AutoCloseable
public class GXSerial
extends Object
implements gurux.common.IGXMedia, gurux.common.IGXMedia2, AutoCloseable
The GXSerial component determines methods that make the communication
possible using serial port connection.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaboutBox()Displays the copyright of the control, user license, and version information, in a dialog box.voidaddListener(gurux.common.IGXMediaListener listener)voidclose()voidprotected voidfinalize()intstatic gurux.io.BaudRate[]getAvailableBaudRates(String portName)Get baud rates supported by given serial port.gurux.io.BaudRateUsed baud rate for communication.booleanGet break state.longlongintGets the number of bytes in the receive buffer.intGets the number of bytes in the send buffer.booleanGets the state of the Carrier Detect line for the port.intbooleanGets the state of the Clear-to-Send line.intGets the standard length of data bits per byte.booleanGets the state of the Data Set Ready (DSR) signal.booleanGet is Data Terminal Ready (DTR) signal enabled.getEop()gurux.io.HandshakeGets the handshaking protocol for serial port transmission of data.booleangetName()gurux.io.ParityGets the parity-checking protocol.Gets the port for communications, including but not limited to all available COM ports.static String[]Gets an array of serial port names for the current computer.intGets the size of the serial port input buffer.intGets the number of milliseconds before a time-out occurs when a read operation does not finish.intbooleanGets a value indicating whether the Request to Send (RTS) signal is enabled during serial communication.gurux.io.StopBitsGets the standard number of stop bits per byte.gurux.common.enums.TraceLevelgetTrace()intGets the number of milliseconds before a time-out occurs when a write operation does not finish.booleanisOpen()voidopen()booleanproperties(JFrame parent)<T> booleanreceive(gurux.common.ReceiveParameters<T> args)voidremoveListener(gurux.common.IGXMediaListener listener)voidvoidvoidvoidsetAsyncWaitTime(int value)voidsetBaudRate(gurux.io.BaudRate value)Set new baud rate.voidsetBreakState(boolean value)Set break state.voidsetConfigurableSettings(int value)voidsetDataBits(int value)Sets the standard length of data bits per byte.voidsetDtrEnable(boolean value)Set is Data Terminal Ready (DTR) signal enabled.voidvoidsetHandshake(gurux.io.Handshake value)Sets the handshaking protocol for serial port transmission of data.voidsetParity(gurux.io.Parity value)Sets the parity-checking protocol.voidsetPortName(String value)Sets the port for communications, including but not limited to all available COM ports.voidsetReadBufferSize(int value)Sets the size of the serial port input buffer.voidsetReadTimeout(int value)Sets the number of milliseconds before a time-out occurs when a read operation does not finish.voidsetReceiveDelay(int value)voidsetRtsEnable(boolean value)Sets a value indicating whether the Request to Send (RTS) signal is enabled during serial communication.voidsetSettings(String value)voidsetStopBits(gurux.io.StopBits value)Sets the standard number of stop bits per byte.voidsetTrace(gurux.common.enums.TraceLevel value)voidsetWriteTimeout(int value)Sets the number of milliseconds before a time-out occurs when a write operation does not finish.voidvalidate()
-
Constructor Details
-
GXSerial
public GXSerial()Constructor. -
GXSerial
public GXSerial(String port, gurux.io.BaudRate baudRateValue, int dataBitsValue, gurux.io.Parity parityValue, gurux.io.StopBits stopBitsValue)Constructor.- Parameters:
port- Serial port.baudRateValue- Baud rate.dataBitsValue- Data bits.parityValue- Parity.stopBitsValue- Stop bits.
-
-
Method Details
-
getPortNames
Gets an array of serial port names for the current computer.- Returns:
- Collection of available serial ports.
-
getAvailableBaudRates
Get baud rates supported by given serial port.- Parameters:
portName- Name of serial port.- Returns:
- Collection of available baud rates.
-
finalize
-
getTrace
public final gurux.common.enums.TraceLevel getTrace()- Specified by:
getTracein interfacegurux.common.IGXMedia
-
setTrace
public final void setTrace(gurux.common.enums.TraceLevel value)- Specified by:
setTracein interfacegurux.common.IGXMedia
-
getConfigurableSettings
public final int getConfigurableSettings()- Specified by:
getConfigurableSettingsin interfacegurux.common.IGXMedia
-
setConfigurableSettings
public final void setConfigurableSettings(int value)- Specified by:
setConfigurableSettingsin interfacegurux.common.IGXMedia
-
properties
- Specified by:
propertiesin interfacegurux.common.IGXMedia
-
aboutBox
public final void aboutBox()Displays the copyright of the control, user license, and version information, in a dialog box. -
send
- Specified by:
sendin interfacegurux.common.IGXMedia- Throws:
Exception
-
open
- Specified by:
openin interfacegurux.common.IGXMedia- Throws:
Exception
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacegurux.common.IGXMedia
-
getBaudRate
public final gurux.io.BaudRate getBaudRate()Used baud rate for communication. Can be changed without disconnecting.- Returns:
- Used baud rate.
-
setBaudRate
public final void setBaudRate(gurux.io.BaudRate value)Set new baud rate.- Parameters:
value- New baud rate.
-
getBreakState
public final boolean getBreakState()Get break state.- Returns:
- True if the port is in a break state; otherwise, false.
-
setBreakState
public final void setBreakState(boolean value)Set break state.- Parameters:
value- True if the port is in a break state; otherwise, false.
-
getBytesToRead
public final int getBytesToRead()Gets the number of bytes in the receive buffer.- Returns:
- Amount of read bytes.
-
getBytesToWrite
public final int getBytesToWrite()Gets the number of bytes in the send buffer.- Returns:
- Amount of bytes to write in the send buffer.
-
getCDHolding
public final boolean getCDHolding()Gets the state of the Carrier Detect line for the port.- Returns:
- Is Carrier Detect in holding state.
-
getCtsHolding
public final boolean getCtsHolding()Gets the state of the Clear-to-Send line.- Returns:
- Clear-to-Send state.
-
getDataBits
public final int getDataBits()Gets the standard length of data bits per byte.- Returns:
- Amount of data bits.
-
setDataBits
public final void setDataBits(int value)Sets the standard length of data bits per byte.- Parameters:
value- Amount of data bits.
-
getDsrHolding
public final boolean getDsrHolding()Gets the state of the Data Set Ready (DSR) signal.- Returns:
- Is Data Set Ready set.
-
getDtrEnable
public final boolean getDtrEnable()Get is Data Terminal Ready (DTR) signal enabled.- Returns:
- Is DTR enabled.
-
setDtrEnable
public final void setDtrEnable(boolean value)Set is Data Terminal Ready (DTR) signal enabled.- Parameters:
value- Is DTR enabled.
-
getHandshake
public final gurux.io.Handshake getHandshake()Gets the handshaking protocol for serial port transmission of data.- Returns:
- Used handshake protocol.
-
setHandshake
public final void setHandshake(gurux.io.Handshake value)Sets the handshaking protocol for serial port transmission of data.- Parameters:
value- Handshake protocol.
-
isOpen
public final boolean isOpen()- Specified by:
isOpenin interfacegurux.common.IGXMedia
-
getParity
public final gurux.io.Parity getParity()Gets the parity-checking protocol.- Returns:
- Used parity.
-
setParity
public final void setParity(gurux.io.Parity value)Sets the parity-checking protocol.- Parameters:
value- Used parity.
-
getPortName
Gets the port for communications, including but not limited to all available COM ports.- Returns:
- Used serial port
-
setPortName
Sets the port for communications, including but not limited to all available COM ports.- Parameters:
value- Used serial port.
-
getReadBufferSize
public final int getReadBufferSize()Gets the size of the serial port input buffer.- Returns:
- Size of input buffer.
-
setReadBufferSize
public final void setReadBufferSize(int value)Sets the size of the serial port input buffer.- Parameters:
value- Size of input buffer.
-
getReadTimeout
public final int getReadTimeout()Gets the number of milliseconds before a time-out occurs when a read operation does not finish.- Returns:
- Read timeout.
-
setReadTimeout
public final void setReadTimeout(int value)Sets the number of milliseconds before a time-out occurs when a read operation does not finish.- Parameters:
value- Read timeout.
-
getRtsEnable
public final boolean getRtsEnable()Gets a value indicating whether the Request to Send (RTS) signal is enabled during serial communication.- Returns:
- Is RTS enabled.
-
setRtsEnable
public final void setRtsEnable(boolean value)Sets a value indicating whether the Request to Send (RTS) signal is enabled during serial communication.- Parameters:
value- Is RTS enabled.
-
getStopBits
public final gurux.io.StopBits getStopBits()Gets the standard number of stop bits per byte.- Returns:
- Used stop bits.
-
setStopBits
public final void setStopBits(gurux.io.StopBits value)Sets the standard number of stop bits per byte.- Parameters:
value- Used stop bits.
-
getWriteTimeout
public final int getWriteTimeout()Gets the number of milliseconds before a time-out occurs when a write operation does not finish.- Returns:
- Used time out.
-
setWriteTimeout
public final void setWriteTimeout(int value)Sets the number of milliseconds before a time-out occurs when a write operation does not finish.- Parameters:
value- Used time out.
-
receive
public final <T> boolean receive(gurux.common.ReceiveParameters<T> args)- Specified by:
receivein interfacegurux.common.IGXMedia
-
getBytesSent
public final long getBytesSent()- Specified by:
getBytesSentin interfacegurux.common.IGXMedia
-
getBytesReceived
public final long getBytesReceived()- Specified by:
getBytesReceivedin interfacegurux.common.IGXMedia
-
resetByteCounters
public final void resetByteCounters()- Specified by:
resetByteCountersin interfacegurux.common.IGXMedia
-
getSettings
- Specified by:
getSettingsin interfacegurux.common.IGXMedia
-
setSettings
- Specified by:
setSettingsin interfacegurux.common.IGXMedia
-
copy
- Specified by:
copyin interfacegurux.common.IGXMedia
-
getName
- Specified by:
getNamein interfacegurux.common.IGXMedia
-
getMediaType
- Specified by:
getMediaTypein interfacegurux.common.IGXMedia
-
getSynchronous
- Specified by:
getSynchronousin interfacegurux.common.IGXMedia
-
getIsSynchronous
public final boolean getIsSynchronous()- Specified by:
getIsSynchronousin interfacegurux.common.IGXMedia
-
resetSynchronousBuffer
public final void resetSynchronousBuffer()- Specified by:
resetSynchronousBufferin interfacegurux.common.IGXMedia
-
validate
public final void validate()- Specified by:
validatein interfacegurux.common.IGXMedia
-
getEop
- Specified by:
getEopin interfacegurux.common.IGXMedia
-
setEop
- Specified by:
setEopin interfacegurux.common.IGXMedia
-
addListener
public final void addListener(gurux.common.IGXMediaListener listener)- Specified by:
addListenerin interfacegurux.common.IGXMedia
-
removeListener
public final void removeListener(gurux.common.IGXMediaListener listener)- Specified by:
removeListenerin interfacegurux.common.IGXMedia
-
getReceiveDelay
public int getReceiveDelay()- Specified by:
getReceiveDelayin interfacegurux.common.IGXMedia2
-
setReceiveDelay
public void setReceiveDelay(int value)- Specified by:
setReceiveDelayin interfacegurux.common.IGXMedia2
-
getAsyncWaitTime
public int getAsyncWaitTime()- Specified by:
getAsyncWaitTimein interfacegurux.common.IGXMedia2
-
setAsyncWaitTime
public void setAsyncWaitTime(int value)- Specified by:
setAsyncWaitTimein interfacegurux.common.IGXMedia2
-
getAsyncWaitHandle
- Specified by:
getAsyncWaitHandlein interfacegurux.common.IGXMedia2
-