From: Ralf Date: Fri, 23 Oct 2020 05:19:38 +0000 (+0200) Subject: rigol-dg: Add user name to waveform spec to allow consistent mapping functions X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=41ab3507b340bebb00ec3033c43501537c08d821;p=libsigrok.git rigol-dg: Add user name to waveform spec to allow consistent mapping functions --- diff --git a/src/hardware/rigol-dg/api.c b/src/hardware/rigol-dg/api.c index a89e1ed5..3201cfe1 100644 --- a/src/hardware/rigol-dg/api.c +++ b/src/hardware/rigol-dg/api.c @@ -53,13 +53,13 @@ static const double dg1000z_phase_min_max_step[] = { 0.0, 360.0, 0.001 }; #define WAVEFORM_DEFAULT WFO_FREQUENCY | WFO_AMPLITUDE | WFO_OFFSET | WFO_PHASE static const struct waveform_spec dg810_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 5.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 0.2E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 5.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 5.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 5.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 0.2E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 5.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 5.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg811_channels[] = { @@ -72,13 +72,13 @@ static const struct channel_spec dg812_channels[] = { }; static const struct waveform_spec dg820_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 0.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 0.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg821_channels[] = { @@ -91,13 +91,13 @@ static const struct channel_spec dg822_channels[] = { }; static const struct waveform_spec dg830_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 35.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 1.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 35.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 1.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg831_channels[] = { @@ -110,13 +110,13 @@ static const struct channel_spec dg832_channels[] = { }; static const struct waveform_spec dg952_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 50.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 1.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 50.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 1.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg952_channels[] = { @@ -125,13 +125,13 @@ static const struct channel_spec dg952_channels[] = { }; static const struct waveform_spec dg972_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 70.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 20.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 1.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 20.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 20.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 70.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 20.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 1.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 20.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 20.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg972_channels[] = { @@ -140,13 +140,13 @@ static const struct channel_spec dg972_channels[] = { }; static const struct waveform_spec dg992_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 100.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 2.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 100.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 2.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 100.0E+6, 100.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg992_channels[] = { @@ -155,13 +155,13 @@ static const struct channel_spec dg992_channels[] = { }; static const struct waveform_spec dg1022z_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 0.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 25.0E+6, 25.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 0.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 25.0E+6, 25.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg1022z_channels[] = { @@ -170,13 +170,13 @@ static const struct channel_spec dg1022z_channels[] = { }; static const struct waveform_spec dg1032z_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 30.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 0.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 30.0E+6, 30.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0 , 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 30.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 0.5E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 15.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 10.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 30.0E+6, 30.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0 , 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg1032z_channels[] = { @@ -185,13 +185,13 @@ static const struct channel_spec dg1032z_channels[] = { }; static const struct waveform_spec dg1062z_waveforms[] = { - { "SIN", WF_SINE, 1.0E-6, 60.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "RAMP", WF_RAMP, 1.0E-6, 1.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "PULSE", WF_PULSE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 1.0E-6, 20.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, - { "NOISE", WF_NOISE, 60.0E+6, 60.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 1.0E-6, 60.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "RAMP", "Ramp", WF_RAMP, 1.0E-6, 1.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "PULSE", "Pulse", WF_PULSE, 1.0E-6, 25.0E+6, 1.0E-6, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 1.0E-6, 20.0E+6, 1.0E-6, WAVEFORM_DEFAULT }, + { "NOISE", "Noise", WF_NOISE, 60.0E+6, 60.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, }; static const struct channel_spec dg1062z_channels[] = { @@ -243,13 +243,20 @@ static const uint32_t mso5000_devopts_cg[] = { static const double mso5000_phase_min_max_step[] = { 0.0, 360.0, 0.1 }; static const struct waveform_spec mso5000_waveforms[] = { - { "SIN", WF_SINE, 100.0E-3, 25.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, - { "SQU", WF_SQUARE, 100.0E-3, 15.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, - { "RAMP", WF_RAMP, 100.0E-3,100.0E+3, 100.0E-3, WAVEFORM_DEFAULT }, - { "PULS", WF_PULSE, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, - { "USER", WF_ARB, 100.0E-3, 10.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, - { "NOIS", WF_NOISE, 60.0E+6, 60.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, - { "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SIN", "Sine", WF_SINE, 100.0E-3, 25.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "SQU", "Square", WF_SQUARE, 100.0E-3, 15.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "RAMP", "Ramp", WF_RAMP, 100.0E-3,100.0E+3, 100.0E-3, WAVEFORM_DEFAULT }, + { "PULS", "Pulse", WF_PULSE, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT | WFO_DUTY_CYCLE }, + { "USER", "Arb", WF_ARB, 100.0E-3, 10.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "NOIS", "Noise", WF_NOISE, 60.0E+6, 60.0E+6, 0.0E-0, WFO_AMPLITUDE | WFO_OFFSET }, + { "DC", "DC", WF_DC, 0.0E-0, 0.0E+0, 0.0E-0, WFO_OFFSET }, + { "SINC", "Sinc", WF_SINC, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "EXPR", "ExpRise", WF_EXPRISE, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "EXPF", "ExpFall", WF_EXPFALL, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "ECG", "ECG", WF_ECG, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "GAUS", "Gauss", WF_GAUSS, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "LOR", "Lorentz", WF_LORENTZ, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, + { "HAV", "Haversin", WF_HAVERSINE, 100.0E-3, 1.0E+6, 100.0E-3, WAVEFORM_DEFAULT }, }; static const struct channel_spec mso5000_channels[] = { @@ -685,7 +692,7 @@ static int config_set(uint32_t key, GVariant *data, ch_spec->waveforms[i].waveform); if (g_ascii_strncasecmp(mode, mode_name, strlen(mode_name)) == 0) - new_mode = ch_spec->waveforms[i].name; + new_mode = ch_spec->waveforms[i].scpi_name; } if (new_mode) ret = sr_scpi_cmd(sdi, devc->cmdset, diff --git a/src/hardware/rigol-dg/protocol.c b/src/hardware/rigol-dg/protocol.c index 16e8d306..89165f09 100644 --- a/src/hardware/rigol-dg/protocol.c +++ b/src/hardware/rigol-dg/protocol.c @@ -58,42 +58,21 @@ SR_PRIV const char *rigol_dg_waveform_to_string(enum waveform_type type) return "Unknown"; } -SR_PRIV int rigol_dg_string_to_waveform(const char *s, enum waveform_type *wf) +SR_PRIV int rigol_dg_string_to_waveform( + const struct channel_spec *ch, const char *s, enum waveform_type *wf) { - if (g_ascii_strncasecmp(s, "SIN", strlen("SIN")) == 0) - *wf = WF_SINE; - else if (g_ascii_strncasecmp(s, "SQU", strlen("SQU")) == 0) - *wf = WF_SQUARE; - else if (g_ascii_strncasecmp(s, "RAMP", strlen("RAMP")) == 0) - *wf = WF_RAMP; - else if (g_ascii_strncasecmp(s, "PULS", strlen("PULS")) == 0) - *wf = WF_PULSE; - else if (g_ascii_strncasecmp(s, "NOIS", strlen("NOIS")) == 0) - *wf = WF_NOISE; - else if (g_ascii_strncasecmp(s, "USER", strlen("USER")) == 0) - *wf = WF_ARB; - else if (g_ascii_strncasecmp(s, "DC", strlen("DC")) == 0) - *wf = WF_DC; - else if (g_ascii_strncasecmp(s, "SINC", strlen("SINC")) == 0) - *wf = WF_SINC; - else if (g_ascii_strncasecmp(s, "EXPR", strlen("EXPR")) == 0) - *wf = WF_EXPRISE; - else if (g_ascii_strncasecmp(s, "EXPF", strlen("EXPF")) == 0) - *wf = WF_EXPFALL; - else if (g_ascii_strncasecmp(s, "ECG", strlen("ECG")) == 0) - *wf = WF_ECG; - else if (g_ascii_strncasecmp(s, "GAUS", strlen("GAUS")) == 0) - *wf = WF_GAUSS; - else if (g_ascii_strncasecmp(s, "LOR", strlen("LOR")) == 0) - *wf = WF_LORENTZ; - else if (g_ascii_strncasecmp(s, "HAV", strlen("HAV")) == 0) - *wf = WF_HAVERSINE; - else { - sr_warn("Unknown waveform: %s\n", s); - return SR_ERR; + unsigned int i; + + for (i = 0; i < ch->num_waveforms; i++) { + if (g_ascii_strncasecmp(s, ch->waveforms[i].scpi_name, strlen(ch->waveforms[i].scpi_name)) == 0 || + g_ascii_strncasecmp(s, ch->waveforms[i].user_name, strlen(ch->waveforms[i].user_name)) == 0) { + *wf = ch->waveforms[i].waveform; + return SR_OK; + } } - return SR_OK; + sr_warn("Unknown waveform: %s\n", s); + return SR_ERR; } SR_PRIV const struct waveform_spec *rigol_dg_get_waveform_spec( @@ -160,7 +139,8 @@ SR_PRIV int rigol_dg_get_channel_state(const struct sr_dev_inst *sdi, /* First parameter is the waveform type */ if (!(s = params[0])) goto done; - if ((ret = rigol_dg_string_to_waveform(s, &wf)) != SR_OK) + if ((ret = rigol_dg_string_to_waveform( + &devc->device->channels[ch->index], s, &wf)) != SR_OK) goto done; ch_status->wf = wf; diff --git a/src/hardware/rigol-dg/protocol.h b/src/hardware/rigol-dg/protocol.h index d62c87c7..3a1e16ac 100644 --- a/src/hardware/rigol-dg/protocol.h +++ b/src/hardware/rigol-dg/protocol.h @@ -87,7 +87,8 @@ enum waveform_options { }; struct waveform_spec { - const char *name; + const char *scpi_name; + const char *user_name; enum waveform_type waveform; double freq_min; double freq_max; @@ -133,7 +134,8 @@ struct dev_context { }; SR_PRIV const char *rigol_dg_waveform_to_string(enum waveform_type type); -SR_PRIV int rigol_dg_string_to_waveform(const char *s, enum waveform_type *wf); +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( const struct channel_spec *ch, enum waveform_type wf); SR_PRIV int rigol_dg_get_channel_state(const struct sr_dev_inst *sdi,