]> sigrok.org Git - libsigrok.git/commitdiff
openbench-logic-sniffer: add a function to handle reset command
authorGwenhael Goavec-Merou <redacted>
Sun, 30 Apr 2017 13:57:39 +0000 (15:57 +0200)
committerUwe Hermann <redacted>
Tue, 2 May 2017 20:06:51 +0000 (22:06 +0200)
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>
src/hardware/openbench-logic-sniffer/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/openbench-logic-sniffer/protocol.h

index 1e22c5b82f97970c9a83e00c36419d47071ad583..c04595350c6bcc562e978a65940c6eadb63c9176 100644 (file)
@@ -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;
index a7c3f96376044b5b7b3e48eb3152b5ef53ad5f3a..0d6efeb85a89fd41d2a21dd81ee3aa400e4c664c 100644 (file)
@@ -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)
 {
index 1e6cd69d8052bda5d5a83dc3624b4b00c0a9fc65..4525ba2ccb750707bfa9db8dfa31402d00a176cc 100644 (file)
@@ -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);