libsigrok
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Typedefs | Functions
sigrok-proto.h File Reference
This graph shows which files directly or indirectly include this file:

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_devsr_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_probesr_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_optionsr_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_sessionsr_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 Documentation

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.

Function Documentation

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.

Parameters
dsThe datastore to destroy.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments.

Definition at line 86 of file datastore.c.

References sr_datastore::chunklist, sr_err(), SR_ERR_ARG, and SR_OK.

Here is the call graph for this function:

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.

Parameters
unitsizeThe unit size (>= 1) to be used for this datastore.
dsPointer to a variable which will hold the newly created datastore structure.
Returns
SR_OK upon success, SR_ERR_MALLOC upon memory allocation errors, or SR_ERR_ARG upon invalid arguments. If something other than SR_OK is returned, the value of 'ds' is undefined.

Definition at line 51 of file datastore.c.

References sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, and SR_OK.

Here is the call graph for this function:

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.

Parameters
dsPointer to the datastore which shall receive the data. Must not be NULL.
dataPointer to the memory buffer containing the data to add. Must not be NULL. TODO: Data format?
lengthLength of the data to add (in number of bytes). TODO: Should 0 be allowed as length?
in_unitsizeThe unit size (>= 1) of the input data.
probelistPointer 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.
Returns
SR_OK upon success, SR_ERR_MALLOC upon memory allocation errors, or SR_ERR_ARG upon invalid arguments. If something other than SR_OK is returned, the value/state of 'ds' is undefined.

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.

Here is the call graph for this function:

SR_API gboolean sr_dev_has_hwcap ( const struct sr_dev dev,
int  hwcap 
)

Determine whether the specified device has the specified capability.

Parameters
devPointer 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).
hwcapThe capability that should be checked (whether it's supported by the specified device).
Returns
TRUE, if the device has the specified capability, FALSE otherwise. FALSE is also returned upon invalid input parameters or other error conditions.

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().

Here is the call graph for this function:

SR_API int sr_dev_info_get ( const struct sr_dev dev,
int  id,
const void **  data 
)

Returns information about the given device.

Parameters
devPointer to the device to be checked. Must not be NULL. The device's 'driver' field must not be NULL either.
idThe type of information.
dataThe return value. Must not be NULL.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR upon other errors.

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?

Returns
The list (GSList) of detected devices, or NULL if none were found.

Definition at line 92 of file device.c.

References sr_dev_scan().

Here is the call graph for this function:

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?

Parameters
driverTODO. If 'driver' is NULL, the created device is a "virtual" one.
driver_indexTODO
Returns
Pointer to the newly allocated device, or NULL upon errors.

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().

Here is the call graph for this function:

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.

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.

Parameters
devThe device to which to add a probe with the specified name. Must not be NULL.
nameThe name of the probe to add to this device. Must not be NULL. TODO: Maximum length, allowed characters, etc.
Returns
SR_OK upon success, SR_ERR_MALLOC upon memory allocation errors, or SR_ERR_ARG upon invalid arguments. If something other than SR_OK is returned, 'dev' is unchanged.

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().

Here is the call graph for this function:

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.

TODO

Parameters
devTODO. Must not be NULL.
probenumThe 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.

Returns
A pointer to the requested probe's 'struct sr_probe', or NULL if the probe could not be found.

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().

Here is the call graph for this function:

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.

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

Parameters
devTODO
probenumThe number of the probe whose name to set. Note that the probe numbers start at 1 (not 0!).
nameThe new name that the specified probe should get.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR upon other errors. If something other than SR_OK is returned, 'dev' is unchanged.

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().

Here is the call graph for this function:

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 attached via USB (can be reliably detected via USB VID/PID).
  • 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.

Returns
SR_OK upon success, SR_ERR_BUG upon internal errors.

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().

Here is the call graph for this function:

SR_API int sr_dev_trigger_remove_all ( struct sr_dev dev)

Remove all triggers set up for the specified device.

TODO: Better description.

Parameters
devTODO
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments. If something other than SR_OK is returned, 'dev' is unchanged.

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.

Here is the call graph for this function:

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).

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.

Parameters
devTODO. Must not be NULL.
probenumThe number of the probe. TODO. Note that the probe numbers start at 1 (not 0!).
triggerTODO. TODO: Is NULL allowed?
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR upon other errors. If something other than SR_OK is returned, 'dev' is unchanged.

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().

Here is the call graph for this function:

SR_API gboolean sr_driver_hwcap_exists ( struct sr_dev_driver driver,
int  hwcap 
)

Find out if a hardware driver has a specific capability.

Parameters
driverThe hardware driver in which to search for the capability.
hwcapThe capability to find in the list.
Returns
TRUE if the specified capability exists in the specified driver, FALSE otherwise. Also, if 'driver' is NULL or the respective driver returns an invalid capability list, FALSE is returned.

Definition at line 268 of file hwdriver.c.

References sr_dev_driver::hwcap_get_all, and sr_err().

Here is the call graph for this function:

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.

Parameters
driverThe driver to initialize.
Returns
The number of devices found and instantiated by the driver.

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().

Here is the call graph for this function:

SR_API struct sr_dev_driver** sr_driver_list ( void  )

Return the list of supported hardware drivers.

Returns
Pointer to the NULL-terminated list of hardware driver pointers.

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.

Returns
SR_OK upon success, a (negative) error code otherwise.

Definition at line 39 of file backend.c.

References sr_hw_cleanup_all(), and SR_OK.

Here is the call graph for this function:

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.

Parameters
in_unitsizeThe unit size (>= 1) of the input (data_in).
out_unitsizeThe 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'.
probelistPointer 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_inPointer to the input data buffer. Must not be NULL.
length_inThe input data length (>= 1), in number of bytes.
data_outVariable 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_outPointer to the variable which will contain the output data length (in number of bytes) when the function returns SR_OK. Must not be NULL.
Returns
SR_OK upon success, SR_ERR_MALLOC upon memory allocation errors, or SR_ERR_ARG upon invalid arguments. If something other than SR_OK is returned, the values of out_unitsize, data_out, and length_out are undefined.

Definition at line 76 of file filter.c.

References sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, and SR_OK.

Here is the call graph for this function:

SR_API struct sr_hwcap_option* sr_hw_hwcap_get ( int  hwcap)

Get a hardware driver capability option.

Parameters
hwcapThe capability to get.
Returns
A pointer to a struct with information about the parameter, or NULL if the capability was not found.

Definition at line 298 of file hwdriver.c.

References sr_hwcap_option::hwcap.

SR_API int sr_init ( void  )

Initialize libsigrok.

Returns
SR_OK upon success, a (negative) error code otherwise.

Definition at line 29 of file backend.c.

References SR_OK.

SR_API struct sr_input_format** sr_input_list ( void  )

Definition at line 33 of file input.c.

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.

Parameters
cbFunction pointer to the log callback function to use. Must not be NULL.
cb_dataPointer 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.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments.

Definition at line 140 of file log.c.

References sr_err(), SR_ERR_ARG, and SR_OK.

Here is the call graph for this function:

SR_API int sr_log_callback_set_default ( void  )

Set the libsigrok log callback to the default built-in one.

Additionally, the internal 'sr_log_callback_data' pointer is set to NULL.

Returns
SR_OK upon success, a negative error code otherwise.

Definition at line 162 of file log.c.

References SR_OK.

SR_API char* sr_log_logdomain_get ( void  )

Get the currently configured libsigrok logdomain.

Returns
A copy of the currently configured libsigrok logdomain string. The caller is responsible for g_free()ing the string when it is no longer needed.

Definition at line 122 of file log.c.

SR_API int sr_log_logdomain_set ( const char *  logdomain)

Set the libsigrok logdomain string.

Parameters
logdomainThe 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.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid logdomain.

Definition at line 100 of file log.c.

References LOGDOMAIN_MAXLEN, sr_dbg(), sr_err(), SR_ERR_ARG, and SR_OK.

Here is the call graph for this function:

SR_API int sr_log_loglevel_get ( void  )

Get the libsigrok loglevel.

Returns
The currently configured 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.

Parameters
loglevelThe loglevel to set (SR_LOG_NONE, SR_LOG_ERR, SR_LOG_WARN, SR_LOG_INFO, SR_LOG_DBG, or SR_LOG_SPEW).
Returns
SR_OK upon success, SR_ERR_ARG upon invalid loglevel.

Definition at line 62 of file log.c.

References sr_dbg(), sr_err(), SR_ERR_ARG, SR_LOG_SPEW, and SR_OK.

Here is the call graph for this function:

SR_API struct sr_output_format** sr_output_list ( void  )

Definition at line 50 of file output.c.

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)

Definition at line 304 of file strutil.c.

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.

Parameters
sizestringA string containing a (decimal) size value.
sizePointer to uint64_t which will contain the string's size value.
Returns
SR_OK upon success, SR_ERR upon errors.

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.

Parameters
timestringA string containing a (decimal) time value.
Returns
The string's time value as uint64_t, in milliseconds.

TODO: Error handling. TODO: Add support for "m" (minutes) and others. TODO: picoseconds? TODO: Allow both lower-case and upper-case.

Definition at line 281 of file strutil.c.

SR_API char** sr_parse_triggerstring ( struct sr_dev dev,
const char *  triggerstring 
)

Parse a trigger specification string.

Parameters
devThe device for which the trigger specification is intended.
triggerstringThe 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"
Returns
Pointer to a list of trigger types (strings), or NULL upon errors. The pointer list (if non-NULL) has as many entries as the respective device has probes (all physically available probes, not just enabled ones). Entries of the list which don't have a trigger value set in 'triggerstring' are NULL, the other entries contain the respective trigger type which is requested for the respective probe (e.g. "r", "c", and so on).

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.

Here is the call graph for this function:

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".

Parameters
frequencyThe frequency in Hz.
Returns
A g_try_malloc()ed string representation of the frequency value, or NULL upon errors. The caller is responsible to g_free() the memory.

Definition at line 84 of file strutil.c.

References sr_err(), SR_GHZ, SR_KHZ, and SR_MHZ.

Here is the call graph for this function:

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".

Parameters
samplerateThe samplerate in Hz.
Returns
A g_try_malloc()ed string representation of the samplerate value, or NULL upon errors. The caller is responsible to g_free() the memory.

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().

Here is the call graph for this function:

SR_API int sr_session_datafeed_callback_add ( sr_datafeed_callback_t  cb)

Add a datafeed callback to the current session.

Parameters
cbFunction to call when a chunk of data is received. Must not be NULL.
Returns
SR_OK upon success, SR_ERR_BUG if no session exists.

Definition at line 187 of file session.c.

References sr_session::datafeed_callbacks, sr_err(), SR_ERR_ARG, SR_ERR_BUG, and SR_OK.

Here is the call graph for this function:

SR_API int sr_session_datafeed_callback_remove_all ( void  )

Remove all datafeed callbacks in the current session.

Returns
SR_OK upon success, SR_ERR_BUG if no session exists.

Definition at line 166 of file session.c.

References sr_session::datafeed_callbacks, sr_err(), SR_ERR_BUG, and SR_OK.

Here is the call graph for this function:

SR_API int sr_session_destroy ( void  )

Destroy the current session.

This frees up all memory used by the session.

Returns
SR_OK upon success, SR_ERR_BUG if no session exists.

Definition at line 72 of file session.c.

References sr_session::devs, sr_err(), SR_ERR_BUG, and SR_OK.

Here is the call graph for this function:

SR_API int sr_session_dev_add ( struct sr_dev dev)

Add a device to the current session.

Parameters
devThe device to add to the current session. Must not be NULL. Also, dev->driver and dev->driver->dev_open must not be NULL.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments.

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().

Here is the call graph for this function:

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.

Returns
SR_OK upon success, SR_ERR_BUG if no session exists.

Definition at line 100 of file session.c.

References sr_session::devs, sr_err(), SR_ERR_BUG, and SR_OK.

Here is the call graph for this function:

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.

Returns
SR_OK upon success, SR_ERR_BUG if no session exists.

Definition at line 347 of file session.c.

References sr_session::running, sr_err(), SR_ERR_BUG, sr_info(), and SR_OK.

Here is the call graph for this function:

SR_API int sr_session_load ( const char *  filename)

Load the session from the specified filename.

Parameters
filenameThe name of the session file to load. Must not be NULL.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments, SR_ERR_MALLOC upon memory allocation errors, or SR_ERR upon other errors.

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().

Here is the call graph for this function:

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.

Returns
A pointer to the newly allocated session, or NULL upon errors.

Definition at line 55 of file session.c.

References session, and sr_err().

Referenced by sr_session_load().

Here is the call graph for this function:

SR_API int sr_session_run ( void  )

Run the session.

TODO: Various error checks etc.

Returns
SR_OK upon success, SR_ERR_BUG upon errors.

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.

Here is the call graph for this function:

SR_API int sr_session_save ( const char *  filename)

Save the current session to the specified file.

Parameters
filenameThe name of the file where to save the current session. Must not be NULL.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR upon other errors.

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.

Here is the call graph for this function:

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.

Parameters
fdTODO.
eventsTODO.
timeoutTODO.
cbCallback function to add. Must not be NULL.
cb_dataData for the callback function. Can be NULL.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR_MALLOC upon memory allocation errors.

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().

Here is the call graph for this function:

SR_API int sr_session_source_remove ( int  fd)

Remove the source belonging to the specified file descriptor.

TODO: More error checks.

Parameters
fdTODO.
Returns
SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR_MALLOC upon memory allocation errors, SR_ERR_BUG upon internal errors.

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().

Here is the call graph for this function:

SR_API int sr_session_start ( void  )

Start a session.

There can only be one session at a time.

Returns
SR_OK upon success, SR_ERR upon errors.

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.

Here is the call graph for this function:

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.

Returns
SR_OK upon success, SR_ERR_BUG if no session exists.

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.

Here is the call graph for this function: