err = snd_pcm_open(&alsa->capture_handle, AUDIO_DEV,
SND_PCM_STREAM_CAPTURE, 0);
if (err < 0) {
- sr_err("cannot open audio device %s (%s)", AUDIO_DEV,
+ sr_err("alsa: can't open audio device %s (%s)", AUDIO_DEV,
snd_strerror(err));
return SR_ERR;
}
err = snd_pcm_hw_params_malloc(&alsa->hw_params);
if (err < 0) {
- sr_err("cannot allocate hardware parameter structure (%s)",
+ sr_err("alsa: can't allocate hardware parameter structure (%s)",
snd_strerror(err));
return SR_ERR;
}
err = snd_pcm_hw_params_any(alsa->capture_handle, alsa->hw_params);
if (err < 0) {
- sr_err("cannot initialize hardware parameter structure (%s)",
- snd_strerror(err));
+ sr_err("alsa: can't initialize hardware parameter structure "
+ "(%s)", snd_strerror(err));
return SR_ERR;
}
count = snd_pcm_readi(alsa->capture_handle, inb,
MIN(4096/4, alsa->limit_samples));
if (count < 1) {
- sr_err("Failed to read samples");
+ sr_err("alsa: Failed to read samples");
return FALSE;
}
err = snd_pcm_hw_params_set_access(alsa->capture_handle,
alsa->hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0) {
- sr_err("cannot set access type (%s)", snd_strerror(err));
+ sr_err("alsa: can't set access type (%s)", snd_strerror(err));
return SR_ERR;
}
err = snd_pcm_hw_params_set_format(alsa->capture_handle,
alsa->hw_params, SND_PCM_FORMAT_S16_LE);
if (err < 0) {
- sr_err("cannot set sample format (%s)", snd_strerror(err));
+ sr_err("alsa: can't set sample format (%s)", snd_strerror(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) {
- sr_err("cannot set sample rate (%s)", snd_strerror(err));
+ sr_err("alsa: can't set sample rate (%s)", snd_strerror(err));
return SR_ERR;
}
err = snd_pcm_hw_params_set_channels(alsa->capture_handle,
alsa->hw_params, NUM_PROBES);
if (err < 0) {
- sr_err("cannot set channel count (%s)", snd_strerror(err));
+ sr_err("alsa: can't set channel count (%s)", snd_strerror(err));
return SR_ERR;
}
err = snd_pcm_hw_params(alsa->capture_handle, alsa->hw_params);
if (err < 0) {
- sr_err("cannot set parameters (%s)", snd_strerror(err));
+ sr_err("alsa: can't set parameters (%s)", snd_strerror(err));
return SR_ERR;
}
err = snd_pcm_prepare(alsa->capture_handle);
if (err < 0) {
- sr_err("cannot prepare audio interface for use (%s)",
+ sr_err("alsa: can't prepare audio interface for use (%s)",
snd_strerror(err));
return SR_ERR;
}
count = snd_pcm_poll_descriptors_count(alsa->capture_handle);
if (count < 1) {
- sr_err("Unable to obtain poll descriptors count");
+ sr_err("alsa: Unable to obtain poll descriptors count");
return SR_ERR;
}
err = snd_pcm_poll_descriptors(alsa->capture_handle, ufds, count);
if (err < 0) {
- sr_err("Unable to obtain poll descriptors (%s)",
+ sr_err("alsa: Unable to obtain poll descriptors (%s)",
snd_strerror(err));
g_free(ufds);
return SR_ERR;
ret = ftdi_read_data(&sigma->ftdic, (unsigned char *)buf, size);
if (ret < 0) {
- sr_err("ftdi_read_data failed: %s",
+ sr_err("sigma: ftdi_read_data failed: %s",
ftdi_get_error_string(&sigma->ftdic));
}
ret = ftdi_write_data(&sigma->ftdic, (unsigned char *)buf, size);
if (ret < 0) {
- sr_err("ftdi_write_data failed: %s",
+ sr_err("sigma: ftdi_write_data failed: %s",
ftdi_get_error_string(&sigma->ftdic));
} else if ((size_t) ret != size) {
- sr_err("ftdi_write_data did not complete write\n");
+ sr_err("sigma: ftdi_write_data did not complete write\n");
}
return ret;
uint8_t value;
if (1 != sigma_read_register(reg, &value, 1, sigma)) {
- sr_err("sigma_get_register: 1 byte expected");
+ sr_err("sigma: sigma_get_register: 1 byte expected");
return 0;
}
f = g_fopen(filename, "rb");
if (!f) {
- sr_err("g_fopen(\"%s\", \"rb\")", filename);
+ sr_err("sigma: g_fopen(\"%s\", \"rb\")", filename);
return SR_ERR;
}
if (-1 == fseek(f, 0, SEEK_END)) {
- sr_err("fseek on %s failed", filename);
+ sr_err("sigma: fseek on %s failed", filename);
fclose(f);
return SR_ERR;
}
if (ret < 0) {
g_free(compressed_buf);
g_free(firmware);
- sr_err("Could not unpack Sigma firmware. (Error %d)\n", ret);
+ sr_err("sigma: Could not unpack Sigma firmware. "
+ "(Error %d)\n", ret);
return SR_ERR;
}
if (offset != *buf_size) {
g_free(*buf);
- sr_err("Error reading firmware %s "
+ sr_err("sigma: Error reading firmware %s "
"offset=%ld, file_size=%ld, buf_size=%zd\n",
filename, offset, file_size, *buf_size);
/* Make sure it's an ASIX SIGMA. */
if ((ret = ftdi_usb_open_desc(&sigma->ftdic,
USB_VENDOR, USB_PRODUCT, USB_DESCRIPTION, NULL)) < 0) {
- sr_err("ftdi_usb_open failed: %s",
+ sr_err("sigma: ftdi_usb_open failed: %s",
ftdi_get_error_string(&sigma->ftdic));
return 0;
}
if ((ret = ftdi_set_bitmode(&sigma->ftdic, 0xdf, BITMODE_BITBANG)) < 0) {
- sr_err("ftdi_set_bitmode failed: %s",
+ sr_err("sigma: ftdi_set_bitmode failed: %s",
ftdi_get_error_string(&sigma->ftdic));
return 0;
}
/* Four times the speed of sigmalogan - Works well. */
if ((ret = ftdi_set_baudrate(&sigma->ftdic, 750000)) < 0) {
- sr_err("ftdi_set_baudrate failed: %s",
+ sr_err("sigma: ftdi_set_baudrate failed: %s",
ftdi_get_error_string(&sigma->ftdic));
return 0;
}
firmware_files[firmware_idx]);
if ((ret = bin2bitbang(firmware_path, &buf, &buf_size)) != SR_OK) {
- sr_err("An error occured while reading the firmware: %s",
+ sr_err("sigma: An error occured while reading the firmware: %s",
firmware_path);
return ret;
}
g_free(buf);
if ((ret = ftdi_set_bitmode(&sigma->ftdic, 0x00, BITMODE_RESET)) < 0) {
- sr_err("ftdi_set_bitmode failed: %s",
+ sr_err("sigma: ftdi_set_bitmode failed: %s",
ftdi_get_error_string(&sigma->ftdic));
return SR_ERR;
}
ret = sigma_read(result, 3, sigma);
if (ret != 3 ||
result[0] != 0xa6 || result[1] != 0x55 || result[2] != 0xaa) {
- sr_err("Configuration failed. Invalid reply received.");
+ sr_err("sigma: Configuration failed. Invalid reply received.");
return SR_ERR;
}
if ((ret = ftdi_usb_open_desc(&sigma->ftdic,
USB_VENDOR, USB_PRODUCT, USB_DESCRIPTION, NULL)) < 0) {
- sr_err("ftdi_usb_open failed: %s",
+ sr_err("sigma: ftdi_usb_open failed: %s",
ftdi_get_error_string(&sigma->ftdic));
return 0;
sigma->samples_per_event = 16 / sigma->num_probes;
sigma->state.state = SIGMA_IDLE;
- sr_info("Firmware uploaded");
+ sr_info("sigma: Firmware uploaded");
return ret;
}
if (sigma->cur_samplerate >= SR_MHZ(100)) {
/* Fast trigger support. */
if (trigger_set) {
- sr_err("ASIX SIGMA only supports a single "
+ sr_err("sigma: ASIX SIGMA only supports a single "
"pin trigger in 100 and 200MHz mode.");
return SR_ERR;
}
else if (probe->trigger[0] == 'r')
sigma->trigger.risingmask |= probebit;
else {
- sr_err("ASIX SIGMA only supports "
+ sr_err("sigma: ASIX SIGMA only supports "
"rising/falling trigger in 100 "
"and 200MHz mode.");
return SR_ERR;
* does not permit ORed triggers.
*/
if (trigger_set > 1) {
- sr_err("ASIX SIGMA only supports 1 rising/"
- "falling triggers.");
+ sr_err("sigma: ASIX SIGMA only supports 1 "
+ "rising/falling triggers.");
return SR_ERR;
}
}
for (l = device_instances; l; l = l->next) {
if (!(sdi = l->data)) {
/* Log error, but continue cleaning up the rest. */
- sr_err("asix: %s: sdi was NULL, continuing", __func__);
+ sr_err("sigma: %s: sdi was NULL, continuing", __func__);
ret = SR_ERR_BUG;
continue;
}
void *info = NULL;
if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
- sr_err("It's NULL.\n");
+ sr_err("sigma: %s: sdi was NULL", __func__);
return NULL;
}
newchunks = MIN(chunks_per_read,
numchunks - sigma->state.chunks_downloaded);
- sr_info("Downloading sample data: %.0f %%",
+ sr_info("sigma: Downloading sample data: %.0f %%",
100.0 * sigma->state.chunks_downloaded / numchunks);
bufsz = sigma_read_dram(sigma->state.chunks_downloaded,
(void)session_data;
if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
- sr_err("asix: %s: sdi was NULL", __func__);
+ sr_err("sigma: %s: sdi was NULL", __func__);
return SR_ERR_BUG;
}
if (!(sigma = sdi->priv)) {
- sr_err("asix: %s: sdi->priv was NULL", __func__);
+ sr_err("sigma: %s: sdi->priv was NULL", __func__);
return SR_ERR_BUG;
}
int err;
unsigned char buf[1];
- sr_info("setting CPU reset mode %s...", set_clear ? "on" : "off");
+ sr_info("ezusb: setting CPU reset mode %s...",
+ set_clear ? "on" : "off");
buf[0] = set_clear ? 1 : 0;
err = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR, 0xa0,
0xe600, 0x0000, buf, 1, 100);
if (err < 0)
- sr_err("Unable to send control request: %d", err);
+ sr_err("ezusb: Unable to send control request: %d", err);
return err;
}
int offset, chunksize, err, result;
unsigned char buf[4096];
- sr_info("Uploading firmware at %s", filename);
+ sr_info("ezusb: Uploading firmware at %s", filename);
if ((fw = g_fopen(filename, "rb")) == NULL) {
- sr_err("Unable to open firmware file %s for reading: %s",
+ sr_err("ezusb: Unable to open firmware file %s for reading: %s",
filename, strerror(errno));
return SR_ERR;
}
LIBUSB_ENDPOINT_OUT, 0xa0, offset,
0x0000, buf, chunksize, 100);
if (err < 0) {
- sr_err("Unable to send firmware to device: %d", err);
+ sr_err("ezusb: Unable to send firmware to device: %d",
+ err);
result = SR_ERR;
break;
}
- sr_info("Uploaded %d bytes", chunksize);
+ sr_info("ezusb: Uploaded %d bytes", chunksize);
offset += chunksize;
}
fclose(fw);
- sr_info("Firmware upload done");
+ sr_info("ezusb: Firmware upload done");
return result;
}
struct libusb_device_handle *hdl;
int err;
- sr_info("uploading firmware to device on %d.%d",
- libusb_get_bus_number(dev), libusb_get_device_address(dev));
+ sr_info("ezusb: uploading firmware to device on %d.%d",
+ libusb_get_bus_number(dev), libusb_get_device_address(dev));
if ((err = libusb_open(dev, &hdl)) < 0) {
- sr_err("failed to open device: %d", err);
+ sr_err("ezusb: failed to open device: %d", err);
return SR_ERR;
}
#if !defined(_WIN32) && !defined(__APPLE__)
if (libusb_kernel_driver_active(hdl, 0)) {
if ((err = libusb_detach_kernel_driver(hdl, 0)) < 0) {
- sr_err("failed to detach kernel driver: %d", err);
+ sr_err("ezusb: failed to detach kernel driver: %d", err);
return SR_ERR;
}
}
#endif
if ((err = libusb_set_configuration(hdl, configuration)) < 0) {
- sr_err("Unable to set configuration: %d", err);
+ sr_err("ezusb: Unable to set configuration: %d", err);
return SR_ERR;
}
ops[1] = mso_trans(REG_CTL1, mso->ctlbase1);
mso->ctlbase1 |= BIT_CTL1_ADC_UNKNOWN4;
- sr_dbg("Requesting ADC reset");
+ sr_dbg("mso19: Requesting ADC reset");
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
mso->ctlbase1 |= BIT_CTL1_RESETFSM;
ops[0] = mso_trans(REG_CTL1, mso->ctlbase1);
- sr_dbg("Requesting ADC reset");
+ sr_dbg("mso19: Requesting ADC reset");
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
mso->ctlbase1 |= BIT_CTL1_LED;
ops[0] = mso_trans(REG_CTL1, mso->ctlbase1);
- sr_dbg("Requesting LED toggle");
+ sr_dbg("mso19: Requesting LED toggle");
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
char buf[1];
int ret;
- sr_dbg("Requesting trigger state");
+ sr_dbg("mso19: Requesting trigger state");
ret = mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
if (info == NULL || ret != SR_OK)
return ret;
ret = SR_ERR;
*info = buf[0];
- sr_dbg("Trigger state is: 0x%x", *info);
+ sr_dbg("mso19: Trigger state is: 0x%x", *info);
return ret;
}
{
uint16_t ops[] = { mso_trans(REG_BUFFER, 0) };
- sr_dbg("Requesting buffer dump");
+ sr_dbg("mso19: Requesting buffer dump");
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
mso_trans(REG_CTL1, mso->ctlbase1),
};
- sr_dbg("Requesting trigger arm");
+ sr_dbg("mso19: Requesting trigger arm");
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
mso_trans(REG_CTL1, mso->ctlbase1),
};
- sr_dbg("Requesting forced capture");
+ sr_dbg("mso19: Requesting forced capture");
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
mso_trans(REG_CTL1, mso->ctlbase1 | BIT_CTL1_RESETADC),
};
- sr_dbg("Setting dac word to 0x%x", val);
+ sr_dbg("mso19: Setting dac word to 0x%x", val);
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
mso_trans(REG_CLKRATE2, val & 0xff),
};
- sr_dbg("Setting clkrate word to 0x%x", val);
+ sr_dbg("mso19: Setting clkrate word to 0x%x", val);
return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops));
}
*/
udev = udev_new();
if (!udev) {
- sr_err("Failed to initialize udev.");
+ sr_err("mso19: Failed to initialize udev.");
goto ret;
}
enumerate = udev_enumerate_new(udev);
parent = udev_device_get_parent_with_subsystem_devtype(
dev, "usb", "usb_device");
if (!parent) {
- sr_err("Unable to find parent usb device for %s",
+ sr_err("mso19: Unable to find parent usb device for %s",
sysname);
continue;
}
s = strcspn(iProduct, " ");
if (s > sizeof(product) ||
strlen(iProduct) - s > sizeof(manufacturer)) {
- sr_err("Could not parse iProduct: %s", iProduct);
+ sr_err("mso19: Could not parse iProduct: %s", iProduct);
continue;
}
strncpy(product, iProduct, s);
}
if (mso_parse_serial(iSerial, iProduct, mso) != SR_OK) {
- sr_err("Invalid iSerial: %s", iSerial);
+ sr_err("mso19: Invalid iSerial: %s", iSerial);
goto err_free_mso;
}
sprintf(hwrev, "r%d", mso->hwrev);
{
/* Initialize the protocol trigger configuration */
int i;
- for (i = 0; i < 4; i++)
- {
+ for (i = 0; i < 4; i++) {
mso->protocol_trigger.word[i] = 0;
mso->protocol_trigger.mask[i] = 0xff;
}
}
sdi = sr_dev_inst_new(devcnt, SR_ST_INITIALIZING,
- manufacturer, product, hwrev);
+ manufacturer, product, hwrev);
if (!sdi) {
- sr_err("Unable to create device instance for %s",
+ sr_err("mso19: Unable to create device instance for %s",
sysname);
goto err_free_mso;
}
/* FIXME: discard serial buffer */
mso_check_trigger(sdi, &mso->trigger_state);
- sr_dbg("trigger state: 0x%x", mso->trigger_state);
+ sr_dbg("mso19: trigger state: 0x%x", mso->trigger_state);
ret = mso_reset_adc(sdi);
if (ret != SR_OK)
return ret;
mso_check_trigger(sdi, &mso->trigger_state);
- sr_dbg("trigger state: 0x%x", mso->trigger_state);
+ sr_dbg("mso19: trigger state: 0x%x", mso->trigger_state);
// ret = mso_reset_fsm(sdi);
// if (ret != SR_OK)
// return ret;
- sr_dbg("Finished %s", __func__);
+ sr_dbg("mso19: Finished %s", __func__);
// return SR_ERR;
return SR_OK;
sdi->status = SR_ST_INACTIVE;
}
- sr_dbg("finished %s", __func__);
+ sr_dbg("mso19: finished %s", __func__);
return SR_OK;
}
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("failed to get device descriptor: %d", err);
+ sr_err("logic: failed to get device descriptor: %d", err);
continue;
}
- if (des.idVendor != fx2->profile->fw_vid || des.idProduct != fx2->profile->fw_pid)
+ if (des.idVendor != fx2->profile->fw_vid
+ || des.idProduct != fx2->profile->fw_pid)
continue;
if (sdi->status == SR_ST_INITIALIZING) {
}
} else if (sdi->status == SR_ST_INACTIVE) {
/*
- * This device is fully enumerated, so we need to find this
- * device by vendor, product, bus and address.
+ * This device is fully enumerated, so we need to find
+ * this device by vendor, product, bus and address.
*/
if (libusb_get_bus_number(devlist[i]) != fx2->usb->bus
|| libusb_get_device_address(devlist[i]) != fx2->usb->address)
fx2->usb->address = libusb_get_device_address(devlist[i]);
sdi->status = SR_ST_ACTIVE;
- sr_info("saleae: opened device %d on %d.%d interface %d",
- sdi->index, fx2->usb->bus,
- fx2->usb->address, USB_INTERFACE);
+ sr_info("logic: opened device %d on %d.%d interface %d",
+ sdi->index, fx2->usb->bus,
+ fx2->usb->address, USB_INTERFACE);
} else {
- sr_err("failed to open device: %d", err);
+ sr_err("logic: failed to open device: %d", err);
}
/* if we made it here, we handled the device one way or another */
if (fx2->usb->devhdl == NULL)
return;
- sr_info("saleae: closing device %d on %d.%d interface %d", sdi->index,
+ sr_info("logic: closing device %d on %d.%d interface %d", sdi->index,
fx2->usb->bus, fx2->usb->address, USB_INTERFACE);
libusb_release_interface(fx2->usb->devhdl, USB_INTERFACE);
libusb_close(fx2->usb->devhdl);
struct fx2_device *fx2;
if (!(fx2 = g_try_malloc0(sizeof(struct fx2_device)))) {
- sr_err("saleae: %s: fx2 malloc failed", __func__);
+ sr_err("logic: %s: fx2 malloc failed", __func__);
return NULL;
}
fx2->trigger_stage = TRIGGER_FIRED;
(void)deviceinfo;
if (libusb_init(&usb_context) != 0) {
- sr_err("Failed to initialize USB.");
+ sr_err("logic: Failed to initialize USB.");
return 0;
}
fx2_prof = NULL;
err = libusb_get_device_descriptor(devlist[i], &des);
if (err != 0) {
- sr_err("failed to get device descriptor: %d", err);
+ sr_err("logic: failed to get device descriptor: %d",
+ err);
continue;
}
if (check_conf_profile(devlist[i])) {
/* Already has the firmware, so fix the new address. */
- sr_dbg("Found a Saleae Logic with %s firmware.",
+ sr_dbg("logic: Found a Saleae Logic with %s firmware.",
new_saleae_logic_firmware ? "new" : "old");
sdi->status = SR_ST_INACTIVE;
fx2->usb = sr_usb_dev_inst_new
/* Remember when the firmware on this device was updated */
g_get_current_time(&fx2->fw_updated);
else
- sr_err("firmware upload failed for device %d", devcnt);
+ sr_err("logic: firmware upload failed for "
+ "device %d", devcnt);
fx2->usb = sr_usb_dev_inst_new
(libusb_get_bus_number(devlist[i]), 0xff, NULL);
}
*/
err = 0;
if (GTV_TO_MSEC(fx2->fw_updated) > 0) {
- sr_info("saleae: waiting for device to reset");
+ sr_info("logic: waiting for device to reset");
/* takes at least 300ms for the FX2 to be gone from the USB bus */
- g_usleep(300*1000);
+ g_usleep(300 * 1000);
timediff = 0;
while (timediff < MAX_RENUM_DELAY) {
if ((err = sl_open_device(device_index)) == SR_OK)
break;
- g_usleep(100*1000);
+ g_usleep(100 * 1000);
g_get_current_time(&cur_time);
timediff = GTV_TO_MSEC(cur_time) - GTV_TO_MSEC(fx2->fw_updated);
}
- sr_info("saleae: device came back after %d ms", timediff);
+ sr_info("logic: device came back after %d ms", timediff);
} else {
err = sl_open_device(device_index);
}
if (err != SR_OK) {
- sr_err("unable to open device");
+ sr_err("logic: unable to open device");
return SR_ERR;
}
fx2 = sdi->priv;
err = libusb_claim_interface(fx2->usb->devhdl, USB_INTERFACE);
if (err != 0) {
- sr_err("Unable to claim interface: %d", err);
+ sr_err("logic: Unable to claim interface: %d", err);
return SR_ERR;
}
for (l = device_instances; l; l = l->next) {
if (!(sdi = l->data)) {
/* Log error, but continue cleaning up the rest. */
- sr_err("fx2: %s: sdi was NULL, continuing", __func__);
+ sr_err("logic: %s: sdi was NULL, continuing", __func__);
ret = SR_ERR_BUG;
continue;
}
if (!(fx2 = sdi->priv)) {
/* Log error, but continue cleaning up the rest. */
- sr_err("fx2: %s: sdi->priv was NULL, continuing",
+ sr_err("logic: %s: sdi->priv was NULL, continuing",
__func__);
ret = SR_ERR_BUG;
continue;
}
/* Shouldn't happen. */
- sr_err("saleae: %s: Invalid samplerate %" PRIu64 "",
+ sr_err("logic: %s: Invalid samplerate %" PRIu64 "",
__func__, samplerate);
return 0;
}
else
divider = (uint8_t) (48 / (samplerate / 1000000.0)) - 1;
- sr_info("saleae: setting samplerate to %" PRIu64 " Hz (divider %d)",
+ sr_info("logic: setting samplerate to %" PRIu64 " Hz (divider %d)",
samplerate, divider);
buf[0] = (new_saleae_logic_firmware) ? 0xd5 : 0x01;
ret = libusb_bulk_transfer(fx2->usb->devhdl, 1 | LIBUSB_ENDPOINT_OUT,
buf, 2, &result, 500);
if (ret != 0) {
- sr_err("failed to set samplerate: %d", ret);
+ sr_err("logic: failed to set samplerate: %d", ret);
return SR_ERR;
}
fx2->cur_samplerate = samplerate;
return;
}
- sr_info("saleae: receive_transfer(): status %d received %d bytes",
+ sr_info("logic: receive_transfer(): status %d received %d bytes",
transfer->status, transfer->actual_length);
/* Save incoming transfer before reusing the transfer struct. */
/* Fire off a new request. */
if (!(new_buf = g_try_malloc(4096))) {
- sr_err("saleae: %s: new_buf malloc failed", __func__);
+ sr_err("logic: %s: new_buf malloc failed", __func__);
return; /* TODO: SR_ERR_MALLOC */
}
transfer->length = 4096;
if (libusb_submit_transfer(transfer) != 0) {
/* TODO: Stop session? */
- sr_err("eek");
+ /* TODO: Better error message. */
+ sr_err("logic: %s: libusb_submit_transfer error", __func__);
}
if (cur_buflen == 0) {
fx2->session_data = session_data;
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
- sr_err("saleae: %s: packet malloc failed", __func__);
+ sr_err("logic: %s: packet malloc failed", __func__);
return SR_ERR_MALLOC;
}
if (!(header = g_try_malloc(sizeof(struct sr_datafeed_header)))) {
- sr_err("saleae: %s: header malloc failed", __func__);
+ sr_err("logic: %s: header malloc failed", __func__);
return SR_ERR_MALLOC;
}
size = 2048;
for (i = 0; i < NUM_SIMUL_TRANSFERS; i++) {
if (!(buf = g_try_malloc(size))) {
- sr_err("saleae: %s: buf malloc failed", __func__);
+ sr_err("logic: %s: buf malloc failed", __func__);
return SR_ERR_MALLOC;
}
transfer = libusb_alloc_transfer(0);
ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEADDR,
0, packet, 1, TIMEOUT);
if (ret != 1)
- sr_err("%s: libusb_control_transfer returned %d\n",
+ sr_err("zp: %s: libusb_control_transfer returned %d\n",
__func__, ret);
return ret;
}
ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEDATA,
0, packet, 1, TIMEOUT);
if (ret != 1)
- sr_err("%s: libusb_control_transfer returned %d\n",
+ sr_err("zp: %s: libusb_control_transfer returned %d\n",
__func__, ret);
return ret;
}
ret = libusb_control_transfer(devh, CTRL_IN, 0xc, REQ_READDATA,
0, packet, 1, TIMEOUT);
if (ret != 1)
- sr_err("%s: libusb_control_transfer returned %d, val=%hhx\n",
- __func__, ret, packet[0]);
+ sr_err("zp: %s: libusb_control_transfer returned %d, "
+ "val=%hhx\n", __func__, ret, packet[0]);
return (ret == 1) ? packet[0] : ret;
}
ret = libusb_control_transfer(devh, CTRL_OUT, 0x4, REQ_READBULK,
0, packet, 8, TIMEOUT);
if (ret != 8)
- sr_err("%s: libusb_control_transfer returned %d\n",
+ sr_err("zp: %s: libusb_control_transfer returned %d\n",
__func__, ret);
ret = libusb_bulk_transfer(devh, EP1_BULK_IN, buffer, size,
&transferred, TIMEOUT);
if (ret < 0)
- sr_err("Bulk read error %d\n", ret);
+ sr_err("zp: Bulk read error %d\n", ret);
return transferred;
}
}
if ((err = libusb_get_device_descriptor(dev, des))) {
- sr_err("failed to get device descriptor: %d", err);
+ sr_err("zp: failed to get device descriptor: %d", err);
return -1;
}
if (!(des->idProduct == zeroplus_models[i].pid))
continue;
- sr_info("Found PID=%04X (%s)", des->idProduct,
- zeroplus_models[i].model_name);
+ sr_info("zp: Found ZeroPlus device 0x%04x (%s)",
+ des->idProduct, zeroplus_models[i].model_name);
zp->num_channels = zeroplus_models[i].channels;
zp->memory_size = zeroplus_models[i].sample_depth * 1024;
break;
}
if (zp->num_channels == 0) {
- sr_err("Unknown ZeroPlus device %04X", des->idProduct);
+ sr_err("zp: Unknown ZeroPlus device 0x%04x",
+ des->idProduct);
return -2;
}
/* Found it. */
if (!(err = libusb_open(dev, &(zp->usb->devhdl)))) {
(*sdi)->status = SR_ST_ACTIVE;
- sr_info("opened device %d on %d.%d interface %d",
+ sr_info("zp: opened device %d on %d.%d interface %d",
(*sdi)->index, zp->usb->bus,
zp->usb->address, USB_INTERFACE);
} else {
- sr_err("failed to open device: %d", err);
+ sr_err("zp: failed to open device: %d", err);
*sdi = NULL;
}
}
if (!zp->usb->devhdl)
return;
- sr_info("closing device %d on %d.%d interface %d", sdi->index,
+ sr_info("zp: closing device %d on %d.%d interface %d", sdi->index,
zp->usb->bus, zp->usb->address, USB_INTERFACE);
libusb_release_interface(zp->usb->devhdl, USB_INTERFACE);
libusb_reset_device(zp->usb->devhdl);
// memset(zp->trigger_buffer, 0, NUM_TRIGGER_STAGES);
if (libusb_init(&usb_context) != 0) {
- sr_err("Failed to initialize USB.");
+ sr_err("zp: Failed to initialize USB.");
return 0;
}
for (i = 0; devlist[i]; i++) {
err = libusb_get_device_descriptor(devlist[i], &des);
if (err != 0) {
- sr_err("failed to get device descriptor: %d", err);
+ sr_err("zp: failed to get device descriptor: %d", err);
continue;
}
int err;
if (!(sdi = zp_open_device(device_index))) {
- sr_err("unable to open device");
+ sr_err("zp: unable to open device");
return SR_ERR;
}
err = libusb_claim_interface(zp->usb->devhdl, USB_INTERFACE);
if (err != 0) {
- sr_err("Unable to claim interface: %d", err);
+ sr_err("zp: Unable to claim interface: %d", err);
return SR_ERR;
}
analyzer_configure(zp->usb->devhdl);
analyzer_start(zp->usb->devhdl);
- sr_info("Waiting for data");
+ sr_info("zp: Waiting for data");
analyzer_wait_data(zp->usb->devhdl);
- sr_info("Stop address = 0x%x", analyzer_get_stop_address(zp->usb->devhdl));
- sr_info("Now address = 0x%x", analyzer_get_now_address(zp->usb->devhdl));
- sr_info("Trigger address = 0x%x", analyzer_get_trigger_address(zp->usb->devhdl));
+ sr_info("zp: Stop address = 0x%x",
+ analyzer_get_stop_address(zp->usb->devhdl));
+ sr_info("zp: Now address = 0x%x",
+ analyzer_get_now_address(zp->usb->devhdl));
+ sr_info("zp: Trigger address = 0x%x",
+ analyzer_get_trigger_address(zp->usb->devhdl));
packet.type = SR_DF_HEADER;
packet.payload = &header;
for (packet_num = 0; packet_num < (zp->memory_size * 4 / PACKET_SIZE);
packet_num++) {
res = analyzer_read_data(zp->usb->devhdl, buf, PACKET_SIZE);
- sr_info("Tried to read %llx bytes, actually read %x bytes",
+ sr_info("zp: Tried to read %llx bytes, actually read %x bytes",
PACKET_SIZE, res);
packet.type = SR_DF_LOGIC;
static int format_match(const char *filename)
{
if (!filename) {
- sr_err("la8input: %s: filename was NULL", __func__);
+ sr_err("la8 in: %s: filename was NULL", __func__);
// return SR_ERR; /* FIXME */
return FALSE;
}
if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
- sr_err("la8input: %s: input file '%s' does not exist",
+ sr_err("la8 in: %s: input file '%s' does not exist",
__func__, filename);
// return SR_ERR; /* FIXME */
return FALSE;
}
if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
- sr_err("la8input: %s: input file '%s' not a regular file",
+ sr_err("la8 in: %s: input file '%s' not a regular file",
__func__, filename);
// return SR_ERR; /* FIXME */
return FALSE;
if (in->param && in->param[0]) {
num_probes = strtoul(in->param, NULL, 10);
if (num_probes < 1) {
- sr_err("la8input: %s: strtoul failed", __func__);
+ sr_err("la8 in: %s: strtoul failed", __func__);
return SR_ERR;
}
} else {
/* TODO: Use glib functions! GIOChannel, g_fopen, etc. */
if ((fd = open(filename, O_RDONLY)) == -1) {
- sr_err("la8input: %s: file open failed", __func__);
+ sr_err("la8 in: %s: file open failed", __func__);
return SR_ERR;
}
close(fd); /* FIXME */
return SR_ERR;
}
- sr_dbg("la8input: %s: samplerate is %" PRIu64, __func__, samplerate);
+ sr_dbg("la8 in: %s: samplerate is %" PRIu64, __func__, samplerate);
/* Send header packet to the session bus. */
- sr_dbg("la8input: %s: sending SR_DF_HEADER packet", __func__);
+ sr_dbg("la8 in: %s: sending SR_DF_HEADER packet", __func__);
packet.type = SR_DF_HEADER;
packet.payload = &header;
header.feed_version = 1;
/* TODO: Handle trigger point. */
/* Send data packets to the session bus. */
- sr_dbg("la8input: %s: sending SR_DF_LOGIC data packets", __func__);
+ sr_dbg("la8 in: %s: sending SR_DF_LOGIC data packets", __func__);
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
logic.unitsize = (num_probes + 7) / 8;
close(fd); /* FIXME */
/* Send end packet to the session bus. */
- sr_dbg("la8input: %s: sending SR_DF_END", __func__);
+ sr_dbg("la8 in: %s: sending SR_DF_END", __func__);
packet.type = SR_DF_END;
packet.payload = NULL;
sr_session_bus(in->vdevice, &packet);
}
}
} else {
- sr_info("short buffer (length_in=%" PRIu64 ")", length_in);
+ sr_info("analog out: short buffer (length_in=%" PRIu64 ")",
+ length_in);
}
*data_out = outbuf;
ctx->prevsample = sample;
}
} else {
- sr_info("short buffer (length_in=%" PRIu64 ")", length_in);
+ sr_info("analog out: short buffer (length_in=%" PRIu64 ")",
+ length_in);
}
*data_out = outbuf;
ctx->prevsample = sample;
}
} else {
- sr_info("short buffer (length_in=%" PRIu64 ")", length_in);
+ sr_info("ascii out: short buffer (length_in=%" PRIu64 ")",
+ length_in);
}
*data_out = outbuf;
}
}
} else {
- sr_info("short buffer (length_in=%" PRIu64 ")", length_in);
+ sr_info("bits out: short buffer (length_in=%" PRIu64 ")",
+ length_in);
}
*data_out = outbuf;
ctx->probelist[ctx->num_enabled_probes++] = probe->name;
}
if (ctx->num_enabled_probes > 94) {
- sr_err("VCD only supports 94 probes.");
+ sr_err("vcd out: VCD only supports 94 probes.");
return SR_ERR;
}
sr_dbg("bus: received unknown packet type %d", packet->type);
break;
}
-
}
/**
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
*/
SR_PRIV int sr_session_bus(struct sr_device *device,
- struct sr_datafeed_packet *packet)
+ struct sr_datafeed_packet *packet)
{
GSList *l;
sr_datafeed_callback cb;
continue;
if (!(buf = g_try_malloc(CHUNKSIZE))) {
- sr_err("session: %s: buf malloc failed", __func__);
+ sr_err("session driver: %s: buf malloc failed",
+ __func__);
return FALSE; /* TODO: SR_ERR_MALLOC */
}
struct sr_device_instance *sdi;
sdi = sr_dev_inst_new(device_index, SR_ST_INITIALIZING,
- NULL, NULL, NULL);
+ NULL, NULL, NULL);
if (!sdi)
return SR_ERR;
if (!(sdi->priv = g_try_malloc0(sizeof(struct session_vdevice)))) {
- sr_err("session: %s: sdi->priv malloc failed", __func__);
+ sr_err("session driver: %s: sdi->priv malloc failed", __func__);
return SR_ERR_MALLOC;
}
vdevice->capturefile);
if (!(vdevice->archive = zip_open(sessionfile, 0, &err))) {
- sr_err("Failed to open session file '%s': zip error %d\n",
- sessionfile, err);
+ sr_err("session driver: Failed to open session file '%s': "
+ "zip error %d\n", sessionfile, err);
return SR_ERR;
}
if (zip_stat(vdevice->archive, vdevice->capturefile, 0, &zs) == -1) {
- sr_err("Failed to check capture file '%s' in session file "
- "'%s'.", vdevice->capturefile, sessionfile);
+ sr_err("session driver: Failed to check capture file '%s' in "
+ "session file '%s'.", vdevice->capturefile, sessionfile);
return SR_ERR;
}
if (!(vdevice->capfile = zip_fopen(vdevice->archive,
vdevice->capturefile, 0))) {
- sr_err("Failed to open capture file '%s' in session file '%s'.",
- vdevice->capturefile, sessionfile);
+ sr_err("session driver: Failed to open capture file '%s' in "
+ "session file '%s'.", vdevice->capturefile, sessionfile);
return SR_ERR;
}
sr_session_source_add(-1, 0, 0, feed_chunk, session_device_id);
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
- sr_err("session: %s: packet malloc failed", __func__);
+ sr_err("session driver: %s: packet malloc failed", __func__);
return SR_ERR_MALLOC;
}
if (!(header = g_try_malloc(sizeof(struct sr_datafeed_header)))) {
- sr_err("session: %s: header malloc failed", __func__);
+ sr_err("session driver: %s: header malloc failed", __func__);
return SR_ERR_MALLOC;
}
}
if (!(archive = zip_open(filename, 0, &err))) {
- sr_dbg("Failed to open session file: zip error %d", err);
+ sr_dbg("session file: Failed to open session file: zip "
+ "error %d", err);
return SR_ERR;
}
/* check "version" */
if (!(zf = zip_fopen(archive, "version", 0))) {
- sr_dbg("Not a sigrok session file.");
+ sr_dbg("session file: Not a sigrok session file.");
return SR_ERR;
}
ret = zip_fread(zf, &c, 1);
if (ret != 1 || c != '1') {
- sr_dbg("Not a valid sigrok session file.");
+ sr_dbg("session file: Not a valid sigrok session file.");
return SR_ERR;
}
zip_fclose(zf);
/* read "metadata" */
if (zip_stat(archive, "metadata", 0, &zs) == -1) {
- sr_dbg("Not a valid sigrok session file.");
+ sr_dbg("session file: Not a valid sigrok session file.");
return SR_ERR;
}
kf = g_key_file_new();
if (!g_key_file_load_from_data(kf, metafile, zs.size, 0, NULL)) {
- sr_dbg("Failed to parse metadata.");
+ sr_dbg("session file: Failed to parse metadata.");
return SR_ERR;
}
if (!(versrc = zip_source_buffer(zipfile, version, 1, 0)))
return SR_ERR;
if (zip_add(zipfile, "version", versrc) == -1) {
- sr_info("error saving version into zipfile: %s",
+ sr_info("session file: error saving version into zipfile: %s",
zip_strerror(zipfile));
return SR_ERR;
}
return SR_ERR;
if ((ret = zip_close(zipfile)) == -1) {
- sr_info("error saving zipfile: %s", zip_strerror(zipfile));
+ sr_info("session file: error saving zipfile: %s",
+ zip_strerror(zipfile));
return SR_ERR;
}