OkoLib
library for accessing Okolab devices
okolib.h File Reference

Go to the source code of this file.

Typedefs

typedef enum _oko_res_type oko_res_type
 Specifies the return values.
 
typedef enum _oko_module_type oko_module_type
 Specifies the available modules types.
 
typedef enum _oko_prop_type oko_prop_type
 Specifies the available property types.
 
typedef enum _oko_write_type oko_write_type
 Specifies the available write types.
 

Enumerations

enum  _oko_res_type {
  OKO_OK = 0,
  OKO_ERR_UNINIT = -1,
  OKO_ERR_ARG = -2,
  OKO_ERR_FAIL = -3,
  OKO_ERR_NOTSUPP = -4,
  OKO_ERR_CLOSED = -5,
  OKO_ERR_UNCONN = -6,
  OKO_ERR_PORT_BUSY = -7,
  OKO_ERR_PORT_CFG = -8,
  OKO_ERR_PORT_NOTVALID = -9,
  OKO_ERR_DB_OPEN = -10,
  OKO_ERR_PROP_NOTFOUND = -11,
  OKO_ERR_DEV_NOTFOUND = -12,
  OKO_ERR_COMM = -13,
  OKO_ERR_ENUM_NOTFOUND = -14,
  OKO_ERR_MODULE_NOTFOUND = -15,
  OKO_ERR_DEV_SLAVE = -16,
  OKO_ERR_DEV_NOTRUNNING = -17,
  OKO_ERR_MEMORY = -18,
  OKO_ERR_TIMEOUT = -19,
  OKO_ERR_UNDEF = -999
}
 Specifies the return values. More...
 
enum  _oko_module_type {
  OKO_MODULE_TEMP = 0,
  OKO_MODULE_CO2 = 1,
  OKO_MODULE_O2 = 2,
  OKO_MODULE_HMD = 3,
  OKO_MODULE_MAXNUM
}
 Specifies the available modules types. More...
 
enum  _oko_prop_type {
  OKO_PROP_UNDEF = 0,
  OKO_PROP_STRING = 1,
  OKO_PROP_INT = 2,
  OKO_PROP_DOUBLE = 3,
  OKO_PROP_ENUM = 4
}
 Specifies the available property types. More...
 
enum  _oko_write_type {
  OKO_WRITE_NONE = 0,
  OKO_WRITE_EEPROM = 1,
  OKO_WRITE_VOLATILE = 2,
  OKO_WRITE_BOTH = 3
}
 Specifies the available write types. More...
 

Functions

oko_res_type oko_LibInit (const char *db_path)
 Initialize the library. More...
 
oko_res_type oko_LibShutDown ()
 Deallocates any resource that were allocated by oko_LibInitialize. More...
 
oko_res_type oko_LibGetVersion (char *version)
 Print the version of Okolib library on a string passed by reference. More...
 
oko_res_type oko_LibGetLastError (char *errmsg, unsigned int maxsize)
 Return a text message that describes the error for the most recent failed call on general library functions. More...
 
oko_res_type oko_LibSetSuggestedUSBOnly (bool use)
 Turn on/off the filter on the USB serial ports. More...
 
oko_res_type oko_LibGetSuggestedUSBOnly (bool *use)
 Get the usage status of the USB serial ports filter. More...
 
oko_res_type oko_ModulesDetect (uint32_t max_num, oko_module_type *modules, uint32_t *detected_num)
 Detect available modules and open them, returning the type for each module. More...
 
oko_res_type oko_ModulesDetectSelected (const oko_module_type *selected_modules, uint32_t selected_modules_num, oko_module_type *modules, uint32_t *detected_num)
 Detect available modules and open them, returning the type for each module. More...
 
oko_res_type oko_ModuleGetDetails (oko_module_type module, char *name, char *dim_unit, bool *can_disable)
 Returns all information about of the specified module of this device, which is not changing during application runtime. More...
 
oko_res_type oko_ModuleGetCurrentValue (oko_module_type module, double *current_value)
 Returns current value of the specified module. More...
 
oko_res_type oko_ModuleGetSetpointValue (oko_module_type module, double *setpoint_value)
 Returns setpoint value of the specified module of this device. More...
 
oko_res_type oko_ModuleGetLimits (oko_module_type module, double *min_value, double *max_value)
 Returns setpoint limits of the specified module of this device. More...
 
oko_res_type oko_ModuleSetSetpointValue (oko_module_type module, double setpoint_value)
 Set setpoint of the specified module of this device. More...
 
oko_res_type oko_ModuleGetEnabled (oko_module_type module, bool *enabled)
 Returns enable status of the specified module of this device. More...
 
oko_res_type oko_ModuleSetEnabled (oko_module_type module, bool enabled)
 Set enable status of the specified module of this device. More...
 
oko_res_type oko_LibGetNumberOfPorts (uint32_t *count)
 Refresh available ports and return the number of them. More...
 
oko_res_type oko_LibGetPortNames (char **names)
 Refresh available ports and return their names. More...
 
oko_res_type oko_LibGetPortName (uint32_t portidx, char *portname)
 Get the name of the specified port, using the ports refreshed by oko_LibGetNumberOfPorts. More...
 
oko_res_type oko_DeviceOpen (const char *port, uint32_t *deviceh)
 Open the specified device, returning a handle for it. More...
 
oko_res_type oko_DevicesDetect (uint32_t max_num, uint32_t *devicesh, uint32_t *detected_num)
 Detect available devices and open them, returning an handle for each device. More...
 
oko_res_type oko_DevicesDetectByName (uint32_t max_num, uint32_t *devicesh, char *name_filter, uint32_t *detected_num)
 Detect the first available device matching the filter name and open it, returning a handle for it. More...
 
oko_res_type oko_DeviceDetectSingle (uint32_t *deviceh)
 Detect the first available device and open it, returning a handle for it. More...
 
oko_res_type oko_DeviceDetectSingleByName (uint32_t *deviceh, char *name_filter)
 Detect the first available device matching the filter name and open it, returning a handle for it. More...
 
oko_res_type oko_DeviceClose (uint32_t deviceh)
 Close the specified device. More...
 
oko_res_type oko_DeviceGetLastError (uint32_t deviceh, char *errmsg, unsigned int maxsize)
 Return a text message that describes the error for the most recent failed call on a specified device. More...
 
oko_res_type oko_DevicesCloseAll (void)
 Close all the opened devices. More...
 
oko_res_type oko_DeviceGetPortName (uint32_t deviceh, char *port)
 Get the Port Name of the specified device. More...
 
oko_res_type oko_DeviceConnectionStatus (uint32_t deviceh, uint32_t *conn)
 Get the connection status of the current device. More...
 
oko_res_type oko_DeviceSetChecksumUsage (uint32_t deviceh, bool use_checksum)
 Set the checksum usage flag of the current device. More...
 
oko_res_type oko_DeviceGetChecksumUsage (uint32_t deviceh, bool *use_checksum)
 Get the checksum usage flag of the current device. More...
 
oko_res_type oko_DeviceGetChecksumAvailable (uint32_t deviceh, bool *checksum)
 Check if the communication protocol of the specified device supports checksum. More...
 
oko_res_type oko_PropertiesGetNumber (uint32_t deviceh, uint32_t *num)
 Get the number of available properties of the current device. More...
 
oko_res_type oko_PropertyGetName (uint32_t deviceh, uint32_t index, char *name)
 Get the name of the specified property, using its index. More...
 
oko_res_type oko_PropertyGetType (uint32_t deviceh, const char *name, oko_prop_type *prop_type)
 Get the type of the specified property. More...
 
oko_res_type oko_PropertyGetEnumNumber (uint32_t deviceh, const char *name, unsigned int *num)
 Get the number of availables enum values of the specified property. More...
 
oko_res_type oko_PropertyGetEnumName (uint32_t deviceh, const char *name, uint32_t enumh, char *enumname)
 Get the name of the specified enum field of the specified property. More...
 
oko_res_type oko_PropertyGetUnit (uint32_t deviceh, const char *name, char *unit)
 Get the measure unit of the specified property. More...
 
oko_res_type oko_PropertyGetDescription (uint32_t deviceh, const char *name, char *desc)
 Get the description of the specified property. More...
 
oko_res_type oko_PropertyGetReadOnly (uint32_t deviceh, const char *name, bool *read_only)
 Verify if the specified property is read-only. More...
 
oko_res_type oko_PropertyGetWriteOnly (uint32_t deviceh, const char *name, bool *write_only)
 Verify if the specified property is write-only. More...
 
oko_res_type oko_PropertyGetWriteType (uint32_t deviceh, const char *name, oko_write_type *write_type)
 Get the write type of the specified property. More...
 
oko_res_type oko_PropertyHasLimits (uint32_t deviceh, const char *name, bool *has_limits)
 Verify if the specified property has readable limits. More...
 
oko_res_type oko_PropertyGetLimits (uint32_t deviceh, const char *name, double *min, double *max)
 Get the minimum and maximum value that can be set for the specified property. More...
 
oko_res_type oko_PropertyIsMain (uint32_t deviceh, const char *name, bool *is_main)
 Verify if the specified property is a main feature of the device. More...
 
oko_res_type oko_PropertyIsAdvanced (uint32_t deviceh, const char *name, bool *is_adv)
 Verify if the specified property is an advanced feature of the device. More...
 
oko_res_type oko_PropertyReadString (uint32_t deviceh, const char *name, char *val)
 Get the current value of a string property. More...
 
oko_res_type oko_PropertyReadInt (uint32_t deviceh, const char *name, int32_t *val)
 Get the current value of a integer property. More...
 
oko_res_type oko_PropertyReadDouble (uint32_t deviceh, const char *name, double *val)
 Get the current value of a double property. More...
 
oko_res_type oko_PropertyUpdate (uint32_t deviceh, const char *name)
 Update the specified property value, reading it from the current device. More...
 
oko_res_type oko_PropertyWriteString (uint32_t deviceh, const char *name, const char *val, bool async)
 Change the current value of the specified string property. More...
 
oko_res_type oko_PropertyWriteInt (uint32_t deviceh, const char *name, int32_t val, char async)
 Change the current value of the specified integer property. More...
 
oko_res_type oko_PropertyWriteDouble (uint32_t deviceh, const char *name, double val, char async)
 Change the current value of the specified double property. More...
 
oko_res_type oko_PropertyWriteVolatileString (uint32_t deviceh, const char *name, const char *val, bool async)
 Change the current value of the specified string property in the volatile memory. More...
 
oko_res_type oko_PropertyWriteVolatileInt (uint32_t deviceh, const char *name, int32_t val, char async)
 Change the current value of the specified integer property in the volatile memory. More...
 
oko_res_type oko_PropertyWriteVolatileDouble (uint32_t deviceh, const char *name, double val, char async)
 Change the current value of the specified double property in the volatile memory. More...
 
oko_res_type oko_PropertyAutoUpdate (uint32_t deviceh, const char *name, uint32_t freq_ms)
 Set the update frequency to read the specified property value from the current device. More...
 
oko_res_type oko_StartPropertyLogging (uint32_t deviceh, const char *filename, uint32_t freq_ms)
 Start the property logging feature for the specified device. More...
 
oko_res_type oko_StopPropertyLogging (uint32_t deviceh)
 Stop the property logging feature for the specified device. More...
 
oko_res_type oko_PropertyLoggingGetFileName (uint32_t deviceh, char *filename)
 Get the file path used to log the specified device. More...
 
oko_res_type oko_StartPlayback (uint32_t deviceh, const char *filename)
 Start the playback feature for the specified device. More...
 
oko_res_type oko_StopPlayback (uint32_t deviceh)
 Start the playback feature for the specified device. More...
 
oko_res_type oko_PlaybakGetFileName (uint32_t deviceh, char *filename)
 Get the file path used to playback the specified device. More...
 
oko_res_type oko_CommandExecute (uint32_t deviceh, const char *name)
 Execute a command. More...