if (probefd.revents != G_IO_IN)
return NULL;
- if (serial_read(serial, buf, 4) != 4)
+ if (serial_read_blocking(serial, buf, 4) != 4)
return NULL;
if (strncmp(buf, "1SLO", 4) && strncmp(buf, "1ALS", 4))
return NULL;
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_probe_group *probe_group)
{
- GVariant *gvar;
+ struct dev_context *devc;
+ GVariant *gvar, *grange[2];
GVariantBuilder gvb;
+ int num_channels, i;
- (void)sdi;
(void)probe_group;
switch (key) {
case SR_CONF_PATTERN_MODE:
*data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));
break;
+ case SR_CONF_LIMIT_SAMPLES:
+ if (!sdi)
+ return SR_ERR_ARG;
+ devc = sdi->priv;
+ if (devc->flag_reg & FLAG_RLE)
+ return SR_ERR_NA;
+ if (devc->max_samples == 0)
+ /* Device didn't specify sample memory size in metadata. */
+ return SR_ERR_NA;
+ /*
+ * Channel groups are turned off if no probes in that group are
+ * enabled, making more room for samples for the enabled group.
+ */
+ ols_configure_probes(sdi);
+ num_channels = 0;
+ for (i = 0; i < 4; i++) {
+ if (devc->probe_mask & (0xff << (i * 8)))
+ num_channels++;
+ }
+ grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES);
+ grange[1] = g_variant_new_uint64(devc->max_samples / num_channels);
+ *data = g_variant_new_tuple(grange, 2);
+ break;
default:
return SR_ERR_NA;
}