![]() |
libsigrok
0.3.0
sigrok hardware access and backend library
|
Initializing and shutting down libsigrok. More...
Functions | |
| int | sr_init (struct sr_context **ctx) |
| Initialize libsigrok. | |
| int | sr_exit (struct sr_context *ctx) |
| Shutdown libsigrok. | |
Initializing and shutting down libsigrok.
Before using any of the libsigrok functionality, sr_init() must be called to initialize the library, which will return a struct sr_context when the initialization was successful.
When libsigrok functionality is no longer needed, sr_exit() should be called, which will (among other things) free the struct sr_context.
Example for a minimal program using libsigrok:
{.c}
#include <stdio.h>
#include <libsigrok/libsigrok.h>
int main(int argc, char **argv)
{
int ret;
struct sr_context *sr_ctx;
if ((ret = sr_init(&sr_ctx)) != SR_OK) {
printf("Error initializing libsigrok (%s): %s.\n",
sr_strerror_name(ret), sr_strerror(ret));
return 1;
}
// Use libsigrok functions here...
if ((ret = sr_exit(sr_ctx)) != SR_OK) {
printf("Error shutting down libsigrok (%s): %s.\n",
sr_strerror_name(ret), sr_strerror(ret));
return 1;
}
return 0;
}
| int sr_exit | ( | struct sr_context * | ctx | ) |
| int sr_init | ( | struct sr_context ** | ctx | ) |
Initialize libsigrok.
This function must be called before any other libsigrok function.
| ctx | Pointer to a libsigrok context struct pointer. Must not be NULL. This will be a pointer to a newly allocated libsigrok context object upon success, and is undefined upon errors. |
Definition at line 318 of file backend.c.
References SR_ERR, SR_ERR_MALLOC, and SR_OK.
1.7.6.1