|
libsigrok
|
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <glib.h>#include "sigrok.h"#include "sigrok-internal.h"
Go to the source code of this file.
Data Structures | |
| struct | source |
Functions | |
| SR_API struct sr_session * | sr_session_new (void) |
| Create a new session. | |
| SR_API int | sr_session_destroy (void) |
| Destroy the current session. | |
| SR_API int | sr_session_dev_remove_all (void) |
| Remove all the devices from the current session. | |
| SR_API int | sr_session_dev_add (struct sr_dev *dev) |
| Add a device to the current session. | |
| SR_API int | sr_session_datafeed_callback_remove_all (void) |
| Remove all datafeed callbacks in the current session. | |
| SR_API int | sr_session_datafeed_callback_add (sr_datafeed_callback_t cb) |
| Add a datafeed callback to the current session. | |
| SR_API int | sr_session_start (void) |
| Start a session. | |
| SR_API int | sr_session_run (void) |
| Run the session. | |
| SR_API int | sr_session_halt (void) |
| Halt the current session. | |
| SR_API int | sr_session_stop (void) |
| Stop the current session. | |
| SR_PRIV int | sr_session_send (struct sr_dev *dev, struct sr_datafeed_packet *packet) |
| Send a packet to whatever is listening on the datafeed bus. | |
| SR_API int | sr_session_source_add (int fd, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data) |
| TODO. | |
| SR_API int | sr_session_source_remove (int fd) |
| Remove the source belonging to the specified file descriptor. | |
Variables | |
| SR_PRIV GIOChannel | channels [2] |
| struct sr_session * | session |
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.

| SR_API int sr_session_dev_add | ( | struct sr_dev * | dev | ) |
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 struct sr_session* sr_session_new | ( | void | ) | [read] |
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_PRIV int sr_session_send | ( | struct sr_dev * | dev, |
| struct sr_datafeed_packet * | packet | ||
| ) |
Send a packet to whatever is listening on the datafeed bus.
Hardware drivers use this to send a data packet to the frontend.
| dev | TODO. |
| packet | The datafeed packet to send to the session bus. |
Definition at line 435 of file session.c.
References sr_session::datafeed_callbacks, sr_err(), SR_ERR_ARG, SR_LOG_DBG, sr_log_loglevel_get(), and SR_OK.

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

| struct sr_session* session |
Definition at line 41 of file session.c.
Referenced by sr_session_new().
1.7.6.1