diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index 0d6efeb8..9178c46e 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -157,6 +157,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) GString *tmp_str, *devname, *version; guchar tmp_c; + uint32_t channel_count = 0; + sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; devc = ols_dev_new(); @@ -222,9 +224,7 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) switch (token) { case 0x00: /* Number of usable channels */ - for (ui = 0; ui < tmp_int; ui++) - sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE, - ols_channel_names[ui]); + channel_count = tmp_int; break; case 0x01: /* Amount of sample memory available (bytes) */ @@ -258,9 +258,7 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) switch (token) { case 0x00: /* Number of usable channels */ - for (ui = 0; ui < tmp_c; ui++) - sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE, - ols_channel_names[ui]); + channel_count = (uint32_t)tmp_c; break; case 0x01: /* protocol version */ @@ -278,6 +276,24 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial) } } + /* Use defaults based on each model. + * (Do not override any possible actual value--new firmware?) + * TBD: default configuration from user file? + */ + if (strstr(devname->str, "Logic Pirate") != NULL) { + if (channel_count == 0) + channel_count = 8; + if (devc->max_samplerate == 0) + devc->max_samplerate = 40000000; // 40 MHz. + if (devc->max_samples == 0) + devc->max_samples = 256*1024; // 256KSamples + } + + /* Declare all usable channels */ + for (ui = 0; ui < channel_count; ui++) + sr_channel_new(sdi, ui, SR_CHANNEL_LOGIC, TRUE, + ols_channel_names[ui]); + sdi->model = devname->str; sdi->version = version->str; g_string_free(devname, FALSE);