Unify all SR_HWOPT_* and SR_HWCAP_* enums.
Only two functions remain for accessing meta info on the keys: sr_config_info_get() and sr_config_info_name_get().
This commit is contained in:
parent
63b9e16e7e
commit
c89c1c9c21
76
hwdriver.c
76
hwdriver.c
|
@ -41,17 +41,11 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
/* Driver scanning options. */
|
||||
static struct sr_config_info sr_drvopts[] = {
|
||||
static struct sr_config_info sr_config_info_data[] = {
|
||||
{SR_HWOPT_CONN, SR_T_CHAR, "conn",
|
||||
"Connection", NULL},
|
||||
{SR_HWOPT_SERIALCOMM, SR_T_CHAR, "serialcomm",
|
||||
"Serial communication", NULL},
|
||||
{0, 0, NULL, NULL, NULL},
|
||||
};
|
||||
|
||||
/* Device instance options. */
|
||||
static struct sr_config_info sr_devopts[] = {
|
||||
{SR_HWCAP_SAMPLERATE, SR_T_UINT64, "samplerate",
|
||||
"Sample rate", NULL},
|
||||
{SR_HWCAP_CAPTURE_RATIO, SR_T_UINT64, "captureratio",
|
||||
|
@ -367,80 +361,40 @@ SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap)
|
|||
}
|
||||
|
||||
/**
|
||||
* Get information about a hardware driver option.
|
||||
* Get information about an sr_config key.
|
||||
*
|
||||
* @param opt The option to get.
|
||||
* @param opt The sr_config key.
|
||||
*
|
||||
* @return A pointer to a struct sr_hwcap_option, or NULL if the option
|
||||
* @return A pointer to a struct sr_config_info, or NULL if the key
|
||||
* was not found.
|
||||
*/
|
||||
SR_API const struct sr_config_info *sr_drvopt_get(int opt)
|
||||
SR_API const struct sr_config_info *sr_config_info_get(int key)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; sr_drvopts[i].key; i++) {
|
||||
if (sr_drvopts[i].key == opt)
|
||||
return &sr_drvopts[i];
|
||||
for (i = 0; sr_config_info_data[i].key; i++) {
|
||||
if (sr_config_info_data[i].key == key)
|
||||
return &sr_config_info_data[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a hardware driver option, by name.
|
||||
* Get information about an sr_config key, by name.
|
||||
*
|
||||
* @param optname The name of the option to get.
|
||||
* @param optname The sr_config key.
|
||||
*
|
||||
* @return A pointer to a struct sr_hwcap_option, or NULL if the option
|
||||
* @return A pointer to a struct sr_config_info, or NULL if the key
|
||||
* was not found.
|
||||
*/
|
||||
SR_API const struct sr_config_info *sr_drvopt_name_get(const char *optname)
|
||||
SR_API const struct sr_config_info *sr_config_info_name_get(const char *optname)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; sr_drvopts[i].key; i++) {
|
||||
if (!strcmp(sr_drvopts[i].id, optname))
|
||||
return &sr_drvopts[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a device option.
|
||||
*
|
||||
* @param opt The option to get.
|
||||
*
|
||||
* @return A pointer to a struct sr_hwcap_option, or NULL if the option
|
||||
* was not found.
|
||||
*/
|
||||
SR_API const struct sr_config_info *sr_devopt_get(int opt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; sr_devopts[i].key; i++) {
|
||||
if (sr_devopts[i].key == opt)
|
||||
return &sr_devopts[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a device option, by name.
|
||||
*
|
||||
* @param optname The name of the option to get.
|
||||
*
|
||||
* @return A pointer to a struct sr_hwcap_option, or NULL if the option
|
||||
* was not found.
|
||||
*/
|
||||
SR_API const struct sr_config_info *sr_devopt_name_get(const char *optname)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; sr_devopts[i].key; i++) {
|
||||
if (!strcmp(sr_devopts[i].id, optname))
|
||||
return &sr_devopts[i];
|
||||
for (i = 0; sr_config_info_data[i].key; i++) {
|
||||
if (!strcmp(sr_config_info_data[i].id, optname))
|
||||
return &sr_config_info_data[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
70
libsigrok.h
70
libsigrok.h
|
@ -384,34 +384,6 @@ struct sr_config_info {
|
|||
char *description;
|
||||
};
|
||||
|
||||
/** Hardware driver options. */
|
||||
enum {
|
||||
/**
|
||||
* Specification on how to connect to a device.
|
||||
*
|
||||
* In combination with SR_HWOPT_SERIALCOMM, this is a serial port in
|
||||
* the form which makes sense to the OS (e.g., /dev/ttyS0).
|
||||
* Otherwise this specifies a USB device, either in the form of
|
||||
* @verbatim <bus>.<address> @endverbatim (decimal, e.g. 1.65) or
|
||||
* @verbatim <vendorid>.<productid> @endverbatim
|
||||
* (hexadecimal, e.g. 1d6b.0001).
|
||||
*/
|
||||
SR_HWOPT_CONN = 10000,
|
||||
|
||||
/**
|
||||
* Serial communication specification, in the form:
|
||||
*
|
||||
* @verbatim <baudrate>/<databits><parity><stopbits> @endverbatim
|
||||
*
|
||||
* Example: 9600/8n1
|
||||
*
|
||||
* This is always an optional parameter, since a driver typically
|
||||
* knows the speed at which the device wants to communicate.
|
||||
*/
|
||||
SR_HWOPT_SERIALCOMM,
|
||||
};
|
||||
|
||||
/** Hardware device capabilities. */
|
||||
enum {
|
||||
/*--- Device classes ------------------------------------------------*/
|
||||
|
||||
|
@ -436,15 +408,49 @@ enum {
|
|||
/** The device can measure humidity. */
|
||||
SR_HWCAP_HYGROMETER,
|
||||
|
||||
/*--- Driver options ------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Specification on how to connect to a device.
|
||||
*
|
||||
* In combination with SR_HWOPT_SERIALCOMM, this is a serial port in
|
||||
* the form which makes sense to the OS (e.g., /dev/ttyS0).
|
||||
* Otherwise this specifies a USB device, either in the form of
|
||||
* @verbatim <bus>.<address> @endverbatim (decimal, e.g. 1.65) or
|
||||
* @verbatim <vendorid>.<productid> @endverbatim
|
||||
* (hexadecimal, e.g. 1d6b.0001).
|
||||
*/
|
||||
SR_HWOPT_CONN = 20000,
|
||||
|
||||
/**
|
||||
* Serial communication specification, in the form:
|
||||
*
|
||||
* @verbatim <baudrate>/<databits><parity><stopbits> @endverbatim
|
||||
*
|
||||
* Example: 9600/8n1
|
||||
*
|
||||
* The string may also be followed by one or more special settings,
|
||||
* in the form "/key=value". Supported keys and their values are:
|
||||
*
|
||||
* rts 0,1 set the port's RTS pin to low or high
|
||||
* dtr 0,1 set the port's DTR pin to low or high
|
||||
* flow 0 no flow control
|
||||
* 1 hardware-based (RTS/CTS) flow control
|
||||
* 2 software-based (XON/XOFF) flow control
|
||||
*
|
||||
* This is always an optional parameter, since a driver typically
|
||||
* knows the speed at which the device wants to communicate.
|
||||
*/
|
||||
SR_HWOPT_SERIALCOMM,
|
||||
|
||||
/*--- Device configuration ------------------------------------------*/
|
||||
|
||||
/** The device supports setting/changing its samplerate. */
|
||||
SR_HWCAP_SAMPLERATE = 20000,
|
||||
SR_HWCAP_SAMPLERATE = 30000,
|
||||
|
||||
/** The device supports setting a pre/post-trigger capture ratio. */
|
||||
SR_HWCAP_CAPTURE_RATIO,
|
||||
|
||||
/* TODO? */
|
||||
/** The device supports setting a pattern (pattern generator mode). */
|
||||
SR_HWCAP_PATTERN_MODE,
|
||||
|
||||
|
@ -478,7 +484,7 @@ enum {
|
|||
/*--- Special stuff -------------------------------------------------*/
|
||||
|
||||
/** Session filename. */
|
||||
SR_HWCAP_SESSIONFILE = 30000,
|
||||
SR_HWCAP_SESSIONFILE = 40000,
|
||||
|
||||
/* TODO: Better description. */
|
||||
/** The device supports specifying a capturefile to inject. */
|
||||
|
@ -498,7 +504,7 @@ enum {
|
|||
* The device supports setting a sample time limit (how long
|
||||
* the sample acquisition should run, in ms).
|
||||
*/
|
||||
SR_HWCAP_LIMIT_MSEC = 40000,
|
||||
SR_HWCAP_LIMIT_MSEC = 50000,
|
||||
|
||||
/**
|
||||
* The device supports setting a sample number limit (how many
|
||||
|
|
6
proto.h
6
proto.h
|
@ -73,10 +73,8 @@ SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options);
|
|||
SR_API int sr_info_get(struct sr_dev_driver *driver, int id,
|
||||
const void **data, const struct sr_dev_inst *sdi);
|
||||
SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap);
|
||||
SR_API const struct sr_config_info *sr_drvopt_get(int opt);
|
||||
SR_API const struct sr_config_info *sr_drvopt_name_get(const char *optname);
|
||||
SR_API const struct sr_config_info *sr_devopt_get(int opt);
|
||||
SR_API const struct sr_config_info *sr_devopt_name_get(const char *optname);
|
||||
SR_API const struct sr_config_info *sr_config_info_get(int key);
|
||||
SR_API const struct sr_config_info *sr_config_info_name_get(const char *optname);
|
||||
|
||||
/*--- session.c -------------------------------------------------------------*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue