![]() |
libsigrok
0.3.0
sigrok hardware access and backend library
|
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... | |
Device handling in libsigrok.
int sr_dev_channel_enable | ( | const struct sr_dev_inst * | sdi, |
int | channelnum, | ||
gboolean | state | ||
) |
Enable or disable a channel on the specified device.
sdi | The device instance the channel is connected to. |
channelnum | The channel number, starting from 0. |
state | TRUE to enable the channel, FALSE to disable. |
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().
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.
sdi | The device instance the channel is connected to. | |
[in] | channelnum | The number of the channel whose name to set. Note that the channel numbers start at 0. |
[in] | name | The new name that the specified channel should get. A copy of the string is made. |
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().
int sr_dev_clear | ( | const struct sr_dev_driver * | driver | ) |
Clear the list of device instances a driver knows about.
driver | The driver to use. This must be a pointer to one of the entries returned by sr_driver_list(). Must not be NULL. |
SR_OK | Success |
SR_ERR_ARG | Invalid driver |
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.
sdi | Device instance to use. Must not be NULL. |
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.
sdi | Pointer 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] | key | The option that should be checked for is supported by the specified device. |
TRUE | Device has the specified option |
FALSE | Device does not have the specified option, invalid input parameters or other error conditions. |
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().
GSList* sr_dev_list | ( | const struct sr_dev_driver * | driver | ) |
Get the list of devices/instances of the specified driver.
driver | The driver to use. Must not be NULL. |
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.
sdi | Device instance to use. Must not be NULL. |
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().
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.
[in,out] | sdi | Pointer to the device instance; must not be NULL. |
[in] | channelnum | Number of channel, starting at 0. |
[in] | trigger | Trigger string, in the format used by sigrok-cli |
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().