Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
YSpiPort Class Reference

#include <yocto_spiport.h>

Inheritance diagram for YSpiPort:
Inheritance graph
[legend]

Public Member Functions

virtual int _invokeValueCallback (string value)
 
string command (void)
 
string currentJob (void)
 
int errCount (void)
 
string get_command (void)
 
string get_currentJob (void)
 
int get_errCount (void)
 
string get_lastMsg (void)
 
string get_protocol (void)
 
int get_rxCount (void)
 
int get_rxMsgCount (void)
 
Y_SHITFTSAMPLING_enum get_shitftSampling (void)
 
string get_spiMode (void)
 
Y_SSPOLARITY_enum get_ssPolarity (void)
 
string get_startupJob (void)
 
int get_txCount (void)
 
int get_txMsgCount (void)
 
Y_VOLTAGELEVEL_enum get_voltageLevel (void)
 
string lastMsg (void)
 
YSpiPortnext (void)
 
YSpiPortnextSpiPort (void)
 
string protocol (void)
 
virtual string queryLine (string query, int maxWait)
 
virtual int read_avail (void)
 
virtual int read_seek (int absPos)
 
virtual int read_tell (void)
 
virtual vector< int > readArray (int nChars)
 
virtual string readBin (int nChars)
 
virtual int readByte (void)
 
virtual string readHex (int nBytes)
 
virtual string readLine (void)
 
virtual vector< string > readMessages (string pattern, int maxWait)
 
virtual string readStr (int nChars)
 
virtual int registerValueCallback (YSpiPortValueCallback callback)
 
virtual int reset (void)
 
int rxCount (void)
 
int rxMsgCount (void)
 
virtual int selectJob (string jobfile)
 
virtual int sendCommand (string text)
 
int set_command (const string &newval)
 
int set_currentJob (const string &newval)
 
int set_protocol (const string &newval)
 
int set_shitftSampling (Y_SHITFTSAMPLING_enum newval)
 
int set_spiMode (const string &newval)
 
virtual int set_SS (int val)
 
int set_ssPolarity (Y_SSPOLARITY_enum newval)
 
int set_startupJob (const string &newval)
 
int set_voltageLevel (Y_VOLTAGELEVEL_enum newval)
 
int setCommand (const string &newval)
 
int setCurrentJob (const string &newval)
 
int setProtocol (const string &newval)
 
int setShitftSampling (Y_SHITFTSAMPLING_enum newval)
 
int setSpiMode (const string &newval)
 
int setSsPolarity (Y_SSPOLARITY_enum newval)
 
int setStartupJob (const string &newval)
 
int setVoltageLevel (Y_VOLTAGELEVEL_enum newval)
 
Y_SHITFTSAMPLING_enum shitftSampling (void)
 
string spiMode (void)
 
Y_SSPOLARITY_enum ssPolarity (void)
 
string startupJob (void)
 
int txCount (void)
 
int txMsgCount (void)
 
virtual int uploadJob (string jobfile, string jsonDef)
 
Y_VOLTAGELEVEL_enum voltageLevel (void)
 
virtual int writeArray (vector< int > byteList)
 
virtual int writeBin (string buff)
 
virtual int writeByte (int code)
 
virtual int writeHex (string hexString)
 
virtual int writeLine (string text)
 
virtual int writeStr (string text)
 
 ~YSpiPort ()
 
- Public Member Functions inherited from YFunction
void _clearDataStreamCache ()
 
string _decode_json_string (const string &json)
 
string _download (const string &url)
 
YDataStream_findDataStream (YDataSet &dataset, const string &def)
 
string _get_json_path (const string &json, const string &path)
 
vector< string > _json_get_array (const string &json)
 
string _json_get_key (const string &json, const string &data)
 
string _json_get_string (const string &json)
 
int _parseEx (yJsonStateMachine &j)
 
virtual int _parserHelper (void)
 
string _parseString (yJsonStateMachine &j)
 
string _request (const string &request)
 
string _requestEx (int tcpchan, const string &request, yapiRequestProgressCallback callback, void *context)
 
void _throw (YRETCODE errType, string errMsg)
 
YRETCODE _upload (const string &path, const string &content)
 
YRETCODE _uploadWithProgress (const string &path, const string &content, yapiRequestProgressCallback callback, void *context)
 
string advertisedValue (void)
 
void clearCache ()
 
string describe (void)
 
string errMessage (void)
 
string errorMessage (void)
 
YRETCODE errorType (void)
 
YRETCODE errType (void)
 
YFUN_DESCR functionDescriptor (void)
 
string get_advertisedValue (void)
 
string get_errorMessage (void)
 
YRETCODE get_errorType (void)
 
virtual string get_friendlyName (void)
 
YFUN_DESCR get_functionDescriptor (void)
 
string get_functionId (void)
 
string get_hardwareId (void)
 
string get_hubSerial ()
 
string get_logicalName (void)
 
YModuleget_module (void)
 
void * get_userData (void)
 
bool isOnline (void)
 
YRETCODE load (int msValidity)
 
virtual string loadAttribute (string attrName)
 
string logicalName (void)
 
YModulemodule (void)
 
virtual int muteValueCallbacks (void)
 
YFunctionnext (void)
 
YFunctionnextFunction (void)
 
virtual int registerValueCallback (YFunctionValueCallback callback)
 
int set_advertisedValue (const string &newval)
 
int set_logicalName (const string &newval)
 
void set_userData (void *data)
 
int setAdvertisedValue (const string &newval)
 
int setLogicalName (const string &newval)
 
void setUserData (void *data)
 
virtual int unmuteValueCallbacks (void)
 
void * userData (void)
 
virtual ~YFunction ()
 

Static Public Member Functions

static YSpiPortFind (string func)
 
static YSpiPortFindSpiPort (string func)
 
static YSpiPortFirst (void)
 
static YSpiPortFirstSpiPort (void)
 
- Static Public Member Functions inherited from YFunction
static void _ClearCache (void)
 
static YFunctionFind (string func)
 
static YFunctionFindFunction (string func)
 
static YFunctionFirst (void)
 
static YFunctionFirstFunction (void)
 

Static Public Attributes

static const string COMMAND_INVALID = YAPI_INVALID_STRING
 
static const string CURRENTJOB_INVALID = YAPI_INVALID_STRING
 
static const int ERRCOUNT_INVALID = YAPI_INVALID_UINT
 
static const string LASTMSG_INVALID = YAPI_INVALID_STRING
 
static const string PROTOCOL_INVALID = YAPI_INVALID_STRING
 
static const int RXCOUNT_INVALID = YAPI_INVALID_UINT
 
static const int RXMSGCOUNT_INVALID = YAPI_INVALID_UINT
 
static const Y_SHITFTSAMPLING_enum SHITFTSAMPLING_INVALID = Y_SHITFTSAMPLING_INVALID
 
static const Y_SHITFTSAMPLING_enum SHITFTSAMPLING_OFF = Y_SHITFTSAMPLING_OFF
 
static const Y_SHITFTSAMPLING_enum SHITFTSAMPLING_ON = Y_SHITFTSAMPLING_ON
 
static const string SPIMODE_INVALID = YAPI_INVALID_STRING
 
static const Y_SSPOLARITY_enum SSPOLARITY_ACTIVE_HIGH = Y_SSPOLARITY_ACTIVE_HIGH
 
static const Y_SSPOLARITY_enum SSPOLARITY_ACTIVE_LOW = Y_SSPOLARITY_ACTIVE_LOW
 
static const Y_SSPOLARITY_enum SSPOLARITY_INVALID = Y_SSPOLARITY_INVALID
 
static const string STARTUPJOB_INVALID = YAPI_INVALID_STRING
 
static const int TXCOUNT_INVALID = YAPI_INVALID_UINT
 
static const int TXMSGCOUNT_INVALID = YAPI_INVALID_UINT
 
static const Y_VOLTAGELEVEL_enum VOLTAGELEVEL_INVALID = Y_VOLTAGELEVEL_INVALID
 
static const Y_VOLTAGELEVEL_enum VOLTAGELEVEL_OFF = Y_VOLTAGELEVEL_OFF
 
static const Y_VOLTAGELEVEL_enum VOLTAGELEVEL_RS232 = Y_VOLTAGELEVEL_RS232
 
static const Y_VOLTAGELEVEL_enum VOLTAGELEVEL_RS485 = Y_VOLTAGELEVEL_RS485
 
static const Y_VOLTAGELEVEL_enum VOLTAGELEVEL_TTL3V = Y_VOLTAGELEVEL_TTL3V
 
static const Y_VOLTAGELEVEL_enum VOLTAGELEVEL_TTL3VR = Y_VOLTAGELEVEL_TTL3VR
 
static const Y_VOLTAGELEVEL_enum VOLTAGELEVEL_TTL5V = Y_VOLTAGELEVEL_TTL5V
 
static const Y_VOLTAGELEVEL_enum VOLTAGELEVEL_TTL5VR = Y_VOLTAGELEVEL_TTL5VR
 
- Static Public Attributes inherited from YFunction
static const string ADVERTISEDVALUE_INVALID = YAPI_INVALID_STRING
 
static const string FRIENDLYNAME_INVALID = YAPI_INVALID_STRING
 
static const YFUN_DESCR FUNCTIONDESCRIPTOR_INVALID = Y_FUNCTIONDESCRIPTOR_INVALID
 
static const string FUNCTIONID_INVALID = YAPI_INVALID_STRING
 
static const string HARDWAREID_INVALID = YAPI_INVALID_STRING
 
static const string LOGICALNAME_INVALID = YAPI_INVALID_STRING
 

Protected Member Functions

virtual int _parseAttr (YJSONObject *json_val)
 
 YSpiPort (const string &func)
 
- Protected Member Functions inherited from YFunction
YRETCODE _buildSetRequest (const string &changeattr, const string *changeval, string &request, string &errmsg)
 
string _escapeAttr (const string &changeval)
 
YRETCODE _getDescriptor (YFUN_DESCR &fundescr, string &errMsg)
 
YRETCODE _getDevice (YDevice *&dev, string &errMsg)
 
YRETCODE _load_unsafe (int msValidity)
 
YRETCODE _nextFunction (string &hwId)
 
int _parse (YJSONObject *j)
 
YRETCODE _setAttr (string attrname, string newvalue)
 
 YFunction (const string &func)
 

Protected Attributes

string _command
 
string _currentJob
 
int _errCount
 
string _lastMsg
 
string _protocol
 
string _rxbuff
 
int _rxbuffptr
 
int _rxCount
 
int _rxMsgCount
 
int _rxptr
 
Y_SHITFTSAMPLING_enum _shitftSampling
 
string _spiMode
 
Y_SSPOLARITY_enum _ssPolarity
 
string _startupJob
 
int _txCount
 
int _txMsgCount
 
YSpiPortValueCallback _valueCallbackSpiPort
 
Y_VOLTAGELEVEL_enum _voltageLevel
 
- Protected Attributes inherited from YFunction
string _advertisedValue
 
u64 _cacheExpiration
 
string _className
 
std::map< string, YDataStream * > _dataStreams
 
string _func
 
YFUN_DESCR _fundescr
 
string _funId
 
string _hwId
 
string _lastErrorMsg
 
YRETCODE _lastErrorType
 
string _logicalName
 
string _serial
 
yCRITICAL_SECTION _this_cs
 
void * _userData
 
YFunctionValueCallback _valueCallbackFunction
 

Friends

YSpiPortyFindSpiPort (const string &func)
 
YSpiPortyFirstSpiPort (void)
 

Additional Inherited Members

- Static Protected Member Functions inherited from YFunction
static void _AddToCache (const string &classname, const string &func, YFunction *obj)
 
static YFunction_FindFromCache (const string &classname, const string &func)
 
static void _UpdateTimedReportCallbackList (YFunction *func, bool add)
 
static void _UpdateValueCallbackList (YFunction *func, bool add)
 
- Static Protected Attributes inherited from YFunction
static std::map< string, YFunction * > _cache
 

Detailed Description

YSpiPort Class: SPI Port function interface

The SpiPort function interface allows you to fully drive a Yoctopuce SPI port, to send and receive data, and to configure communication parameters (baud rate, bit count, parity, flow control and protocol). Note that Yoctopuce SPI ports are not exposed as virtual COM ports. They are meant to be used in the same way as all Yoctopuce devices.

Definition at line 107 of file yocto_spiport.h.

Constructor & Destructor Documentation

YSpiPort::YSpiPort ( const string &  func)
protected

Definition at line 51 of file yocto_spiport.cpp.

YSpiPort::~YSpiPort ( )

Definition at line 75 of file yocto_spiport.cpp.

Member Function Documentation

int YSpiPort::_invokeValueCallback ( string  value)
virtual

Reimplemented from YFunction.

Definition at line 836 of file yocto_spiport.cpp.

int YSpiPort::_parseAttr ( YJSONObject json_val)
protectedvirtual

Reimplemented from YFunction.

Definition at line 89 of file yocto_spiport.cpp.

string YSpiPort::command ( void  )
inline

Definition at line 302 of file yocto_spiport.h.

string YSpiPort::currentJob ( void  )
inline

Definition at line 255 of file yocto_spiport.h.

int YSpiPort::errCount ( void  )
inline

Definition at line 207 of file yocto_spiport.h.

static YSpiPort* YSpiPort::Find ( string  func)
inlinestatic

Definition at line 763 of file yocto_spiport.h.

YSpiPort * YSpiPort::FindSpiPort ( string  func)
static

Retrieves a SPI port for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

This function does not require that the SPI port is online at the time it is invoked. The returned object is nevertheless valid. Use the method YSpiPort.isOnline() to test if the SPI port is indeed online at a given time. In case of ambiguity when looking for a SPI port by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.

If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string that uniquely characterizes the SPI port
Returns
a YSpiPort object allowing you to drive the SPI port.

Definition at line 785 of file yocto_spiport.cpp.

static YSpiPort* YSpiPort::First ( void  )
inlinestatic

Definition at line 787 of file yocto_spiport.h.

YSpiPort * YSpiPort::FirstSpiPort ( void  )
static

Starts the enumeration of SPI ports currently accessible. Use the method YSpiPort.nextSpiPort() to iterate on next SPI ports.

Returns
a pointer to a YSpiPort object, corresponding to the first SPI port currently online, or a NULL pointer if there are none.

Definition at line 1495 of file yocto_spiport.cpp.

string YSpiPort::get_command ( void  )

Definition at line 423 of file yocto_spiport.cpp.

string YSpiPort::get_currentJob ( void  )

Returns the name of the job file currently in use.

Returns
a string corresponding to the name of the job file currently in use

On failure, throws an exception or returns Y_CURRENTJOB_INVALID.

Definition at line 318 of file yocto_spiport.cpp.

int YSpiPort::get_errCount ( void  )

Returns the total number of communication errors detected since last reset.

Returns
an integer corresponding to the total number of communication errors detected since last reset

On failure, throws an exception or returns Y_ERRCOUNT_INVALID.

Definition at line 202 of file yocto_spiport.cpp.

string YSpiPort::get_lastMsg ( void  )

Returns the latest message fully received (for Line and Frame protocols).

Returns
a string corresponding to the latest message fully received (for Line and Frame protocols)

On failure, throws an exception or returns Y_LASTMSG_INVALID.

Definition at line 289 of file yocto_spiport.cpp.

string YSpiPort::get_protocol ( void  )

Returns the type of protocol used over the serial line, as a string. Possible values are "Line" for ASCII messages separated by CR and/or LF, "Frame:[timeout]ms" for binary messages separated by a delay time, "Char" for a continuous ASCII stream or "Byte" for a continuous binary stream.

Returns
a string corresponding to the type of protocol used over the serial line, as a string

On failure, throws an exception or returns Y_PROTOCOL_INVALID.

Definition at line 534 of file yocto_spiport.cpp.

int YSpiPort::get_rxCount ( void  )

Returns the total number of bytes received since last reset.

Returns
an integer corresponding to the total number of bytes received since last reset

On failure, throws an exception or returns Y_RXCOUNT_INVALID.

Definition at line 144 of file yocto_spiport.cpp.

int YSpiPort::get_rxMsgCount ( void  )

Returns the total number of messages received since last reset.

Returns
an integer corresponding to the total number of messages received since last reset

On failure, throws an exception or returns Y_RXMSGCOUNT_INVALID.

Definition at line 231 of file yocto_spiport.cpp.

Y_SHITFTSAMPLING_enum YSpiPort::get_shitftSampling ( void  )

Returns true when the SDI line phase is shifted with regards to the SDO line.

Returns
either Y_SHITFTSAMPLING_OFF or Y_SHITFTSAMPLING_ON, according to true when the SDI line phase is shifted with regards to the SDO line

On failure, throws an exception or returns Y_SHITFTSAMPLING_INVALID.

Definition at line 709 of file yocto_spiport.cpp.

string YSpiPort::get_spiMode ( void  )

Returns the SPI port communication parameters, as a string such as "125000,0,msb". The string includes the baud rate, the SPI mode (between 0 and 3) and the bit order.

Returns
a string corresponding to the SPI port communication parameters, as a string such as "125000,0,msb"

On failure, throws an exception or returns Y_SPIMODE_INVALID.

Definition at line 597 of file yocto_spiport.cpp.

Y_SSPOLARITY_enum YSpiPort::get_ssPolarity ( void  )

Returns the SS line polarity.

Returns
either Y_SSPOLARITY_ACTIVE_LOW or Y_SSPOLARITY_ACTIVE_HIGH, according to the SS line polarity

On failure, throws an exception or returns Y_SSPOLARITY_INVALID.

Definition at line 654 of file yocto_spiport.cpp.

string YSpiPort::get_startupJob ( void  )

Returns the job file to use when the device is powered on.

Returns
a string corresponding to the job file to use when the device is powered on

On failure, throws an exception or returns Y_STARTUPJOB_INVALID.

Definition at line 374 of file yocto_spiport.cpp.

int YSpiPort::get_txCount ( void  )

Returns the total number of bytes transmitted since last reset.

Returns
an integer corresponding to the total number of bytes transmitted since last reset

On failure, throws an exception or returns Y_TXCOUNT_INVALID.

Definition at line 173 of file yocto_spiport.cpp.

int YSpiPort::get_txMsgCount ( void  )

Returns the total number of messages send since last reset.

Returns
an integer corresponding to the total number of messages send since last reset

On failure, throws an exception or returns Y_TXMSGCOUNT_INVALID.

Definition at line 260 of file yocto_spiport.cpp.

Y_VOLTAGELEVEL_enum YSpiPort::get_voltageLevel ( void  )

Returns the voltage level used on the serial line.

Returns
a value among Y_VOLTAGELEVEL_OFF, Y_VOLTAGELEVEL_TTL3V, Y_VOLTAGELEVEL_TTL3VR, Y_VOLTAGELEVEL_TTL5V, Y_VOLTAGELEVEL_TTL5VR, Y_VOLTAGELEVEL_RS232 and Y_VOLTAGELEVEL_RS485 corresponding to the voltage level used on the serial line

On failure, throws an exception or returns Y_VOLTAGELEVEL_INVALID.

Definition at line 470 of file yocto_spiport.cpp.

string YSpiPort::lastMsg ( void  )
inline

Definition at line 243 of file yocto_spiport.h.

YSpiPort* YSpiPort::next ( void  )
inline

Definition at line 774 of file yocto_spiport.h.

YSpiPort * YSpiPort::nextSpiPort ( void  )

Continues the enumeration of SPI ports started using yFirstSpiPort().

Returns
a pointer to a YSpiPort object, corresponding to a SPI port currently online, or a NULL pointer if there are no more SPI ports to enumerate.

Definition at line 1485 of file yocto_spiport.cpp.

string YSpiPort::protocol ( void  )
inline

Definition at line 355 of file yocto_spiport.h.

string YSpiPort::queryLine ( string  query,
int  maxWait 
)
virtual

Sends a text line query to the serial port, and reads the reply, if any. This function is intended to be used when the serial port is configured for 'Line' protocol.

Parameters
query: the line query to send (without CR/LF)
maxWait: the maximum number of milliseconds to wait for a reply.
Returns
the next text line received after sending the text query, as a string. Additional lines can be obtained by calling readLine or readMessages.

On failure, throws an exception or returns an empty array.

Definition at line 1412 of file yocto_spiport.cpp.

int YSpiPort::read_avail ( void  )
virtual

Returns the number of bytes available to read in the input buffer starting from the current absolute stream position pointer of the API object.

Returns
the number of bytes available to read

Definition at line 1385 of file yocto_spiport.cpp.

int YSpiPort::read_seek ( int  absPos)
virtual

Changes the current internal stream position to the specified value. This function does not affect the device, it only changes the value stored in the API object for the next read operations.

Parameters
absPos: the absolute position index for next read operations.
Returns
nothing.

Definition at line 1363 of file yocto_spiport.cpp.

int YSpiPort::read_tell ( void  )
virtual

Returns the current absolute stream position pointer of the API object.

Returns
the absolute position index for next read operations.

Definition at line 1374 of file yocto_spiport.cpp.

vector< int > YSpiPort::readArray ( int  nChars)
virtual

Reads data from the receive buffer as a list of bytes, starting at current stream position. If data at current stream position is not available anymore in the receive buffer, the function performs a short read.

Parameters
nChars: the maximum number of bytes to read
Returns
a sequence of bytes with receive buffer contents

On failure, throws an exception or returns a negative error code.

Definition at line 1189 of file yocto_spiport.cpp.

string YSpiPort::readBin ( int  nChars)
virtual

Reads data from the receive buffer as a binary buffer, starting at current stream position. If data at current stream position is not available anymore in the receive buffer, the function performs a short read.

Parameters
nChars: the maximum number of bytes to read
Returns
a binary object with receive buffer contents

On failure, throws an exception or returns a negative error code.

Definition at line 1147 of file yocto_spiport.cpp.

int YSpiPort::readByte ( void  )
virtual

Reads one byte from the receive buffer, starting at current stream position. If data at current stream position is not available anymore in the receive buffer, or if there is no data available yet, the function returns YAPI_NO_MORE_DATA.

Returns
the next byte

On failure, throws an exception or returns a negative error code.

Definition at line 1040 of file yocto_spiport.cpp.

string YSpiPort::readHex ( int  nBytes)
virtual

Reads data from the receive buffer as a hexadecimal string, starting at current stream position. If data at current stream position is not available anymore in the receive buffer, the function performs a short read.

Parameters
nBytes: the maximum number of bytes to read
Returns
a string with receive buffer contents, encoded in hexadecimal

On failure, throws an exception or returns a negative error code.

Definition at line 1233 of file yocto_spiport.cpp.

string YSpiPort::readLine ( void  )
virtual

Reads a single line (or message) from the receive buffer, starting at current stream position. This function is intended to be used when the serial port is configured for a message protocol, such as 'Line' mode or frame protocols.

If data at current stream position is not available anymore in the receive buffer, the function returns the oldest available line and moves the stream position just after. If no new full line is received, the function returns an empty line.

Returns
a string with a single line of text

On failure, throws an exception or returns a negative error code.

Definition at line 1281 of file yocto_spiport.cpp.

vector< string > YSpiPort::readMessages ( string  pattern,
int  maxWait 
)
virtual

Searches for incoming messages in the serial port receive buffer matching a given pattern, starting at current position. This function will only compare and return printable characters in the message strings. Binary protocols are handled as hexadecimal strings.

The search returns all messages matching the expression provided as argument in the buffer. If no matching message is found, the search waits for one up to the specified maximum timeout (in milliseconds).

Parameters
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.
Returns
an array of strings containing the messages found, if any. Binary messages are converted to hexadecimal representation.

On failure, throws an exception or returns an empty array.

Definition at line 1327 of file yocto_spiport.cpp.

string YSpiPort::readStr ( int  nChars)
virtual

Reads data from the receive buffer as a string, starting at current stream position. If data at current stream position is not available anymore in the receive buffer, the function performs a short read.

Parameters
nChars: the maximum number of characters to read
Returns
a string with receive buffer contents

On failure, throws an exception or returns a negative error code.

Definition at line 1111 of file yocto_spiport.cpp.

int YSpiPort::registerValueCallback ( YSpiPortValueCallback  callback)
virtual

Registers the callback function that is invoked on every change of advertised value. The callback is invoked only during the execution of ySleep or yHandleEvents. This provides control over the time when the callback is triggered. For good responsiveness, remember to call one of these two functions periodically. To unregister a callback, pass a NULL pointer as argument.

Parameters
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.

Definition at line 817 of file yocto_spiport.cpp.

int YSpiPort::reset ( void  )
virtual

Clears the serial port buffer and resets counters to zero.

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 858 of file yocto_spiport.cpp.

int YSpiPort::rxCount ( void  )
inline

Definition at line 183 of file yocto_spiport.h.

int YSpiPort::rxMsgCount ( void  )
inline

Definition at line 219 of file yocto_spiport.h.

int YSpiPort::selectJob ( string  jobfile)
virtual

Load and start processing the specified job file. The file must have been previously created using the user interface or uploaded on the device filesystem using the uploadJob() function.

Parameters
jobfile: name of the job file (on the device filesystem)
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 1465 of file yocto_spiport.cpp.

int YSpiPort::sendCommand ( string  text)
virtual

Definition at line 846 of file yocto_spiport.cpp.

int YSpiPort::set_command ( const string &  newval)

Definition at line 445 of file yocto_spiport.cpp.

int YSpiPort::set_currentJob ( const string &  newval)

Changes the job to use when the device is powered on. Remember to call the saveToFlash() method of the module if the modification must be kept.

Parameters
newval: a string corresponding to the job to use when the device is powered on
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 351 of file yocto_spiport.cpp.

int YSpiPort::set_protocol ( const string &  newval)

Changes the type of protocol used over the serial line. Possible values are "Line" for ASCII messages separated by CR and/or LF, "Frame:[timeout]ms" for binary messages separated by a delay time, "Char" for a continuous ASCII stream or "Byte" for a continuous binary stream. The suffix "/[wait]ms" can be added to reduce the transmit rate so that there is always at lest the specified number of milliseconds between each bytes sent.

Parameters
newval: a string corresponding to the type of protocol used over the serial line
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 571 of file yocto_spiport.cpp.

int YSpiPort::set_shitftSampling ( Y_SHITFTSAMPLING_enum  newval)

Changes the SDI line sampling shift. When disabled, SDI line is sampled in the middle of data output time. When enabled, SDI line is samples at the end of data output time.

Parameters
newval: either Y_SHITFTSAMPLING_OFF or Y_SHITFTSAMPLING_ON, according to the SDI line sampling shift
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 742 of file yocto_spiport.cpp.

int YSpiPort::set_spiMode ( const string &  newval)

Changes the SPI port communication parameters, with a string such as "125000,0,msb". The string includes the baud rate, the SPI mode (between 0 and 3) and the bit order.

Parameters
newval: a string corresponding to the SPI port communication parameters, with a string such as "125000,0,msb"
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 631 of file yocto_spiport.cpp.

int YSpiPort::set_SS ( int  val)
virtual

Manually sets the state of the SS line. This function has no effect when the SS line is handled automatically.

Parameters
val: 1 to turn SS active, 0 to release SS.
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 1480 of file yocto_spiport.cpp.

int YSpiPort::set_ssPolarity ( Y_SSPOLARITY_enum  newval)

Changes the SS line polarity.

Parameters
newval: either Y_SSPOLARITY_ACTIVE_LOW or Y_SSPOLARITY_ACTIVE_HIGH, according to the SS line polarity
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 685 of file yocto_spiport.cpp.

int YSpiPort::set_startupJob ( const string &  newval)

Changes the job to use when the device is powered on. Remember to call the saveToFlash() method of the module if the modification must be kept.

Parameters
newval: a string corresponding to the job to use when the device is powered on
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 407 of file yocto_spiport.cpp.

int YSpiPort::set_voltageLevel ( Y_VOLTAGELEVEL_enum  newval)

Changes the voltage type used on the serial line. Valid values will depend on the Yoctopuce device model featuring the serial port feature. Check your device documentation to find out which values are valid for that specific model. Trying to set an invalid value will have no effect.

Parameters
newval: a value among Y_VOLTAGELEVEL_OFF, Y_VOLTAGELEVEL_TTL3V, Y_VOLTAGELEVEL_TTL3VR, Y_VOLTAGELEVEL_TTL5V, Y_VOLTAGELEVEL_TTL5VR, Y_VOLTAGELEVEL_RS232 and Y_VOLTAGELEVEL_RS485 corresponding to the voltage type used on the serial line
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 507 of file yocto_spiport.cpp.

int YSpiPort::setCommand ( const string &  newval)
inline

Definition at line 306 of file yocto_spiport.h.

int YSpiPort::setCurrentJob ( const string &  newval)
inline

Definition at line 270 of file yocto_spiport.h.

int YSpiPort::setProtocol ( const string &  newval)
inline

Definition at line 374 of file yocto_spiport.h.

int YSpiPort::setShitftSampling ( Y_SHITFTSAMPLING_enum  newval)
inline

Definition at line 458 of file yocto_spiport.h.

int YSpiPort::setSpiMode ( const string &  newval)
inline

Definition at line 405 of file yocto_spiport.h.

int YSpiPort::setSsPolarity ( Y_SSPOLARITY_enum  newval)
inline

Definition at line 430 of file yocto_spiport.h.

int YSpiPort::setStartupJob ( const string &  newval)
inline

Definition at line 297 of file yocto_spiport.h.

int YSpiPort::setVoltageLevel ( Y_VOLTAGELEVEL_enum  newval)
inline

Definition at line 339 of file yocto_spiport.h.

Y_SHITFTSAMPLING_enum YSpiPort::shitftSampling ( void  )
inline

Definition at line 443 of file yocto_spiport.h.

string YSpiPort::spiMode ( void  )
inline

Definition at line 389 of file yocto_spiport.h.

Y_SSPOLARITY_enum YSpiPort::ssPolarity ( void  )
inline

Definition at line 417 of file yocto_spiport.h.

string YSpiPort::startupJob ( void  )
inline

Definition at line 282 of file yocto_spiport.h.

int YSpiPort::txCount ( void  )
inline

Definition at line 195 of file yocto_spiport.h.

int YSpiPort::txMsgCount ( void  )
inline

Definition at line 231 of file yocto_spiport.h.

int YSpiPort::uploadJob ( string  jobfile,
string  jsonDef 
)
virtual

Saves the job definition string (JSON data) into a job file. The job file can be later enabled using selectJob().

Parameters
jobfile: name of the job file to save on the device filesystem
jsonDef: a string containing a JSON definition of the job
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 1448 of file yocto_spiport.cpp.

Y_VOLTAGELEVEL_enum YSpiPort::voltageLevel ( void  )
inline

Definition at line 320 of file yocto_spiport.h.

int YSpiPort::writeArray ( vector< int >  byteList)
virtual

Sends a byte sequence (provided as a list of bytes) to the serial port.

Parameters
byteList: a list of byte codes
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 941 of file yocto_spiport.cpp.

int YSpiPort::writeBin ( string  buff)
virtual

Sends a binary buffer to the serial port, as is.

Parameters
buff: the binary buffer to send
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 927 of file yocto_spiport.cpp.

int YSpiPort::writeByte ( int  code)
virtual

Sends a single byte to the serial port.

Parameters
code: the byte to send
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 876 of file yocto_spiport.cpp.

int YSpiPort::writeHex ( string  hexString)
virtual

Sends a byte sequence (provided as a hexadecimal string) to the serial port.

Parameters
hexString: a string of hexadecimal byte codes
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 970 of file yocto_spiport.cpp.

int YSpiPort::writeLine ( string  text)
virtual

Sends an ASCII string to the serial port, followed by a line break (CR LF).

Parameters
text: the text string to send
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 1003 of file yocto_spiport.cpp.

int YSpiPort::writeStr ( string  text)
virtual

Sends an ASCII string to the serial port, as is.

Parameters
text: the text string to send
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 890 of file yocto_spiport.cpp.

Friends And Related Function Documentation

YSpiPort* yFindSpiPort ( const string &  func)
friend

Retrieves a SPI port for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

This function does not require that the SPI port is online at the time it is invoked. The returned object is nevertheless valid. Use the method YSpiPort.isOnline() to test if the SPI port is indeed online at a given time. In case of ambiguity when looking for a SPI port by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.

If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string that uniquely characterizes the SPI port
Returns
a YSpiPort object allowing you to drive the SPI port.

Definition at line 824 of file yocto_spiport.h.

YSpiPort* yFirstSpiPort ( void  )
friend

Starts the enumeration of SPI ports currently accessible. Use the method YSpiPort.nextSpiPort() to iterate on next SPI ports.

Returns
a pointer to a YSpiPort object, corresponding to the first SPI port currently online, or a NULL pointer if there are none.

Definition at line 835 of file yocto_spiport.h.

Member Data Documentation

string YSpiPort::_command
protected

Definition at line 123 of file yocto_spiport.h.

string YSpiPort::_currentJob
protected

Definition at line 121 of file yocto_spiport.h.

int YSpiPort::_errCount
protected

Definition at line 117 of file yocto_spiport.h.

string YSpiPort::_lastMsg
protected

Definition at line 120 of file yocto_spiport.h.

string YSpiPort::_protocol
protected

Definition at line 125 of file yocto_spiport.h.

string YSpiPort::_rxbuff
protected

Definition at line 131 of file yocto_spiport.h.

int YSpiPort::_rxbuffptr
protected

Definition at line 132 of file yocto_spiport.h.

int YSpiPort::_rxCount
protected

Definition at line 115 of file yocto_spiport.h.

int YSpiPort::_rxMsgCount
protected

Definition at line 118 of file yocto_spiport.h.

int YSpiPort::_rxptr
protected

Definition at line 130 of file yocto_spiport.h.

Y_SHITFTSAMPLING_enum YSpiPort::_shitftSampling
protected

Definition at line 128 of file yocto_spiport.h.

string YSpiPort::_spiMode
protected

Definition at line 126 of file yocto_spiport.h.

Y_SSPOLARITY_enum YSpiPort::_ssPolarity
protected

Definition at line 127 of file yocto_spiport.h.

string YSpiPort::_startupJob
protected

Definition at line 122 of file yocto_spiport.h.

int YSpiPort::_txCount
protected

Definition at line 116 of file yocto_spiport.h.

int YSpiPort::_txMsgCount
protected

Definition at line 119 of file yocto_spiport.h.

YSpiPortValueCallback YSpiPort::_valueCallbackSpiPort
protected

Definition at line 129 of file yocto_spiport.h.

Y_VOLTAGELEVEL_enum YSpiPort::_voltageLevel
protected

Definition at line 124 of file yocto_spiport.h.

const string YSpiPort::COMMAND_INVALID = YAPI_INVALID_STRING
static

Definition at line 156 of file yocto_spiport.h.

const string YSpiPort::CURRENTJOB_INVALID = YAPI_INVALID_STRING
static

Definition at line 154 of file yocto_spiport.h.

const int YSpiPort::ERRCOUNT_INVALID = YAPI_INVALID_UINT
static

Definition at line 150 of file yocto_spiport.h.

const string YSpiPort::LASTMSG_INVALID = YAPI_INVALID_STRING
static

Definition at line 153 of file yocto_spiport.h.

const string YSpiPort::PROTOCOL_INVALID = YAPI_INVALID_STRING
static

Definition at line 165 of file yocto_spiport.h.

const int YSpiPort::RXCOUNT_INVALID = YAPI_INVALID_UINT
static

Definition at line 148 of file yocto_spiport.h.

const int YSpiPort::RXMSGCOUNT_INVALID = YAPI_INVALID_UINT
static

Definition at line 151 of file yocto_spiport.h.

const Y_SHITFTSAMPLING_enum YSpiPort::SHITFTSAMPLING_INVALID = Y_SHITFTSAMPLING_INVALID
static

Definition at line 172 of file yocto_spiport.h.

const Y_SHITFTSAMPLING_enum YSpiPort::SHITFTSAMPLING_OFF = Y_SHITFTSAMPLING_OFF
static

Definition at line 170 of file yocto_spiport.h.

const Y_SHITFTSAMPLING_enum YSpiPort::SHITFTSAMPLING_ON = Y_SHITFTSAMPLING_ON
static

Definition at line 171 of file yocto_spiport.h.

const string YSpiPort::SPIMODE_INVALID = YAPI_INVALID_STRING
static

Definition at line 166 of file yocto_spiport.h.

const Y_SSPOLARITY_enum YSpiPort::SSPOLARITY_ACTIVE_HIGH = Y_SSPOLARITY_ACTIVE_HIGH
static

Definition at line 168 of file yocto_spiport.h.

const Y_SSPOLARITY_enum YSpiPort::SSPOLARITY_ACTIVE_LOW = Y_SSPOLARITY_ACTIVE_LOW
static

Definition at line 167 of file yocto_spiport.h.

const Y_SSPOLARITY_enum YSpiPort::SSPOLARITY_INVALID = Y_SSPOLARITY_INVALID
static

Definition at line 169 of file yocto_spiport.h.

const string YSpiPort::STARTUPJOB_INVALID = YAPI_INVALID_STRING
static

Definition at line 155 of file yocto_spiport.h.

const int YSpiPort::TXCOUNT_INVALID = YAPI_INVALID_UINT
static

Definition at line 149 of file yocto_spiport.h.

const int YSpiPort::TXMSGCOUNT_INVALID = YAPI_INVALID_UINT
static

Definition at line 152 of file yocto_spiport.h.

const Y_VOLTAGELEVEL_enum YSpiPort::VOLTAGELEVEL_INVALID = Y_VOLTAGELEVEL_INVALID
static

Definition at line 164 of file yocto_spiport.h.

const Y_VOLTAGELEVEL_enum YSpiPort::VOLTAGELEVEL_OFF = Y_VOLTAGELEVEL_OFF
static

Definition at line 157 of file yocto_spiport.h.

const Y_VOLTAGELEVEL_enum YSpiPort::VOLTAGELEVEL_RS232 = Y_VOLTAGELEVEL_RS232
static

Definition at line 162 of file yocto_spiport.h.

const Y_VOLTAGELEVEL_enum YSpiPort::VOLTAGELEVEL_RS485 = Y_VOLTAGELEVEL_RS485
static

Definition at line 163 of file yocto_spiport.h.

const Y_VOLTAGELEVEL_enum YSpiPort::VOLTAGELEVEL_TTL3V = Y_VOLTAGELEVEL_TTL3V
static

Definition at line 158 of file yocto_spiport.h.

const Y_VOLTAGELEVEL_enum YSpiPort::VOLTAGELEVEL_TTL3VR = Y_VOLTAGELEVEL_TTL3VR
static

Definition at line 159 of file yocto_spiport.h.

const Y_VOLTAGELEVEL_enum YSpiPort::VOLTAGELEVEL_TTL5V = Y_VOLTAGELEVEL_TTL5V
static

Definition at line 160 of file yocto_spiport.h.

const Y_VOLTAGELEVEL_enum YSpiPort::VOLTAGELEVEL_TTL5VR = Y_VOLTAGELEVEL_TTL5VR
static

Definition at line 161 of file yocto_spiport.h.


The documentation for this class was generated from the following files:


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:14