#include <yocto_api.h>
Static Public Member Functions | |
static string | _bin2HexStr (const string &data) |
static string | _checkFirmware (const string &serial, const string &rev, const string &path) |
static double | _decimalToDouble (s16 val) |
static vector< int > | _decodeFloats (string sdat) |
static vector< int > | _decodeWords (string s) |
static s16 | _doubleToDecimal (double val) |
static string | _flattenJsonStruct (string jsonbuffer) |
static yCalibrationHandler | _getCalibrationHandler (int calibType) |
static string | _hexStr2Bin (const string &str) |
static void | _yapiFunctionUpdateCallbackFwd (YFUN_DESCR fundesc, const char *value) |
static bool | CheckLogicalName (const string &name) |
static void | DisableExceptions (void) |
static void | EnableExceptions (void) |
static void | FreeAPI (void) |
static string | GetAPIVersion (void) |
static u64 | GetTickCount (void) |
static YRETCODE | HandleEvents (string &errmsg) |
static YRETCODE | InitAPI (int mode, string &errmsg) |
static double | LinearCalibrationHandler (double rawValue, int calibType, intArr params, floatArr rawValues, floatArr refValues) |
static YRETCODE | PreregisterHub (const string &url, string &errmsg) |
static void | RegisterCalibrationHandler (int calibrationType, yCalibrationHandler calibrationHandler) |
static void | RegisterDeviceArrivalCallback (yDeviceUpdateCallback arrivalCallback) |
static void | RegisterDeviceChangeCallback (yDeviceUpdateCallback changeCallback) |
static void | RegisterDeviceRemovalCallback (yDeviceUpdateCallback removalCallback) |
static YRETCODE | RegisterHub (const string &url, string &errmsg) |
static void | RegisterHubDiscoveryCallback (YHubDiscoveryCallback hubDiscoveryCallback) |
static void | RegisterLogFunction (yLogFunction logfun) |
static YRETCODE | Sleep (unsigned ms_duration, string &errmsg) |
static YRETCODE | TestHub (const string &url, int mstimeout, string &errmsg) |
static YRETCODE | TriggerHubDiscovery (string &errmsg) |
static void | UnregisterHub (const string &url) |
static YRETCODE | UpdateDeviceList (string &errmsg) |
Static Public Attributes | |
static bool | _apiInitialized = false |
static yCRITICAL_SECTION | _global_cs |
static int | DefaultCacheValidity = 5 |
static const u32 | DETECT_ALL = (Y_DETECT_USB | Y_DETECT_NET) |
static const u32 | DETECT_NET = 2 |
static const u32 | DETECT_NONE = 0 |
static const u32 | DETECT_USB = 1 |
static const int | DEVICE_BUSY = -6 |
static const int | DEVICE_NOT_FOUND = -4 |
static yDeviceUpdateCallback | DeviceArrivalCallback = NULL |
static yDeviceUpdateCallback | DeviceChangeCallback = NULL |
static yDeviceUpdateCallback | DeviceRemovalCallback = NULL |
static const int | DOUBLE_ACCES = -11 |
static bool | ExceptionsDisabled = false |
static const int | EXHAUSTED = -10 |
static const int | FILE_NOT_FOUND = -14 |
static const int | INVALID_ARGUMENT = -2 |
static const double | INVALID_DOUBLE = (-DBL_MAX) |
static const int | INVALID_INT = YAPI_INVALID_INT |
static const s64 | INVALID_LONG = YAPI_INVALID_LONG |
static const string | INVALID_STRING = YAPI_INVALID_STRING |
static const int | INVALID_UINT = YAPI_INVALID_UINT |
static const int | IO_ERROR = -8 |
static yLogFunction | LogFunction = NULL |
static const int | NO_MORE_DATA = -9 |
static const int | NOT_INITIALIZED = -1 |
static const int | NOT_SUPPORTED = -3 |
static const u32 | RESEND_MISSING_PKT = 4 |
static const int | RTC_NOT_READY = -13 |
static const int | SUCCESS = 0 |
static const int | TIMEOUT = -7 |
static const int | UNAUTHORIZED = -12 |
static const int | VERSION_MISMATCH = -5 |
Static Private Member Functions | |
static void | _yapiDeviceArrivalCallbackFwd (YDEV_DESCR devdesc) |
static void | _yapiDeviceChangeCallbackFwd (YDEV_DESCR devdesc) |
static void | _yapiDeviceLogCallbackFwd (YDEV_DESCR devdesc, const char *line) |
static void | _yapiDeviceRemovalCallbackFwd (YDEV_DESCR devdesc) |
static void | _yapiFunctionTimedReportCallbackFwd (YAPI_FUNCTION fundesc, double timestamp, const u8 *bytes, u32 len) |
static void | _yapiHubDiscoveryCallbackFwd (const char *serial, const char *url) |
static void | _yapiLogFunctionFwd (const char *log, u32 loglen) |
Static Private Attributes | |
static map< int, yCalibrationHandler > | _calibHandlers |
static queue< yapiDataEvent > | _data_events |
static YHubDiscoveryCallback | _HubDiscoveryCallback = NULL |
static u64 | _nextEnum = 0 |
static queue< yapiGlobalEvent > | _plug_events |
Definition at line 440 of file yocto_api.h.
|
static |
Definition at line 4116 of file yocto_api.cpp.
|
static |
|
static |
Definition at line 3977 of file yocto_api.cpp.
|
static |
Definition at line 4067 of file yocto_api.cpp.
|
static |
Definition at line 4033 of file yocto_api.cpp.
|
static |
Definition at line 3995 of file yocto_api.cpp.
|
static |
|
static |
Definition at line 4023 of file yocto_api.cpp.
|
static |
Definition at line 4130 of file yocto_api.cpp.
|
staticprivate |
Definition at line 3863 of file yocto_api.cpp.
|
staticprivate |
Definition at line 3903 of file yocto_api.cpp.
|
staticprivate |
Definition at line 3847 of file yocto_api.cpp.
|
staticprivate |
Definition at line 3889 of file yocto_api.cpp.
|
staticprivate |
Definition at line 3937 of file yocto_api.cpp.
|
static |
Definition at line 3918 of file yocto_api.cpp.
|
staticprivate |
Definition at line 3956 of file yocto_api.cpp.
|
staticprivate |
Definition at line 3840 of file yocto_api.cpp.
|
static |
Checks if a given string is valid as logical name for a module or a function. A valid logical name has a maximum of 19 characters, all among A..Z, a..z, 0..9, _, and -. If you try to configure a logical name with an incorrect string, the invalid characters are ignored.
name | : a string containing the name to check. |
Definition at line 4771 of file yocto_api.cpp.
|
static |
Disables the use of exceptions to report runtime errors. When exceptions are disabled, every function returns a specific error value which depends on its type and which is documented in this reference manual.
Definition at line 4288 of file yocto_api.cpp.
|
static |
Re-enables the use of exceptions for runtime error handling. Be aware than when exceptions are enabled, every function that fails triggers an exception. If the exception is not caught by the user code, it either fires the debugger or aborts (i.e. crash) the program. On failure, throws an exception or returns a negative error code.
Definition at line 4298 of file yocto_api.cpp.
|
static |
Frees dynamically allocated memory blocks used by the Yoctopuce library. It is generally not required to call this function, unless you want to free all dynamically allocated memory blocks in order to track a memory leak for instance. You should not call any other library function after calling yFreeAPI(), or your program will crash.
Definition at line 4262 of file yocto_api.cpp.
|
static |
Returns the version identifier for the Yoctopuce library in use. The version is a string in the form "Major.Minor.Build", for instance "1.01.5535". For languages using an external DLL (for instance C#, VisualBasic or Delphi), the character string includes as well the DLL version, for instance "1.01.5535 (1.01.5439)".
If you want to verify in your code that the library version is compatible with the version that you have used during development, verify that the major number is strictly equal and that the minor number is greater or equal. The build number is not relevant with respect to the library compatibility.
Definition at line 4192 of file yocto_api.cpp.
|
static |
Returns the current value of a monotone millisecond-based time counter. This counter can be used to compute delays in relation with Yoctopuce devices, which also uses the millisecond as timebase.
Definition at line 4755 of file yocto_api.cpp.
|
static |
Maintains the device-to-library communication channel. If your program includes significant loops, you may want to include a call to this function to make sure that the library takes care of the information pushed by the modules on the communication channels. This is not strictly necessary, but it may improve the reactivity of the library for the following commands.
This function may signal an error in case there is a communication problem while contacting a module.
errmsg | : a string passed by reference to receive any error message. |
On failure, throws an exception or returns a negative error code.
Definition at line 4658 of file yocto_api.cpp.
|
static |
Initializes the Yoctopuce programming library explicitly. It is not strictly needed to call yInitAPI(), as the library is automatically initialized when calling yRegisterHub() for the first time.
When Y_DETECT_NONE is used as detection mode, you must explicitly use yRegisterHub() to point the API to the VirtualHub on which your devices are connected before trying to access them.
mode | : an integer corresponding to the type of automatic device detection to use. Possible values are Y_DETECT_NONE, Y_DETECT_USB, Y_DETECT_NET, and Y_DETECT_ALL. |
errmsg | : a string passed by reference to receive any error message. |
On failure, throws an exception or returns a negative error code.
Definition at line 4221 of file yocto_api.cpp.
|
static |
Definition at line 4408 of file yocto_api.cpp.
|
static |
Fault-tolerant alternative to RegisterHub(). This function has the same purpose and same arguments as RegisterHub(), but does not trigger an error when the selected hub is not available at the time of the function call. This makes it possible to register a network hub independently of the current connectivity, and to try to contact it only when a device is actively needed.
url | : a string containing either "usb","callback" or the root URL of the hub to monitor |
errmsg | : a string passed by reference to receive any error message. |
On failure, throws an exception or returns a negative error code.
Definition at line 4539 of file yocto_api.cpp.
|
static |
Definition at line 4401 of file yocto_api.cpp.
|
static |
Register a callback function, to be called each time a device is plugged. This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis.
arrivalCallback | : a procedure taking a YModule parameter, or NULL to unregister a previously registered callback. |
Definition at line 4321 of file yocto_api.cpp.
|
static |
Definition at line 4350 of file yocto_api.cpp.
|
static |
Register a callback function, to be called each time a device is unplugged. This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis.
removalCallback | : a procedure taking a YModule parameter, or NULL to unregister a previously registered callback. |
Definition at line 4345 of file yocto_api.cpp.
|
static |
Setup the Yoctopuce library to use modules connected on a given machine. The parameter will determine how the API will work. Use the following values:
usb: When the usb keyword is used, the API will work with devices connected directly to the USB bus. Some programming languages such a Javascript, PHP, and Java don't provide direct access to USB hardware, so usb will not work with these. In this case, use a VirtualHub or a networked YoctoHub (see below).
x.x.x.x or hostname: The API will use the devices connected to the host with the given IP address or hostname. That host can be a regular computer running a VirtualHub, or a networked YoctoHub such as YoctoHub-Ethernet or YoctoHub-Wireless. If you want to use the VirtualHub running on you local computer, use the IP address 127.0.0.1.
callback: that keyword make the API run in "<i>HTTP Callback</i>" mode. This a special mode allowing to take control of Yoctopuce devices through a NAT filter when using a VirtualHub or a networked YoctoHub. You only need to configure your hub to call your server script on a regular basis. This mode is currently available for PHP and Node.JS only.
Be aware that only one application can use direct USB access at a given time on a machine. Multiple access would cause conflicts while trying to access the USB modules. In particular, this means that you must stop the VirtualHub software before starting an application that uses direct USB access. The workaround for this limitation is to setup the library to use the VirtualHub rather than direct USB access.
If access control has been activated on the hub, virtual or not, you want to reach, the URL parameter should look like:
http://username:password@address:port
You can call RegisterHub several times to connect to several machines.
url | : a string containing either "usb","callback" or the root URL of the hub to monitor |
errmsg | : a string passed by reference to receive any error message. |
On failure, throws an exception or returns a negative error code.
Definition at line 4509 of file yocto_api.cpp.
|
static |
Register a callback function, to be called each time an Network Hub send an SSDP message. The callback has two string parameter, the first one contain the serial number of the hub and the second contain the URL of the network hub (this URL can be passed to RegisterHub). This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis.
hubDiscoveryCallback | : a procedure taking two string parameter, the serial number and the hub URL. Use NULL to unregister a previously registered callback. |
Definition at line 4365 of file yocto_api.cpp.
|
static |
Registers a log callback function. This callback will be called each time the API have something to say. Quite useful to debug the API.
logfun | : a procedure taking a string parameter, or NULL to unregister a previously registered callback. |
Definition at line 4308 of file yocto_api.cpp.
|
static |
Pauses the execution flow for a specified duration. This function implements a passive waiting loop, meaning that it does not consume CPU cycles significantly. The processor is left available for other threads and processes. During the pause, the library nevertheless reads from time to time information from the Yoctopuce modules by calling yHandleEvents(), in order to stay up-to-date.
This function may signal an error in case there is a communication problem while contacting a module.
ms_duration | : an integer corresponding to the duration of the pause, in milliseconds. |
errmsg | : a string passed by reference to receive any error message. |
On failure, throws an exception or returns a negative error code.
Definition at line 4725 of file yocto_api.cpp.
|
static |
Test if the hub is reachable. This method do not register the hub, it only test if the hub is usable. The url parameter follow the same convention as the RegisterHub method. This method is useful to verify the authentication parameters for a hub. It is possible to force this method to return after mstimeout milliseconds.
url | : a string containing either "usb","callback" or the root URL of the hub to monitor |
mstimeout | : the number of millisecond available to test the connection. |
errmsg | : a string passed by reference to receive any error message. |
On failure returns a negative error code.
Definition at line 4453 of file yocto_api.cpp.
|
static |
Force a hub discovery, if a callback as been registered with yRegisterHubDiscoveryCallback it will be called for each net work hub that will respond to the discovery.
errmsg | : a string passed by reference to receive any error message. |
Definition at line 4381 of file yocto_api.cpp.
|
static |
Setup the Yoctopuce library to no more use modules connected on a previously registered machine with RegisterHub.
url | : a string containing either "usb" or the root URL of the hub to monitor |
Definition at line 4560 of file yocto_api.cpp.
|
static |
Triggers a (re)detection of connected Yoctopuce modules. The library searches the machines or USB ports previously registered using yRegisterHub(), and invokes any user-defined callback function in case a change in the list of connected devices is detected.
This function can be called as frequently as desired to refresh the device list and to make the application aware of hot-plug events.
errmsg | : a string passed by reference to receive any error message. |
On failure, throws an exception or returns a negative error code.
Definition at line 4584 of file yocto_api.cpp.
|
static |
Definition at line 475 of file yocto_api.h.
|
staticprivate |
Definition at line 447 of file yocto_api.h.
|
staticprivate |
Definition at line 443 of file yocto_api.h.
|
static |
Definition at line 476 of file yocto_api.h.
|
staticprivate |
Definition at line 444 of file yocto_api.h.
|
staticprivate |
Definition at line 445 of file yocto_api.h.
|
staticprivate |
Definition at line 442 of file yocto_api.h.
|
static |
Definition at line 468 of file yocto_api.h.
|
static |
Definition at line 488 of file yocto_api.h.
|
static |
Definition at line 486 of file yocto_api.h.
|
static |
Definition at line 484 of file yocto_api.h.
|
static |
Definition at line 485 of file yocto_api.h.
|
static |
Definition at line 497 of file yocto_api.h.
|
static |
Definition at line 495 of file yocto_api.h.
|
static |
Definition at line 480 of file yocto_api.h.
|
static |
Definition at line 482 of file yocto_api.h.
|
static |
Definition at line 481 of file yocto_api.h.
|
static |
Definition at line 502 of file yocto_api.h.
|
static |
Definition at line 469 of file yocto_api.h.
|
static |
Definition at line 501 of file yocto_api.h.
|
static |
Definition at line 505 of file yocto_api.h.
|
static |
Definition at line 493 of file yocto_api.h.
|
static |
Definition at line 473 of file yocto_api.h.
|
static |
Definition at line 471 of file yocto_api.h.
|
static |
Definition at line 474 of file yocto_api.h.
|
static |
Definition at line 470 of file yocto_api.h.
|
static |
Definition at line 472 of file yocto_api.h.
|
static |
Definition at line 499 of file yocto_api.h.
|
static |
Definition at line 479 of file yocto_api.h.
|
static |
Definition at line 500 of file yocto_api.h.
|
static |
Definition at line 492 of file yocto_api.h.
|
static |
Definition at line 494 of file yocto_api.h.
|
static |
Definition at line 487 of file yocto_api.h.
|
static |
Definition at line 504 of file yocto_api.h.
|
static |
Definition at line 491 of file yocto_api.h.
|
static |
Definition at line 498 of file yocto_api.h.
|
static |
Definition at line 503 of file yocto_api.h.
|
static |
Definition at line 496 of file yocto_api.h.