scpi: add a struct drv_context parameter to scpi_dev_inst_new()
This commit is contained in:
parent
ea2d6d994f
commit
17bdda5868
|
@ -87,8 +87,8 @@ static const struct sr_scpi_dev_inst *scpi_devs[] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(const char *resource,
|
SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(struct drv_context *drvc,
|
||||||
const char *serialcomm)
|
const char *resource, const char *serialcomm)
|
||||||
{
|
{
|
||||||
struct sr_scpi_dev_inst *scpi = NULL;
|
struct sr_scpi_dev_inst *scpi = NULL;
|
||||||
const struct sr_scpi_dev_inst *scpi_dev;
|
const struct sr_scpi_dev_inst *scpi_dev;
|
||||||
|
@ -103,7 +103,7 @@ SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(const char *resource,
|
||||||
*scpi = *scpi_dev;
|
*scpi = *scpi_dev;
|
||||||
scpi->priv = g_malloc0(scpi->priv_size);
|
scpi->priv = g_malloc0(scpi->priv_size);
|
||||||
params = g_strsplit(resource, "/", 0);
|
params = g_strsplit(resource, "/", 0);
|
||||||
if (scpi->dev_inst_new(scpi->priv, resource,
|
if (scpi->dev_inst_new(scpi->priv, drvc, resource,
|
||||||
params, serialcomm) != SR_OK) {
|
params, serialcomm) != SR_OK) {
|
||||||
sr_scpi_free(scpi);
|
sr_scpi_free(scpi);
|
||||||
scpi = NULL;
|
scpi = NULL;
|
||||||
|
|
|
@ -35,11 +35,12 @@ struct scpi_serial {
|
||||||
size_t read;
|
size_t read;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int scpi_serial_dev_inst_new(void *priv, const char *resource,
|
static int scpi_serial_dev_inst_new(void *priv, struct drv_context *drvc,
|
||||||
char **params, const char *serialcomm)
|
const char *resource, char **params, const char *serialcomm)
|
||||||
{
|
{
|
||||||
struct scpi_serial *sscpi = priv;
|
struct scpi_serial *sscpi = priv;
|
||||||
|
|
||||||
|
(void)drvc;
|
||||||
(void)params;
|
(void)params;
|
||||||
|
|
||||||
if (!(sscpi->serial = sr_serial_dev_inst_new(resource, serialcomm)))
|
if (!(sscpi->serial = sr_serial_dev_inst_new(resource, serialcomm)))
|
||||||
|
|
|
@ -51,11 +51,12 @@ struct scpi_tcp {
|
||||||
int response_bytes_read;
|
int response_bytes_read;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int scpi_tcp_dev_inst_new(void *priv, const char *resource,
|
static int scpi_tcp_dev_inst_new(void *priv, struct drv_context *drvc,
|
||||||
char **params, const char *serialcomm)
|
const char *resource, char **params, const char *serialcomm)
|
||||||
{
|
{
|
||||||
struct scpi_tcp *tcp = priv;
|
struct scpi_tcp *tcp = priv;
|
||||||
|
|
||||||
|
(void)drvc;
|
||||||
(void)resource;
|
(void)resource;
|
||||||
(void)serialcomm;
|
(void)serialcomm;
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,12 @@ struct usbtmc_scpi {
|
||||||
int response_bytes_read;
|
int response_bytes_read;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int scpi_usbtmc_dev_inst_new(void *priv, const char *resource,
|
static int scpi_usbtmc_dev_inst_new(void *priv, struct drv_context *drvc,
|
||||||
char **params, const char *serialcomm)
|
const char *resource, char **params, const char *serialcomm)
|
||||||
{
|
{
|
||||||
struct usbtmc_scpi *uscpi = priv;
|
struct usbtmc_scpi *uscpi = priv;
|
||||||
|
|
||||||
|
(void)drvc;
|
||||||
(void)params;
|
(void)params;
|
||||||
(void)serialcomm;
|
(void)serialcomm;
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,12 @@ struct scpi_vxi {
|
||||||
unsigned int read_complete;
|
unsigned int read_complete;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int scpi_vxi_dev_inst_new(void *priv, const char *resource,
|
static int scpi_vxi_dev_inst_new(void *priv, struct drv_context *drvc,
|
||||||
char **params, const char *serialcomm)
|
const char *resource, char **params, const char *serialcomm)
|
||||||
{
|
{
|
||||||
struct scpi_vxi *vxi = priv;
|
struct scpi_vxi *vxi = priv;
|
||||||
|
|
||||||
|
(void)drvc;
|
||||||
(void)resource;
|
(void)resource;
|
||||||
(void)serialcomm;
|
(void)serialcomm;
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ static struct sr_dev_inst *hmo_probe_serial_device(const char *serial_device,
|
||||||
scpi = NULL;
|
scpi = NULL;
|
||||||
hw_info = NULL;
|
hw_info = NULL;
|
||||||
|
|
||||||
if (!(scpi = scpi_dev_inst_new(serial_device, serial_options)))
|
if (!(scpi = scpi_dev_inst_new(di->priv, serial_device, serial_options)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
sr_info("Probing %s.", serial_device);
|
sr_info("Probing %s.", serial_device);
|
||||||
|
|
|
@ -269,7 +269,7 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev
|
||||||
|
|
||||||
*devices = NULL;
|
*devices = NULL;
|
||||||
|
|
||||||
if (!(scpi = scpi_dev_inst_new(resource, serialcomm)))
|
if (!(scpi = scpi_dev_inst_new(di->priv, resource, serialcomm)))
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
if (sr_scpi_open(scpi) != SR_OK) {
|
if (sr_scpi_open(scpi) != SR_OK) {
|
||||||
|
|
|
@ -438,8 +438,8 @@ struct sr_scpi_dev_inst {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
int priv_size;
|
int priv_size;
|
||||||
int (*dev_inst_new)(void *priv, const char *resource, char **params,
|
int (*dev_inst_new)(void *priv, struct drv_context *drvc,
|
||||||
const char *serialcomm);
|
const char *resource, char **params, const char *serialcomm);
|
||||||
int (*open)(void *priv);
|
int (*open)(void *priv);
|
||||||
int (*source_add)(void *priv, int events,
|
int (*source_add)(void *priv, int events,
|
||||||
int timeout, sr_receive_data_callback_t cb, void *cb_data);
|
int timeout, sr_receive_data_callback_t cb, void *cb_data);
|
||||||
|
@ -453,8 +453,8 @@ struct sr_scpi_dev_inst {
|
||||||
void *priv;
|
void *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(const char *resource,
|
SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(struct drv_context *drvc,
|
||||||
const char *serialcomm);
|
const char *resource, const char *serialcomm);
|
||||||
SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi);
|
SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi);
|
||||||
SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events,
|
SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events,
|
||||||
int timeout, sr_receive_data_callback_t cb, void *cb_data);
|
int timeout, sr_receive_data_callback_t cb, void *cb_data);
|
||||||
|
|
Loading…
Reference in New Issue