public class YI2cPort extends YFunction
Modifier and Type | Class and Description |
---|---|
static interface |
YI2cPort.TimedReportCallback
TimedReportCallback for I2cPort
|
static interface |
YI2cPort.UpdateCallback
Deprecated UpdateCallback for I2cPort
|
Modifier and Type | Field and Description |
---|---|
protected String |
_command |
protected String |
_currentJob |
protected int |
_errCount |
protected String |
_i2cMode |
protected int |
_i2cVoltageLevel |
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 String |
_startupJob |
protected int |
_txCount |
protected int |
_txMsgCount |
protected YI2cPort.UpdateCallback |
_valueCallbackI2cPort |
static String |
COMMAND_INVALID
invalid command value
|
static String |
CURRENTJOB_INVALID
invalid currentJob value
|
static int |
ERRCOUNT_INVALID
invalid errCount value
|
static String |
I2CMODE_INVALID
invalid i2cMode value
|
static int |
I2CVOLTAGELEVEL_1V8 |
static int |
I2CVOLTAGELEVEL_3V3 |
static int |
I2CVOLTAGELEVEL_INVALID |
static int |
I2CVOLTAGELEVEL_OFF
invalid i2cVoltageLevel 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 String |
STARTUPJOB_INVALID
invalid startupJob value
|
static int |
TXCOUNT_INVALID
invalid txCount value
|
static int |
TXMSGCOUNT_INVALID
invalid txMsgCount value
|
_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 |
YI2cPort(String func) |
protected |
YI2cPort(YAPIContext ctx,
String func) |
Modifier and Type | Method and Description |
---|---|
int |
_invokeValueCallback(String value) |
protected void |
_parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) |
static YI2cPort |
FindI2cPort(String func)
Retrieves an I2C port for a given identifier.
|
static YI2cPort |
FindI2cPortInContext(YAPIContext yctx,
String func)
Retrieves an I2C port for a given identifier in a YAPI context.
|
static YI2cPort |
FirstI2cPort()
Starts the enumeration of I2C ports currently accessible.
|
static YI2cPort |
FirstI2cPortInContext(YAPIContext yctx)
Starts the enumeration of I2C 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.
|
String |
get_i2cMode()
Returns the I2C port communication parameters, as a string such as
"400kbps,2000ms,NoRestart".
|
int |
get_i2cVoltageLevel()
Returns the voltage level used on the I2C bus.
|
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 to send I2C messages, 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.
|
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.
|
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.
|
String |
getI2cMode()
Returns the I2C port communication parameters, as a string such as
"400kbps,2000ms,NoRestart".
|
int |
getI2cVoltageLevel()
Returns the voltage level used on the I2C bus.
|
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 to send I2C messages, 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.
|
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.
|
ArrayList<Integer> |
i2cSendAndReceiveArray(int slaveAddr,
ArrayList<Integer> values,
int rcvCount)
Sends a one-way message (provided as a list of integer) to a device on the I2C bus,
then read back the specified number of bytes from device.
|
byte[] |
i2cSendAndReceiveBin(int slaveAddr,
byte[] buff,
int rcvCount)
Sends a one-way message (provided as a a binary buffer) to a device on the I2C bus,
then read back the specified number of bytes from device.
|
int |
i2cSendArray(int slaveAddr,
ArrayList<Integer> values)
Sends a one-way message (provided as a list of integer) to a device on the I2C bus.
|
int |
i2cSendBin(int slaveAddr,
byte[] buff)
Sends a one-way message (provided as a a binary buffer) to a device on the I2C bus.
|
YI2cPort |
nextI2cPort()
Continues the enumeration of I2C ports started using yFirstI2cPort().
|
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.
|
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.
|
int |
registerValueCallback(YI2cPort.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_i2cMode(String newval)
Changes the I2C port communication parameters, with a string such as
"400kbps,2000ms".
|
int |
set_i2cVoltageLevel(int newval)
Changes the voltage level used on the I2C bus.
|
int |
set_protocol(String newval)
Changes the type of protocol used to send I2C messages.
|
int |
set_startupJob(String newval)
Changes the job to use when the device is powered on.
|
int |
setCurrentJob(String newval)
Selects a job file to run immediately.
|
int |
setI2cMode(String newval)
Changes the I2C port communication parameters, with a string such as
"400kbps,2000ms".
|
int |
setI2cVoltageLevel(int newval)
Changes the voltage level used on the I2C bus.
|
int |
setProtocol(String newval)
Changes the type of protocol used to send I2C messages.
|
int |
setStartupJob(String newval)
Changes the job to use when the device is powered on.
|
ArrayList<YI2cSnoopingRecord> |
snoopMessages(int maxWait)
Retrieves messages (both direction) in the I2C port buffer, starting at current position.
|
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 I2C bus.
|
int |
writeBin(byte[] buff)
Sends a binary buffer to the I2C bus, as is.
|
int |
writeByte(int code)
Sends a single byte to the I2C bus.
|
int |
writeHex(String hexString)
Sends a byte sequence (provided as a hexadecimal string) to the I2C bus.
|
int |
writeLine(String codes)
Sends a text-encoded I2C code stream to the I2C bus, and terminate
the message en relâchant le bus.
|
int |
writeStr(String codes)
Sends a text-encoded I2C code stream to the I2C bus, 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 I2CVOLTAGELEVEL_OFF
public static final int I2CVOLTAGELEVEL_3V3
public static final int I2CVOLTAGELEVEL_1V8
public static final int I2CVOLTAGELEVEL_INVALID
public static final String I2CMODE_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 _i2cVoltageLevel
protected String _i2cMode
protected YI2cPort.UpdateCallback _valueCallbackI2cPort
protected int _rxptr
protected byte[] _rxbuff
protected int _rxbuffptr
protected YI2cPort(YAPIContext ctx, String func)
func
- : functionidprotected YI2cPort(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 to send I2C messagesYAPI_Exception
- on errorpublic int setProtocol(String newval) throws YAPI_Exception
newval
- : a string corresponding to the type of protocol used to send I2C messagesYAPI_Exception
- on errorpublic int get_i2cVoltageLevel() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getI2cVoltageLevel() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_i2cVoltageLevel(int newval) throws YAPI_Exception
newval
- : a value among YI2cPort.I2CVOLTAGELEVEL_OFF, YI2cPort.I2CVOLTAGELEVEL_3V3 and
YI2cPort.I2CVOLTAGELEVEL_1V8 corresponding to the voltage level used on the I2C busYAPI_Exception
- on errorpublic int setI2cVoltageLevel(int newval) throws YAPI_Exception
newval
- : a value among YI2cPort.I2CVOLTAGELEVEL_OFF, YI2cPort.I2CVOLTAGELEVEL_3V3 and
YI2cPort.I2CVOLTAGELEVEL_1V8 corresponding to the voltage level used on the I2C busYAPI_Exception
- on errorpublic String get_i2cMode() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getI2cMode() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_i2cMode(String newval) throws YAPI_Exception
newval
- : a string corresponding to the I2C port communication parameters, with a string such as
"400kbps,2000ms"YAPI_Exception
- on errorpublic int setI2cMode(String newval) throws YAPI_Exception
newval
- : a string corresponding to the I2C port communication parameters, with a string such as
"400kbps,2000ms"YAPI_Exception
- on errorpublic static YI2cPort FindI2cPort(String func)
func
- : a string that uniquely characterizes the I2C port, for instance
YI2CMK01.i2cPort.public static YI2cPort FindI2cPortInContext(YAPIContext yctx, String func)
yctx
- : a YAPI contextfunc
- : a string that uniquely characterizes the I2C port, for instance
YI2CMK01.i2cPort.public int registerValueCallback(YI2cPort.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 i2cSendBin(int slaveAddr, byte[] buff) throws YAPI_Exception
slaveAddr
- : the 7-bit address of the slave device (without the direction bit)buff
- : the binary buffer to be sentYAPI_Exception
- on errorpublic int i2cSendArray(int slaveAddr, ArrayList<Integer> values) throws YAPI_Exception
slaveAddr
- : the 7-bit address of the slave device (without the direction bit)values
- : a list of data bytes to be sentYAPI_Exception
- on errorpublic byte[] i2cSendAndReceiveBin(int slaveAddr, byte[] buff, int rcvCount) throws YAPI_Exception
slaveAddr
- : the 7-bit address of the slave device (without the direction bit)buff
- : the binary buffer to be sentrcvCount
- : the number of bytes to receive once the data bytes are sentYAPI_Exception
- on errorpublic ArrayList<Integer> i2cSendAndReceiveArray(int slaveAddr, ArrayList<Integer> values, int rcvCount) throws YAPI_Exception
slaveAddr
- : the 7-bit address of the slave device (without the direction bit)values
- : a list of data bytes to be sentrcvCount
- : the number of bytes to receive once the data bytes are sentYAPI_Exception
- on errorpublic int writeStr(String codes) throws YAPI_Exception
codes
- : the code stream to sendYAPI_Exception
- on errorpublic int writeLine(String codes) throws YAPI_Exception
codes
- : the code stream to sendYAPI_Exception
- on errorpublic int writeByte(int code) throws YAPI_Exception
code
- : the byte to sendYAPI_Exception
- on errorpublic int writeHex(String hexString) throws YAPI_Exception
hexString
- : a string of hexadecimal byte codesYAPI_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 ArrayList<YI2cSnoopingRecord> snoopMessages(int maxWait) throws YAPI_Exception
maxWait
- : the maximum number of milliseconds to wait for a message if none is found
in the receive buffer.YAPI_Exception
- on errorpublic YI2cPort nextI2cPort()
public static YI2cPort FirstI2cPort()
public static YI2cPort FirstI2cPortInContext(YAPIContext yctx)
yctx
- : a YAPI context.Copyright © 2021. All rights reserved.