public class YSpiPort extends YFunction
Modifier and Type | Class and Description |
---|---|
static interface |
YSpiPort.TimedReportCallback
TimedReportCallback for SpiPort
|
static interface |
YSpiPort.UpdateCallback
Deprecated UpdateCallback for SpiPort
|
Modifier and Type | Field and Description |
---|---|
protected String |
_command |
protected String |
_currentJob |
protected int |
_errCount |
protected int |
_jobMaxSize |
protected int |
_jobMaxTask |
protected String |
_lastMsg |
protected String |
_protocol |
protected byte[] |
_rxbuff |
protected int |
_rxbuffptr |
protected int |
_rxCount |
protected int |
_rxMsgCount |
protected int |
_rxptr |
protected int |
_shiftSampling |
protected String |
_spiMode |
protected int |
_ssPolarity |
protected String |
_startupJob |
protected int |
_txCount |
protected int |
_txMsgCount |
protected YSpiPort.UpdateCallback |
_valueCallbackSpiPort |
protected int |
_voltageLevel |
static String |
COMMAND_INVALID
invalid command value
|
static String |
CURRENTJOB_INVALID
invalid currentJob value
|
static int |
ERRCOUNT_INVALID
invalid errCount value
|
static int |
JOBMAXSIZE_INVALID
invalid jobMaxSize value
|
static int |
JOBMAXTASK_INVALID
invalid jobMaxTask value
|
static String |
LASTMSG_INVALID
invalid lastMsg value
|
static String |
PROTOCOL_INVALID
invalid protocol value
|
static int |
RXCOUNT_INVALID
invalid rxCount value
|
static int |
RXMSGCOUNT_INVALID
invalid rxMsgCount value
|
static int |
SHIFTSAMPLING_INVALID |
static int |
SHIFTSAMPLING_OFF
invalid shiftSampling value
|
static int |
SHIFTSAMPLING_ON |
static String |
SPIMODE_INVALID
invalid spiMode value
|
static int |
SSPOLARITY_ACTIVE_HIGH |
static int |
SSPOLARITY_ACTIVE_LOW
invalid ssPolarity value
|
static int |
SSPOLARITY_INVALID |
static String |
STARTUPJOB_INVALID
invalid startupJob value
|
static int |
TXCOUNT_INVALID
invalid txCount value
|
static int |
TXMSGCOUNT_INVALID
invalid txMsgCount value
|
static int |
VOLTAGELEVEL_INVALID |
static int |
VOLTAGELEVEL_OFF
invalid voltageLevel value
|
static int |
VOLTAGELEVEL_RS232 |
static int |
VOLTAGELEVEL_RS485 |
static int |
VOLTAGELEVEL_TTL1V8 |
static int |
VOLTAGELEVEL_TTL3V |
static int |
VOLTAGELEVEL_TTL3VR |
static int |
VOLTAGELEVEL_TTL5V |
static int |
VOLTAGELEVEL_TTL5VR |
_advertisedValue, _cacheExpiration, _className, _dataStreams, _func, _funId, _hwId, _lastErrorMsg, _lastErrorType, _logicalName, _serial, _userData, _valueCallbackFunction, _yapi, ADVERTISEDVALUE_INVALID, FUNCTIONDESCRIPTOR_INVALID, LOGICALNAME_INVALID
Modifier | Constructor and Description |
---|---|
protected |
YSpiPort(String func) |
protected |
YSpiPort(YAPIContext ctx,
String func) |
Modifier and Type | Method and Description |
---|---|
int |
_invokeValueCallback(String value) |
protected void |
_parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) |
static YSpiPort |
FindSpiPort(String func)
Retrieves a SPI port for a given identifier.
|
static YSpiPort |
FindSpiPortInContext(YAPIContext yctx,
String func)
Retrieves a SPI port for a given identifier in a YAPI context.
|
static YSpiPort |
FirstSpiPort()
Starts the enumeration of SPI ports currently accessible.
|
static YSpiPort |
FirstSpiPortInContext(YAPIContext yctx)
Starts the enumeration of SPI ports currently accessible.
|
String |
get_command() |
String |
get_currentJob()
Returns the name of the job file currently in use.
|
int |
get_errCount()
Returns the total number of communication errors detected since last reset.
|
int |
get_jobMaxSize()
Returns maximum size allowed for job files.
|
int |
get_jobMaxTask()
Returns the maximum number of tasks in a job that the device can handle.
|
String |
get_lastMsg()
Returns the latest message fully received (for Line and Frame protocols).
|
String |
get_protocol()
Returns the type of protocol used over the serial line, as a string.
|
int |
get_rxCount()
Returns the total number of bytes received since last reset.
|
int |
get_rxMsgCount()
Returns the total number of messages received since last reset.
|
int |
get_shiftSampling()
Returns true when the SDI line phase is shifted with regards to the SDO line.
|
String |
get_spiMode()
Returns the SPI port communication parameters, as a string such as
"125000,0,msb".
|
int |
get_ssPolarity()
Returns the SS line polarity.
|
String |
get_startupJob()
Returns the job file to use when the device is powered on.
|
int |
get_txCount()
Returns the total number of bytes transmitted since last reset.
|
int |
get_txMsgCount()
Returns the total number of messages send since last reset.
|
int |
get_voltageLevel()
Returns the voltage level used on the serial line.
|
String |
getCurrentJob()
Returns the name of the job file currently in use.
|
int |
getErrCount()
Returns the total number of communication errors detected since last reset.
|
int |
getJobMaxSize()
Returns maximum size allowed for job files.
|
int |
getJobMaxTask()
Returns the maximum number of tasks in a job that the device can handle.
|
String |
getLastMsg()
Returns the latest message fully received (for Line and Frame protocols).
|
String |
getProtocol()
Returns the type of protocol used over the serial line, as a string.
|
int |
getRxCount()
Returns the total number of bytes received since last reset.
|
int |
getRxMsgCount()
Returns the total number of messages received since last reset.
|
int |
getShiftSampling()
Returns true when the SDI line phase is shifted with regards to the SDO line.
|
String |
getSpiMode()
Returns the SPI port communication parameters, as a string such as
"125000,0,msb".
|
int |
getSsPolarity()
Returns the SS line polarity.
|
String |
getStartupJob()
Returns the job file to use when the device is powered on.
|
int |
getTxCount()
Returns the total number of bytes transmitted since last reset.
|
int |
getTxMsgCount()
Returns the total number of messages send since last reset.
|
int |
getVoltageLevel()
Returns the voltage level used on the serial line.
|
YSpiPort |
nextSpiPort()
Continues the enumeration of SPI ports started using yFirstSpiPort().
|
String |
queryHex(String hexString,
int maxWait)
Sends a binary message to the serial port, and reads the reply, if any.
|
String |
queryLine(String query,
int maxWait)
Sends a text line query to the serial port, and reads the reply, if any.
|
int |
read_avail()
Returns the number of bytes available to read in the input buffer starting from the
current absolute stream position pointer of the API object.
|
int |
read_seek(int absPos)
Changes the current internal stream position to the specified value.
|
int |
read_tell()
Returns the current absolute stream position pointer of the API object.
|
ArrayList<Integer> |
readArray(int nChars)
Reads data from the receive buffer as a list of bytes, starting at current stream position.
|
byte[] |
readBin(int nChars)
Reads data from the receive buffer as a binary buffer, starting at current stream position.
|
int |
readByte()
Reads one byte from the receive buffer, starting at current stream position.
|
String |
readHex(int nBytes)
Reads data from the receive buffer as a hexadecimal string, starting at current stream position.
|
String |
readLine()
Reads a single line (or message) from the receive buffer, starting at current stream position.
|
ArrayList<String> |
readMessages(String pattern,
int maxWait)
Searches for incoming messages in the serial port receive buffer matching a given pattern,
starting at current position.
|
String |
readStr(int nChars)
Reads data from the receive buffer as a string, starting at current stream position.
|
int |
registerValueCallback(YSpiPort.UpdateCallback callback)
Registers the callback function that is invoked on every change of advertised value.
|
int |
reset()
Clears the serial port buffer and resets counters to zero.
|
int |
selectJob(String jobfile)
Load and start processing the specified job file.
|
int |
sendCommand(String text) |
int |
set_command(String newval) |
int |
set_currentJob(String newval)
Selects a job file to run immediately.
|
int |
set_protocol(String newval)
Changes the type of protocol used over the serial line.
|
int |
set_shiftSampling(int newval)
Changes the SDI line sampling shift.
|
int |
set_spiMode(String newval)
Changes the SPI port communication parameters, with a string such as
"125000,0,msb".
|
int |
set_SS(int val)
Manually sets the state of the SS line.
|
int |
set_ssPolarity(int newval)
Changes the SS line polarity.
|
int |
set_startupJob(String newval)
Changes the job to use when the device is powered on.
|
int |
set_voltageLevel(int newval)
Changes the voltage type used on the serial line.
|
int |
setCurrentJob(String newval)
Selects a job file to run immediately.
|
int |
setProtocol(String newval)
Changes the type of protocol used over the serial line.
|
int |
setShiftSampling(int newval)
Changes the SDI line sampling shift.
|
int |
setSpiMode(String newval)
Changes the SPI port communication parameters, with a string such as
"125000,0,msb".
|
int |
setSsPolarity(int newval)
Changes the SS line polarity.
|
int |
setStartupJob(String newval)
Changes the job to use when the device is powered on.
|
int |
setVoltageLevel(int newval)
Changes the voltage type used on the serial line.
|
int |
uploadJob(String jobfile,
String jsonDef)
Saves the job definition string (JSON data) into a job file.
|
int |
writeArray(ArrayList<Integer> byteList)
Sends a byte sequence (provided as a list of bytes) to the serial port.
|
int |
writeBin(byte[] buff)
Sends a binary buffer to the serial port, as is.
|
int |
writeByte(int code)
Sends a single byte to the serial port.
|
int |
writeHex(String hexString)
Sends a byte sequence (provided as a hexadecimal string) to the serial port.
|
int |
writeLine(String text)
Sends an ASCII string to the serial port, followed by a line break (CR LF).
|
int |
writeStr(String text)
Sends an ASCII string to the serial port, as is.
|
_AddToCache, _clearDataStreamCache, _download, _escapeAttr, _FindFromCache, _FindFromCacheInContext, _get_json_path_struct, _get_json_path, _json_get_array, _json_get_key, _json_get_string, _parse, _parserHelper, _setAttr, _throw, _UpdateTimedReportCallbackList, _UpdateValueCallbackList, _upload, _upload, _uploadEx, clearCache, describe, errMessage, errorMessage, errorType, errType, FindFunction, FindFunctionInContext, FirstFunction, FirstFunctionInContext, functionDescriptor, get_advertisedValue, get_errorMessage, get_errorType, get_friendlyName, get_functionDescriptor, get_functionId, get_hardwareId, get_logicalName, get_module, get_serialNumber, get_userData, getAdvertisedValue, getErrorMessage, getErrorType, getFriendlyName, getFunctionDescriptor, getFunctionId, getHardwareId, getLogicalName, getModule, getUserData, isOnline, isReadOnly, load, loadAttribute, module, muteValueCallbacks, nextFunction, registerValueCallback, set_advertisedValue, set_logicalName, set_userData, setLogicalName, setUserData, toString, unmuteValueCallbacks, userData
public static final int RXCOUNT_INVALID
public static final int TXCOUNT_INVALID
public static final int ERRCOUNT_INVALID
public static final int RXMSGCOUNT_INVALID
public static final int TXMSGCOUNT_INVALID
public static final String LASTMSG_INVALID
public static final String CURRENTJOB_INVALID
public static final String STARTUPJOB_INVALID
public static final int JOBMAXTASK_INVALID
public static final int JOBMAXSIZE_INVALID
public static final String COMMAND_INVALID
public static final String PROTOCOL_INVALID
public static final int VOLTAGELEVEL_OFF
public static final int VOLTAGELEVEL_TTL3V
public static final int VOLTAGELEVEL_TTL3VR
public static final int VOLTAGELEVEL_TTL5V
public static final int VOLTAGELEVEL_TTL5VR
public static final int VOLTAGELEVEL_RS232
public static final int VOLTAGELEVEL_RS485
public static final int VOLTAGELEVEL_TTL1V8
public static final int VOLTAGELEVEL_INVALID
public static final String SPIMODE_INVALID
public static final int SSPOLARITY_ACTIVE_LOW
public static final int SSPOLARITY_ACTIVE_HIGH
public static final int SSPOLARITY_INVALID
public static final int SHIFTSAMPLING_OFF
public static final int SHIFTSAMPLING_ON
public static final int SHIFTSAMPLING_INVALID
protected int _rxCount
protected int _txCount
protected int _errCount
protected int _rxMsgCount
protected int _txMsgCount
protected String _lastMsg
protected String _currentJob
protected String _startupJob
protected int _jobMaxTask
protected int _jobMaxSize
protected String _command
protected String _protocol
protected int _voltageLevel
protected String _spiMode
protected int _ssPolarity
protected int _shiftSampling
protected YSpiPort.UpdateCallback _valueCallbackSpiPort
protected int _rxptr
protected byte[] _rxbuff
protected int _rxbuffptr
protected YSpiPort(YAPIContext ctx, String func)
func
- : functionidprotected YSpiPort(String func)
func
- : functionidprotected void _parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) throws Exception
_parseAttr
in class YFunction
Exception
public int get_rxCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getRxCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_txCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getTxCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_errCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getErrCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_rxMsgCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getRxMsgCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_txMsgCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getTxMsgCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_lastMsg() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getLastMsg() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_currentJob() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getCurrentJob() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_currentJob(String newval) throws YAPI_Exception
newval
- : a stringYAPI_Exception
- on errorpublic int setCurrentJob(String newval) throws YAPI_Exception
newval
- : a stringYAPI_Exception
- on errorpublic String get_startupJob() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getStartupJob() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_startupJob(String newval) throws YAPI_Exception
newval
- : a string corresponding to the job to use when the device is powered onYAPI_Exception
- on errorpublic int setStartupJob(String newval) throws YAPI_Exception
newval
- : a string corresponding to the job to use when the device is powered onYAPI_Exception
- on errorpublic int get_jobMaxTask() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getJobMaxTask() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_jobMaxSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getJobMaxSize() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_command() throws YAPI_Exception
YAPI_Exception
public int set_command(String newval) throws YAPI_Exception
YAPI_Exception
public String get_protocol() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getProtocol() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_protocol(String newval) throws YAPI_Exception
newval
- : a string corresponding to the type of protocol used over the serial lineYAPI_Exception
- on errorpublic int setProtocol(String newval) throws YAPI_Exception
newval
- : a string corresponding to the type of protocol used over the serial lineYAPI_Exception
- on errorpublic int get_voltageLevel() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getVoltageLevel() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_voltageLevel(int newval) throws YAPI_Exception
newval
- : a value among YSpiPort.VOLTAGELEVEL_OFF, YSpiPort.VOLTAGELEVEL_TTL3V,
YSpiPort.VOLTAGELEVEL_TTL3VR, YSpiPort.VOLTAGELEVEL_TTL5V, YSpiPort.VOLTAGELEVEL_TTL5VR,
YSpiPort.VOLTAGELEVEL_RS232, YSpiPort.VOLTAGELEVEL_RS485 and YSpiPort.VOLTAGELEVEL_TTL1V8
corresponding to the voltage type used on the serial lineYAPI_Exception
- on errorpublic int setVoltageLevel(int newval) throws YAPI_Exception
newval
- : a value among Y_VOLTAGELEVEL_OFF, Y_VOLTAGELEVEL_TTL3V, Y_VOLTAGELEVEL_TTL3VR,
Y_VOLTAGELEVEL_TTL5V, Y_VOLTAGELEVEL_TTL5VR, Y_VOLTAGELEVEL_RS232, Y_VOLTAGELEVEL_RS485 and
Y_VOLTAGELEVEL_TTL1V8 corresponding to the voltage type used on the serial lineYAPI_Exception
- on errorpublic String get_spiMode() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getSpiMode() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_spiMode(String newval) throws YAPI_Exception
newval
- : a string corresponding to the SPI port communication parameters, with a string such as
"125000,0,msb"YAPI_Exception
- on errorpublic int setSpiMode(String newval) throws YAPI_Exception
newval
- : a string corresponding to the SPI port communication parameters, with a string such as
"125000,0,msb"YAPI_Exception
- on errorpublic int get_ssPolarity() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getSsPolarity() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_ssPolarity(int newval) throws YAPI_Exception
newval
- : either YSpiPort.SSPOLARITY_ACTIVE_LOW or YSpiPort.SSPOLARITY_ACTIVE_HIGH, according
to the SS line polarityYAPI_Exception
- on errorpublic int setSsPolarity(int newval) throws YAPI_Exception
newval
- : either Y_SSPOLARITY_ACTIVE_LOW or Y_SSPOLARITY_ACTIVE_HIGH, according to the SS line polarityYAPI_Exception
- on errorpublic int get_shiftSampling() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getShiftSampling() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_shiftSampling(int newval) throws YAPI_Exception
newval
- : either YSpiPort.SHIFTSAMPLING_OFF or YSpiPort.SHIFTSAMPLING_ON, according to the
SDI line sampling shiftYAPI_Exception
- on errorpublic int setShiftSampling(int newval) throws YAPI_Exception
newval
- : either Y_SHIFTSAMPLING_OFF or Y_SHIFTSAMPLING_ON, according to the SDI line sampling shiftYAPI_Exception
- on errorpublic static YSpiPort FindSpiPort(String func)
func
- : a string that uniquely characterizes the SPI port, for instance
YSPIMK01.spiPort.public static YSpiPort FindSpiPortInContext(YAPIContext yctx, String func)
yctx
- : a YAPI contextfunc
- : a string that uniquely characterizes the SPI port, for instance
YSPIMK01.spiPort.public int registerValueCallback(YSpiPort.UpdateCallback callback)
callback
- : the callback function to call, or a null pointer. The callback function should take two
arguments: the function object of which the value has changed, and the character string describing
the new advertised value.public int _invokeValueCallback(String value)
_invokeValueCallback
in class YFunction
public int sendCommand(String text) throws YAPI_Exception
YAPI_Exception
public String readLine() throws YAPI_Exception
YAPI_Exception
- on errorpublic ArrayList<String> readMessages(String pattern, int maxWait) throws YAPI_Exception
pattern
- : a limited regular expression describing the expected message format,
or an empty string if all messages should be returned (no filtering).
When using binary protocols, the format applies to the hexadecimal
representation of the message.maxWait
- : the maximum number of milliseconds to wait for a message if none is found
in the receive buffer.YAPI_Exception
- on errorpublic int read_seek(int absPos)
absPos
- : the absolute position index for next read operations.public int read_tell()
public int read_avail() throws YAPI_Exception
YAPI_Exception
public String queryLine(String query, int maxWait) throws YAPI_Exception
query
- : the line query to send (without CR/LF)maxWait
- : the maximum number of milliseconds to wait for a reply.YAPI_Exception
- on errorpublic String queryHex(String hexString, int maxWait) throws YAPI_Exception
hexString
- : the message to send, coded in hexadecimalmaxWait
- : the maximum number of milliseconds to wait for a reply.YAPI_Exception
- on errorpublic int uploadJob(String jobfile, String jsonDef) throws YAPI_Exception
jobfile
- : name of the job file to save on the device filesystemjsonDef
- : a string containing a JSON definition of the jobYAPI_Exception
- on errorpublic int selectJob(String jobfile) throws YAPI_Exception
jobfile
- : name of the job file (on the device filesystem)YAPI_Exception
- on errorpublic int reset() throws YAPI_Exception
YAPI_Exception
- on errorpublic int writeByte(int code) throws YAPI_Exception
code
- : the byte to sendYAPI_Exception
- on errorpublic int writeStr(String text) throws YAPI_Exception
text
- : the text string to sendYAPI_Exception
- on errorpublic int writeBin(byte[] buff) throws YAPI_Exception
buff
- : the binary buffer to sendYAPI_Exception
- on errorpublic int writeArray(ArrayList<Integer> byteList) throws YAPI_Exception
byteList
- : a list of byte codesYAPI_Exception
- on errorpublic int writeHex(String hexString) throws YAPI_Exception
hexString
- : a string of hexadecimal byte codesYAPI_Exception
- on errorpublic int writeLine(String text) throws YAPI_Exception
text
- : the text string to sendYAPI_Exception
- on errorpublic int readByte() throws YAPI_Exception
YAPI_Exception
- on errorpublic String readStr(int nChars) throws YAPI_Exception
nChars
- : the maximum number of characters to readYAPI_Exception
- on errorpublic byte[] readBin(int nChars) throws YAPI_Exception
nChars
- : the maximum number of bytes to readYAPI_Exception
- on errorpublic ArrayList<Integer> readArray(int nChars) throws YAPI_Exception
nChars
- : the maximum number of bytes to readYAPI_Exception
- on errorpublic String readHex(int nBytes) throws YAPI_Exception
nBytes
- : the maximum number of bytes to readYAPI_Exception
- on errorpublic int set_SS(int val) throws YAPI_Exception
val
- : 1 to turn SS active, 0 to release SS.YAPI_Exception
- on errorpublic YSpiPort nextSpiPort()
public static YSpiPort FirstSpiPort()
public static YSpiPort FirstSpiPortInContext(YAPIContext yctx)
yctx
- : a YAPI context.Copyright © 2020. All rights reserved.