#include <yocto_digitalio.h>
Public Member Functions | |
virtual int | _invokeValueCallback (string value) |
string | command (void) |
virtual int | delayedPulse (int bitno, int ms_delay, int ms_duration) |
virtual int | get_bitDirection (int bitno) |
virtual int | get_bitOpenDrain (int bitno) |
virtual int | get_bitPolarity (int bitno) |
virtual int | get_bitState (int bitno) |
string | get_command (void) |
Y_OUTPUTVOLTAGE_enum | get_outputVoltage (void) |
int | get_portDiags (void) |
int | get_portDirection (void) |
int | get_portOpenDrain (void) |
int | get_portPolarity (void) |
int | get_portSize (void) |
int | get_portState (void) |
YDigitalIO * | next (void) |
YDigitalIO * | nextDigitalIO (void) |
Y_OUTPUTVOLTAGE_enum | outputVoltage (void) |
int | portDiags (void) |
int | portDirection (void) |
int | portOpenDrain (void) |
int | portPolarity (void) |
int | portSize (void) |
int | portState (void) |
virtual int | pulse (int bitno, int ms_duration) |
virtual int | registerValueCallback (YDigitalIOValueCallback callback) |
virtual int | set_bitDirection (int bitno, int bitdirection) |
virtual int | set_bitOpenDrain (int bitno, int opendrain) |
virtual int | set_bitPolarity (int bitno, int bitpolarity) |
virtual int | set_bitState (int bitno, int bitstate) |
int | set_command (const string &newval) |
int | set_outputVoltage (Y_OUTPUTVOLTAGE_enum newval) |
int | set_portDirection (int newval) |
int | set_portOpenDrain (int newval) |
int | set_portPolarity (int newval) |
int | set_portState (int newval) |
int | setCommand (const string &newval) |
int | setOutputVoltage (Y_OUTPUTVOLTAGE_enum newval) |
int | setPortDirection (int newval) |
int | setPortOpenDrain (int newval) |
int | setPortPolarity (int newval) |
int | setPortState (int newval) |
virtual int | toggle_bitState (int bitno) |
~YDigitalIO () | |
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) |
YModule * | get_module (void) |
void * | get_userData (void) |
bool | isOnline (void) |
YRETCODE | load (int msValidity) |
virtual string | loadAttribute (string attrName) |
string | logicalName (void) |
YModule * | module (void) |
virtual int | muteValueCallbacks (void) |
YFunction * | next (void) |
YFunction * | nextFunction (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 YDigitalIO * | Find (string func) |
static YDigitalIO * | FindDigitalIO (string func) |
static YDigitalIO * | First (void) |
static YDigitalIO * | FirstDigitalIO (void) |
Static Public Member Functions inherited from YFunction | |
static void | _ClearCache (void) |
static YFunction * | Find (string func) |
static YFunction * | FindFunction (string func) |
static YFunction * | First (void) |
static YFunction * | FirstFunction (void) |
Protected Member Functions | |
virtual int | _parseAttr (YJSONObject *json_val) |
YDigitalIO (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 |
Y_OUTPUTVOLTAGE_enum | _outputVoltage |
int | _portDiags |
int | _portDirection |
int | _portOpenDrain |
int | _portPolarity |
int | _portSize |
int | _portState |
YDigitalIOValueCallback | _valueCallbackDigitalIO |
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 | |
YDigitalIO * | yFindDigitalIO (const string &func) |
YDigitalIO * | yFirstDigitalIO (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 |
YDigitalIO Class: Digital IO function interface
The Yoctopuce application programming interface allows you to switch the state of each bit of the I/O port. You can switch all bits at once, or one by one. The library can also automatically generate short pulses of a determined duration. Electrical behavior of each I/O can be modified (open drain and reverse polarity).
Definition at line 82 of file yocto_digitalio.h.
|
protected |
Definition at line 51 of file yocto_digitalio.cpp.
YDigitalIO::~YDigitalIO | ( | ) |
Definition at line 67 of file yocto_digitalio.cpp.
|
virtual |
Reimplemented from YFunction.
Definition at line 568 of file yocto_digitalio.cpp.
|
protectedvirtual |
Reimplemented from YFunction.
Definition at line 76 of file yocto_digitalio.cpp.
|
inline |
Definition at line 295 of file yocto_digitalio.h.
|
virtual |
Schedules a pulse on a single bit for a specified duration. The specified bit will be turned to 1, and then back to 0 after the given duration.
bitno | : the bit number; lowest bit has index 0 |
ms_delay | : waiting time before the pulse, in milliseconds |
ms_duration | : desired pulse duration in milliseconds. Be aware that the device time resolution is not guaranteed up to the millisecond. |
On failure, throws an exception or returns a negative error code.
Definition at line 786 of file yocto_digitalio.cpp.
|
inlinestatic |
Definition at line 488 of file yocto_digitalio.h.
|
static |
Retrieves a digital IO port for a given identifier. The identifier can be specified using several formats:
This function does not require that the digital IO port is online at the time it is invoked. The returned object is nevertheless valid. Use the method YDigitalIO.isOnline() to test if the digital IO port is indeed online at a given time. In case of ambiguity when looking for a digital IO 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.
func | : a string that uniquely characterizes the digital IO port |
Definition at line 517 of file yocto_digitalio.cpp.
|
inlinestatic |
Definition at line 512 of file yocto_digitalio.h.
|
static |
Starts the enumeration of digital IO ports currently accessible. Use the method YDigitalIO.nextDigitalIO() to iterate on next digital IO ports.
Definition at line 801 of file yocto_digitalio.cpp.
|
virtual |
Returns the direction of a single bit from the I/O port (0 means the bit is an input, 1 an output).
bitno | : the bit number; lowest bit has index 0 |
On failure, throws an exception or returns a negative error code.
Definition at line 664 of file yocto_digitalio.cpp.
|
virtual |
Returns the type of electrical interface of a single bit from the I/O port. (0 means the bit is an input, 1 an output).
bitno | : the bit number; lowest bit has index 0 |
On failure, throws an exception or returns a negative error code.
Definition at line 749 of file yocto_digitalio.cpp.
|
virtual |
Returns the polarity of a single bit from the I/O port (0 means the I/O works in regular mode, 1 means the I/O works in reverse mode).
bitno | : the bit number; lowest bit has index 0 |
On failure, throws an exception or returns a negative error code.
Definition at line 706 of file yocto_digitalio.cpp.
|
virtual |
Returns the state of a single bit of the I/O port.
bitno | : the bit number; lowest bit has index 0 |
On failure, throws an exception or returns a negative error code.
Definition at line 610 of file yocto_digitalio.cpp.
string YDigitalIO::get_command | ( | void | ) |
Definition at line 452 of file yocto_digitalio.cpp.
Y_OUTPUTVOLTAGE_enum YDigitalIO::get_outputVoltage | ( | void | ) |
Returns the voltage source used to drive output bits.
On failure, throws an exception or returns Y_OUTPUTVOLTAGE_INVALID.
Definition at line 403 of file yocto_digitalio.cpp.
int YDigitalIO::get_portDiags | ( | void | ) |
Returns the port state diagnostics (Yocto-IO and Yocto-MaxiIO-V2 only). Bit 0 indicates a shortcut on output 0, etc. Bit 8 indicates a power failure, and bit 9 signals overheating (overcurrent). During normal use, all diagnostic bits should stay clear.
On failure, throws an exception or returns Y_PORTDIAGS_INVALID.
Definition at line 344 of file yocto_digitalio.cpp.
int YDigitalIO::get_portDirection | ( | void | ) |
Returns the IO direction of all bits of the port: 0 makes a bit an input, 1 makes it an output.
On failure, throws an exception or returns Y_PORTDIRECTION_INVALID.
Definition at line 169 of file yocto_digitalio.cpp.
int YDigitalIO::get_portOpenDrain | ( | void | ) |
Returns the electrical interface for each bit of the port. For each bit set to 0 the matching I/O works in the regular, intuitive way, for each bit set to 1, the I/O works in reverse mode.
On failure, throws an exception or returns Y_PORTOPENDRAIN_INVALID.
Definition at line 227 of file yocto_digitalio.cpp.
int YDigitalIO::get_portPolarity | ( | void | ) |
Returns the polarity of all the bits of the port. For each bit set to 0, the matching I/O works the regular, intuitive way; for each bit set to 1, the I/O works in reverse mode.
On failure, throws an exception or returns Y_PORTPOLARITY_INVALID.
Definition at line 284 of file yocto_digitalio.cpp.
int YDigitalIO::get_portSize | ( | void | ) |
Returns the number of bits implemented in the I/O port.
On failure, throws an exception or returns Y_PORTSIZE_INVALID.
Definition at line 373 of file yocto_digitalio.cpp.
int YDigitalIO::get_portState | ( | void | ) |
Returns the digital IO port state: bit 0 represents input 0, and so on.
On failure, throws an exception or returns Y_PORTSTATE_INVALID.
Definition at line 113 of file yocto_digitalio.cpp.
|
inline |
Definition at line 499 of file yocto_digitalio.h.
YDigitalIO * YDigitalIO::nextDigitalIO | ( | void | ) |
Continues the enumeration of digital IO ports started using yFirstDigitalIO().
Definition at line 791 of file yocto_digitalio.cpp.
|
inline |
Definition at line 275 of file yocto_digitalio.h.
|
inline |
Definition at line 250 of file yocto_digitalio.h.
|
inline |
Definition at line 162 of file yocto_digitalio.h.
|
inline |
Definition at line 191 of file yocto_digitalio.h.
|
inline |
Definition at line 219 of file yocto_digitalio.h.
|
inline |
Definition at line 262 of file yocto_digitalio.h.
|
inline |
Definition at line 135 of file yocto_digitalio.h.
|
virtual |
Triggers a pulse on a single bit for a specified duration. The specified bit will be turned to 1, and then back to 0 after the given duration.
bitno | : the bit number; lowest bit has index 0 |
ms_duration | : desired pulse duration in milliseconds. Be aware that the device time resolution is not guaranteed up to the millisecond. |
On failure, throws an exception or returns a negative error code.
Definition at line 768 of file yocto_digitalio.cpp.
|
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.
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 549 of file yocto_digitalio.cpp.
|
virtual |
Changes the direction of a single bit from the I/O port.
bitno | : the bit number; lowest bit has index 0 |
bitdirection | : direction to set, 0 makes the bit an input, 1 makes it an output. Remember to call the saveToFlash() method to make sure the setting is kept after a reboot. |
On failure, throws an exception or returns a negative error code.
Definition at line 642 of file yocto_digitalio.cpp.
|
virtual |
Changes the electrical interface of a single bit from the I/O port.
bitno | : the bit number; lowest bit has index 0 |
opendrain | : 0 makes a bit a regular input/output, 1 makes it an open-drain (open-collector) input/output. Remember to call the saveToFlash() method to make sure the setting is kept after a reboot. |
On failure, throws an exception or returns a negative error code.
Definition at line 725 of file yocto_digitalio.cpp.
|
virtual |
Changes the polarity of a single bit from the I/O port.
bitno | : the bit number; lowest bit has index 0. |
bitpolarity | : polarity to set, 0 makes the I/O work in regular mode, 1 makes the I/O works in reverse mode. Remember to call the saveToFlash() method to make sure the setting is kept after a reboot. |
On failure, throws an exception or returns a negative error code.
Definition at line 683 of file yocto_digitalio.cpp.
|
virtual |
Sets a single bit of the I/O port.
bitno | : the bit number; lowest bit has index 0 |
bitstate | : the state of the bit (1 or 0) |
On failure, throws an exception or returns a negative error code.
Definition at line 588 of file yocto_digitalio.cpp.
int YDigitalIO::set_command | ( | const string & | newval | ) |
Definition at line 474 of file yocto_digitalio.cpp.
int YDigitalIO::set_outputVoltage | ( | Y_OUTPUTVOLTAGE_enum | newval | ) |
Changes the voltage source used to drive output bits. Remember to call the saveToFlash() method to make sure the setting is kept after a reboot.
newval | : a value among Y_OUTPUTVOLTAGE_USB_5V, Y_OUTPUTVOLTAGE_USB_3V and Y_OUTPUTVOLTAGE_EXT_V corresponding to the voltage source used to drive output bits |
On failure, throws an exception or returns a negative error code.
Definition at line 436 of file yocto_digitalio.cpp.
int YDigitalIO::set_portDirection | ( | int | newval | ) |
Changes the IO direction of all bits of the port: 0 makes a bit an input, 1 makes it an output. Remember to call the saveToFlash() method to make sure the setting is kept after a reboot.
newval | : an integer corresponding to the IO direction of all bits of the port: 0 makes a bit an input, 1 makes it an output |
On failure, throws an exception or returns a negative error code.
Definition at line 202 of file yocto_digitalio.cpp.
int YDigitalIO::set_portOpenDrain | ( | int | newval | ) |
Changes the electrical interface for each bit of the port. 0 makes a bit a regular input/output, 1 makes it an open-drain (open-collector) input/output. Remember to call the saveToFlash() method to make sure the setting is kept after a reboot.
newval | : an integer corresponding to the electrical interface for each bit of the port |
On failure, throws an exception or returns a negative error code.
Definition at line 260 of file yocto_digitalio.cpp.
int YDigitalIO::set_portPolarity | ( | int | newval | ) |
Changes the polarity of all the bits of the port: For each bit set to 0, the matching I/O works the regular, intuitive way; for each bit set to 1, the I/O works in reverse mode. Remember to call the saveToFlash() method to make sure the setting will be kept after a reboot.
newval | : an integer corresponding to the polarity of all the bits of the port: For each bit set to 0, the matching I/O works the regular, intuitive way; for each bit set to 1, the I/O works in reverse mode |
On failure, throws an exception or returns a negative error code.
Definition at line 319 of file yocto_digitalio.cpp.
int YDigitalIO::set_portState | ( | int | newval | ) |
Changes the digital IO port state: bit 0 represents input 0, and so on. This function has no effect on bits configured as input in portDirection.
newval | : an integer corresponding to the digital IO port state: bit 0 represents input 0, and so on |
On failure, throws an exception or returns a negative error code.
Definition at line 145 of file yocto_digitalio.cpp.
|
inline |
Definition at line 299 of file yocto_digitalio.h.
|
inline |
Definition at line 290 of file yocto_digitalio.h.
|
inline |
Definition at line 177 of file yocto_digitalio.h.
|
inline |
Definition at line 206 of file yocto_digitalio.h.
|
inline |
Definition at line 236 of file yocto_digitalio.h.
|
inline |
Definition at line 149 of file yocto_digitalio.h.
|
virtual |
Reverts a single bit of the I/O port.
bitno | : the bit number; lowest bit has index 0 |
On failure, throws an exception or returns a negative error code.
Definition at line 626 of file yocto_digitalio.cpp.
|
friend |
Retrieves a digital IO port for a given identifier. The identifier can be specified using several formats:
This function does not require that the digital IO port is online at the time it is invoked. The returned object is nevertheless valid. Use the method YDigitalIO.isOnline() to test if the digital IO port is indeed online at a given time. In case of ambiguity when looking for a digital IO 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.
func | : a string that uniquely characterizes the digital IO port |
Definition at line 549 of file yocto_digitalio.h.
|
friend |
Starts the enumeration of digital IO ports currently accessible. Use the method YDigitalIO.nextDigitalIO() to iterate on next digital IO ports.
Definition at line 560 of file yocto_digitalio.h.
|
protected |
Definition at line 97 of file yocto_digitalio.h.
|
protected |
Definition at line 96 of file yocto_digitalio.h.
|
protected |
Definition at line 94 of file yocto_digitalio.h.
|
protected |
Definition at line 91 of file yocto_digitalio.h.
|
protected |
Definition at line 92 of file yocto_digitalio.h.
|
protected |
Definition at line 93 of file yocto_digitalio.h.
|
protected |
Definition at line 95 of file yocto_digitalio.h.
|
protected |
Definition at line 90 of file yocto_digitalio.h.
|
protected |
Definition at line 98 of file yocto_digitalio.h.
|
static |
Definition at line 124 of file yocto_digitalio.h.
|
static |
Definition at line 122 of file yocto_digitalio.h.
|
static |
Definition at line 123 of file yocto_digitalio.h.
|
static |
Definition at line 121 of file yocto_digitalio.h.
|
static |
Definition at line 120 of file yocto_digitalio.h.
|
static |
Definition at line 118 of file yocto_digitalio.h.
|
static |
Definition at line 115 of file yocto_digitalio.h.
|
static |
Definition at line 116 of file yocto_digitalio.h.
|
static |
Definition at line 117 of file yocto_digitalio.h.
|
static |
Definition at line 119 of file yocto_digitalio.h.
|
static |
Definition at line 114 of file yocto_digitalio.h.