int datastore_new(int unitsize, struct datastore **ds)
{
if (!ds)
- return SIGROK_ERR;
+ return SR_ERR;
if (unitsize <= 0)
- return SIGROK_ERR; /* TODO: Different error? */
+ return SR_ERR; /* TODO: Different error? */
if (!(*ds = g_malloc(sizeof(struct datastore))))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
(*ds)->ds_unitsize = unitsize;
(*ds)->num_units = 0;
(*ds)->chunklist = NULL;
- return SIGROK_OK;
+ return SR_OK;
}
int datastore_destroy(struct datastore *ds)
GSList *chunk;
if (!ds)
- return SIGROK_ERR;
+ return SR_ERR;
for (chunk = ds->chunklist; chunk; chunk = chunk->next)
g_free(chunk->data);
g_slist_free(ds->chunklist);
g_free(ds);
- return SIGROK_OK;
+ return SR_OK;
}
void datastore_put(struct datastore *ds, void *data, unsigned int length,
uint64_t sample_in, sample_out;
if (!(*data_out = malloc(length_in)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
num_enabled_probes = 0;
for (i = 0; probelist[i]; i++)
/* All probes are used -- no need to compress anything. */
memcpy(*data_out, data_in, length_in);
*length_out = length_in;
- return SIGROK_OK;
+ return SR_OK;
}
/* If we reached this point, not all probes are used, so "compress". */
}
*length_out = out_offset;
- return SIGROK_OK;
+ return SR_OK;
}
int err;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
alsa = sdi->priv;
err = snd_pcm_open(&alsa->capture_handle, AUDIO_DEV,
if (err < 0) {
g_warning("cannot open audio device %s (%s)", AUDIO_DEV,
snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
err = snd_pcm_hw_params_malloc(&alsa->hw_params);
if (err < 0) {
g_warning("cannot allocate hardware parameter structure (%s)",
snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
err = snd_pcm_hw_params_any(alsa->capture_handle, alsa->hw_params);
if (err < 0) {
g_warning("cannot initialize hardware parameter structure (%s)",
snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_closedev(int device_index)
struct alsa *alsa;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
alsa = sdi->priv;
switch (capability) {
case HWCAP_PROBECONFIG:
- return SIGROK_OK;
+ return SR_OK;
case HWCAP_SAMPLERATE:
alsa->cur_rate = *(uint64_t *) value;
- return SIGROK_OK;
+ return SR_OK;
case HWCAP_LIMIT_SAMPLES:
alsa->limit_samples = *(uint64_t *) value;
- return SIGROK_OK;
+ return SR_OK;
default:
- return SIGROK_ERR;
+ return SR_ERR;
}
}
int err;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
alsa = sdi->priv;
err = snd_pcm_hw_params_set_access(alsa->capture_handle,
alsa->hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0) {
g_warning("cannot set access type (%s)", snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
/* FIXME: Hardcoded for 16bits */
alsa->hw_params, SND_PCM_FORMAT_S16_LE);
if (err < 0) {
g_warning("cannot set sample format (%s)", snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
err = snd_pcm_hw_params_set_rate_near(alsa->capture_handle,
alsa->hw_params, (unsigned int *) &alsa->cur_rate, 0);
if (err < 0) {
g_warning("cannot set sample rate (%s)", snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
err = snd_pcm_hw_params_set_channels(alsa->capture_handle,
alsa->hw_params, NUM_PROBES);
if (err < 0) {
g_warning("cannot set channel count (%s)", snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
err = snd_pcm_hw_params(alsa->capture_handle, alsa->hw_params);
if (err < 0) {
g_warning("cannot set parameters (%s)", snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
err = snd_pcm_prepare(alsa->capture_handle);
if (err < 0) {
g_warning("cannot prepare audio interface for use (%s)",
snd_strerror(err));
- return SIGROK_ERR;
+ return SR_ERR;
}
count = snd_pcm_poll_descriptors_count(alsa->capture_handle);
if (count < 1) {
g_warning("Unable to obtain poll descriptors count");
- return SIGROK_ERR;
+ return SR_ERR;
}
ufds = malloc(count * sizeof(struct pollfd));
if (!ufds)
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
err = snd_pcm_poll_descriptors(alsa->capture_handle, ufds, count);
if (err < 0) {
g_warning("Unable to obtain poll descriptors (%s)",
snd_strerror(err));
free(ufds);
- return SIGROK_ERR;
+ return SR_ERR;
}
alsa->session_id = session_device_id;
session_bus(session_device_id, &packet);
free(ufds);
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_stop_acquisition(int device_index, gpointer session_device_id)
sigma_write_register(WRITE_TRIGGER_SELECT0, (uint8_t *) &lut->params,
sizeof(lut->params), sigma);
- return SIGROK_OK;
+ return SR_OK;
}
/* Generate the bitbang stream for programming the FPGA. */
if (-1 == bin2bitbang(firmware_path, &buf, &buf_size)) {
g_warning("An error occured while reading the firmware: %s",
firmware_path);
- return SIGROK_ERR;
+ return SR_ERR;
}
/* Upload firmare. */
if ((ret = ftdi_set_bitmode(&sigma->ftdic, 0x00, BITMODE_RESET)) < 0) {
g_warning("ftdi_set_bitmode failed: %s",
ftdi_get_error_string(&sigma->ftdic));
- return SIGROK_ERR;
+ return SR_ERR;
}
ftdi_usb_purge_buffers(&sigma->ftdic);
if (ret != 3 ||
result[0] != 0xa6 || result[1] != 0x55 || result[2] != 0xaa) {
g_warning("Configuration failed. Invalid reply received.");
- return SIGROK_ERR;
+ return SR_ERR;
}
sigma->cur_firmware = firmware_idx;
- return SIGROK_OK;
+ return SR_OK;
}
static int hw_opendev(int device_index)
int ret;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
sigma = sdi->priv;
sdi->status = ST_ACTIVE;
- return SIGROK_OK;
+ return SR_OK;
}
static int set_samplerate(struct sigrok_device_instance *sdi,
break;
}
if (supported_samplerates[i] == 0)
- return SIGROK_ERR_SAMPLERATE;
+ return SR_ERR_SAMPLERATE;
if (samplerate <= MHZ(50)) {
ret = upload_firmware(0, sigma);
g_warning("Asix Sigma only supports a single "
"pin trigger in 100 and 200 "
"MHz mode.");
- return SIGROK_ERR;
+ return SR_ERR;
}
if (probe->trigger[0] == 'f')
sigma->trigger.fallingmask |= probebit;
g_warning("Asix Sigma only supports "
"rising/falling trigger in 100 "
"and 200 MHz mode.");
- return SIGROK_ERR;
+ return SR_ERR;
}
++trigger_set;
if (trigger_set > 1) {
g_warning("Asix Sigma only supports 1 rising/"
"falling triggers.");
- return SIGROK_ERR;
+ return SR_ERR;
}
}
sigma->use_triggers = 1;
}
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_closedev(int device_index)
int ret;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
sigma = sdi->priv;
} else if (capability == HWCAP_LIMIT_MSEC) {
sigma->limit_msec = *(uint64_t*) value;
if (sigma->limit_msec > 0)
- ret = SIGROK_OK;
+ ret = SR_OK;
else
- ret = SIGROK_ERR;
+ ret = SR_ERR;
} else if (capability == HWCAP_CAPTURE_RATIO) {
sigma->capture_ratio = *(uint64_t*) value;
if (sigma->capture_ratio < 0 || sigma->capture_ratio > 100)
- ret = SIGROK_ERR;
+ ret = SR_ERR;
else
- ret = SIGROK_OK;
+ ret = SR_OK;
} else {
- ret = SIGROK_ERR;
+ ret = SR_ERR;
}
return ret;
/* Decode partial chunk. */
if (limit_chunk && ts > limit_chunk)
- return SIGROK_OK;
+ return SR_OK;
/* Pad last sample up to current point. */
numpad = tsdiff * sigma->samples_per_event - clustersize;
*lastsample = samples[n - 1];
}
- return SIGROK_OK;
+ return SR_OK;
}
static int receive_data(int fd, int revents, void *user_data)
/* Triggertype: event. */
lut->params.selres = 3;
- return SIGROK_OK;
+ return SR_OK;
}
static int hw_start_acquisition(int device_index, gpointer session_device_id)
session_device_id = session_device_id;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
sigma = sdi->priv;
sigma->state.state = SIGMA_CAPTURE;
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_stop_acquisition(int device_index, gpointer session_device_id)
if (!GetCommState(hdl, &dcb)) {
/* TODO: Error handling. */
- return SIGROK_ERR;
+ return SR_ERR;
}
/* TODO: Rename 'speed' to 'baudrate'. */
if (!SetCommState(hdl, &dcb)) {
/* TODO: Error handling. */
- return SIGROK_ERR;
+ return SR_ERR;
}
#else
struct termios term;
baud = B460800;
break;
default:
- return SIGROK_ERR;
+ return SR_ERR;
}
if (tcgetattr(fd, &term) < 0)
- return SIGROK_ERR;
+ return SR_ERR;
if (cfsetispeed(&term, baud) < 0)
- return SIGROK_ERR;
+ return SR_ERR;
term.c_cflag &= ~CSIZE;
switch (bits) {
term.c_cflag |= CS7;
break;
default:
- return SIGROK_ERR;
+ return SR_ERR;
}
term.c_cflag &= ~CSTOPB;
case 2:
term.c_cflag |= CSTOPB;
default:
- return SIGROK_ERR;
+ return SR_ERR;
}
term.c_cflag &= ~(IXON | IXOFF | CRTSCTS);
case 1:
term.c_cflag |= CRTSCTS;
default:
- return SIGROK_ERR;
+ return SR_ERR;
}
term.c_iflag &= ~IGNPAR;
term.c_cflag |= PARENB | PARODD;
break;
default:
- return SIGROK_ERR;
+ return SR_ERR;
}
if (tcsetattr(fd, TCSADRAIN, &term) < 0)
- return SIGROK_ERR;
+ return SR_ERR;
#endif
- return SIGROK_OK;
+ return SR_OK;
}
device_index = device_index;
/* Nothing needed so far. */
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_closedev(int device_index)
if (capability == HWCAP_PROBECONFIG) {
/* Nothing to do. */
- ret = SIGROK_OK;
+ ret = SR_OK;
} else if (capability == HWCAP_LIMIT_SAMPLES) {
tmp_u64 = value;
limit_samples = *tmp_u64;
- ret = SIGROK_OK;
+ ret = SR_OK;
} else if (capability == HWCAP_LIMIT_MSEC) {
tmp_u64 = value;
limit_msec = *tmp_u64;
- ret = SIGROK_OK;
+ ret = SR_OK;
} else if (capability == HWCAP_PATTERN_MODE) {
stropt = value;
if (!strcmp(stropt, "random")) {
default_genmode = GENMODE_RANDOM;
- ret = SIGROK_OK;
+ ret = SR_OK;
} else if (!strcmp(stropt, "incremental")) {
default_genmode = GENMODE_INC;
- ret = SIGROK_OK;
+ ret = SR_OK;
} else {
- ret = SIGROK_ERR;
+ ret = SR_ERR;
}
} else {
- ret = SIGROK_ERR;
+ ret = SR_ERR;
}
return ret;
mydata = malloc(sizeof(struct databag));
if (!mydata)
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
mydata->sample_generator = default_genmode;
mydata->session_device_id = session_device_id;
mydata->samples_counter = 0;
if (pipe(mydata->pipe_fds))
- return SIGROK_ERR;
+ return SR_ERR;
channels[0] = g_io_channel_unix_new(mydata->pipe_fds[0]);
channels[1] = g_io_channel_unix_new(mydata->pipe_fds[1]);
my_thread =
g_thread_create((GThreadFunc)thread_func, mydata, TRUE, NULL);
if (!my_thread)
- return SIGROK_ERR;
+ return SR_ERR;
packet = malloc(sizeof(struct datafeed_packet));
header = malloc(sizeof(struct datafeed_header));
if (!packet || !header)
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
packet->type = DF_HEADER;
packet->length = sizeof(struct datafeed_header);
free(header);
free(packet);
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_stop_acquisition(int device_index, gpointer session_device_id)
while (w < s) {
ret = serial_write(fd, buf + w, s - w);
if (ret < 0) {
- ret = SIGROK_ERR;
+ ret = SR_ERR;
goto free;
}
w += ret;
}
- ret = SIGROK_OK;
+ ret = SR_OK;
free:
free(buf);
ret:
int ret;
ret = mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
- if (info == NULL || ret != SIGROK_OK)
+ if (info == NULL || ret != SR_OK)
return ret;
buf[0] = 0;
if (serial_read(sdi->serial->fd, buf, 1) != 1) /* FIXME: Need timeout */
- ret = SIGROK_ERR;
+ ret = SR_ERR;
*info = buf[0];
return ret;
{
struct mso *mso = sdi->priv;
unsigned int i;
- int ret = SIGROK_ERR;
+ int ret = SR_ERR;
for (i = 0; i < ARRAY_SIZE(rate_map); i++) {
if (rate_map[i].rate == rate) {
mso->slowmode = rate_map[i].slowmode;
ret = mso_clkrate_out(sdi, rate_map[i].val);
- if (ret == SIGROK_OK)
+ if (ret == SR_OK)
mso->cur_rate = rate;
return ret;
}
/* parse iSerial */
if (iSerial[0] != '4' || sscanf(iSerial, "%5u%3u%3u%1u%1u%6u",
&u1, &u2, &u3, &u4, &u5, &u6) != 6)
- return SIGROK_ERR;
+ return SR_ERR;
mso->hwmodel = u4;
mso->hwrev = u5;
mso->serial = u6;
* I will not implement it yet
*/
- return SIGROK_OK;
+ return SR_OK;
}
static int hw_init(char *deviceinfo)
continue;
memset(mso, 0, sizeof(struct mso));
- if (mso_parse_serial(iSerial, iProduct, mso) != SIGROK_OK) {
+ if (mso_parse_serial(iSerial, iProduct, mso) != SR_OK) {
g_warning("Invalid iSerial: %s", iSerial);
goto err_free_mso;
}
{
struct sigrok_device_instance *sdi;
struct mso *mso;
- int ret = SIGROK_ERR;
+ int ret = SR_ERR;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
return ret;
return ret;
ret = serial_set_params(sdi->serial->fd, 460800, 8, 0, 1, 2);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
sdi->status = ST_ACTIVE;
// g_warning("trigger state: %c", mso->trigger_state);
ret = mso_reset_adc(sdi);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
mso_check_trigger(sdi, &mso->trigger_state);
// g_warning("trigger state: %c", mso->trigger_state);
// ret = mso_reset_fsm(sdi);
-// if (ret != SIGROK_OK)
+// if (ret != SR_OK)
// return ret;
-// return SIGROK_ERR;
- return SIGROK_OK;
+// return SR_ERR;
+ return SR_OK;
}
static void hw_closedev(int device_index)
struct sigrok_device_instance *sdi;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
switch (capability) {
case HWCAP_SAMPLERATE:
case HWCAP_PROBECONFIG:
case HWCAP_LIMIT_SAMPLES:
default:
- return SIGROK_OK; /* FIXME */
+ return SR_OK; /* FIXME */
}
}
struct mso *mso;
struct datafeed_packet packet;
struct datafeed_header header;
- int ret = SIGROK_ERR;
+ int ret = SR_ERR;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
return ret;
/* FIXME: No need to do full reconfigure every time */
// ret = mso_reset_fsm(sdi);
-// if (ret != SIGROK_OK)
+// if (ret != SR_OK)
// return ret;
/* FIXME: ACDC Mode */
// mso->ctlbase |= mso->acdcmode;
ret = mso_configure_rate(sdi, mso->cur_rate);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
/* set dac offset */
ret = mso_dac_out(sdi, mso->dac_offset);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
ret = mso_configure_threshold_level(sdi);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
ret = mso_configure_trigger(sdi);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
/* FIXME: trigger_position */
/* with trigger */
ret = mso_arm(sdi);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
/* without trigger */
// ret = mso_force_capture(sdi);
-// if (ret != SIGROK_OK)
+// if (ret != SR_OK)
// return ret;
mso_check_trigger(sdi, &mso->trigger_state);
ret = mso_check_trigger(sdi, NULL);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
mso->session_id = session_device_id;
g_debug("ols: sending cmd 0x%.2x", command);
buf[0] = command;
if (serial_write(fd, buf, 1) != 1)
- return SIGROK_ERR;
+ return SR_ERR;
- return SIGROK_OK;
+ return SR_OK;
}
static int send_longcommand(int fd, uint8_t command, uint32_t data)
buf[3] = (data & 0xff00) >> 8;
buf[4] = data & 0xff;
if (serial_write(fd, buf, 5) != 5)
- return SIGROK_ERR;
+ return SR_ERR;
- return SIGROK_OK;
+ return SR_OK;
}
static int configure_probes(GSList *probes)
* TODO: Only supporting parallel mode, with
* up to 4 stages.
*/
- return SIGROK_ERR;
+ return SR_ERR;
}
if (stage > num_stages)
num_stages = stage;
}
- return SIGROK_OK;
+ return SR_OK;
}
static uint32_t reverse16(uint32_t in)
if (fd != -1) {
serial_params[devcnt] = serial_backup_params(fd);
serial_set_params(fd, 115200, 8, 0, 1, 2);
- ret = SIGROK_OK;
+ ret = SR_OK;
for (i = 0; i < 5; i++) {
if ((ret = send_shortcommand(fd,
- CMD_RESET)) != SIGROK_OK) {
+ CMD_RESET)) != SR_OK) {
/* Serial port is not writable. */
break;
}
}
- if (ret != SIGROK_OK) {
+ if (ret != SR_OK) {
serial_restore_params(fd,
serial_params[devcnt]);
serial_close(fd);
struct sigrok_device_instance *sdi;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
sdi->serial->fd = serial_open(sdi->serial->port, O_RDWR);
if (sdi->serial->fd == -1)
- return SIGROK_ERR;
+ return SR_ERR;
sdi->status = ST_ACTIVE;
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_closedev(int device_index)
uint32_t divider;
if (samplerate < samplerates.low || samplerate > samplerates.high)
- return SIGROK_ERR_SAMPLERATE;
+ return SR_ERR_SAMPLERATE;
if (samplerate > CLOCK_RATE) {
flag_reg |= FLAG_DEMUX;
g_message("ols: setting samplerate to %" PRIu64 " Hz (divider %u, demux %s)",
samplerate, divider, flag_reg & FLAG_DEMUX ? "on" : "off");
- if (send_longcommand(sdi->serial->fd, CMD_SET_DIVIDER, reverse32(divider)) != SIGROK_OK)
- return SIGROK_ERR;
+ if (send_longcommand(sdi->serial->fd, CMD_SET_DIVIDER, reverse32(divider)) != SR_OK)
+ return SR_ERR;
cur_samplerate = samplerate;
- return SIGROK_OK;
+ return SR_OK;
}
static int hw_set_configuration(int device_index, int capability, void *value)
uint64_t *tmp_u64;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
if (sdi->status != ST_ACTIVE)
- return SIGROK_ERR;
+ return SR_ERR;
switch (capability) {
case HWCAP_SAMPLERATE:
case HWCAP_LIMIT_SAMPLES:
tmp_u64 = value;
if (*tmp_u64 < MIN_NUM_SAMPLES)
- return SIGROK_ERR;
+ return SR_ERR;
limit_samples = *tmp_u64;
g_message("ols: sample limit %" PRIu64, limit_samples);
- ret = SIGROK_OK;
+ ret = SR_OK;
break;
case HWCAP_CAPTURE_RATIO:
tmp_u64 = value;
capture_ratio = *tmp_u64;
if (capture_ratio < 0 || capture_ratio > 100) {
capture_ratio = 0;
- ret = SIGROK_ERR;
+ ret = SR_ERR;
} else
- ret = SIGROK_OK;
+ ret = SR_OK;
break;
default:
- ret = SIGROK_ERR;
+ ret = SR_ERR;
}
return ret;
uint8_t changrp_mask;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
if (sdi->status != ST_ACTIVE)
- return SIGROK_ERR;
+ return SR_ERR;
readcount = limit_samples / 4;
trigger_at = (readcount - delaycount) * 4 - num_stages;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_0,
- reverse32(trigger_mask[0])) != SIGROK_OK)
- return SIGROK_ERR;
+ reverse32(trigger_mask[0])) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_0,
- reverse32(trigger_value[0])) != SIGROK_OK)
- return SIGROK_ERR;
+ reverse32(trigger_value[0])) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_0,
- trigger_config[0]) != SIGROK_OK)
- return SIGROK_ERR;
+ trigger_config[0]) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_1,
- reverse32(trigger_mask[1])) != SIGROK_OK)
- return SIGROK_ERR;
+ reverse32(trigger_mask[1])) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_1,
- reverse32(trigger_value[1])) != SIGROK_OK)
- return SIGROK_ERR;
+ reverse32(trigger_value[1])) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_1,
- trigger_config[1]) != SIGROK_OK)
- return SIGROK_ERR;
+ trigger_config[1]) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_2,
- reverse32(trigger_mask[2])) != SIGROK_OK)
- return SIGROK_ERR;
+ reverse32(trigger_mask[2])) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_2,
- reverse32(trigger_value[2])) != SIGROK_OK)
- return SIGROK_ERR;
+ reverse32(trigger_value[2])) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_2,
- trigger_config[2]) != SIGROK_OK)
- return SIGROK_ERR;
+ trigger_config[2]) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_3,
- reverse32(trigger_mask[3])) != SIGROK_OK)
- return SIGROK_ERR;
+ reverse32(trigger_mask[3])) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_3,
- reverse32(trigger_value[3])) != SIGROK_OK)
- return SIGROK_ERR;
+ reverse32(trigger_value[3])) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_3,
- trigger_config[3]) != SIGROK_OK)
- return SIGROK_ERR;
+ trigger_config[3]) != SR_OK)
+ return SR_ERR;
} else {
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_MASK_0,
- trigger_mask[0]) != SIGROK_OK)
- return SIGROK_ERR;
+ trigger_mask[0]) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_VALUE_0,
- trigger_value[0]) != SIGROK_OK)
- return SIGROK_ERR;
+ trigger_value[0]) != SR_OK)
+ return SR_ERR;
if (send_longcommand(sdi->serial->fd, CMD_SET_TRIGGER_CONFIG_0,
- 0x00000008) != SIGROK_OK)
- return SIGROK_ERR;
+ 0x00000008) != SR_OK)
+ return SR_ERR;
delaycount = readcount;
}
/* Send sample limit and pre/post-trigger capture ratio. */
data = ((readcount - 1) & 0xffff) << 16;
data |= (delaycount - 1) & 0xffff;
- if (send_longcommand(sdi->serial->fd, CMD_CAPTURE_SIZE, reverse16(data)) != SIGROK_OK)
- return SIGROK_ERR;
+ if (send_longcommand(sdi->serial->fd, CMD_CAPTURE_SIZE, reverse16(data)) != SR_OK)
+ return SR_ERR;
/*
* Enable/disable channel groups in the flag register according to the
flag_reg |= ~(changrp_mask << 2) & 0x3c;
flag_reg |= FLAG_FILTER;
data = flag_reg << 24;
- if (send_longcommand(sdi->serial->fd, CMD_SET_FLAGS, data) != SIGROK_OK)
- return SIGROK_ERR;
+ if (send_longcommand(sdi->serial->fd, CMD_SET_FLAGS, data) != SR_OK)
+ return SR_ERR;
/* Start acquisition on the device. */
- if (send_shortcommand(sdi->serial->fd, CMD_RUN) != SIGROK_OK)
- return SIGROK_ERR;
+ if (send_shortcommand(sdi->serial->fd, CMD_RUN) != SR_OK)
+ return SR_ERR;
source_add(sdi->serial->fd, G_IO_IN, -1, receive_data,
session_device_id);
packet = g_malloc(sizeof(struct datafeed_packet));
header = g_malloc(sizeof(struct datafeed_header));
if (!packet || !header)
- return SIGROK_ERR;
+ return SR_ERR;
packet->type = DF_HEADER;
packet->length = sizeof(struct datafeed_header);
packet->payload = (unsigned char *)header;
g_free(header);
g_free(packet);
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_stop_acquisition(int device_index, gpointer session_device_id)
trigger_value[stage] |= probe_bit;
stage++;
if (stage > NUM_TRIGGER_STAGES)
- return SIGROK_ERR;
+ return SR_ERR;
}
}
else
trigger_stage = 0;
- return SIGROK_OK;
+ return SR_OK;
}
/*
if (!(sdi = sl_open_device(device_index))) {
g_warning("unable to open device");
- return SIGROK_ERR;
+ return SR_ERR;
}
err = libusb_claim_interface(sdi->usb->devhdl, USB_INTERFACE);
if (err != 0) {
g_warning("Unable to claim interface: %d", err);
- return SIGROK_ERR;
+ return SR_ERR;
}
if (cur_samplerate == 0) {
/* Samplerate hasn't been set; default to the slowest one. */
if (hw_set_configuration(device_index, HWCAP_SAMPLERATE,
- &supported_samplerates[0]) == SIGROK_ERR)
- return SIGROK_ERR;
+ &supported_samplerates[0]) == SR_ERR)
+ return SR_ERR;
}
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_closedev(int device_index)
break;
}
if (supported_samplerates[i] == 0)
- return SIGROK_ERR_SAMPLERATE;
+ return SR_ERR_SAMPLERATE;
divider = (uint8_t) (48 / (samplerate / 1000000.0)) - 1;
buf, 2, &result, 500);
if (ret != 0) {
g_warning("failed to set samplerate: %d", ret);
- return SIGROK_ERR;
+ return SR_ERR;
}
cur_samplerate = samplerate;
- return SIGROK_OK;
+ return SR_OK;
}
static int hw_set_configuration(int device_index, int capability, void *value)
uint64_t *tmp_u64;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
if (capability == HWCAP_SAMPLERATE) {
tmp_u64 = value;
} else if (capability == HWCAP_LIMIT_SAMPLES) {
tmp_u64 = value;
limit_samples = *tmp_u64;
- ret = SIGROK_OK;
+ ret = SR_OK;
} else {
- ret = SIGROK_ERR;
+ ret = SR_ERR;
}
return ret;
unsigned char *buf;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
packet = g_malloc(sizeof(struct datafeed_packet));
header = g_malloc(sizeof(struct datafeed_header));
if (!packet || !header)
- return SIGROK_ERR;
+ return SR_ERR;
/* Start with 2K transfer, subsequently increased to 4K. */
size = 2048;
/* TODO: Free them all. */
libusb_free_transfer(transfer);
g_free(buf);
- return SIGROK_ERR;
+ return SR_ERR;
}
size = 4096;
}
g_free(header);
g_free(packet);
- return SIGROK_OK;
+ return SR_OK;
}
/* This stops acquisition on ALL devices, ignoring device_index. */
trigger_value[stage] |= probe_bit;
stage++;
if (stage > NUM_TRIGGER_STAGES)
- return SIGROK_ERR;
+ return SR_ERR;
}
}
}
- return SIGROK_OK;
+ return SR_OK;
}
/*
if (!(sdi = zp_open_device(device_index))) {
g_warning("unable to open device");
- return SIGROK_ERR;
+ return SR_ERR;
}
err = libusb_claim_interface(sdi->usb->devhdl, USB_INTERFACE);
if (err != 0) {
g_warning("Unable to claim interface: %d", err);
- return SIGROK_ERR;
+ return SR_ERR;
}
analyzer_reset(sdi->usb->devhdl);
analyzer_initialize(sdi->usb->devhdl);
if (cur_samplerate == 0) {
/* Samplerate hasn't been set. Default to the slowest one. */
if (hw_set_configuration(device_index, HWCAP_SAMPLERATE,
- &samplerates.low) == SIGROK_ERR)
- return SIGROK_ERR;
+ &samplerates.low) == SR_ERR)
+ return SR_ERR;
}
- return SIGROK_OK;
+ return SR_OK;
}
static void hw_closedev(int device_index)
cur_samplerate = samplerate;
- return SIGROK_OK;
+ return SR_OK;
}
static int hw_set_configuration(int device_index, int capability, void *value)
uint64_t *tmp_u64;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
switch (capability) {
case HWCAP_SAMPLERATE:
case HWCAP_LIMIT_SAMPLES:
tmp_u64 = value;
limit_samples = *tmp_u64;
- return SIGROK_OK;
+ return SR_OK;
default:
- return SIGROK_ERR;
+ return SR_ERR;
}
}
unsigned char *buf;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
+ return SR_ERR;
/* push configured settings to device */
analyzer_configure(sdi->usb->devhdl);
buf = g_malloc(PACKET_SIZE);
if (!buf)
- return SIGROK_ERR;
+ return SR_ERR;
analyzer_read_start(sdi->usb->devhdl);
/* Send the incoming transfer to the session bus. */
for (packet_num = 0; packet_num < (memory_size * 4 / PACKET_SIZE);
packet.type = DF_END;
session_bus(session_device_id, &packet);
- return SIGROK_OK;
+ return SR_OK;
}
/* This stops acquisition on ALL devices, ignoring device_index. */
#endif
- return SIGROK_OK;
+ return SR_OK;
}
GSList *list_hwplugins(void)
if (in->param && in->param[0]) {
num_probes = strtoul(in->param, NULL, 10);
if (num_probes < 1)
- return SIGROK_ERR;
+ return SR_ERR;
} else
num_probes = DEFAULT_NUM_PROBES;
/* create a virtual device */
in->vdevice = device_new(NULL, 0, num_probes);
- return SIGROK_OK;
+ return SR_OK;
}
static int loadfile(struct input *in, const char *filename)
int fd, size, num_probes;
if ((fd = open(filename, O_RDONLY)) == -1)
- return SIGROK_ERR;
+ return SR_ERR;
num_probes = g_slist_length(in->vdevice->probes);
packet.length = 0;
session_bus(in->vdevice, &packet);
- return SIGROK_OK;
+ return SR_OK;
}
struct input_format input_binary = {
char *samplerate_s;
if (!(ctx = calloc(1, sizeof(struct context))))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
o->internal = ctx;
ctx->num_enabled_probes = 0;
if (o->param && o->param[0]) {
ctx->samples_per_line = strtoul(o->param, NULL, 10);
if (ctx->samples_per_line < 1)
- return SIGROK_ERR;
+ return SR_ERR;
} else
ctx->samples_per_line = default_spl;
if (!(ctx->header = malloc(512))) {
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
if (!(samplerate_s = sigrok_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
snprintf(ctx->header + strlen(ctx->header),
511 - strlen(ctx->header),
if (!(ctx->linebuf = calloc(1, num_probes * ctx->linebuf_len))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
if (!(ctx->linevalues = calloc(1, num_probes))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
- return SIGROK_OK;
+ return SR_OK;
}
static int event(struct output *o, int event_type, char **data_out,
outsize = ctx->num_enabled_probes
* (ctx->samples_per_line + 20) + 512;
if (!(outbuf = calloc(1, outsize)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
flush_linebufs(ctx, outbuf);
*data_out = outbuf;
*length_out = strlen(outbuf);
break;
}
- return SIGROK_OK;
+ return SR_OK;
}
static int init_bits(struct output *o)
* (ctx->num_enabled_probes * max_linelen);
if (!(outbuf = calloc(1, outsize + 1)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
#if 0
static int init_hex(struct output *o)
/ ctx->samples_per_line * max_linelen + 512;
if (!(outbuf = calloc(1, outsize + 1)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
static int init_ascii(struct output *o)
* (ctx->num_enabled_probes * max_linelen);
if (!(outbuf = calloc(1, outsize + 1)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
#endif
o = o;
if (!(outbuf = calloc(1, length_in)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
memcpy(outbuf, data_in, length_in);
*data_out = outbuf;
*length_out = length_in;
- return SIGROK_OK;
+ return SR_OK;
}
struct output_format output_binary = {
time_t t;
if (!(ctx = calloc(1, sizeof(struct context))))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
if (!(ctx->header = calloc(1, MAX_HEADER_LEN + 1))) {
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
o->internal = ctx;
if (!(frequency_s = sigrok_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
snprintf(comment, 127, gnuplot_header_comment,
ctx->num_enabled_probes, num_probes, frequency_s);
if (!(frequency_s = sigrok_period_string(samplerate))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
t = time(NULL);
b = snprintf(ctx->header, MAX_HEADER_LEN, gnuplot_header,
if (b < 0) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
return 0;
*data_out = NULL;
*length_out = 0;
- return SIGROK_OK;
+ return SR_OK;
}
static int data(struct output *o, char *data_in, uint64_t length_in,
outsize += strlen(ctx->header);
if (!(outbuf = calloc(1, outsize)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
static int analog_init(struct output *o)
time_t t;
if (!(ctx = calloc(1, sizeof(struct context))))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
if (!(ctx->header = calloc(1, MAX_HEADER_LEN + 1))) {
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
o->internal = ctx;
if (!(frequency_s = sigrok_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
snprintf(comment, 127, gnuplot_header_comment,
ctx->num_enabled_probes, num_probes, frequency_s);
if (!(frequency_s = sigrok_period_string(samplerate))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
t = time(NULL);
b = snprintf(ctx->header, MAX_HEADER_LEN, gnuplot_header,
if (b < 0) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
return 0;
outsize += strlen(ctx->header);
if (!(outbuf = calloc(1, outsize)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
struct output_format output_gnuplot = {
time_t t;
if (!(ctx = calloc(1, sizeof(struct context))))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
if (!(ctx->header = calloc(1, MAX_HEADER_LEN + 1))) {
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
o->internal = ctx;
if (!(frequency_s = sigrok_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
snprintf(comment, 127, ols_header_comment,
ctx->num_enabled_probes, num_probes, frequency_s);
if (!(frequency_s = sigrok_period_string(samplerate))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
t = time(NULL);
if (b < 0) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
return 0;
*data_out = NULL;
*length_out = 0;
- return SIGROK_OK;
+ return SR_OK;
}
static int data(struct output *o, char *data_in, uint64_t length_in,
outsize += strlen(ctx->header);
if (!(outbuf = calloc(1, outsize)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
struct output_format output_ols = {
static int data(struct output *o, char *data_in, uint64_t length_in,
char **data_out, uint64_t *length_out)
{
- return SIGROK_OK;
+ return SR_OK;
}
static int event(struct output *o, int event_type, char **data_out,
uint64_t *length_out)
{
- return SIGROK_OK;
+ return SR_OK;
}
struct output_format output_foo = {
time_t t;
if (!(ctx = calloc(1, sizeof(struct context))))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
o->internal = ctx;
ctx->num_enabled_probes = 0;
}
if (ctx->num_enabled_probes > 94) {
g_warning("VCD only supports 94 probes.");
- return SIGROK_ERR;
+ return SR_ERR;
}
ctx->probelist[ctx->num_enabled_probes] = 0;
if (!((samplerate_s = sigrok_samplerate_string(ctx->samplerate)))) {
g_string_free(ctx->header, TRUE);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
g_string_append_printf(ctx->header, vcd_header_comment,
ctx->num_enabled_probes, num_probes, samplerate_s);
if (!(frequency_s = sigrok_period_string(ctx->period))) {
g_string_free(ctx->header, TRUE);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
g_string_append_printf(ctx->header, "$timescale %s $end\n", frequency_s);
free(frequency_s);
if (!(ctx->prevbits = calloc(sizeof(int), num_probes))) {
g_string_free(ctx->header, TRUE);
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
- return SIGROK_OK;
+ return SR_OK;
}
static int event(struct output *o, int event_type, char **data_out,
break;
}
- return SIGROK_OK;
+ return SR_OK;
}
static int data(struct output *o, char *data_in, uint64_t length_in,
*length_out = out->len;
g_string_free(out, FALSE);
- return SIGROK_OK;
+ return SR_OK;
}
struct output_format output_vcd = {
* (ctx->num_enabled_probes * max_linelen);
if (!(outbuf = calloc(1, outsize + 1)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
* (ctx->num_enabled_probes * max_linelen);
if (!(outbuf = calloc(1, outsize + 1)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
/ ctx->samples_per_line * max_linelen + 512;
if (!(outbuf = calloc(1, outsize + 1)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
outbuf[0] = '\0';
if (ctx->header) {
*data_out = outbuf;
*length_out = strlen(outbuf);
- return SIGROK_OK;
+ return SR_OK;
}
char *samplerate_s;
if (!(ctx = calloc(1, sizeof(struct context))))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
o->internal = ctx;
ctx->num_enabled_probes = 0;
if (o->param && o->param[0]) {
ctx->samples_per_line = strtoul(o->param, NULL, 10);
if (ctx->samples_per_line < 1)
- return SIGROK_ERR;
+ return SR_ERR;
} else
ctx->samples_per_line = default_spl;
if (!(ctx->header = malloc(512))) {
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
if (!(samplerate_s = sigrok_samplerate_string(samplerate))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR;
+ return SR_ERR;
}
snprintf(ctx->header + strlen(ctx->header),
511 - strlen(ctx->header),
if (!(ctx->linebuf = calloc(1, num_probes * ctx->linebuf_len))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
if (!(ctx->linevalues = calloc(1, num_probes))) {
free(ctx->header);
free(ctx);
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
}
- return SIGROK_OK;
+ return SR_OK;
}
int event(struct output *o, int event_type, char **data_out,
outsize = ctx->num_enabled_probes
* (ctx->samples_per_line + 20) + 512;
if (!(outbuf = calloc(1, outsize)))
- return SIGROK_ERR_MALLOC;
+ return SR_ERR_MALLOC;
flush_linebufs(ctx, outbuf);
*data_out = outbuf;
*length_out = strlen(outbuf);
break;
}
- return SIGROK_OK;
+ return SR_OK;
}
if (device->plugin && device->plugin->open) {
ret = device->plugin->open(device->plugin_index);
- if (ret != SIGROK_OK)
+ if (ret != SR_OK)
return ret;
}
session->devices = g_slist_append(session->devices, device);
- return SIGROK_OK;
+ return SR_OK;
}
void session_pa_clear(void)
for (l = session->devices; l; l = l->next) {
device = l->data;
if ((ret = device->plugin->start_acquisition(
- device->plugin_index, device)) != SIGROK_OK)
+ device->plugin_index, device)) != SR_OK)
break;
}
/* Quietly delete it first, libzip wants replace ops otherwise. */
unlink(newfn);
if (!(zipfile = zip_open(newfn, ZIP_CREATE, &error)))
- return SIGROK_ERR;
+ return SR_ERR;
g_free(newfn);
/* "version" */
version[0] = '1';
if (!(versrc = zip_source_buffer(zipfile, version, 1, 0)))
- return SIGROK_ERR;
+ return SR_ERR;
if (zip_add(zipfile, "version", versrc) == -1) {
g_message("error saving version into zipfile: %s",
zip_strerror(zipfile));
- return SIGROK_ERR;
+ return SR_ERR;
}
/* init "metadata" */
strcpy(metafile, "sigrok-meta-XXXXXX");
if ((tmpfile = g_mkstemp(metafile)) == -1)
- return SIGROK_ERR;
+ return SR_ERR;
close(tmpfile);
meta = fopen(metafile, "wb");
fprintf(meta, "sigrok version = %s\n", PACKAGE_VERSION);
}
if (!(logicsrc = zip_source_buffer(zipfile, buf,
ds->num_units * ds->ds_unitsize, TRUE)))
- return SIGROK_ERR;
+ return SR_ERR;
snprintf(rawname, 15, "logic-%d", devcnt);
if (zip_add(zipfile, rawname, logicsrc) == -1)
- return SIGROK_ERR;
+ return SR_ERR;
}
devcnt++;
}
fclose(meta);
if (!(metasrc = zip_source_file(zipfile, metafile, 0, -1)))
- return SIGROK_ERR;
+ return SR_ERR;
if (zip_add(zipfile, "metadata", metasrc) == -1)
- return SIGROK_ERR;
+ return SR_ERR;
if ((ret = zip_close(zipfile)) == -1) {
g_message("error saving zipfile: %s", zip_strerror(zipfile));
- return SIGROK_ERR;
+ return SR_ERR;
}
unlink(metafile);
- return SIGROK_OK;
+ return SR_OK;
}
void session_source_add(int fd, int events, int timeout,
* or reused for different #defines later. You can only add new #defines and
* return codes, but never remove or redefine existing ones.
*/
-#define SIGROK_OK 0 /* No error */
-#define SIGROK_ERR -1 /* Generic/unspecified error */
-#define SIGROK_ERR_MALLOC -2 /* Malloc/calloc/realloc error */
-#define SIGROK_ERR_SAMPLERATE -3 /* Incorrect samplerate */
+#define SR_OK 0 /* No error */
+#define SR_ERR -1 /* Generic/unspecified error */
+#define SR_ERR_MALLOC -2 /* Malloc/calloc/realloc error */
+#define SR_ERR_SAMPLERATE -3 /* Incorrect samplerate */
/* limited by uint64_t */
#define MAX_NUM_PROBES 64