Package jisa.visa.drivers
Class SerialDriver.JSSCConnection
- java.lang.Object
-
- jisa.visa.drivers.SerialDriver.JSSCConnection
-
- All Implemented Interfaces:
Connection,SerialConnection
- Enclosing class:
- SerialDriver
public static class SerialDriver.JSSCConnection extends java.lang.Object implements SerialConnection
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jisa.visa.connections.SerialConnection
SerialConnection.FlowControl, SerialConnection.Parity, SerialConnection.Stop
-
-
Constructor Summary
Constructors Constructor Description JSSCConnection(jssc.SerialPort comPort)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()voidclose()Closes the connection, freeing up the resources used by it.java.nio.charset.CharsetgetEncoding()voidoverrideSerialParameters(int baud, int data, SerialConnection.Parity parity, SerialConnection.Stop stop)byte[]readBytes(int bufferSize)Attempts to read the given number of bytes from the connection.voidsetEncoding(java.nio.charset.Charset charset)voidsetReadTerminator(long character)Sets the "End of String" terminator, in numerical form.voidsetReadTerminator(java.lang.String character)Sets the "End of String" terminator, in String form.voidsetSerialParameters(int baud, int data, SerialConnection.Parity parity, SerialConnection.Stop stop, SerialConnection.FlowControl... flows)voidsetTimeout(int timeout)Sets the time-out, in milli-seconds, to use on this connection.voidwrite(java.lang.String toWrite)Writes the specified string over the connection.voidwriteBytes(byte[] bytes)-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jisa.visa.connections.Connection
read, read
-
Methods inherited from interface jisa.visa.connections.SerialConnection
setSerialParameters
-
-
-
-
Constructor Detail
-
JSSCConnection
public JSSCConnection(jssc.SerialPort comPort) throws VISAException- Throws:
VISAException
-
-
Method Detail
-
writeBytes
public void writeBytes(byte[] bytes) throws VISAException- Specified by:
writeBytesin interfaceConnection- Throws:
VISAException
-
clear
public void clear() throws VISAException- Specified by:
clearin interfaceConnection- Throws:
VISAException
-
setEncoding
public void setEncoding(java.nio.charset.Charset charset)
- Specified by:
setEncodingin interfaceConnection
-
getEncoding
public java.nio.charset.Charset getEncoding()
- Specified by:
getEncodingin interfaceConnection
-
write
public void write(java.lang.String toWrite) throws VISAExceptionDescription copied from interface:ConnectionWrites the specified string over the connection.- Specified by:
writein interfaceConnection- Parameters:
toWrite- String to write- Throws:
VISAException- Upon something going wrong with VISA
-
readBytes
public byte[] readBytes(int bufferSize) throws VISAExceptionDescription copied from interface:ConnectionAttempts to read the given number of bytes from the connection. Will return if either the number of bytes is reached or the specified EOS terminator is found. Will time-out if neither of these conditions are met within the value specified by setTMO(...).- Specified by:
readBytesin interfaceConnection- Parameters:
bufferSize- The number of bytes to read- Returns:
- Array of bytes read (trimmed)
- Throws:
VISAException- Upon something going wrong
-
setReadTerminator
public void setReadTerminator(long character)
Description copied from interface:ConnectionSets the "End of String" terminator, in numerical form. This is the terminator used for reading from the connection, to specify the end of a message from the instrument. For example:line-feed: \n = 0x0A carriage-return \r = 0x0D CR-LF \r\n = 0x0D0A
- Specified by:
setReadTerminatorin interfaceConnection- Parameters:
character- The terminator to look for (numerical representation)
-
setReadTerminator
public void setReadTerminator(java.lang.String character)
Description copied from interface:ConnectionSets the "End of String" terminator, in String form. This is the terminator used for reading from the connection, to specify the end of a message from the instrument.- Specified by:
setReadTerminatorin interfaceConnection- Parameters:
character- The terminator to look from (String representation)
-
setTimeout
public void setTimeout(int timeout) throws VISAExceptionDescription copied from interface:ConnectionSets the time-out, in milli-seconds, to use on this connection.- Specified by:
setTimeoutin interfaceConnection- Parameters:
timeout- Time-out, in milli-seconds- Throws:
VISAException- Upon something going wrong
-
overrideSerialParameters
public void overrideSerialParameters(int baud, int data, SerialConnection.Parity parity, SerialConnection.Stop stop) throws VISAException- Throws:
VISAException
-
setSerialParameters
public void setSerialParameters(int baud, int data, SerialConnection.Parity parity, SerialConnection.Stop stop, SerialConnection.FlowControl... flows) throws VISAException- Specified by:
setSerialParametersin interfaceSerialConnection- Throws:
VISAException
-
close
public void close() throws VISAExceptionDescription copied from interface:ConnectionCloses the connection, freeing up the resources used by it.- Specified by:
closein interfaceConnection- Throws:
VISAException- Upon something going wrong
-
-