/*
* This file is part of the sigrok project.
*
- * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
+ * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
GString *tmp_str, *devicename, *version;
gchar tmp_c;
- sdi = sr_device_instance_new(0, SR_ST_INACTIVE, NULL, NULL, NULL);
+ sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, NULL, NULL);
ols = ols_device_new();
sdi->priv = ols;
final_devcnt = 0;
if (deviceinfo)
- ports = g_slist_append(NULL, strdup(deviceinfo));
+ ports = g_slist_append(NULL, g_strdup(deviceinfo));
else
/* No specific device given, so scan all serial ports. */
ports = list_serial_ports();
send_shortcommand(fd, CMD_ID);
fds[devcnt].fd = fd;
fds[devcnt].events = G_IO_IN;
- device_names[devcnt] = strdup(l->data);
+ device_names[devcnt] = g_strdup(l->data);
devcnt++;
}
- free(l->data);
+ g_free(l->data);
}
/* 2ms isn't enough for reliable transfer with pl2303, let's try 10 */
sdi->index = final_devcnt;
} else {
/* not an OLS -- some other board that uses the sump protocol */
- sdi = sr_device_instance_new(final_devcnt, SR_ST_INACTIVE,
+ sdi = sr_dev_inst_new(final_devcnt, SR_ST_INACTIVE,
"Sump", "Logic Analyzer", "v1.0");
ols = ols_device_new();
ols->num_probes = 32;
sdi->priv = ols;
}
- ols->serial = sr_serial_device_instance_new(device_names[i], -1);
+ ols->serial = sr_serial_dev_inst_new(device_names[i], -1);
device_instances = g_slist_append(device_instances, sdi);
final_devcnt++;
serial_close(fds[i].fd);
serial_restore_params(fds[i].fd, serial_params[i]);
serial_close(fds[i].fd);
}
- free(serial_params[i]);
- free(device_names[i]);
+ g_free(serial_params[i]);
+ g_free(device_names[i]);
}
g_free(serial_params);
struct sr_device_instance *sdi;
struct ols_device *ols;
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+ if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
return SR_ERR;
ols = sdi->priv;
struct sr_device_instance *sdi;
struct ols_device *ols;
- if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+ if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
sr_err("ols: %s: sdi was NULL", __func__);
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
return SR_OK;
}
-static void hw_cleanup(void)
+static int hw_cleanup(void)
{
GSList *l;
struct sr_device_instance *sdi;
struct ols_device *ols;
+ int ret = SR_OK;
/* Properly close and free all devices. */
for (l = device_instances; l; l = l->next) {
- sdi = l->data;
- ols = sdi->priv;
+ if (!(sdi = l->data)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("ols: %s: sdi was NULL, continuing", __func__);
+ ret = SR_ERR_BUG;
+ continue;
+ }
+ if (!(ols = sdi->priv)) {
+ /* Log error, but continue cleaning up the rest. */
+ sr_err("ols: %s: sdi->priv was NULL, continuing",
+ __func__);
+ ret = SR_ERR_BUG;
+ continue;
+ }
+ /* TODO: Check for serial != NULL. */
if (ols->serial->fd != -1)
serial_close(ols->serial->fd);
- sr_serial_device_instance_free(ols->serial);
- sr_device_instance_free(sdi);
+ sr_serial_dev_inst_free(ols->serial);
+ sr_dev_inst_free(sdi);
}
g_slist_free(device_instances);
device_instances = NULL;
+
+ return ret;
}
static void *hw_get_device_info(int device_index, int device_info_id)
struct ols_device *ols;
void *info;
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+ if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
return NULL;
ols = sdi->priv;
{
struct sr_device_instance *sdi;
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+ if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
return SR_ST_NOT_FOUND;
return sdi->status;
* from the requested.
*/
ols->cur_samplerate = CLOCK_RATE / (ols->cur_samplerate_divider + 1);
- if(ols->flag_reg & FLAG_DEMUX)
+ if (ols->flag_reg & FLAG_DEMUX)
ols->cur_samplerate *= 2;
- if(ols->cur_samplerate != samplerate)
- sr_warn("ols: can't match samplerate %" PRIu64 ", using %" PRIu64,
- samplerate, ols->cur_samplerate);
+ if (ols->cur_samplerate != samplerate)
+ sr_err("ols: can't match samplerate %" PRIu64 ", using %"
+ PRIu64, samplerate, ols->cur_samplerate);
return SR_OK;
}
int ret;
uint64_t *tmp_u64;
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+ if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
return SR_ERR;
ols = sdi->priv;
if (*tmp_u64 < MIN_NUM_SAMPLES)
return SR_ERR;
if (*tmp_u64 > ols->max_samples)
- sr_warn("ols: sample limit exceeds hw max");
+ sr_err("ols: sample limit exceeds hw max");
ols->limit_samples = *tmp_u64;
sr_info("ols: sample limit %" PRIu64, ols->limit_samples);
ret = SR_OK;
int num_channels;
int i;
- if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+ if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
return SR_ERR;
ols = sdi->priv;
gettimeofday(&header->starttime, NULL);
header->samplerate = ols->cur_samplerate;
header->num_logic_probes = NUM_PROBES;
- header->num_analog_probes = 0;
sr_session_bus(session_data, packet);
g_free(header);
return SR_OK;
}
-static void hw_stop_acquisition(int device_index, gpointer session_device_id)
+static int hw_stop_acquisition(int device_index, gpointer session_device_id)
{
struct sr_datafeed_packet packet;
packet.type = SR_DF_END;
sr_session_bus(session_device_id, &packet);
+
+ return SR_OK;
}
SR_PRIV struct sr_device_plugin ols_plugin_info = {