+
+ case SR_DF_META:
+ g_debug("cli: received SR_DF_META");
+ meta = packet->payload;
+ for (l = meta->config; l; l = l->next) {
+ src = l->data;
+ switch (src->key) {
+ case SR_CONF_SAMPLERATE:
+ samplerate = g_variant_get_uint64(src->data);
+ g_debug("cli: got samplerate %"PRIu64" Hz", samplerate);
+ break;
+ case SR_CONF_SAMPLE_INTERVAL:
+ samplerate = g_variant_get_uint64(src->data);
+ g_debug("cli: got sample interval %"PRIu64" ms", samplerate);
+ break;
+ default:
+ /* Unknown metadata is not an error. */
+ break;
+ }
+ }
+ break;
+
+ case SR_DF_TRIGGER:
+ g_debug("cli: received SR_DF_TRIGGER");
+ if (o->format->event)
+ o->format->event(o, SR_DF_TRIGGER, &output_buf,
+ &output_len);
+ triggered = 1;
+ break;
+
+ case SR_DF_LOGIC:
+ logic = packet->payload;
+ g_message("cli: received SR_DF_LOGIC, %"PRIu64" bytes", logic->length);
+ sample_size = logic->unitsize;
+ if (logic->length == 0)
+ break;
+
+ /* Don't store any samples until triggered. */
+ if (opt_wait_trigger && !triggered)
+ break;
+
+ if (limit_samples && received_samples >= limit_samples)
+ break;
+
+ ret = sr_filter_probes(sample_size, unitsize, logic_probelist,
+ logic->data, logic->length,
+ &filter_out, &filter_out_len);
+ if (ret != SR_OK)
+ break;
+
+ /* What comes out of the filter is guaranteed to be packed into the
+ * minimum size needed to support the number of samples at this sample
+ * size. however, the driver may have submitted too much -- cut off
+ * the buffer of the last packet according to the sample limit.
+ */
+ if (limit_samples && (received_samples + logic->length / sample_size >
+ limit_samples * sample_size))
+ filter_out_len = limit_samples * sample_size - received_samples;
+
+ if (opt_output_file && default_output_format) {
+ /* Saving to a session file. */
+ g_byte_array_append(savebuf, filter_out, filter_out_len);
+ } else {
+ if (opt_pds) {
+#ifdef HAVE_SRD
+ if (srd_session_send(received_samples, (uint8_t*)filter_out,
+ filter_out_len) != SRD_OK)
+ sr_session_stop();
+#endif
+ } else {
+ output_len = 0;
+ if (o->format->data && packet->type == o->format->df_type)
+ o->format->data(o, filter_out, filter_out_len,
+ &output_buf, &output_len);
+ if (output_len) {
+ fwrite(output_buf, 1, output_len, outfile);
+ fflush(outfile);
+ g_free(output_buf);
+ }
+ }
+ }
+ g_free(filter_out);
+
+ received_samples += logic->length / sample_size;
+ break;
+
+ case SR_DF_ANALOG:
+ analog = packet->payload;
+ g_message("cli: received SR_DF_ANALOG, %d samples", analog->num_samples);
+ if (analog->num_samples == 0)
+ break;
+
+ if (limit_samples && received_samples >= limit_samples)