Go to the source code of this file.
Typedefs | |
typedef int(* | sr_log_callback_t )(void *cb_data, int loglevel, const char *format, va_list args) |
typedef void(* | sr_datafeed_callback_t )(struct sr_dev *dev, struct sr_datafeed_packet *packet) |
Functions | |
SR_API int | sr_init (void) |
Initialize libsigrok. More... | |
SR_API int | sr_exit (void) |
Shutdown libsigrok. More... | |
SR_API int | sr_log_loglevel_set (int loglevel) |
Set the libsigrok loglevel. More... | |
SR_API int | sr_log_loglevel_get (void) |
Get the libsigrok loglevel. More... | |
SR_API int | sr_log_callback_set (sr_log_callback_t cb, void *cb_data) |
Set the libsigrok log callback to the specified function. More... | |
SR_API int | sr_log_callback_set_default (void) |
Set the libsigrok log callback to the default built-in one. More... | |
SR_API int | sr_log_logdomain_set (const char *logdomain) |
Set the libsigrok logdomain string. More... | |
SR_API char * | sr_log_logdomain_get (void) |
Get the currently configured libsigrok logdomain. More... | |
SR_API int | sr_datastore_new (int unitsize, struct sr_datastore **ds) |
Create a new datastore with the specified unit size. More... | |
SR_API int | sr_datastore_destroy (struct sr_datastore *ds) |
Destroy the specified datastore and free the memory used by it. More... | |
SR_API int | sr_datastore_put (struct sr_datastore *ds, void *data, unsigned int length, int in_unitsize, const int *probelist) |
Append some data to the specified datastore. More... | |
SR_API int | sr_dev_scan (void) |
Scan the system for attached logic analyzers / devices. More... | |
SR_API GSList * | sr_dev_list (void) |
Return the list of logic analyzer devices libsigrok has detected. More... | |
SR_API struct sr_dev * | sr_dev_new (const struct sr_dev_driver *driver, int driver_index) |
Create a new device. More... | |
SR_API int | sr_dev_probe_add (struct sr_dev *dev, const char *name) |
Add a probe with the specified name to the specified device. More... | |
SR_API struct sr_probe * | sr_dev_probe_find (const struct sr_dev *dev, int probenum) |
Find the probe with the specified number in the specified device. More... | |
SR_API int | sr_dev_probe_name_set (struct sr_dev *dev, int probenum, const char *name) |
Set the name of the specified probe in the specified device. More... | |
SR_API int | sr_dev_trigger_remove_all (struct sr_dev *dev) |
Remove all triggers set up for the specified device. More... | |
SR_API int | sr_dev_trigger_set (struct sr_dev *dev, int probenum, const char *trigger) |
Add a trigger to the specified device (and the specified probe). More... | |
SR_API gboolean | sr_dev_has_hwcap (const struct sr_dev *dev, int hwcap) |
Determine whether the specified device has the specified capability. More... | |
SR_API int | sr_dev_info_get (const struct sr_dev *dev, int id, const void **data) |
Returns information about the given device. More... | |
SR_API int | sr_filter_probes (int in_unitsize, int out_unitsize, const int *probelist, const uint8_t *data_in, uint64_t length_in, uint8_t **data_out, uint64_t *length_out) |
Remove unused probes from samples. More... | |
SR_API struct sr_dev_driver ** | sr_driver_list (void) |
Return the list of supported hardware drivers. More... | |
SR_API int | sr_driver_init (struct sr_dev_driver *driver) |
Initialize a hardware driver. More... | |
SR_API gboolean | sr_driver_hwcap_exists (struct sr_dev_driver *driver, int hwcap) |
Find out if a hardware driver has a specific capability. More... | |
SR_API struct sr_hwcap_option * | sr_hw_hwcap_get (int hwcap) |
Get a hardware driver capability option. More... | |
SR_API int | sr_session_load (const char *filename) |
Load the session from the specified filename. More... | |
SR_API struct sr_session * | sr_session_new (void) |
Create a new session. More... | |
SR_API int | sr_session_destroy (void) |
Destroy the current session. More... | |
SR_API int | sr_session_dev_remove_all (void) |
Remove all the devices from the current session. More... | |
SR_API int | sr_session_dev_add (struct sr_dev *dev) |
Add a device to the current session. More... | |
SR_API int | sr_session_datafeed_callback_remove_all (void) |
Remove all datafeed callbacks in the current session. More... | |
SR_API int | sr_session_datafeed_callback_add (sr_datafeed_callback_t cb) |
Add a datafeed callback to the current session. More... | |
SR_API int | sr_session_start (void) |
Start a session. More... | |
SR_API int | sr_session_run (void) |
Run the session. More... | |
SR_API int | sr_session_halt (void) |
Halt the current session. More... | |
SR_API int | sr_session_stop (void) |
Stop the current session. More... | |
SR_API int | sr_session_save (const char *filename) |
Save the current session to the specified file. More... | |
SR_API int | sr_session_source_add (int fd, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data) |
TODO. More... | |
SR_API int | sr_session_source_remove (int fd) |
Remove the source belonging to the specified file descriptor. More... | |
SR_API struct sr_input_format ** | sr_input_list (void) |
SR_API struct sr_output_format ** | sr_output_list (void) |
SR_API char * | sr_samplerate_string (uint64_t samplerate) |
Convert a numeric samplerate value to its "natural" string representation. More... | |
SR_API char * | sr_period_string (uint64_t frequency) |
Convert a numeric frequency value to the "natural" string representation of its period. More... | |
SR_API char ** | sr_parse_triggerstring (struct sr_dev *dev, const char *triggerstring) |
Parse a trigger specification string. More... | |
SR_API int | sr_parse_sizestring (const char *sizestring, uint64_t *size) |
Convert a "natural" string representation of a size value to uint64_t. More... | |
SR_API uint64_t | sr_parse_timestring (const char *timestring) |
Convert a "natural" string representation of a time value to an uint64_t value in milliseconds. More... | |
SR_API gboolean | sr_parse_boolstring (const char *boolstring) |
SR_API int | sr_package_version_major_get (void) |
SR_API int | sr_package_version_minor_get (void) |
SR_API int | sr_package_version_micro_get (void) |
SR_API const char * | sr_package_version_string_get (void) |
SR_API int | sr_lib_version_current_get (void) |
SR_API int | sr_lib_version_revision_get (void) |
SR_API int | sr_lib_version_age_get (void) |
SR_API const char * | sr_lib_version_string_get (void) |
typedef void(* sr_datafeed_callback_t)(struct sr_dev *dev, struct sr_datafeed_packet *packet) |
Definition at line 81 of file sigrok-proto.h.
typedef int(* sr_log_callback_t)(void *cb_data, int loglevel, const char *format, va_list args) |
Definition at line 30 of file sigrok-proto.h.
SR_API int sr_datastore_destroy | ( | struct sr_datastore * | ds | ) |
Destroy the specified datastore and free the memory used by it.
This will free the memory used by the data in the datastore's 'chunklist', by the chunklist data structure itself, and by the datastore struct.
ds | The datastore to destroy. |
Definition at line 86 of file datastore.c.
References sr_datastore::chunklist, sr_err(), SR_ERR_ARG, and SR_OK.
SR_API int sr_datastore_new | ( | int | unitsize, |
struct sr_datastore ** | ds | ||
) |
Create a new datastore with the specified unit size.
The unit size is fixed once the datastore is created, and cannot be changed later on, neither can data be added to the datastore with different unit sizes later.
It is the caller's responsibility to free the allocated memory of the datastore via the sr_datastore_destroy() function, if no longer needed.
TODO: Unitsize should probably be unsigned int or uint32_t or similar. TODO: This function should have a 'chunksize' parameter, and struct sr_datastore a 'chunksize' field.
unitsize | The unit size (>= 1) to be used for this datastore. |
ds | Pointer to a variable which will hold the newly created datastore structure. |
Definition at line 51 of file datastore.c.
References sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, and SR_OK.
SR_API int sr_datastore_put | ( | struct sr_datastore * | ds, |
void * | data, | ||
unsigned int | length, | ||
int | in_unitsize, | ||
const int * | probelist | ||
) |
Append some data to the specified datastore.
TODO: More elaborate function description.
TODO: This function should use the (not yet available) 'chunksize' field of struct sr_datastore (instead of hardcoding DATASTORE_CHUNKSIZE). TODO: in_unitsize and probelist are unused? TODO: A few of the parameters can be const. TODO: Ideally, 'ds' should be unmodified upon errors.
ds | Pointer to the datastore which shall receive the data. Must not be NULL. |
data | Pointer to the memory buffer containing the data to add. Must not be NULL. TODO: Data format? |
length | Length of the data to add (in number of bytes). TODO: Should 0 be allowed as length? |
in_unitsize | The unit size (>= 1) of the input data. |
probelist | Pointer to a list of integers (probe numbers). The probe numbers in this list are 1-based, i.e. the first probe is expected to be numbered 1 (not 0!). Must not be NULL. |
Definition at line 130 of file datastore.c.
References sr_datastore::chunklist, sr_datastore::ds_unitsize, sr_datastore::num_units, sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, and SR_OK.
Determine whether the specified device has the specified capability.
dev | Pointer to the device 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). |
hwcap | The capability that should be checked (whether it's supported by the specified device). |
Definition at line 376 of file device.c.
References sr_dev::driver, sr_dev_driver::hwcap_get_all, sr_dbg(), sr_err(), and sr_spew().
Referenced by init(), and sr_session_save().
Returns information about the given device.
dev | Pointer to the device to be checked. Must not be NULL. The device's 'driver' field must not be NULL either. |
id | The type of information. |
data | The return value. Must not be NULL. |
Definition at line 427 of file device.c.
References sr_dev_driver::dev_info_get, sr_dev::driver, sr_dev::driver_index, SR_ERR, SR_ERR_ARG, and SR_OK.
SR_API GSList* sr_dev_list | ( | void | ) |
Return the list of logic analyzer devices libsigrok has detected.
If the libsigrok-internal device list is empty, a scan for attached devices – via a call to sr_dev_scan() – is performed first.
TODO: Error handling?
Definition at line 92 of file device.c.
References sr_dev_scan().
SR_API struct sr_dev* sr_dev_new | ( | const struct sr_dev_driver * | driver, |
int | driver_index | ||
) |
Create a new device.
The device is added to the (libsigrok-internal) list of devices, but additionally a pointer to the newly created device is also returned.
The device has no probes attached to it yet after this call. You can use sr_dev_probe_add() to add one or more probes.
TODO: Should return int, so that we can return SR_OK, SR_ERR_* etc.
It is the caller's responsibility to g_free() the allocated memory when no longer needed. TODO: Using which API function?
driver | TODO. If 'driver' is NULL, the created device is a "virtual" one. |
driver_index | TODO |
Definition at line 120 of file device.c.
References sr_dev::driver, sr_dev::driver_index, and sr_err().
Referenced by sr_driver_init(), and sr_session_load().
Add a probe with the specified name to the specified device.
The added probe is automatically enabled (the 'enabled' field is TRUE).
The 'trigger' field of the added probe is set to NULL. A trigger can be added via sr_dev_trigger_set().
TODO: Are duplicate names allowed? TODO: Do we enforce a maximum probe number for a device? TODO: Error if the max. probe number for the specific LA is reached, e.g. if the caller tries to add more probes than the device actually has.
dev | The device to which to add a probe with the specified name. Must not be NULL. |
name | The name of the probe to add to this device. Must not be NULL. TODO: Maximum length, allowed characters, etc. |
Definition at line 161 of file device.c.
References sr_probe::enabled, sr_probe::index, sr_probe::name, sr_dev::probes, sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, SR_OK, and sr_probe::trigger.
Referenced by sr_driver_init(), and sr_session_load().
Find the probe with the specified number in the specified device.
TODO
dev | TODO. Must not be NULL. |
probenum | The number of the probe whose 'struct sr_probe' we want. Note that the probe numbers start at 1 (not 0!). |
TODO: Should return int. TODO: probenum should be unsigned.
Definition at line 209 of file device.c.
References sr_probe::index, sr_dev::probes, and sr_err().
Referenced by sr_dev_probe_name_set(), sr_dev_trigger_remove_all(), and sr_dev_trigger_set().
Set the name of the specified probe in the specified device.
If the probe already has a different name assigned to it, it will be removed, and the new name will be saved instead.
dev | TODO |
probenum | The number of the probe whose name to set. Note that the probe numbers start at 1 (not 0!). |
name | The new name that the specified probe should get. |
Definition at line 250 of file device.c.
References sr_probe::name, sr_dev_probe_find(), SR_ERR, sr_err(), SR_ERR_ARG, and SR_OK.
Referenced by sr_session_load().
SR_API int sr_dev_scan | ( | void | ) |
Scan the system for attached logic analyzers / devices.
This will try to autodetect all supported logic analyzer devices:
Those using a (real or virtual) serial port (detected by sending device-specific commands to all OS-specific serial port devices such as /dev/ttyS*, /dev/ttyUSB*, /dev/ttyACM*, and others). The autodetection for this kind of devices can potentially be unreliable.
Also, sending various bytes/commands to (all!) devices which happen to be attached to the system via a (real or virtual) serial port can be problematic. There is no way for libsigrok to know how unknown devices react to the bytes libsigrok sends. Potentially they could lead to the device getting into invalid/error states, losing/overwriting data, or...
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.
After the system has been scanned for devices, the list of detected (and supported) devices can be acquired via sr_dev_list().
TODO: Error checks? TODO: Option to only scan for specific devices or device classes.
Definition at line 60 of file device.c.
References sr_driver_init(), sr_driver_list(), sr_err(), SR_ERR_BUG, and SR_OK.
Referenced by sr_dev_list().
Remove all triggers set up for the specified device.
TODO: Better description.
dev | TODO |
Definition at line 286 of file device.c.
References sr_dev::probes, sr_dev_probe_find(), sr_err(), SR_ERR_ARG, SR_OK, and sr_probe::trigger.
Add a trigger to the specified device (and the specified probe).
If the specified probe of this device already has a trigger, it will be silently replaced.
TODO: Better description. TODO: Describe valid format of the 'trigger' string.
dev | TODO. Must not be NULL. |
probenum | The number of the probe. TODO. Note that the probe numbers start at 1 (not 0!). |
trigger | TODO. TODO: Is NULL allowed? |
Definition at line 332 of file device.c.
References sr_dbg(), sr_dev_probe_find(), SR_ERR, sr_err(), SR_ERR_ARG, SR_OK, and sr_probe::trigger.
Referenced by sr_session_load().
SR_API gboolean sr_driver_hwcap_exists | ( | struct sr_dev_driver * | driver, |
int | hwcap | ||
) |
Find out if a hardware driver has a specific capability.
driver | The hardware driver in which to search for the capability. |
hwcap | The capability to find in the list. |
Definition at line 268 of file hwdriver.c.
References sr_dev_driver::hwcap_get_all, and sr_err().
SR_API int sr_driver_init | ( | struct sr_dev_driver * | driver | ) |
Initialize a hardware driver.
The specified driver is initialized, and all devices discovered by the driver are instantiated.
driver | The driver to initialize. |
Definition at line 121 of file hwdriver.c.
References sr_dev_driver::dev_info_get, sr_dev_driver::init, sr_dev_driver::name, sr_dbg(), sr_dev_new(), sr_dev_probe_add(), SR_DI_NUM_PROBES, SR_DI_PROBE_NAMES, and sr_warn().
Referenced by sr_dev_scan().
SR_API struct sr_dev_driver** sr_driver_list | ( | void | ) |
Return the list of supported hardware drivers.
Definition at line 106 of file hwdriver.c.
Referenced by sr_dev_scan(), and sr_hw_cleanup_all().
SR_API int sr_exit | ( | void | ) |
Shutdown libsigrok.
Definition at line 39 of file backend.c.
References sr_hw_cleanup_all(), and SR_OK.
SR_API int sr_filter_probes | ( | int | in_unitsize, |
int | out_unitsize, | ||
const int * | probelist, | ||
const uint8_t * | data_in, | ||
uint64_t | length_in, | ||
uint8_t ** | data_out, | ||
uint64_t * | length_out | ||
) |
Remove unused probes from samples.
Convert sample from maximum probes – the way the hardware driver sent it – to a sample taking up only as much space as required, with unused probes removed.
The "unit size" is the number of bytes used to store probe values. For example, a unit size of 1 means one byte is used (which can store 8 probe values, each of them is 1 bit). A unit size of 2 means we can store 16 probe values, 3 means we can store 24 probe values, and so on.
If the data coming from the logic analyzer has a unit size of 4 for example (as the device has 32 probes), but only 2 of them are actually used in an acquisition, this function can convert the samples to only use up 1 byte per sample (unit size = 1) instead of 4 bytes per sample.
The output will contain the probe values in the order specified via the probelist. For example, if in_unitsize = 4, probelist = [5, 16, 30], and out_unitsize = 1, then the output samples (each of them one byte in size) will have the following format: bit 0 = value of probe 5, bit 1 = value of probe 16, bit 2 = value of probe 30. Unused bit(s) in the output byte(s) are zero.
The caller must make sure that length_in is not bigger than the memory actually allocated for the input data (data_in), as this function does not check that.
in_unitsize | The unit size (>= 1) of the input (data_in). |
out_unitsize | The unit size (>= 1) the output shall have (data_out). The requested unit size must be big enough to hold as much data as is specified by the number of enabled probes in 'probelist'. |
probelist | Pointer to a list of integers (probe numbers). The probe numbers in this list are 1-based, i.e. the first probe is expected to be numbered 1 (not 0!). Must not be NULL. |
data_in | Pointer to the input data buffer. Must not be NULL. |
length_in | The input data length (>= 1), in number of bytes. |
data_out | Variable which will point to the newly allocated buffer of output data. The caller is responsible for g_free()'ing the buffer when it's no longer needed. Must not be NULL. |
length_out | Pointer to the variable which will contain the output data length (in number of bytes) when the function returns SR_OK. Must not be NULL. |
Definition at line 76 of file filter.c.
References sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, and SR_OK.
SR_API struct sr_hwcap_option* sr_hw_hwcap_get | ( | int | hwcap | ) |
Get a hardware driver capability option.
hwcap | The capability to get. |
Definition at line 298 of file hwdriver.c.
References sr_hwcap_option::hwcap.
SR_API int sr_init | ( | void | ) |
SR_API struct sr_input_format** sr_input_list | ( | void | ) |
SR_API int sr_lib_version_age_get | ( | void | ) |
Definition at line 53 of file version.c.
References SR_LIB_VERSION_AGE.
SR_API int sr_lib_version_current_get | ( | void | ) |
Definition at line 43 of file version.c.
References SR_LIB_VERSION_CURRENT.
SR_API int sr_lib_version_revision_get | ( | void | ) |
Definition at line 48 of file version.c.
References SR_LIB_VERSION_REVISION.
SR_API const char* sr_lib_version_string_get | ( | void | ) |
Definition at line 58 of file version.c.
References SR_LIB_VERSION_STRING.
SR_API int sr_log_callback_set | ( | sr_log_callback_t | cb, |
void * | cb_data | ||
) |
Set the libsigrok log callback to the specified function.
cb | Function pointer to the log callback function to use. Must not be NULL. |
cb_data | Pointer to private data to be passed on. This can be used by the caller to pass arbitrary data to the log functions. This pointer is only stored or passed on by libsigrok, and is never used or interpreted in any way. The pointer is allowed to be NULL if the caller doesn't need/want to pass any data. |
Definition at line 140 of file log.c.
References sr_err(), SR_ERR_ARG, and SR_OK.
SR_API int sr_log_callback_set_default | ( | void | ) |
SR_API char* sr_log_logdomain_get | ( | void | ) |
SR_API int sr_log_logdomain_set | ( | const char * | logdomain | ) |
Set the libsigrok logdomain string.
logdomain | The string to use as logdomain for libsigrok log messages from now on. Must not be NULL. The maximum length of the string is 30 characters (this does not include the trailing NUL-byte). Longer strings are silently truncated. In order to not use a logdomain, pass an empty string. The function makes its own copy of the input string, i.e. the caller does not need to keep it around. |
Definition at line 100 of file log.c.
References LOGDOMAIN_MAXLEN, sr_dbg(), sr_err(), SR_ERR_ARG, and SR_OK.
SR_API int sr_log_loglevel_get | ( | void | ) |
Get the libsigrok loglevel.
Definition at line 81 of file log.c.
Referenced by sr_session_send().
SR_API int sr_log_loglevel_set | ( | int | loglevel | ) |
Set the libsigrok loglevel.
This influences the amount of log messages (debug messages, error messages, and so on) libsigrok will output. Using SR_LOG_NONE disables all messages.
Note that this function itself will also output log messages. After the loglevel has changed, it will output a debug message with SR_LOG_DBG for example. Whether this message is shown depends on the (new) loglevel.
loglevel | The loglevel to set (SR_LOG_NONE, SR_LOG_ERR, SR_LOG_WARN, SR_LOG_INFO, SR_LOG_DBG, or SR_LOG_SPEW). |
Definition at line 62 of file log.c.
References sr_dbg(), sr_err(), SR_ERR_ARG, SR_LOG_SPEW, and SR_OK.
SR_API struct sr_output_format** sr_output_list | ( | void | ) |
SR_API int sr_package_version_major_get | ( | void | ) |
Definition at line 23 of file version.c.
References SR_PACKAGE_VERSION_MAJOR.
SR_API int sr_package_version_micro_get | ( | void | ) |
Definition at line 33 of file version.c.
References SR_PACKAGE_VERSION_MICRO.
SR_API int sr_package_version_minor_get | ( | void | ) |
Definition at line 28 of file version.c.
References SR_PACKAGE_VERSION_MINOR.
SR_API const char* sr_package_version_string_get | ( | void | ) |
Definition at line 38 of file version.c.
References SR_PACKAGE_VERSION_STRING.
SR_API gboolean sr_parse_boolstring | ( | const char * | boolstring | ) |
SR_API int sr_parse_sizestring | ( | const char * | sizestring, |
uint64_t * | size | ||
) |
Convert a "natural" string representation of a size value to uint64_t.
E.g. a value of "3k" or "3 K" would be converted to 3000, a value of "15M" would be converted to 15000000.
Value representations other than decimal (such as hex or octal) are not supported. Only 'k' (kilo), 'm' (mega), 'g' (giga) suffixes are supported. Spaces (but not other whitespace) between value and suffix are allowed.
sizestring | A string containing a (decimal) size value. |
size | Pointer to uint64_t which will contain the string's size value. |
Definition at line 223 of file strutil.c.
References SR_ERR, SR_GHZ, SR_KHZ, SR_MHZ, and SR_OK.
Referenced by sr_session_load().
SR_API uint64_t sr_parse_timestring | ( | const char * | timestring | ) |
Convert a "natural" string representation of a time value to an uint64_t value in milliseconds.
E.g. a value of "3s" or "3 s" would be converted to 3000, a value of "15ms" would be converted to 15.
Value representations other than decimal (such as hex or octal) are not supported. Only lower-case "s" and "ms" time suffixes are supported. Spaces (but not other whitespace) between value and suffix are allowed.
timestring | A string containing a (decimal) time value. |
TODO: Error handling. TODO: Add support for "m" (minutes) and others. TODO: picoseconds? TODO: Allow both lower-case and upper-case.
Parse a trigger specification string.
dev | The device for which the trigger specification is intended. |
triggerstring | The string containing the trigger specification for one or more probes of this device. Entries for multiple probes are comma-separated. Triggers are specified in the form key=value, where the key is a probe number (or probe name) and the value is the requested trigger type. Valid trigger types currently include 'r' (rising edge), 'f' (falling edge), 'c' (any pin value change), '0' (low value), or '1' (high value). Example: "1=r,sck=f,miso=0,7=c" |
Definition at line 134 of file strutil.c.
References sr_dev_driver::dev_info_get, sr_dev::driver, sr_probe::enabled, sr_probe::index, sr_probe::name, sr_dev::probes, SR_DI_TRIGGER_TYPES, sr_err(), and sr_probe::trigger.
SR_API char* sr_period_string | ( | uint64_t | frequency | ) |
Convert a numeric frequency value to the "natural" string representation of its period.
E.g. a value of 3000000 would be converted to "3 us", 20000 to "50 ms".
frequency | The frequency in Hz. |
Definition at line 84 of file strutil.c.
References sr_err(), SR_GHZ, SR_KHZ, and SR_MHZ.
SR_API char* sr_samplerate_string | ( | uint64_t | samplerate | ) |
Convert a numeric samplerate value to its "natural" string representation.
E.g. a value of 3000000 would be converted to "3 MHz", 20000 to "20 kHz", 31500 would become "31.5 kHz".
samplerate | The samplerate in Hz. |
Definition at line 39 of file strutil.c.
References sr_err(), SR_GHZ, SR_KHZ, and SR_MHZ.
Referenced by init(), and sr_session_save().
SR_API int sr_session_datafeed_callback_add | ( | sr_datafeed_callback_t | cb | ) |
Add a datafeed callback to the current session.
cb | Function to call when a chunk of data is received. Must not be NULL. |
Definition at line 187 of file session.c.
References sr_session::datafeed_callbacks, sr_err(), SR_ERR_ARG, SR_ERR_BUG, and SR_OK.
SR_API int sr_session_datafeed_callback_remove_all | ( | void | ) |
Remove all datafeed callbacks in the current session.
Definition at line 166 of file session.c.
References sr_session::datafeed_callbacks, sr_err(), SR_ERR_BUG, and SR_OK.
SR_API int sr_session_destroy | ( | void | ) |
Destroy the current session.
This frees up all memory used by the session.
Definition at line 72 of file session.c.
References sr_session::devs, sr_err(), SR_ERR_BUG, and SR_OK.
Add a device to the current session.
dev | The device to add to the current session. Must not be NULL. Also, dev->driver and dev->driver->dev_open must not be NULL. |
Definition at line 121 of file session.c.
References sr_dev_driver::dev_open, sr_session::devs, sr_dev::driver, sr_dev::driver_index, sr_dbg(), sr_err(), SR_ERR_ARG, SR_ERR_BUG, and SR_OK.
Referenced by sr_session_load().
SR_API int sr_session_dev_remove_all | ( | void | ) |
Remove all the devices from the current session.
TODO?
The session itself (i.e., the struct sr_session) is not free'd and still exists after this function returns.
Definition at line 100 of file session.c.
References sr_session::devs, sr_err(), SR_ERR_BUG, and SR_OK.
SR_API int sr_session_halt | ( | void | ) |
Halt the current session.
This requests the current session be stopped as soon as possible, for example on receiving an SR_DF_END packet.
Definition at line 347 of file session.c.
References sr_session::running, sr_err(), SR_ERR_BUG, sr_info(), and SR_OK.
SR_API int sr_session_load | ( | const char * | filename | ) |
Load the session from the specified filename.
filename | The name of the session file to load. Must not be NULL. |
Definition at line 42 of file session_file.c.
References sr_dev_driver::dev_config_set, sr_dev::driver, sr_probe::enabled, sr_dev_driver::init, sr_dev::probes, session_driver, sr_dbg(), sr_dev_new(), sr_dev_probe_add(), sr_dev_probe_name_set(), sr_dev_trigger_set(), SR_ERR, sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, SR_HWCAP_CAPTURE_NUM_PROBES, SR_HWCAP_CAPTURE_UNITSIZE, SR_HWCAP_CAPTUREFILE, SR_HWCAP_SAMPLERATE, SR_MAX_PROBENAME_LEN, SR_OK, sr_parse_sizestring(), sr_session_dev_add(), and sr_session_new().
SR_API struct sr_session* sr_session_new | ( | void | ) |
Create a new session.
TODO: Should it use the file-global "session" variable or take an argument? The same question applies to all the other session functions.
Definition at line 55 of file session.c.
References session, and sr_err().
Referenced by sr_session_load().
SR_API int sr_session_run | ( | void | ) |
Run the session.
TODO: Various error checks etc.
Definition at line 308 of file session.c.
References source::cb, sr_session::devs, sr_session::running, sr_err(), SR_ERR_BUG, sr_info(), and SR_OK.
SR_API int sr_session_save | ( | const char * | filename | ) |
Save the current session to the specified file.
filename | The name of the file where to save the current session. Must not be NULL. |
Definition at line 170 of file session_file.c.
References sr_datastore::chunklist, sr_dev::datastore, sr_dev_driver::dev_info_get, sr_session::devs, sr_dev::driver, sr_dev::driver_index, sr_datastore::ds_unitsize, sr_probe::enabled, sr_probe::name, sr_dev_driver::name, sr_datastore::num_units, PACKAGE_VERSION, sr_dev::probes, sr_dev_has_hwcap(), SR_DI_CUR_SAMPLERATE, SR_ERR, sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, SR_HWCAP_SAMPLERATE, sr_info(), SR_OK, sr_samplerate_string(), and sr_probe::trigger.
SR_API int sr_session_source_add | ( | int | fd, |
int | events, | ||
int | timeout, | ||
sr_receive_data_callback_t | cb, | ||
void * | cb_data | ||
) |
TODO.
TODO: More error checks etc.
fd | TODO. |
events | TODO. |
timeout | TODO. |
cb | Callback function to add. Must not be NULL. |
cb_data | Data for the callback function. Can be NULL. |
Definition at line 476 of file session.c.
References source::cb, source::cb_data, source::events, source::fd, sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, SR_OK, and source::timeout.
Referenced by sr_source_add().
SR_API int sr_session_source_remove | ( | int | fd | ) |
Remove the source belonging to the specified file descriptor.
TODO: More error checks.
fd | TODO. |
Definition at line 526 of file session.c.
References sr_err(), SR_ERR_BUG, SR_ERR_MALLOC, and SR_OK.
Referenced by sr_source_remove().
SR_API int sr_session_start | ( | void | ) |
Start a session.
There can only be one session at a time.
Definition at line 262 of file session.c.
References sr_dev_driver::dev_acquisition_start, sr_session::devs, sr_dev::driver, sr_dev::driver_index, sr_err(), SR_ERR_BUG, sr_info(), and SR_OK.
SR_API int sr_session_stop | ( | void | ) |
Stop the current session.
The current session is stopped immediately, with all acquisition sessions being stopped and hardware drivers cleaned up.
Definition at line 368 of file session.c.
References sr_dev_driver::cleanup, sr_dev_driver::dev_acquisition_stop, sr_session::devs, sr_dev::driver, sr_dev::driver_index, sr_session::running, sr_err(), SR_ERR_BUG, sr_info(), and SR_OK.