struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
+ struct sr_serial_dev_inst *serial;
GSList *l;
if (!(drvc = di->priv))
continue;
if (!(devc = sdi->priv))
continue;
- sr_serial_dev_inst_free(devc->serial);
+ serial = sdi->conn;
+ sr_serial_dev_inst_free(serial);
sr_dev_inst_free(sdi);
}
g_slist_free(drvc->instances);
return NULL;
}
- if (!(devc->serial = sr_serial_dev_inst_new(conn, serialcomm)))
+ if (!(sdi->conn = sr_serial_dev_inst_new(conn, serialcomm)))
return NULL;
+ sdi->inst_type = SR_INST_SERIAL;
sdi->priv = devc;
sdi->driver = di;
if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
static int hw_dev_open(struct sr_dev_inst *sdi)
{
- struct dev_context *devc;
-
- if (!(devc = sdi->priv)) {
- sr_err("sdi->priv was NULL.");
- return SR_ERR_BUG;
- }
+ struct sr_serial_dev_inst *serial;
- if (serial_open(devc->serial, SERIAL_RDWR) != SR_OK)
+ serial = sdi->conn;
+ if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return SR_ERR;
sdi->status = SR_ST_ACTIVE;
static int hw_dev_close(struct sr_dev_inst *sdi)
{
- struct dev_context *devc;
-
- devc = sdi->priv;
+ struct sr_serial_dev_inst *serial;
- if (devc->serial && devc->serial->fd != -1) {
- serial_close(devc->serial);
+ serial = sdi->conn;
+ if (serial && serial->fd != -1) {
+ serial_close(serial);
sdi->status = SR_ST_INACTIVE;
}
void *cb_data)
{
struct dev_context *devc;
+ struct sr_serial_dev_inst *serial;
if (!(devc = sdi->priv)) {
sr_err("sdi->priv was NULL.");
std_session_send_df_header(cb_data, DRIVER_LOG_DOMAIN);
/* Poll every 150ms, or whenever some data comes in. */
- sr_source_add(devc->serial->fd, G_IO_IN, 150, colead_slm_receive_data,
+ serial = sdi->conn;
+ sr_source_add(serial->fd, G_IO_IN, 150, colead_slm_receive_data,
(void *)sdi);
return SR_OK;
static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
return std_hw_dev_acquisition_stop_serial(sdi, cb_data, hw_dev_close,
- ((struct dev_context *)(sdi->priv))->serial, DRIVER_LOG_DOMAIN);
+ sdi->conn, DRIVER_LOG_DOMAIN);
}
SR_PRIV struct sr_dev_driver colead_slm_driver_info = {
{
const struct sr_dev_inst *sdi;
struct dev_context *devc;
+ struct sr_serial_dev_inst *serial;
int len;
char buf[128];
/* Timeout event. */
return TRUE;
+ serial = sdi->conn;
if (devc->state == IDLE) {
- if (serial_read(devc->serial, buf, 128) != 1 || buf[0] != 0x10)
+ if (serial_read(serial, buf, 128) != 1 || buf[0] != 0x10)
/* Nothing there, or caught the tail end of a previous packet,
* or some garbage. Unless it's a single "data ready" byte,
* we don't want it. */
return TRUE;
/* Got 0x10, "measurement ready". */
- if (serial_write(devc->serial, "\x20", 1) == -1)
+ if (serial_write(serial, "\x20", 1) == -1)
sr_err("unable to send command: %s", strerror(errno));
else {
devc->state = COMMAND_SENT;
devc->buflen = 0;
}
} else {
- len = serial_read(devc->serial, devc->buf + devc->buflen,
+ len = serial_read(serial, devc->buf + devc->buflen,
10 - devc->buflen);
if (len < 1)
return TRUE;