- }
- if (!model) {
- sr_err("Unsupported model '%s'.", reply);
- goto error;
- }
-
- sr_info("Detected model '%s'.", model->name);
-
- sdi = g_malloc0(sizeof(struct sr_dev_inst));
- sdi->status = SR_ST_INACTIVE;
- sdi->vendor = g_strdup("GW Instek");
- sdi->model = g_strdup(model->name);
- sdi->inst_type = SR_INST_SERIAL;
- sdi->conn = serial;
-
- for (i = 0; i < model->num_channels; i++) {
- snprintf(channel, sizeof(channel), "CH%d", i + 1);
- ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel);
- cg = g_malloc(sizeof(struct sr_channel_group));
- cg->name = g_strdup(channel);
- cg->channels = g_slist_append(NULL, ch);
- cg->priv = NULL;
- sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
- }
-
- devc = g_malloc0(sizeof(struct dev_context));
- sr_sw_limits_init(&devc->limits);
- devc->model = model;
- devc->config = g_malloc0(sizeof(struct per_channel_config)
- * model->num_channels);
- sdi->priv = devc;
-
- serial_flush(serial);
- gpd_send_cmd(serial, "STATUS?\n");
- gpd_receive_reply(serial, reply, sizeof(reply));
-
- 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) {
- /* 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);