#include "protocol.h"
extern SR_PRIV struct sr_dev_driver p_ols_driver_info;
-static struct sr_dev_driver *di = &p_ols_driver_info;
SR_PRIV int write_shortcommand(struct dev_context *devc, uint8_t command)
{
SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, struct dev_context *devc)
{
struct sr_dev_inst *sdi;
- struct sr_channel *ch;
uint32_t tmp_int, ui;
uint8_t key, type, token;
GString *tmp_str, *devname, *version;
guchar tmp_c;
int index, i;
- sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, NULL, NULL);
- sdi->driver = di;
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
+ sdi->status = SR_ST_INACTIVE;
+ sdi->driver = &p_ols_driver_info;
sdi->priv = devc;
devname = g_string_new("");
switch (token) {
case 0x00:
/* Number of usable channels */
- for (ui = 0; ui < tmp_int; ui++) {
- if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
- p_ols_channel_names[ui])))
- return 0;
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
+ for (ui = 0; ui < tmp_int; ui++)
+ sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
+ p_ols_channel_names[ui]);
break;
case 0x01:
/* Amount of sample memory available (bytes) */
switch (token) {
case 0x00:
/* Number of usable channels */
- for (ui = 0; ui < tmp_c; ui++) {
- if (!(ch = sr_channel_new(ui, SR_CHANNEL_LOGIC, TRUE,
- p_ols_channel_names[ui])))
- return 0;
- sdi->channels = g_slist_append(sdi->channels, ch);
- }
+ for (ui = 0; ui < tmp_c; ui++)
+ sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE,
+ p_ols_channel_names[ui]);
break;
case 0x01:
/* protocol version */
num_channels++;
}
}
- sr_dbg("num_channels = %d", num_channels);
/* Get a block of data. */
bytes_read = ftdi_read_data(devc->ftdic, devc->ftdi_buf, FTDI_BUF_SIZE);