+ if (len == -1) {
+ sr_err("Read error, aborting capture.");
+ packet.type = SR_DF_FRAME_END;
+ sr_session_send(sdi, &packet);
+ sdi->driver->dev_acquisition_stop(sdi);
+ return TRUE;
+ }
+
+ sr_dbg("Received %d bytes.", len);
+
+ devc->num_block_read += len;
+
+ if (ch->type == SR_CHANNEL_ANALOG) {
+ vref = devc->vert_reference[ch->index];
+ vdiv = devc->vdiv[ch->index] / 25.6;
+ offset = devc->vert_offset[ch->index];
+ if (devc->model->series->protocol >= PROTOCOL_V3)
+ for (i = 0; i < len; i++)
+ devc->data[i] = ((int)devc->buffer[i] - vref) * vdiv - offset;
+ else
+ for (i = 0; i < len; i++)
+ devc->data[i] = (128 - devc->buffer[i]) * vdiv - offset;
+ float vdivlog = log10f(vdiv);
+ int digits = -(int)vdivlog + (vdivlog < 0.0);
+ sr_analog_init(&analog, &encoding, &meaning, &spec, digits);
+ analog.meaning->channels = g_slist_append(NULL, ch);
+ analog.num_samples = len;
+ analog.data = devc->data;
+ analog.meaning->mq = SR_MQ_VOLTAGE;
+ analog.meaning->unit = SR_UNIT_VOLT;
+ analog.meaning->mqflags = 0;
+ packet.type = SR_DF_ANALOG;
+ packet.payload = &analog;
+ sr_session_send(sdi, &packet);
+ g_slist_free(analog.meaning->channels);
+ } else {
+ logic.length = len;
+ // TODO: For the MSO1000Z series, we need a way to express that
+ // this data is in fact just for a single channel, with the valid
+ // data for that channel in the LSB of each byte.
+ logic.unitsize = devc->model->series->protocol == PROTOCOL_V4 ? 1 : 2;
+ logic.data = devc->buffer;
+ packet.type = SR_DF_LOGIC;
+ packet.payload = &logic;
+ sr_session_send(sdi, &packet);
+ }
+
+ if (devc->num_block_read == devc->num_block_bytes) {
+ sr_dbg("Block has been completed");