libsigrok  0.2.2
sigrok hardware access and backend library
 All Data Structures Files Functions Variables Typedefs Enumerator Macros Groups Pages
Functions
Hardware drivers

Hardware driver handling in libsigrok. More...

Functions

struct sr_dev_driver ** sr_driver_list (void)
 Return the list of supported hardware drivers. More...
 
int sr_driver_init (struct sr_context *ctx, struct sr_dev_driver *driver)
 Initialize a hardware driver. More...
 
GSList * sr_driver_scan (struct sr_dev_driver *driver, GSList *options)
 Tell a hardware driver to scan for devices. More...
 
int sr_config_get (const struct sr_dev_driver *driver, int key, GVariant **data, const struct sr_dev_inst *sdi)
 Returns information about the given driver or device instance. More...
 
int sr_config_set (const struct sr_dev_inst *sdi, int key, GVariant *data)
 Set a configuration key in a device instance. More...
 
int sr_config_list (const struct sr_dev_driver *driver, int key, GVariant **data, const struct sr_dev_inst *sdi)
 List all possible values for a configuration key. More...
 
struct sr_config_infosr_config_info_get (int key)
 Get information about a configuration key. More...
 
struct sr_config_infosr_config_info_name_get (const char *optname)
 Get information about an configuration key, by name. More...
 

Detailed Description

Hardware driver handling in libsigrok.

Function Documentation

int sr_config_get ( const struct sr_dev_driver driver,
int  key,
GVariant **  data,
const struct sr_dev_inst sdi 
)

Returns information about the given driver or device instance.

Parameters
driverThe sr_dev_driver struct to query.
keyThe configuration key (SR_CONF_*).
dataPointer to a GVariant where the value will be stored. Must not be NULL. The caller is given ownership of the GVariant and must thus decrease the refcount after use. However if this function returns an error code, the field should be considered unused, and should not be unreferenced.
sdi(optional) If the key is specific to a device, this must contain a pointer to the struct sr_dev_inst to be checked. Otherwise it must be NULL.
Returns
SR_OK upon success or SR_ERR in case of error. Note SR_ERR_ARG may be returned by the driver indicating it doesn't know that key, but this is not to be flagged as an error by the caller; merely as an indication that it's not applicable.

Definition at line 507 of file hwdriver.c.

References sr_dev_driver::config_get, SR_ERR, SR_ERR_ARG, and SR_OK.

Referenced by sr_session_save().

+ Here is the caller graph for this function:

struct sr_config_info* sr_config_info_get ( int  key)
read

Get information about a configuration key.

Parameters
keyThe configuration key.
Returns
A pointer to a struct sr_config_info, or NULL if the key was not found.

Definition at line 600 of file hwdriver.c.

References sr_config_info::key.

struct sr_config_info* sr_config_info_name_get ( const char *  optname)
read

Get information about an configuration key, by name.

Parameters
optnameThe configuration key.
Returns
A pointer to a struct sr_config_info, or NULL if the key was not found.

Definition at line 620 of file hwdriver.c.

References sr_config_info::key.

int sr_config_list ( const struct sr_dev_driver driver,
int  key,
GVariant **  data,
const struct sr_dev_inst sdi 
)

List all possible values for a configuration key.

Parameters
driverThe sr_dev_driver struct to query.
keyThe configuration key (SR_CONF_*).
dataA pointer to a GVariant where the list will be stored. The caller is given ownership of the GVariant and must thus unref the GVariant after use. However if this function returns an error code, the field should be considered unused, and should not be unreferenced.
sdi(optional) If the key is specific to a device, this must contain a pointer to the struct sr_dev_inst to be checked.
Returns
SR_OK upon success or SR_ERR in case of error. Note SR_ERR_ARG may be returned by the driver indicating it doesn't know that key, but this is not to be flagged as an error by the caller; merely as an indication that it's not applicable.

Definition at line 577 of file hwdriver.c.

References sr_dev_driver::config_list, SR_ERR, SR_ERR_ARG, and SR_OK.

int sr_config_set ( const struct sr_dev_inst sdi,
int  key,
GVariant *  data 
)

Set a configuration key in a device instance.

Parameters
sdiThe device instance.
keyThe configuration key (SR_CONF_*).
dataThe new value for the key, as a GVariant with GVariantType appropriate to that key. A floating reference can be passed in; its refcount will be sunk and unreferenced after use.
Returns
SR_OK upon success or SR_ERR in case of error. Note SR_ERR_ARG may be returned by the driver indicating it doesn't know that key, but this is not to be flagged as an error by the caller; merely as an indication that it's not applicable.

Definition at line 541 of file hwdriver.c.

References sr_dev_driver::config_set, sr_dev_inst::driver, SR_ERR, and SR_ERR_ARG.

int sr_driver_init ( struct sr_context *  ctx,
struct sr_dev_driver driver 
)

Initialize a hardware driver.

This usually involves memory allocations and variable initializations within the driver, but not scanning for attached devices. The API call sr_driver_scan() is used for that.

Parameters
ctxA libsigrok context object allocated by a previous call to sr_init(). Must not be NULL.
driverThe driver to initialize. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid parameters, SR_ERR_BUG upon internal errors, or another negative error code upon other errors.

Definition at line 381 of file hwdriver.c.

References sr_dev_driver::init, sr_dev_driver::name, sr_err, SR_ERR_ARG, and sr_spew.

struct sr_dev_driver** sr_driver_list ( void  )
read

Return the list of supported hardware drivers.

Returns
Pointer to the NULL-terminated list of hardware driver pointers.

Definition at line 359 of file hwdriver.c.

GSList* sr_driver_scan ( struct sr_dev_driver driver,
GSList *  options 
)

Tell a hardware driver to scan for devices.

In addition to the detection, the devices that are found are also initialized automatically. On some devices, this involves a firmware upload, or other such measures.

The order in which the system is scanned for devices is not specified. The caller should not assume or rely on any specific order.

Before calling sr_driver_scan(), the user must have previously initialized the driver by calling sr_driver_init().

Parameters
driverThe driver that should scan. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL.
optionsA list of 'struct sr_hwopt' options to pass to the driver's scanner. Can be NULL/empty.
Returns
A GSList * of 'struct sr_dev_inst', or NULL if no devices were found (or errors were encountered). This list must be freed by the caller using g_slist_free(), but without freeing the data pointed to in the list.

Definition at line 425 of file hwdriver.c.

References sr_dev_driver::name, sr_dev_driver::priv, sr_dev_driver::scan, sr_err, and sr_spew.