Change SIGROK_ prefix to SR_.

This commit is contained in:
Uwe Hermann 2011-01-29 16:23:12 +01:00
parent 544a458212
commit e46b8fb154
24 changed files with 284 additions and 284 deletions

View File

@ -28,19 +28,19 @@ static gpointer new_chunk(struct datastore **ds);
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)
@ -48,14 +48,14 @@ 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,

View File

@ -36,7 +36,7 @@ int filter_probes(int in_unitsize, int out_unitsize, int *probelist,
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++)
@ -46,7 +46,7 @@ int filter_probes(int in_unitsize, int out_unitsize, int *probelist,
/* 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". */
@ -65,5 +65,5 @@ int filter_probes(int in_unitsize, int out_unitsize, int *probelist,
}
*length_out = out_offset;
return SIGROK_OK;
return SR_OK;
}

View File

@ -79,7 +79,7 @@ static int hw_opendev(int device_index)
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,
@ -87,24 +87,24 @@ static int hw_opendev(int device_index)
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)
@ -182,20 +182,20 @@ static int hw_set_configuration(int device_index, int capability, void *value)
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;
}
}
@ -267,14 +267,14 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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 */
@ -282,52 +282,52 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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;
@ -345,7 +345,7 @@ static int hw_start_acquisition(int device_index, gpointer 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)

View File

@ -294,7 +294,7 @@ static int sigma_write_trigger_lut(struct triggerlut *lut, struct sigma *sigma)
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. */
@ -484,7 +484,7 @@ static int upload_firmware(int firmware_idx, struct sigma *sigma)
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. */
@ -495,7 +495,7 @@ static int upload_firmware(int firmware_idx, struct sigma *sigma)
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);
@ -512,12 +512,12 @@ static int upload_firmware(int firmware_idx, struct sigma *sigma)
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)
@ -527,7 +527,7 @@ 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;
@ -543,7 +543,7 @@ static int hw_opendev(int device_index)
sdi->status = ST_ACTIVE;
return SIGROK_OK;
return SR_OK;
}
static int set_samplerate(struct sigrok_device_instance *sdi,
@ -557,7 +557,7 @@ 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);
@ -612,7 +612,7 @@ static int configure_probes(struct sigrok_device_instance *sdi, GSList *probes)
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;
@ -622,7 +622,7 @@ static int configure_probes(struct sigrok_device_instance *sdi, GSList *probes)
g_warning("Asix Sigma only supports "
"rising/falling trigger in 100 "
"and 200 MHz mode.");
return SIGROK_ERR;
return SR_ERR;
}
++trigger_set;
@ -653,7 +653,7 @@ static int configure_probes(struct sigrok_device_instance *sdi, GSList *probes)
if (trigger_set > 1) {
g_warning("Asix Sigma only supports 1 rising/"
"falling triggers.");
return SIGROK_ERR;
return SR_ERR;
}
}
@ -661,7 +661,7 @@ static int configure_probes(struct sigrok_device_instance *sdi, GSList *probes)
sigma->use_triggers = 1;
}
return SIGROK_OK;
return SR_OK;
}
static void hw_closedev(int device_index)
@ -752,7 +752,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
int ret;
if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
return SIGROK_ERR;
return SR_ERR;
sigma = sdi->priv;
@ -763,17 +763,17 @@ static int hw_set_configuration(int device_index, int capability, void *value)
} 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;
@ -855,7 +855,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
/* 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;
@ -947,7 +947,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
*lastsample = samples[n - 1];
}
return SIGROK_OK;
return SR_OK;
}
static int receive_data(int fd, int revents, void *user_data)
@ -1193,7 +1193,7 @@ static int build_basic_trigger(struct triggerlut *lut, struct sigma *sigma)
/* Triggertype: event. */
lut->params.selres = 3;
return SIGROK_OK;
return SR_OK;
}
static int hw_start_acquisition(int device_index, gpointer session_device_id)
@ -1212,7 +1212,7 @@ 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;
@ -1311,7 +1311,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
sigma->state.state = SIGMA_CAPTURE;
return SIGROK_OK;
return SR_OK;
}
static void hw_stop_acquisition(int device_index, gpointer session_device_id)

View File

@ -193,7 +193,7 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
if (!GetCommState(hdl, &dcb)) {
/* TODO: Error handling. */
return SIGROK_ERR;
return SR_ERR;
}
/* TODO: Rename 'speed' to 'baudrate'. */
@ -224,7 +224,7 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
if (!SetCommState(hdl, &dcb)) {
/* TODO: Error handling. */
return SIGROK_ERR;
return SR_ERR;
}
#else
struct termios term;
@ -247,13 +247,13 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
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) {
@ -264,7 +264,7 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
term.c_cflag |= CS7;
break;
default:
return SIGROK_ERR;
return SR_ERR;
}
term.c_cflag &= ~CSTOPB;
@ -274,7 +274,7 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
case 2:
term.c_cflag |= CSTOPB;
default:
return SIGROK_ERR;
return SR_ERR;
}
term.c_cflag &= ~(IXON | IXOFF | CRTSCTS);
@ -285,7 +285,7 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
case 1:
term.c_cflag |= CRTSCTS;
default:
return SIGROK_ERR;
return SR_ERR;
}
term.c_iflag &= ~IGNPAR;
@ -301,12 +301,12 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits,
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;
}

View File

@ -111,7 +111,7 @@ static int hw_opendev(int device_index)
device_index = device_index;
/* Nothing needed so far. */
return SIGROK_OK;
return SR_OK;
}
static void hw_closedev(int device_index)
@ -177,28 +177,28 @@ static int hw_set_configuration(int device_index, int capability, void *value)
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;
@ -326,7 +326,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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;
@ -334,7 +334,7 @@ static int hw_start_acquisition(int device_index, gpointer 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]);
@ -357,12 +357,12 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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);
@ -377,7 +377,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
free(header);
free(packet);
return SIGROK_OK;
return SR_OK;
}
static void hw_stop_acquisition(int device_index, gpointer session_device_id)

View File

@ -86,12 +86,12 @@ static int mso_send_control_message(struct sigrok_device_instance *sdi,
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:
@ -142,12 +142,12 @@ static int mso_check_trigger(struct sigrok_device_instance *sdi,
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;
@ -210,13 +210,13 @@ static int mso_configure_rate(struct sigrok_device_instance *sdi,
{
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;
}
@ -325,7 +325,7 @@ static int mso_parse_serial(const char *iSerial, const char *iProduct,
/* 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;
@ -345,7 +345,7 @@ static int mso_parse_serial(const char *iSerial, const char *iProduct,
* I will not implement it yet
*/
return SIGROK_OK;
return SR_OK;
}
static int hw_init(char *deviceinfo)
@ -418,7 +418,7 @@ 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;
}
@ -479,7 +479,7 @@ static int hw_opendev(int device_index)
{
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;
@ -490,7 +490,7 @@ static int hw_opendev(int device_index)
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;
@ -501,18 +501,18 @@ static int hw_opendev(int device_index)
// 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)
@ -579,7 +579,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
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:
@ -587,7 +587,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
case HWCAP_PROBECONFIG:
case HWCAP_LIMIT_SAMPLES:
default:
return SIGROK_OK; /* FIXME */
return SR_OK; /* FIXME */
}
}
@ -670,7 +670,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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;
@ -678,7 +678,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
/* 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 */
@ -686,20 +686,20 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
// 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 */
@ -709,17 +709,17 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
/* 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;

View File

@ -122,9 +122,9 @@ static int send_shortcommand(int fd, uint8_t command)
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)
@ -138,9 +138,9 @@ 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)
@ -184,13 +184,13 @@ 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)
@ -252,15 +252,15 @@ static int hw_init(char *deviceinfo)
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);
@ -329,15 +329,15 @@ static int hw_opendev(int device_index)
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)
@ -421,7 +421,7 @@ static int set_configuration_samplerate(struct sigrok_device_instance *sdi,
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;
@ -434,11 +434,11 @@ static int set_configuration_samplerate(struct sigrok_device_instance *sdi,
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)
@ -448,10 +448,10 @@ 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:
@ -464,22 +464,22 @@ static int hw_set_configuration(int device_index, int capability, void *value)
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;
@ -659,10 +659,10 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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;
@ -673,54 +673,54 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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;
}
@ -729,8 +729,8 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
/* 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
@ -746,12 +746,12 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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);
@ -760,7 +760,7 @@ static int hw_start_acquisition(int device_index, gpointer 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;
@ -774,7 +774,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
g_free(header);
g_free(packet);
return SIGROK_OK;
return SR_OK;
}
static void hw_stop_acquisition(int device_index, gpointer session_device_id)

View File

@ -271,7 +271,7 @@ static int configure_probes(GSList *probes)
trigger_value[stage] |= probe_bit;
stage++;
if (stage > NUM_TRIGGER_STAGES)
return SIGROK_ERR;
return SR_ERR;
}
}
@ -284,7 +284,7 @@ static int configure_probes(GSList *probes)
else
trigger_stage = 0;
return SIGROK_OK;
return SR_OK;
}
/*
@ -375,23 +375,23 @@ static int hw_opendev(int device_index)
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)
@ -478,7 +478,7 @@ static int set_configuration_samplerate(struct sigrok_device_instance *sdi,
break;
}
if (supported_samplerates[i] == 0)
return SIGROK_ERR_SAMPLERATE;
return SR_ERR_SAMPLERATE;
divider = (uint8_t) (48 / (samplerate / 1000000.0)) - 1;
@ -490,11 +490,11 @@ static int set_configuration_samplerate(struct sigrok_device_instance *sdi,
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)
@ -504,7 +504,7 @@ 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;
@ -514,9 +514,9 @@ static int hw_set_configuration(int device_index, int capability, void *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;
@ -678,12 +678,12 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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;
@ -697,7 +697,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
/* TODO: Free them all. */
libusb_free_transfer(transfer);
g_free(buf);
return SIGROK_ERR;
return SR_ERR;
}
size = 4096;
}
@ -721,7 +721,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
g_free(header);
g_free(packet);
return SIGROK_OK;
return SR_OK;
}
/* This stops acquisition on ALL devices, ignoring device_index. */

View File

@ -261,12 +261,12 @@ static int configure_probes(GSList *probes)
trigger_value[stage] |= probe_bit;
stage++;
if (stage > NUM_TRIGGER_STAGES)
return SIGROK_ERR;
return SR_ERR;
}
}
}
return SIGROK_OK;
return SR_OK;
}
/*
@ -330,13 +330,13 @@ static int hw_opendev(int device_index)
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);
@ -361,11 +361,11 @@ static int hw_opendev(int device_index)
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)
@ -453,7 +453,7 @@ static int set_configuration_samplerate(uint64_t samplerate)
cur_samplerate = samplerate;
return SIGROK_OK;
return SR_OK;
}
static int hw_set_configuration(int device_index, int capability, void *value)
@ -462,7 +462,7 @@ 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:
@ -473,9 +473,9 @@ static int hw_set_configuration(int device_index, int capability, void *value)
case HWCAP_LIMIT_SAMPLES:
tmp_u64 = value;
limit_samples = *tmp_u64;
return SIGROK_OK;
return SR_OK;
default:
return SIGROK_ERR;
return SR_ERR;
}
}
@ -489,7 +489,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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);
@ -518,7 +518,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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);
@ -541,7 +541,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
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. */

View File

@ -91,7 +91,7 @@ int load_hwplugins(void)
#endif
return SIGROK_OK;
return SR_OK;
}
GSList *list_hwplugins(void)

View File

@ -46,14 +46,14 @@ static int init(struct input *in)
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)
@ -64,7 +64,7 @@ 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);
@ -95,7 +95,7 @@ static int loadfile(struct input *in, const char *filename)
packet.length = 0;
session_bus(in->vdevice, &packet);
return SIGROK_OK;
return SR_OK;
}
struct input_format input_binary = {

View File

@ -99,7 +99,7 @@ static int init(struct output *o, int default_spl, enum outputmode mode)
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;
@ -122,13 +122,13 @@ static int init(struct output *o, int default_spl, enum outputmode mode)
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);
@ -139,7 +139,7 @@ static int init(struct output *o, int default_spl, enum outputmode mode)
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),
@ -152,15 +152,15 @@ static int init(struct output *o, int default_spl, enum outputmode mode)
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,
@ -181,7 +181,7 @@ 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);
@ -194,7 +194,7 @@ static int event(struct output *o, int event_type, char **data_out,
break;
}
return SIGROK_OK;
return SR_OK;
}
static int init_bits(struct output *o)
@ -222,7 +222,7 @@ static int data_bits(struct output *o, char *data_in, uint64_t length_in,
* (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) {
@ -280,7 +280,7 @@ static int data_bits(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}
#if 0
static int init_hex(struct output *o)
@ -304,7 +304,7 @@ static int data_hex(struct output *o, char *data_in, uint64_t length_in,
/ 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) {
@ -345,7 +345,7 @@ static int data_hex(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}
static int init_ascii(struct output *o)
@ -373,7 +373,7 @@ static int data_ascii(struct output *o, char *data_in, uint64_t length_in,
* (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) {
@ -434,7 +434,7 @@ static int data_ascii(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}
#endif

View File

@ -34,13 +34,13 @@ static int data(struct output *o, char *data_in, uint64_t length_in,
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 = {

View File

@ -59,11 +59,11 @@ static int 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;
@ -85,7 +85,7 @@ static int init(struct output *o)
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);
@ -102,7 +102,7 @@ static int init(struct output *o)
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,
@ -113,7 +113,7 @@ static int init(struct output *o)
if (b < 0) {
free(ctx->header);
free(ctx);
return SIGROK_ERR;
return SR_ERR;
}
return 0;
@ -138,7 +138,7 @@ static int event(struct output *o, int event_type, char **data_out,
*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,
@ -157,7 +157,7 @@ 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) {
@ -188,7 +188,7 @@ static int data(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}
static int analog_init(struct output *o)
@ -204,11 +204,11 @@ 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;
@ -232,7 +232,7 @@ static int analog_init(struct output *o)
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);
@ -249,7 +249,7 @@ static int analog_init(struct output *o)
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,
@ -260,7 +260,7 @@ static int analog_init(struct output *o)
if (b < 0) {
free(ctx->header);
free(ctx);
return SIGROK_ERR;
return SR_ERR;
}
return 0;
@ -284,7 +284,7 @@ static int analog_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) {
@ -323,7 +323,7 @@ static int analog_data(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}
struct output_format output_gnuplot = {

View File

@ -79,11 +79,11 @@ static int 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;
@ -108,7 +108,7 @@ static int init(struct output *o)
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);
@ -125,7 +125,7 @@ static int init(struct output *o)
if (!(frequency_s = sigrok_period_string(samplerate))) {
free(ctx->header);
free(ctx);
return SIGROK_ERR;
return SR_ERR;
}
t = time(NULL);
@ -149,7 +149,7 @@ static int init(struct output *o)
if (b < 0) {
free(ctx->header);
free(ctx);
return SIGROK_ERR;
return SR_ERR;
}
return 0;
@ -174,7 +174,7 @@ static int event(struct output *o, int event_type, char **data_out,
*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,
@ -193,7 +193,7 @@ 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) {
@ -215,7 +215,7 @@ static int data(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}
struct output_format output_ols = {

View File

@ -28,13 +28,13 @@ static int init(struct output *o)
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 = {

View File

@ -59,7 +59,7 @@ static int init(struct output *o)
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;
@ -72,7 +72,7 @@ static int init(struct output *o)
}
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;
@ -97,7 +97,7 @@ static int init(struct output *o)
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);
@ -115,7 +115,7 @@ static int init(struct output *o)
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);
@ -135,10 +135,10 @@ static int init(struct output *o)
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,
@ -162,7 +162,7 @@ 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,
@ -219,7 +219,7 @@ 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 = {

View File

@ -50,7 +50,7 @@ int data_ascii(struct output *o, char *data_in, uint64_t length_in,
* (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) {
@ -111,7 +111,7 @@ int data_ascii(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}

View File

@ -50,7 +50,7 @@ int data_bits(struct output *o, char *data_in, uint64_t length_in,
* (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) {
@ -98,7 +98,7 @@ int data_bits(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}

View File

@ -46,7 +46,7 @@ int data_hex(struct output *o, char *data_in, uint64_t length_in,
/ 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) {
@ -87,7 +87,7 @@ int data_hex(struct output *o, char *data_in, uint64_t length_in,
*data_out = outbuf;
*length_out = strlen(outbuf);
return SIGROK_OK;
return SR_OK;
}

View File

@ -74,7 +74,7 @@ int init(struct output *o, int default_spl, enum outputmode mode)
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;
@ -96,13 +96,13 @@ int init(struct output *o, int default_spl, enum outputmode mode)
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);
@ -113,7 +113,7 @@ int init(struct output *o, int default_spl, enum outputmode mode)
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),
@ -126,15 +126,15 @@ int init(struct output *o, int default_spl, enum outputmode mode)
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,
@ -155,7 +155,7 @@ 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);
@ -168,6 +168,6 @@ int event(struct output *o, int event_type, char **data_out,
break;
}
return SIGROK_OK;
return SR_OK;
}

View File

@ -89,13 +89,13 @@ int session_device_add(struct device *device)
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)
@ -135,7 +135,7 @@ int session_start(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;
}
@ -244,23 +244,23 @@ int session_save(char *filename)
/* 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);
@ -303,28 +303,28 @@ int session_save(char *filename)
}
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,

View File

@ -48,10 +48,10 @@ extern "C" {
* 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