]> sigrok.org Git - libsigrok.git/commitdiff
scpi-pps: Use software sample and time limits.
authorMartin Ling <redacted>
Mon, 10 Sep 2018 14:06:25 +0000 (15:06 +0100)
committerMartin Ling <redacted>
Mon, 10 Sep 2018 15:33:11 +0000 (16:33 +0100)
src/hardware/scpi-pps/api.c
src/hardware/scpi-pps/profiles.c
src/hardware/scpi-pps/protocol.c
src/hardware/scpi-pps/protocol.h

index c2ed416ab46d9bf7906f9c28f4d4a0fe58ab2274..c6d5a73e5e6c8efe9c9505e1224bc0e725cb2746 100644 (file)
@@ -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;
 }
index 475e09fb3d059b52928be2a84644b2f884ef1553..6fdff9bb9b9c03e5f1585de62f421058ce83784c 100644 (file)
@@ -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[] = {
index 8dd669722d776e6a47c8588cafc48979ed3884a0..37c327c41bab10e12c806da01b546909b4182a23 100644 (file)
@@ -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;
 }
index b4336593cf3643d8d80944d738e5eac5b2bf4ef7..cf0dbdd5aa227a2815269378fabb917b888d6513 100644 (file)
@@ -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;