X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fgwinstek-gpd%2Fapi.c;h=aff3a7a2faf4d2885c05db94b513d64448a4ecf5;hb=1c5d5905a44f8e3abbb9327cb47e80d09eb2dc6a;hp=ac2fe2e17409d8567a6e765f08a35119c826df3a;hpb=f1e82915a88bcbb4d76a9c36c896c24c19c33a3a;p=libsigrok.git diff --git a/src/hardware/gwinstek-gpd/api.c b/src/hardware/gwinstek-gpd/api.c index ac2fe2e1..aff3a7a2 100644 --- a/src/hardware/gwinstek-gpd/api.c +++ b/src/hardware/gwinstek-gpd/api.c @@ -60,6 +60,16 @@ static const struct gpd_model models[] = { { { 0, 30, 0.001 }, { 0, 3, 0.001 } }, }, }, + { GPD_3303S, "GPD-3303S", + CHANMODE_INDEPENDENT, + 2, + { + /* Channel 1 */ + { { 0, 32, 0.001 }, { 0, 3.2, 0.001 } }, + /* Channel 2 */ + { { 0, 32, 0.001 }, { 0, 3.2, 0.001 } }, + }, + }, }; static GSList *scan(struct sr_dev_driver *di, GSList *options) @@ -72,7 +82,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) GSList *l; struct sr_serial_dev_inst *serial; struct sr_dev_inst *sdi; - char reply[50]; + char reply[100]; unsigned int i; struct dev_context *devc; char channel[10]; @@ -107,7 +117,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) if (serial_open(serial, SERIAL_RDWR) != SR_OK) return NULL; - serial_flush(serial); gpd_send_cmd(serial, "*IDN?\n"); if (gpd_receive_reply(serial, reply, sizeof(reply)) != SR_OK) { sr_err("Device did not reply."); @@ -170,8 +179,16 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) if (sscanf(reply, "%1u%1u%1u%1u%1u%1u%1u%1u", &cc_cv_ch1, &cc_cv_ch2, &track1, &track2, &beep, &devc->output_enabled, &baud1, &baud2) != 8) { - sr_err("Invalid reply to STATUS: '%s'.", reply); - goto error; + /* old firmware (< 2.00?) responds with different format */ + if (sscanf(reply, "%1u %1u %1u %1u %1u X %1u X", &cc_cv_ch1, + &cc_cv_ch2, &track1, &track2, &beep, + &devc->output_enabled) != 6) { + sr_err("Invalid reply to STATUS: '%s'.", reply); + goto error; + } + /* ignore remaining two lines of status message */ + gpd_receive_reply(serial, reply, sizeof(reply)); + gpd_receive_reply(serial, reply, sizeof(reply)); } for (i = 0; i < model->num_channels; ++i) { @@ -220,7 +237,7 @@ error: static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - int ret, channel; + int channel; const struct dev_context *devc; const struct sr_channel *ch; @@ -231,6 +248,9 @@ static int config_get(uint32_t key, GVariant **data, if (!cg) { switch (key) { + case SR_CONF_LIMIT_SAMPLES: + case SR_CONF_LIMIT_MSEC: + return sr_sw_limits_config_get(&devc->limits, key, data); case SR_CONF_CHANNEL_CONFIG: *data = g_variant_new_string( channel_modes[devc->channel_mode]); @@ -244,7 +264,6 @@ static int config_get(uint32_t key, GVariant **data, } else { ch = cg->channels->data; channel = ch->index; - ret = SR_OK; switch (key) { case SR_CONF_VOLTAGE: *data = g_variant_new_double( @@ -267,7 +286,7 @@ static int config_get(uint32_t key, GVariant **data, } } - return ret; + return SR_OK; } static int config_set(uint32_t key, GVariant *data,