return SR_OK;
}
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct context *ctx;
char serial_txt[10];
uint32_t serial;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("sigma: %s: ctx malloc failed", __func__);
return SR_ERR_MALLOC;
/* Function prototypes. */
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
int ret;
struct sr_dev_inst *sdi;
struct context *ctx;
unsigned int i;
- /* Avoid compiler errors. */
- (void)devinfo;
-
/* Allocate memory for our private driver context. */
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("la8: %s: struct context malloc failed", __func__);
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) {
sr_err("demo: %s: sr_dev_inst_new failed", __func__);
* API callbacks
*/
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
int devcnt = 0;
int i, j;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
if (libusb_init(&usb_context) != 0) {
sr_warn("fx2lafw: Failed to initialize libusb.");
return 0;
SR_PRIV libusb_context *genericdmm_usb_context = NULL;
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct context *ctx;
int devcnt = 0;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
if (libusb_init(&genericdmm_usb_context) != 0) {
sr_err("genericdmm: Failed to initialize USB.");
return 0;
return SR_OK;
}
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
libusb_device **devlist;
int err, devcnt, i, j;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
if (libusb_init(&usb_context) != 0) {
sr_err("hantek-dso: Failed to initialize USB.");
return 0;
return SR_OK;
}
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
int devcnt = 0;
struct udev_list_entry *devs, *dev_list_entry;
struct context *ctx;
- devinfo = devinfo;
-
/* It's easier to map usb<->serial using udev */
/*
* FIXME: On windows we can get the same information from the
return sdi;
}
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct context *ctx;
final_devcnt = 0;
- if (devinfo)
- ports = g_slist_append(NULL, g_strdup(devinfo));
- else
- /* No specific device given, so scan all serial ports. */
- ports = list_serial_ports();
-
+ /* Scan all serial ports. */
+ ports = list_serial_ports();
num_ports = g_slist_length(ports);
if (!(fds = g_try_malloc0(num_ports * sizeof(GPollFD)))) {
* API callbacks
*/
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
int ret, devcnt, i;
struct context *ctx;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
/* Allocate memory for our private driver context. */
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("zp: %s: ctx malloc failed", __func__);
char **probe_names;
sr_dbg("initializing %s driver", driver->name);
- num_devs = driver->init(NULL);
+ num_devs = driver->init();
for (i = 0; i < num_devs; i++) {
num_probes = GPOINTER_TO_INT(
driver->dev_info_get(i, SR_DI_NUM_PROBES));
/*--- Special stuff -------------------------------------------------*/
+ /** Session filename */
+ SR_HWCAP_SESSIONFILE,
+
/* TODO: Better description. */
/** The device supports specifying a capturefile to inject. */
SR_HWCAP_CAPTUREFILE,
char *name;
char *longname;
int api_version;
- int (*init) (const char *devinfo);
+ int (*init) (void);
int (*cleanup) (void);
/* Device-specific */
#define CHUNKSIZE (512 * 1024)
struct session_vdev {
+ char *sessionfile;
char *capturefile;
struct zip *archive;
struct zip_file *capfile;
int num_probes;
};
-static char *sessionfile = NULL;
static GSList *dev_insts = NULL;
static const int hwcaps[] = {
SR_HWCAP_CAPTUREFILE,
*
* @return TODO.
*/
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
- sessionfile = g_strdup(devinfo);
return 0;
}
sr_session_source_remove(-1);
- g_free(sessionfile);
-
return SR_OK;
}
sr_info("session driver: setting samplerate to %" PRIu64,
vdev->samplerate);
break;
+ case SR_HWCAP_SESSIONFILE:
+ vdev->sessionfile = g_strdup(value);
+ sr_info("session driver: setting sessionfile to %s",
+ vdev->sessionfile);
+ break;
case SR_HWCAP_CAPTUREFILE:
vdev->capturefile = g_strdup(value);
sr_info("session driver: setting capturefile to %s",
if (!(vdev = get_vdev_by_index(dev_index)))
return SR_ERR;
- sr_info("session_driver: opening archive %s file %s", sessionfile,
+ sr_info("session_driver: opening archive %s file %s", vdev->sessionfile,
vdev->capturefile);
- if (!(vdev->archive = zip_open(sessionfile, 0, &ret))) {
+ if (!(vdev->archive = zip_open(vdev->sessionfile, 0, &ret))) {
sr_err("session driver: Failed to open session file '%s': "
- "zip error %d\n", sessionfile, ret);
+ "zip error %d\n", vdev->sessionfile, ret);
return SR_ERR;
}
if (zip_stat(vdev->archive, vdev->capturefile, 0, &zs) == -1) {
sr_err("session driver: Failed to check capture file '%s' in "
- "session file '%s'.", vdev->capturefile, sessionfile);
+ "session file '%s'.", vdev->capturefile, vdev->sessionfile);
return SR_ERR;
}
if (!(vdev->capfile = zip_fopen(vdev->archive, vdev->capturefile, 0))) {
sr_err("session driver: Failed to open capture file '%s' in "
- "session file '%s'.", vdev->capturefile, sessionfile);
+ "session file '%s'.", vdev->capturefile, vdev->sessionfile);
return SR_ERR;
}
dev = sr_dev_new(&session_driver, devcnt);
if (devcnt == 0)
/* first device, init the driver */
- dev->driver->init((char *)filename);
+ dev->driver->init();
sr_session_dev_add(dev);
+ dev->driver->dev_config_set(devcnt, SR_HWCAP_SESSIONFILE, filename);
dev->driver->dev_config_set(devcnt, SR_HWCAP_CAPTUREFILE, val);
g_ptr_array_add(capturefiles, val);
} else if (!strcmp(keys[j], "samplerate")) {