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 <redacted>
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;
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)
{
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);