![]() |
libsigrok
0.2.0
sigrok hardware access and backend library
|
Creating, using, or destroying libsigrok sessions. More...
Functions | |
struct sr_session * | sr_session_new (void) |
Create a new session. More... | |
int | sr_session_destroy (void) |
Destroy the current session. More... | |
int | sr_session_dev_remove_all (void) |
Remove all the devices from the current session. More... | |
int | sr_session_dev_add (const struct sr_dev_inst *sdi) |
Add a device instance to the current session. More... | |
int | sr_session_datafeed_callback_remove_all (void) |
Remove all datafeed callbacks in the current session. More... | |
int | sr_session_datafeed_callback_add (sr_datafeed_callback_t cb, void *cb_data) |
Add a datafeed callback to the current session. More... | |
int | sr_session_start (void) |
Start a session. More... | |
int | sr_session_run (void) |
Run the session. More... | |
SR_PRIV int | sr_session_stop_sync (void) |
Stop the current session. More... | |
int | sr_session_stop (void) |
Stop the current session. More... | |
int | sr_session_source_add (int fd, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data) |
Add an event source for a file descriptor. More... | |
int | sr_session_source_add_pollfd (GPollFD *pollfd, int timeout, sr_receive_data_callback_t cb, void *cb_data) |
Add an event source for a GPollFD. More... | |
int | sr_session_source_add_channel (GIOChannel *channel, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data) |
Add an event source for a GIOChannel. More... | |
int | sr_session_source_remove (int fd) |
Remove the source belonging to the specified file descriptor. More... | |
int | sr_session_source_remove_pollfd (GPollFD *pollfd) |
Remove the source belonging to the specified poll descriptor. More... | |
int | sr_session_source_remove_channel (GIOChannel *channel) |
Remove the source belonging to the specified channel. More... | |
int | sr_session_load (const char *filename) |
Load the session from the specified filename. More... | |
int | sr_session_save (const char *filename, const struct sr_dev_inst *sdi, unsigned char *buf, int unitsize, int units) |
Save the current session to the specified file. More... | |
Variables | |
struct sr_session * | session |
struct sr_session * | session |
SR_PRIV struct sr_dev_driver | session_driver |
Creating, using, or destroying libsigrok sessions.
int sr_session_datafeed_callback_add | ( | sr_datafeed_callback_t | cb, |
void * | cb_data | ||
) |
Add a datafeed callback to the current session.
cb | Function to call when a chunk of data is received. Must not be NULL. |
cb_data | Opaque pointer passed in by the caller. |
Definition at line 209 of file session.c.
References sr_session::datafeed_callbacks, sr_err, SR_ERR_ARG, SR_ERR_BUG, SR_ERR_MALLOC, and SR_OK.
int sr_session_datafeed_callback_remove_all | ( | void | ) |
Remove all datafeed callbacks in the current session.
Definition at line 187 of file session.c.
References sr_session::datafeed_callbacks, sr_err, SR_ERR_BUG, and SR_OK.
int sr_session_destroy | ( | void | ) |
Destroy the current session.
This frees up all memory used by the session.
Definition at line 100 of file session.c.
References sr_err, SR_ERR_BUG, SR_OK, sr_session_dev_remove_all(), and sr_session::stop_mutex.
int sr_session_dev_add | ( | const struct sr_dev_inst * | sdi | ) |
Add a device instance to the current session.
sdi | The device instance to add to the current session. Must not be NULL. Also, sdi->driver and sdi->driver->dev_open must not be NULL. |
Definition at line 149 of file session.c.
References sr_dev_driver::dev_open, sr_session::devs, sr_dev_inst::driver, sr_dbg, sr_err, SR_ERR_ARG, SR_ERR_BUG, and SR_OK.
Referenced by sr_session_load().
int sr_session_dev_remove_all | ( | void | ) |
Remove all the devices from the current session.
The session itself (i.e., the struct sr_session) is not free'd and still exists after this function returns.
Definition at line 127 of file session.c.
References sr_session::devs, sr_err, SR_ERR_BUG, and SR_OK.
Referenced by sr_session_destroy().
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 63 of file session_file.c.
References sr_dev_driver::config_set, sr_dev_inst::driver, sr_dev_driver::init, sr_dev_inst::probes, session_driver, SR_CONF_CAPTURE_NUM_PROBES, SR_CONF_CAPTURE_UNITSIZE, SR_CONF_CAPTUREFILE, SR_CONF_SAMPLERATE, SR_CONF_SESSIONFILE, sr_dbg, sr_dev_open(), sr_dev_probe_enable(), sr_dev_probe_name_set(), sr_dev_trigger_set(), sr_err, SR_ERR, SR_ERR_ARG, SR_ERR_MALLOC, SR_MAX_PROBENAME_LEN, SR_OK, sr_parse_sizestring(), SR_PROBE_LOGIC, sr_session_dev_add(), sr_session_new(), and SR_ST_ACTIVE.
|
read |
Create a new session.
Definition at line 79 of file session.c.
References sr_session::abort_session, session, sr_session::source_timeout, sr_err, and sr_session::stop_mutex.
Referenced by sr_session_load().
int sr_session_run | ( | void | ) |
Run the session.
Definition at line 322 of file session.c.
References sr_session::devs, sr_session::num_sources, sr_session::pollfds, sr_session::sources, sr_err, SR_ERR_BUG, sr_info, and SR_OK.
int sr_session_save | ( | const char * | filename, |
const struct sr_dev_inst * | sdi, | ||
unsigned char * | buf, | ||
int | unitsize, | ||
int | units | ||
) |
Save the current session to the specified file.
filename | The name of the filename to save the current session as. Must not be NULL. |
sdi | The device instance from which the data was captured. |
buf | The data to be saved. |
unitsize | The number of bytes per sample. |
units | The number of samples. |
Definition at line 213 of file session_file.c.
References sr_dev_inst::driver, sr_probe::enabled, sr_probe::name, sr_dev_driver::name, sr_dev_inst::probes, SR_CONF_SAMPLERATE, sr_config_get(), sr_dev_has_option(), sr_err, SR_ERR, SR_ERR_ARG, sr_info, SR_OK, sr_samplerate_string(), and sr_probe::trigger.
int sr_session_source_add | ( | int | fd, |
int | events, | ||
int | timeout, | ||
sr_receive_data_callback_t | cb, | ||
void * | cb_data | ||
) |
Add an event source for a file descriptor.
fd | The file descriptor. |
events | Events to check for. |
timeout | Max time to wait before the callback is called, ignored if 0. |
cb | Callback function to add. Must not be NULL. |
cb_data | Data for the callback function. Can be NULL. |
int sr_session_source_add_channel | ( | GIOChannel * | channel, |
int | events, | ||
int | timeout, | ||
sr_receive_data_callback_t | cb, | ||
void * | cb_data | ||
) |
Add an event source for a GIOChannel.
channel | The GIOChannel. |
events | Events to poll on. |
timeout | Max time to wait before the callback is called, ignored if 0. |
cb | Callback function to add. Must not be NULL. |
cb_data | Data for the callback function. Can be NULL. |
int sr_session_source_add_pollfd | ( | GPollFD * | pollfd, |
int | timeout, | ||
sr_receive_data_callback_t | cb, | ||
void * | cb_data | ||
) |
Add an event source for a GPollFD.
pollfd | The GPollFD. |
timeout | Max time to wait before the callback is called, ignored if 0. |
cb | Callback function to add. Must not be NULL. |
cb_data | Data for the callback function. Can be NULL. |
int sr_session_source_remove | ( | int | fd | ) |
Remove the source belonging to the specified file descriptor.
fd | The file descriptor for which the source should be removed. |
int sr_session_source_remove_channel | ( | GIOChannel * | channel | ) |
Remove the source belonging to the specified channel.
channel | The channel for which the source should be removed. |
int sr_session_source_remove_pollfd | ( | GPollFD * | pollfd | ) |
Remove the source belonging to the specified poll descriptor.
pollfd | The poll descriptor for which the source should be removed. |
int sr_session_start | ( | void | ) |
Start a session.
There can only be one session at a time.
Definition at line 282 of file session.c.
References sr_dev_driver::dev_acquisition_start, sr_session::devs, sr_dev_inst::driver, sr_err, SR_ERR_BUG, sr_info, and SR_OK.
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.
If the session is run in a separate thread, this function will not block until the session is finished executing. It is the caller's responsibility to wait for the session thread to return before assuming that the session is completely decommissioned.
Definition at line 399 of file session.c.
References sr_session::abort_session, sr_err, SR_ERR_BUG, SR_OK, and sr_session::stop_mutex.
SR_PRIV int sr_session_stop_sync | ( | void | ) |
Stop the current session.
The current session is stopped immediately, with all acquisition sessions being stopped and hardware drivers cleaned up.
This must be called from within the session thread, to prevent freeing resources that the session thread will try to use.
Definition at line 363 of file session.c.
References sr_dev_driver::dev_acquisition_stop, sr_session::devs, sr_dev_inst::driver, sr_err, SR_ERR_BUG, sr_info, and SR_OK.
struct sr_session* session |
Definition at line 69 of file session.c.
Referenced by sr_session_new().
struct sr_session* session |
Definition at line 69 of file session.c.
Referenced by sr_session_new().
SR_PRIV struct sr_dev_driver session_driver |
Referenced by sr_session_load().