X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fpipistrello-ols%2Fprotocol.c;fp=src%2Fhardware%2Fpipistrello-ols%2Fprotocol.c;h=62515050511b67ead751998e9f7bdd44ee100cc0;hb=8cd15dd4ce2fdbefbcc6e64632c8006e5404f253;hp=9948944d2681703ceedac4306d49740bbbbc6c30;hpb=1aba65727015e298f213c851dbc8d2d57d27d37b;p=libsigrok.git diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index 9948944d..62515050 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -73,16 +73,13 @@ SR_PRIV int p_ols_open(struct dev_context *devc) /* Note: Caller checks devc and devc->ftdic. */ - /* Select interface B, otherwise communication will fail. */ ret = ftdi_set_interface(devc->ftdic, INTERFACE_B); if (ret < 0) { sr_err("Failed to set FTDI interface B (%d): %s", ret, ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI chip interface B set successfully."); - /* Check for the device and temporarily open it. */ ret = ftdi_usb_open_desc(devc->ftdic, USB_VENDOR_ID, USB_DEVICE_ID, USB_IPRODUCT, NULL); if (ret < 0) { @@ -92,47 +89,39 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI device opened successfully."); - /* Purge RX/TX buffers in the FTDI chip. */ if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) { sr_err("Failed to purge FTDI RX/TX buffers (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip buffers purged successfully."); - /* Reset the FTDI bitmode. */ ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_RESET); if (ret < 0) { sr_err("Failed to reset the FTDI chip bitmode (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip bitmode reset successfully."); - /* Set the FTDI latency timer to 16. */ ret = ftdi_set_latency_timer(devc->ftdic, 16); if (ret < 0) { sr_err("Failed to set FTDI latency timer (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip latency timer set successfully."); - /* Set the FTDI read data chunk size to 64kB. */ ret = ftdi_read_data_set_chunksize(devc->ftdic, 64 * 1024); if (ret < 0) { sr_err("Failed to set FTDI read data chunk size (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip read data chunk size set successfully."); return SR_OK; err_open_close_ftdic: ftdi_usb_close(devc->ftdic); + return SR_ERR; } @@ -221,7 +210,7 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str uint8_t key, type, token; GString *tmp_str, *devname, *version; guchar tmp_c; - int index, i; + int index; sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; @@ -275,10 +264,8 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str break; case 1: /* 32-bit unsigned integer */ - tmp_int = 0; - for (i = 0; i < 4; i++) { - tmp_int = (tmp_int << 8) | buf[index++]; - } + tmp_int = RB32(&buf[index]); + index += sizeof(uint32_t); sr_dbg("Got metadata key 0x%.2x value 0x%.8x.", key, tmp_int); switch (token) { @@ -424,7 +411,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) if (bytes_read < 0) { sr_err("Failed to read FTDI data (%d): %s.", bytes_read, ftdi_get_error_string(devc->ftdic)); - sdi->driver->dev_acquisition_stop(sdi); + sr_dev_acquisition_stop(sdi); return FALSE; } if (bytes_read == 0) { @@ -672,7 +659,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) } g_free(devc->raw_sample_buf); - sdi->driver->dev_acquisition_stop(sdi); + sr_dev_acquisition_stop(sdi); } return TRUE;