24 #include "libsigrok-internal.h"
27 #define LOG_PREFIX "backend"
129 static int sanity_check_all_drivers(
void)
131 int i, errors, ret =
SR_OK;
135 sr_spew(
"Sanity-checking all drivers.");
138 for (i = 0; drivers[i]; i++) {
141 d = (drivers[i]->
name) ? drivers[i]->
name :
"NULL";
143 if (!drivers[i]->
name) {
144 sr_err(
"No name in driver %d ('%s').", i, d);
148 sr_err(
"No longname in driver %d ('%s').", i, d);
152 sr_err(
"API version in driver %d ('%s') < 1.", i, d);
155 if (!drivers[i]->
init) {
156 sr_err(
"No init in driver %d ('%s').", i, d);
160 sr_err(
"No cleanup in driver %d ('%s').", i, d);
163 if (!drivers[i]->
scan) {
164 sr_err(
"No scan in driver %d ('%s').", i, d);
168 sr_err(
"No dev_list in driver %d ('%s').", i, d);
173 sr_err(
"No config_set in driver %d ('%s').", i, d);
177 sr_err(
"No config_list in driver %d ('%s').", i, d);
181 sr_err(
"No dev_open in driver %d ('%s').", i, d);
185 sr_err(
"No dev_close in driver %d ('%s').", i, d);
189 sr_err(
"No dev_acquisition_start in driver %d ('%s').",
194 sr_err(
"No dev_acquisition_stop in driver %d ('%s').",
216 static int sanity_check_all_input_modules(
void)
218 int i, errors, ret =
SR_OK;
222 sr_spew(
"Sanity-checking all input modules.");
225 for (i = 0; inputs[i]; i++) {
228 d = (inputs[i]->
id) ? inputs[i]->
id :
"NULL";
230 if (!inputs[i]->
id) {
231 sr_err(
"No ID in module %d ('%s').", i, d);
235 sr_err(
"No description in module %d ('%s').", i, d);
239 sr_err(
"No format_match in module %d ('%s').", i, d);
242 if (!inputs[i]->
init) {
243 sr_err(
"No init in module %d ('%s').", i, d);
247 sr_err(
"No loadfile in module %d ('%s').", i, d);
266 static int sanity_check_all_output_modules(
void)
268 int i, errors, ret =
SR_OK;
272 sr_spew(
"Sanity-checking all output modules.");
275 for (i = 0; outputs[i]; i++) {
278 d = (outputs[i]->
id) ? outputs[i]->
id :
"NULL";
280 if (!outputs[i]->
id) {
281 sr_err(
"No ID in module %d ('%s').", i, d);
285 sr_err(
"No description in module '%s'.", d);
289 sr_err(
"No receive in module '%s'.", d);
324 sr_err(
"%s(): libsigrok context was NULL.", __func__);
328 if (sanity_check_all_drivers() < 0) {
329 sr_err(
"Internal driver error(s), aborting.");
333 if (sanity_check_all_input_modules() < 0) {
334 sr_err(
"Internal input module error(s), aborting.");
338 if (sanity_check_all_output_modules() < 0) {
339 sr_err(
"Internal output module error(s), aborting.");
344 context = g_try_malloc0(
sizeof(
struct sr_context) + 1);
351 #ifdef HAVE_LIBUSB_1_0
352 ret = libusb_init(&context->libusb_ctx);
353 if (LIBUSB_SUCCESS != ret) {
354 sr_err(
"libusb_init() returned %s.", libusb_error_name(ret));
384 sr_err(
"%s(): libsigrok context was NULL.", __func__);
390 #ifdef HAVE_LIBUSB_1_0
391 libusb_exit(ctx->libusb_ctx);
Generic/unspecified error.
char * description
A short description of the input format, which can (for example) be displayed to the user by frontend...
struct sr_session * session
GSList *(* scan)(GSList *options)
Scan for devices.
struct sr_input_format ** sr_input_list(void)
char * longname
Long name.
int sr_exit(struct sr_context *ctx)
Shutdown libsigrok.
int(* dev_open)(struct sr_dev_inst *sdi)
Open device.
The public libsigrok header file to be used by frontends.
char * description
A short description of the output format.
int(* init)(struct sr_input *in, const char *filename)
Initialize the input module.
int api_version
API version (currently 1).
struct sr_dev_driver ** sr_driver_list(void)
Return the list of supported hardware drivers.
int(* cleanup)(void)
Called before driver is unloaded.
int(* dev_acquisition_stop)(struct sr_dev_inst *sdi, void *cb_data)
End data acquisition on the specified device.
Input (file) format driver.
Opaque data structure representing a libsigrok session.
int(* receive)(struct sr_output *o, const struct sr_datafeed_packet *packet, GString **out)
This function is passed a copy of every packed in the data feed.
int(* dev_acquisition_start)(const struct sr_dev_inst *sdi, void *cb_data)
Begin data acquisition on the specified device.
Opaque structure representing a libsigrok context.
Malloc/calloc/realloc error.
int(* loadfile)(struct sr_input *in, const char *filename)
Load a file, parsing the input according to the file's format.
int(* dev_close)(struct sr_dev_inst *sdi)
Close device.
char * id
The unique ID for this input format.
struct sr_output_format ** sr_output_list(void)
GSList *(* dev_list)(void)
Get list of device instances the driver knows about.
int(* init)(struct sr_context *sr_ctx)
Called when driver is loaded, e.g.
int(* format_match)(const char *filename)
Check if this input module can load and parse the specified file.
int(* config_list)(int info_id, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
List all possible values for a configuration key in a device instance.
int sr_init(struct sr_context **ctx)
Initialize libsigrok.
int(* config_set)(int id, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
Set value of a configuration key in driver or a given device instance.
Output (file) format driver.
char * id
A unique ID for this output format.