]> sigrok.org Git - libsigrok.git/commitdiff
rigol-dg: Use user name in waveform spec for rigol_dg_waveform_to_string
authorRalf <redacted>
Fri, 23 Oct 2020 10:00:02 +0000 (12:00 +0200)
committerSoeren Apel <redacted>
Sat, 28 Sep 2024 21:59:59 +0000 (23:59 +0200)
src/hardware/rigol-dg/api.c
src/hardware/rigol-dg/protocol.c
src/hardware/rigol-dg/protocol.h

index 3201cfe10978593f87c5791a1d32e7b22560d9f5..537d6188437af4c25d3c0066186457277d08ff88 100644 (file)
@@ -584,6 +584,7 @@ static int config_get(uint32_t key, GVariant **data,
                        if ((ret = rigol_dg_get_channel_state(sdi, cg)) == SR_OK) {
                                *data = g_variant_new_string(
                                         rigol_dg_waveform_to_string(
+                                                &devc->device->channels[ch->index],
                                                 ch_status->wf));
                        }
                        break;
@@ -689,6 +690,7 @@ static int config_set(uint32_t key, GVariant *data,
                        mode = g_variant_get_string(data, NULL);
                        for (i = 0; i < ch_spec->num_waveforms; i++) {
                                mode_name = rigol_dg_waveform_to_string(
+                                               &devc->device->channels[ch->index],
                                                ch_spec->waveforms[i].waveform);
                                if (g_ascii_strncasecmp(mode, mode_name,
                                                strlen(mode_name)) == 0)
@@ -805,6 +807,7 @@ static int config_list(uint32_t key, GVariant **data,
                        for (i = 0; i < ch_spec->num_waveforms; i++) {
                                g_variant_builder_add(b, "s",
                                        rigol_dg_waveform_to_string(
+                                               &devc->device->channels[ch->index],
                                                ch_spec->waveforms[i].waveform));
                        }
                        *data = g_variant_new("as", b);
index 89165f09deb556cd9415d67490f17b7a8f39d2f5..0b26bc599d5ddd2a0d80af5a1baa61e30ec9404d 100644 (file)
 #include "scpi.h"
 #include "protocol.h"
 
-SR_PRIV const char *rigol_dg_waveform_to_string(enum waveform_type type)
+SR_PRIV const char *rigol_dg_waveform_to_string(const struct channel_spec *ch,
+               enum waveform_type type)
 {
-       switch (type) {
-       case WF_DC:
-               return "DC";
-       case WF_SINE:
-               return "Sine";
-       case WF_SQUARE:
-               return "Square";
-       case WF_RAMP:
-               return "Ramp";
-       case WF_PULSE:
-               return "Pulse";
-       case WF_NOISE:
-               return "Noise";
-       case WF_ARB:
-               return "Arb";
-       case WF_SINC:
-               return "Sinc";
-       case WF_EXPRISE:
-               return "ExpRise";
-       case WF_EXPFALL:
-               return "ExpFall";
-       case WF_ECG:
-               return "ECG";
-       case WF_GAUSS:
-               return "Gauss";
-       case WF_LORENTZ:
-               return "Lorentz";
-       case WF_HAVERSINE:
-               return "Haversine";
+       unsigned int i;
+
+       for (i = 0; i < ch->num_waveforms; i++) {
+               if (ch->waveforms[i].waveform == type) {
+                       return ch->waveforms[i].user_name;
+               }
        }
 
        return "Unknown";
index 3a1e16ac5bd3ab26cc7e7f1f51b848cee56ca31d..3e48e751e94a42be2165800b7e0cb88ceb55b8fe 100644 (file)
@@ -133,7 +133,8 @@ struct dev_context {
        uint32_t quirks;
 };
 
-SR_PRIV const char *rigol_dg_waveform_to_string(enum waveform_type type);
+SR_PRIV const char *rigol_dg_waveform_to_string(const struct channel_spec *ch,
+               enum waveform_type type);
 SR_PRIV int rigol_dg_string_to_waveform(
                const struct channel_spec *ch, const char *s, enum waveform_type *wf);
 SR_PRIV const struct waveform_spec *rigol_dg_get_waveform_spec(