libsigrok  0.3.0
sigrok hardware access and backend library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
Devices

Device handling in libsigrok. More...

Functions

int sr_dev_channel_name_set (const struct sr_dev_inst *sdi, int channelnum, const char *name)
 Set the name of the specified channel in the specified device. More...
 
int sr_dev_channel_enable (const struct sr_dev_inst *sdi, int channelnum, gboolean state)
 Enable or disable a channel on the specified device. More...
 
int sr_dev_trigger_set (const struct sr_dev_inst *sdi, int channelnum, const char *trigger)
 Add a trigger to the specified device (and the specified channel). More...
 
gboolean sr_dev_has_option (const struct sr_dev_inst *sdi, int key)
 Determine whether the specified device instance has the specified capability. More...
 
GSList * sr_dev_list (const struct sr_dev_driver *driver)
 Get the list of devices/instances of the specified driver. More...
 
int sr_dev_clear (const struct sr_dev_driver *driver)
 Clear the list of device instances a driver knows about. More...
 
int sr_dev_open (struct sr_dev_inst *sdi)
 Open the specified device. More...
 
int sr_dev_close (struct sr_dev_inst *sdi)
 Close the specified device. More...
 

Detailed Description

Device handling in libsigrok.

Function Documentation

int sr_dev_channel_enable ( const struct sr_dev_inst sdi,
int  channelnum,
gboolean  state 
)

Enable or disable a channel on the specified device.

Parameters
sdiThe device instance the channel is connected to.
channelnumThe channel number, starting from 0.
stateTRUE to enable the channel, FALSE to disable.
Returns
SR_OK on success or SR_ERR on failure. In case of invalid arguments, SR_ERR_ARG is returned and the channel enabled state remains unchanged.
Since
0.3.0

Definition at line 127 of file device.c.

References sr_dev_inst::channels, sr_dev_driver::config_channel_set, sr_dev_inst::driver, sr_channel::enabled, sr_channel::index, SR_ERR_ARG, and SR_OK.

Referenced by sr_session_load().

+ Here is the caller graph for this function:

int sr_dev_channel_name_set ( const struct sr_dev_inst sdi,
int  channelnum,
const char *  name 
)

Set the name of the specified channel in the specified device.

If the channel already has a different name assigned to it, it will be removed, and the new name will be saved instead.

Parameters
sdiThe device instance the channel is connected to.
[in]channelnumThe number of the channel whose name to set. Note that the channel numbers start at 0.
[in]nameThe new name that the specified channel should get. A copy of the string is made.
Returns
SR_OK on success, or SR_ERR_ARG on invalid arguments.
Since
0.3.0

Definition at line 88 of file device.c.

References sr_dev_inst::channels, sr_channel::index, sr_channel::name, SR_ERR_ARG, and SR_OK.

Referenced by sr_session_load().

+ Here is the caller graph for this function:

int sr_dev_clear ( const struct sr_dev_driver driver)

Clear the list of device instances a driver knows about.

Parameters
driverThe driver to use. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL.
Return values
SR_OKSuccess
SR_ERR_ARGInvalid driver
Since
0.2.0

Definition at line 471 of file device.c.

References sr_dev_driver::dev_clear, and SR_ERR_ARG.

int sr_dev_close ( struct sr_dev_inst sdi)

Close the specified device.

Parameters
sdiDevice instance to use. Must not be NULL.
Returns
SR_OK upon success, a negative error code upon errors.
Since
0.2.0

Definition at line 518 of file device.c.

References sr_dev_driver::dev_close, sr_dev_inst::driver, and SR_ERR.

gboolean sr_dev_has_option ( const struct sr_dev_inst sdi,
int  key 
)

Determine whether the specified device instance has the specified capability.

Parameters
sdiPointer to the device instance to be checked. Must not be NULL. If the device's 'driver' field is NULL (virtual device), this function will always return FALSE (virtual devices don't have a hardware capabilities list).
[in]keyThe option that should be checked for is supported by the specified device.
Return values
TRUEDevice has the specified option
FALSEDevice does not have the specified option, invalid input parameters or other error conditions.
Since
0.2.0

Definition at line 233 of file device.c.

References sr_dev_driver::config_list, sr_dev_inst::driver, SR_CONF_DEVICE_OPTIONS, and SR_OK.

Referenced by sr_session_save().

+ Here is the caller graph for this function:

GSList* sr_dev_list ( const struct sr_dev_driver driver)

Get the list of devices/instances of the specified driver.

Parameters
driverThe driver to use. Must not be NULL.
Returns
The list of devices/instances of this driver, or NULL upon errors or if the list is empty.
Since
0.2.0

Definition at line 452 of file device.c.

References sr_dev_driver::dev_list.

int sr_dev_open ( struct sr_dev_inst sdi)

Open the specified device.

Parameters
sdiDevice instance to use. Must not be NULL.
Returns
SR_OK upon success, a negative error code upon errors.
Since
0.2.0

Definition at line 497 of file device.c.

References sr_dev_driver::dev_open, sr_dev_inst::driver, and SR_ERR.

Referenced by sr_session_load().

+ Here is the caller graph for this function:

int sr_dev_trigger_set ( const struct sr_dev_inst sdi,
int  channelnum,
const char *  trigger 
)

Add a trigger to the specified device (and the specified channel).

If the specified channel of this device already has a trigger, it will be silently replaced.

Parameters
[in,out]sdiPointer to the device instance; must not be NULL.
[in]channelnumNumber of channel, starting at 0.
[in]triggerTrigger string, in the format used by sigrok-cli
Returns
SR_OK on success or SR_ERR on failure. In case of invalid arguments, SR_ERR_ARG is returned and the trigger settings remain unchanged.
Since
0.2.0

Definition at line 176 of file device.c.

References sr_dev_inst::channels, sr_dev_driver::config_channel_set, sr_dev_inst::driver, sr_channel::index, SR_ERR_ARG, SR_OK, and sr_channel::trigger.

Referenced by sr_session_load().

+ Here is the caller graph for this function: