libsigrok
0.4.0
sigrok hardware access and backend library
|
Device handling in libsigrok. More...
Functions | |
int | sr_dev_channel_name_set (struct sr_channel *channel, const char *name) |
Set the name of the specified channel. More... | |
int | sr_dev_channel_enable (struct sr_channel *channel, gboolean state) |
Enable or disable a channel. More... | |
SR_PRIV struct sr_channel * | sr_next_enabled_channel (const struct sr_dev_inst *sdi, struct sr_channel *cur_channel) |
gboolean | sr_dev_has_option (const struct sr_dev_inst *sdi, int key) |
Determine whether the specified device instance has the specified capability. More... | |
GArray * | sr_dev_options (const struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) |
Enumerate the configuration options of the specified item. More... | |
int | sr_dev_config_capabilities_list (const struct sr_dev_inst *sdi, const struct sr_channel_group *cg, const int key) |
Enumerate the configuration capabilities supported by a device instance for a given configuration key. More... | |
struct sr_dev_inst * | sr_dev_inst_user_new (const char *vendor, const char *model, const char *version) |
Allocate and init a new user-generated device instance. More... | |
int | sr_dev_inst_channel_add (struct sr_dev_inst *sdi, int index, int type, const char *name) |
Add a new channel to the specified device instance. 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... | |
struct sr_dev_driver * | sr_dev_inst_driver_get (const struct sr_dev_inst *sdi) |
Queries a device instances' driver. More... | |
const char * | sr_dev_inst_vendor_get (const struct sr_dev_inst *sdi) |
Queries a device instances' vendor. More... | |
const char * | sr_dev_inst_model_get (const struct sr_dev_inst *sdi) |
Queries a device instances' model. More... | |
const char * | sr_dev_inst_version_get (const struct sr_dev_inst *sdi) |
Queries a device instances' version. More... | |
const char * | sr_dev_inst_sernum_get (const struct sr_dev_inst *sdi) |
Queries a device instances' serial number. More... | |
const char * | sr_dev_inst_connid_get (const struct sr_dev_inst *sdi) |
Queries a device instances' connection identifier. More... | |
GSList * | sr_dev_inst_channels_get (const struct sr_dev_inst *sdi) |
Queries a device instances' channel list. More... | |
GSList * | sr_dev_inst_channel_groups_get (const struct sr_dev_inst *sdi) |
Queries a device instances' channel groups list. More... | |
Device handling in libsigrok.
int sr_dev_channel_enable | ( | struct sr_channel * | channel, |
gboolean | state | ||
) |
Enable or disable a channel.
[in] | channel | The channel to enable or disable. |
[in] | state | TRUE to enable the channel, FALSE to disable. |
Definition at line 111 of file device.c.
References sr_channel::enabled, sr_channel::sdi, SR_ERR_ARG, and SR_OK.
Referenced by sr_session_load().
int sr_dev_channel_name_set | ( | struct sr_channel * | channel, |
const char * | name | ||
) |
Set the name of the specified channel.
If the channel already has a different name assigned to it, it will be removed, and the new name will be saved instead.
[in] | channel | The channel whose name to set. |
[in] | name | The new name that the specified channel should get. A copy of the string is made. |
Definition at line 86 of file device.c.
References 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 494 of file device.c.
References sr_dev_driver::dev_clear, and SR_ERR_ARG.
int sr_dev_close | ( | struct sr_dev_inst * | sdi | ) |
int sr_dev_config_capabilities_list | ( | const struct sr_dev_inst * | sdi, |
const struct sr_channel_group * | cg, | ||
const int | key | ||
) |
Enumerate the configuration capabilities supported by a device instance for a given configuration key.
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). | |
cg | Pointer to a channel group, if a specific channel group is to be checked. Must be NULL to check device-wide options. | |
[in] | key | The option that should be checked for is supported by the specified device. |
A | bitmask of enum sr_configcap values, which will be zero for invalid inputs or if the key is unsupported. |
Definition at line 264 of file device.c.
References SR_OK.
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 172 of file device.c.
References SR_OK.
int sr_dev_inst_channel_add | ( | struct sr_dev_inst * | sdi, |
int | index, | ||
int | type, | ||
const char * | name | ||
) |
Add a new channel to the specified device instance.
Definition at line 320 of file device.c.
References SR_ERR_ARG, SR_INST_USER, and SR_OK.
GSList* sr_dev_inst_channel_groups_get | ( | const struct sr_dev_inst * | sdi | ) |
GSList* sr_dev_inst_channels_get | ( | const struct sr_dev_inst * | sdi | ) |
const char* sr_dev_inst_connid_get | ( | const struct sr_dev_inst * | sdi | ) |
Queries a device instances' connection identifier.
sdi | Device instance to use. Must not be NULL. |
Definition at line 636 of file device.c.
References SR_INST_SERIAL, and SR_INST_USB.
struct sr_dev_driver* sr_dev_inst_driver_get | ( | const struct sr_dev_inst * | sdi | ) |
const char* sr_dev_inst_model_get | ( | const struct sr_dev_inst * | sdi | ) |
const char* sr_dev_inst_sernum_get | ( | const struct sr_dev_inst * | sdi | ) |
struct sr_dev_inst* sr_dev_inst_user_new | ( | const char * | vendor, |
const char * | model, | ||
const char * | version | ||
) |
Allocate and init a new user-generated device instance.
vendor | Device vendor |
model | Device model |
version | Device version |
struct | sr_dev_inst *. Dynamically allocated, free using sr_dev_inst_free(). |
Definition at line 302 of file device.c.
References SR_INST_USER.
const char* sr_dev_inst_vendor_get | ( | const struct sr_dev_inst * | sdi | ) |
const char* sr_dev_inst_version_get | ( | const struct sr_dev_inst * | sdi | ) |
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 475 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 520 of file device.c.
References SR_ERR.
Referenced by sr_session_load().
GArray* sr_dev_options | ( | const struct sr_dev_driver * | driver, |
const struct sr_dev_inst * | sdi, | ||
const struct sr_channel_group * | cg | ||
) |
Enumerate the configuration options of the specified item.
driver | Pointer to the driver to be checked. Must not be NULL. |
sdi | Pointer to the device instance to be checked. May be NULL to check driver options. |
cg | Pointer to a channel group, if a specific channel group is to be checked. Must be NULL to check device-wide options. |
Definition at line 213 of file device.c.
References sr_dev_driver::config_list, and SR_OK.
SR_PRIV struct sr_channel* sr_next_enabled_channel | ( | const struct sr_dev_inst * | sdi, |
struct sr_channel * | cur_channel | ||
) |
Definition at line 137 of file device.c.
References sr_channel::enabled.