Package jisa.visa.connections
Interface Connection
-
- All Known Subinterfaces:
GPIBConnection
,LXIConnection
,SerialConnection
,TCPIPConnection
,USBConnection
- All Known Implementing Classes:
GPIBDriver.GPIBConnection
,SerialDriver.JSSCConnection
,TCPIPDriver.TCPIPConnection
,VISADriver.VISAConnection
,VISADriver.VISAGPIBConnection
,VISADriver.VISALXIConnection
,VISADriver.VISASerialConnection
,VISADriver.VISATCPIPConnection
,VISADriver.VISAUSBConnection
public interface Connection
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
clear()
void
close()
Closes the connection, freeing up the resources used by it.java.nio.charset.Charset
getEncoding()
default java.lang.String
read()
Reads from the connection (max buffer of 1024 bytes), returning the data as a Stringdefault java.lang.String
read(int bufferSize)
Reads from the connection, using the specified maximum buffer size.byte[]
readBytes(int bufferSize)
Attempts to read the given number of bytes from the connection.void
setEncoding(java.nio.charset.Charset charset)
void
setReadTerminator(long terminator)
Sets the "End of String" terminator, in numerical form.default void
setReadTerminator(java.lang.String terminator)
Sets the "End of String" terminator, in String form.void
setTimeout(int duration)
Sets the time-out, in milli-seconds, to use on this connection.default void
write(java.lang.String toWrite)
Writes the specified string over the connection.void
writeBytes(byte[] bytes)
-
-
-
Method Detail
-
writeBytes
void writeBytes(byte[] bytes) throws VISAException
- Throws:
VISAException
-
clear
void clear() throws VISAException
- Throws:
VISAException
-
setEncoding
void setEncoding(java.nio.charset.Charset charset)
-
getEncoding
java.nio.charset.Charset getEncoding()
-
write
default void write(java.lang.String toWrite) throws VISAException
Writes the specified string over the connection.- Parameters:
toWrite
- String to write- Throws:
VISAException
- Upon something going wrong with VISA
-
read
default java.lang.String read(int bufferSize) throws VISAException
Reads from the connection, using the specified maximum buffer size. Returns data as a String- Parameters:
bufferSize
- Buffer size, in bytes- Returns:
- Read data, as a String
- Throws:
VISAException
- Upon something going wrong with VISA
-
read
default java.lang.String read() throws VISAException
Reads from the connection (max buffer of 1024 bytes), returning the data as a String- Returns:
- Read data, as a String
- Throws:
VISAException
- Upon something going wrong
-
readBytes
byte[] readBytes(int bufferSize) throws VISAException
Attempts 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(...).- Parameters:
bufferSize
- The number of bytes to read- Returns:
- Array of bytes read (trimmed)
- Throws:
VISAException
- Upon something going wrong
-
setReadTerminator
void setReadTerminator(long terminator) throws VISAException
Sets 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
- Parameters:
terminator
- The terminator to look for (numerical representation)- Throws:
VISAException
- Upon something going wrong
-
setReadTerminator
default void setReadTerminator(java.lang.String terminator) throws VISAException
Sets 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.- Parameters:
terminator
- The terminator to look from (String representation)- Throws:
VISAException
- Upon something going wrong
-
setTimeout
void setTimeout(int duration) throws VISAException
Sets the time-out, in milli-seconds, to use on this connection.- Parameters:
duration
- Time-out, in milli-seconds- Throws:
VISAException
- Upon something going wrong
-
close
void close() throws VISAException
Closes the connection, freeing up the resources used by it.- Throws:
VISAException
- Upon something going wrong
-
-