openbench-logic-sniffer: add a function to handle reset command
Openbench Logic Sniffer reset is a little more complex than a simple send. To avoid code duplication, this patch adds a new function dedicated to this task. Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
This commit is contained in:
parent
07d4e86316
commit
244995a2e3
|
@ -126,14 +126,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
|
||||
return NULL;
|
||||
|
||||
ret = SR_OK;
|
||||
for (i = 0; i < 5; i++) {
|
||||
if ((ret = send_shortcommand(serial, CMD_RESET)) != SR_OK) {
|
||||
sr_err("Port %s is not writable.", conn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ret != SR_OK) {
|
||||
if (ols_send_reset(serial) != SR_OK) {
|
||||
serial_close(serial);
|
||||
sr_err("Could not use port %s. Quitting.", conn);
|
||||
return NULL;
|
||||
|
|
|
@ -57,6 +57,18 @@ SR_PRIV int send_longcommand(struct sr_serial_dev_inst *serial,
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
SR_PRIV int ols_send_reset(struct sr_serial_dev_inst *serial)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (send_shortcommand(serial, CMD_RESET) != SR_OK)
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
/* Configures the channel mask based on which channels are enabled. */
|
||||
SR_PRIV void ols_channel_mask(const struct sr_dev_inst *sdi)
|
||||
{
|
||||
|
|
|
@ -107,6 +107,7 @@ SR_PRIV int send_shortcommand(struct sr_serial_dev_inst *serial,
|
|||
uint8_t command);
|
||||
SR_PRIV int send_longcommand(struct sr_serial_dev_inst *serial,
|
||||
uint8_t command, uint8_t *data);
|
||||
SR_PRIV int ols_send_reset(struct sr_serial_dev_inst *serial);
|
||||
SR_PRIV void ols_channel_mask(const struct sr_dev_inst *sdi);
|
||||
SR_PRIV int ols_convert_trigger(const struct sr_dev_inst *sdi);
|
||||
SR_PRIV struct dev_context *ols_dev_new(void);
|
||||
|
|
Loading…
Reference in New Issue