From: Martin Ling Date: Mon, 10 Sep 2018 14:06:25 +0000 (+0100) Subject: scpi-pps: Use software sample and time limits. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=88e4daa9ff82f45f5966ac662d794c04625df176;p=libsigrok.git scpi-pps: Use software sample and time limits. --- diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index c2ed416a..c6d5a73e 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -100,6 +100,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi, devc = g_malloc0(sizeof(struct dev_context)); devc->device = device; + sr_sw_limits_init(&devc->limits); sdi->priv = devc; if (device->num_channels) { @@ -400,6 +401,8 @@ static int config_get(uint32_t key, GVariant **data, case SR_CONF_REGULATION: gvtype = G_VARIANT_TYPE_STRING; cmd = SCPI_CMD_GET_OUTPUT_REGULATION; + default: + return sr_sw_limits_config_get(&devc->limits, key, data); } if (!gvtype) return SR_ERR_NA; @@ -533,7 +536,7 @@ static int config_set(uint32_t key, GVariant *data, SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE); break; default: - ret = SR_ERR_NA; + ret = sr_sw_limits_config_set(&devc->limits, key, data); } g_free(channel_group_name); @@ -640,6 +643,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) scpi_pps_receive_data, (void *)sdi)) != SR_OK) return ret; std_session_send_df_header(sdi); + sr_sw_limits_acquisition_start(&devc->limits); return SR_OK; } diff --git a/src/hardware/scpi-pps/profiles.c b/src/hardware/scpi-pps/profiles.c index 475e09fb..6fdff9bb 100644 --- a/src/hardware/scpi-pps/profiles.c +++ b/src/hardware/scpi-pps/profiles.c @@ -33,6 +33,8 @@ /* Agilent/Keysight N5700A series */ static const uint32_t agilent_n5700a_devopts[] = { SR_CONF_CONTINUOUS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t agilent_n5700a_devopts_cg[] = { @@ -87,6 +89,8 @@ static const struct scpi_command agilent_n5700a_cmd[] = { /* Chroma 61600 series AC source */ static const uint32_t chroma_61604_devopts[] = { SR_CONF_CONTINUOUS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t chroma_61604_devopts_cg[] = { @@ -133,6 +137,8 @@ static const struct scpi_command chroma_61604_cmd[] = { /* Chroma 62000 series DC source */ static const uint32_t chroma_62000_devopts[] = { SR_CONF_CONTINUOUS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t chroma_62000_devopts_cg[] = { @@ -224,6 +230,8 @@ static int chroma_62000p_probe_channels(struct sr_dev_inst *sdi, /* Rigol DP700 series */ static const uint32_t rigol_dp700_devopts[] = { SR_CONF_CONTINUOUS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t rigol_dp700_devopts_cg[] = { @@ -291,6 +299,8 @@ static const struct scpi_command rigol_dp700_cmd[] = { static const uint32_t rigol_dp800_devopts[] = { SR_CONF_CONTINUOUS, SR_CONF_OVER_TEMPERATURE_PROTECTION | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t rigol_dp800_devopts_cg[] = { @@ -375,6 +385,8 @@ static const struct scpi_command rigol_dp800_cmd[] = { /* HP 663xx series */ static const uint32_t hp_6630a_devopts[] = { SR_CONF_CONTINUOUS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t hp_6630a_devopts_cg[] = { @@ -389,6 +401,8 @@ static const uint32_t hp_6630a_devopts_cg[] = { static const uint32_t hp_6630b_devopts[] = { SR_CONF_CONTINUOUS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t hp_6630b_devopts_cg[] = { @@ -465,6 +479,8 @@ static const struct scpi_command hp_6630b_cmd[] = { /* Philips/Fluke PM2800 series */ static const uint32_t philips_pm2800_devopts[] = { SR_CONF_CONTINUOUS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t philips_pm2800_devopts_cg[] = { @@ -613,6 +629,8 @@ static const struct scpi_command philips_pm2800_cmd[] = { static const uint32_t rs_hmc8043_devopts[] = { SR_CONF_CONTINUOUS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t rs_hmc8043_devopts_cg[] = { diff --git a/src/hardware/scpi-pps/protocol.c b/src/hardware/scpi-pps/protocol.c index 8dd66972..37c327c4 100644 --- a/src/hardware/scpi-pps/protocol.c +++ b/src/hardware/scpi-pps/protocol.c @@ -32,7 +32,7 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data) struct sr_analog_encoding encoding; struct sr_analog_meaning meaning; struct sr_analog_spec spec; - const struct sr_dev_inst *sdi; + struct sr_dev_inst *sdi; int channel_group_cmd; char *channel_group_name; struct pps_channel *pch; @@ -116,5 +116,13 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data) sr_next_enabled_channel(sdi, devc->cur_acquisition_channel); } + if (devc->cur_acquisition_channel == sr_next_enabled_channel(sdi, NULL)) + /* First enabled channel, so each channel has been sampled */ + sr_sw_limits_update_samples_read(&devc->limits, 1); + + /* Stop if limits have been hit. */ + if (sr_sw_limits_check(&devc->limits)) + sr_dev_acquisition_stop(sdi); + return TRUE; } diff --git a/src/hardware/scpi-pps/protocol.h b/src/hardware/scpi-pps/protocol.h index b4336593..cf0dbdd5 100644 --- a/src/hardware/scpi-pps/protocol.h +++ b/src/hardware/scpi-pps/protocol.h @@ -147,6 +147,7 @@ struct dev_context { struct channel_group_spec *channel_groups; struct sr_channel *cur_acquisition_channel; + struct sr_sw_limits limits; }; SR_PRIV extern unsigned int num_pps_profiles;